123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.SQLite;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using PaintDotNet.Base.CommTool;
- namespace PaintDotNet.GeneralAnalysis.Countometer
- {
- public partial class SavingDialog : PdnBaseForm
- {
- #region
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
- #region Windows Form Designer generated code
- private void InitializeLanguageText()
- {
- this.Text = PdnResources.GetString("Menu.File.Save.Text");
- this.label2.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Sampletype.text") + ":";
- this.label1.Text = PdnResources.GetString("Menu.Measuringtime.text") + ":";
- this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
- this.btnClose.Text = PdnResources.GetString("Menu.File.Close.Text");
- this.btnSave.Text = PdnResources.GetString("Menu.File.Save.Text");
- this.groupBox2.Text = PdnResources.GetString("Menu.Organizationinformation.text");
- this.label5.Text = PdnResources.GetString("Menu.Remark.text") + ":";
- this.label6.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Samplingtime.text") + ":";
- this.label4.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.filename.text") + ":";
- this.label3.Text = PdnResources.GetString("Menu.samplename.text") + ":";
- }
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.btnClose = new System.Windows.Forms.Button();
- this.btnSave = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.dtpSamplingTime = new System.Windows.Forms.DateTimePicker();
- this.dtpAssayTime = new System.Windows.Forms.DateTimePicker();
- this.txtNotes = new System.Windows.Forms.TextBox();
- this.txtFileName = new System.Windows.Forms.TextBox();
- this.txtName = new System.Windows.Forms.TextBox();
- this.txtType = new System.Windows.Forms.TextBox();
- this.label5 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.btnClose);
- this.groupBox1.Controls.Add(this.btnSave);
- this.groupBox1.Location = new System.Drawing.Point(12, 12);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(445, 71);
- this.groupBox1.TabIndex = 0;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "操作";
- //
- // btnClose
- //
- this.btnClose.Location = new System.Drawing.Point(248, 24);
- this.btnClose.Name = "btnClose";
- this.btnClose.Size = new System.Drawing.Size(84, 31);
- this.btnClose.TabIndex = 1;
- this.btnClose.Text = "关闭";
- this.btnClose.UseVisualStyleBackColor = true;
- this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
- //
- // btnSave
- //
- this.btnSave.Location = new System.Drawing.Point(338, 24);
- this.btnSave.Name = "btnSave";
- this.btnSave.Size = new System.Drawing.Size(84, 31);
- this.btnSave.TabIndex = 0;
- this.btnSave.Text = "保存";
- this.btnSave.UseVisualStyleBackColor = true;
- this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.dtpSamplingTime);
- this.groupBox2.Controls.Add(this.dtpAssayTime);
- this.groupBox2.Controls.Add(this.txtNotes);
- this.groupBox2.Controls.Add(this.txtFileName);
- this.groupBox2.Controls.Add(this.txtName);
- this.groupBox2.Controls.Add(this.txtType);
- this.groupBox2.Controls.Add(this.label5);
- this.groupBox2.Controls.Add(this.label6);
- this.groupBox2.Controls.Add(this.label4);
- this.groupBox2.Controls.Add(this.label3);
- this.groupBox2.Controls.Add(this.label2);
- this.groupBox2.Controls.Add(this.label1);
- this.groupBox2.Location = new System.Drawing.Point(12, 89);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(445, 414);
- this.groupBox2.TabIndex = 1;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "组织信息";
- //
- // dtpSamplingTime
- //
- this.dtpSamplingTime.CustomFormat = "yyyy-MM-dd HH:mm:ss";
- this.dtpSamplingTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
- this.dtpSamplingTime.Location = new System.Drawing.Point(130, 185);
- this.dtpSamplingTime.Name = "dtpSamplingTime";
- this.dtpSamplingTime.Size = new System.Drawing.Size(290, 21);
- this.dtpSamplingTime.TabIndex = 13;
- //
- // dtpAssayTime
- //
- this.dtpAssayTime.CustomFormat = "yyyy-MM-dd HH:mm:ss";
- this.dtpAssayTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
- this.dtpAssayTime.Location = new System.Drawing.Point(130, 37);
- this.dtpAssayTime.Name = "dtpAssayTime";
- this.dtpAssayTime.Size = new System.Drawing.Size(290, 21);
- this.dtpAssayTime.TabIndex = 12;
- //
- // txtNotes
- //
- this.txtNotes.Location = new System.Drawing.Point(130, 228);
- this.txtNotes.Multiline = true;
- this.txtNotes.Name = "txtNotes";
- this.txtNotes.Size = new System.Drawing.Size(290, 164);
- this.txtNotes.TabIndex = 11;
- //
- // txtFileName
- //
- this.txtFileName.Location = new System.Drawing.Point(130, 148);
- this.txtFileName.Name = "txtFileName";
- this.txtFileName.Size = new System.Drawing.Size(290, 21);
- this.txtFileName.TabIndex = 9;
- //
- // txtName
- //
- this.txtName.Location = new System.Drawing.Point(130, 111);
- this.txtName.Name = "txtName";
- this.txtName.Size = new System.Drawing.Size(290, 21);
- this.txtName.TabIndex = 8;
- //
- // txtType
- //
- this.txtType.Location = new System.Drawing.Point(130, 74);
- this.txtType.Name = "txtType";
- this.txtType.Size = new System.Drawing.Size(290, 21);
- this.txtType.TabIndex = 7;
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(23, 228);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(41, 12);
- this.label5.TabIndex = 5;
- this.label5.Text = "备注:";
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(23, 191);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(65, 12);
- this.label6.TabIndex = 4;
- this.label6.Text = "取样时间:";
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(23, 154);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(65, 12);
- this.label4.TabIndex = 3;
- this.label4.Text = "文件名称:";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(23, 117);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(65, 12);
- this.label3.TabIndex = 2;
- this.label3.Text = "样品名称:";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(23, 80);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(65, 12);
- this.label2.TabIndex = 1;
- this.label2.Text = "样品类型:";
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(23, 43);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(65, 12);
- this.label1.TabIndex = 0;
- this.label1.Text = "测定时间:";
- //
- // SavingDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(472, 517);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.MaximizeBox = false;
- this.Name = "SavingDialog";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SavingDialog_FormClosing);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.groupBox1.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- this.groupBox2.PerformLayout();
- this.ResumeLayout(false);
- }
- #endregion
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.TextBox txtNotes;
- private System.Windows.Forms.TextBox txtFileName;
- private System.Windows.Forms.TextBox txtName;
- private System.Windows.Forms.TextBox txtType;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Button btnSave;
- private System.Windows.Forms.Button btnClose;
- private System.Windows.Forms.DateTimePicker dtpSamplingTime;
- private System.Windows.Forms.DateTimePicker dtpAssayTime;
- #endregion
- private SQLiteHelper m_sqlHelper;
- private string m_tissuesId;
- private string m_tissuesName;
- private DataTable m_assayList;
- public SavingDialog(string tissuesId, DataTable data)
- {
- m_tissuesId = tissuesId;
- m_assayList = data;
- InitializeData();
- InitializeComponent();
- InitializeLanguageText();
- }
- private void InitializeData()
- {
- m_sqlHelper = new SQLiteHelper(); //连接数据库
- m_sqlHelper.Connect();
- // 组织信息
- string select_sql1 = "select * from mic_tissues where delete_flag = 0 and id = '" + m_tissuesId + "'"; //查询的SQL语句
- DataTable tissuesList = m_sqlHelper.ExecuteDataTable(select_sql1, null); //执行查询操作,结果存放在dt中
- m_tissuesName = tissuesList.Rows[0]["tissue_name"].ToString();
- }
- private void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- DateTime assayTime = dtpAssayTime.Value;
- string samplingType = txtType.Text.Trim();
- string samplingName = txtName.Text.Trim();
- string fileName = txtFileName.Text.Trim();
- DateTime samplingTime = dtpSamplingTime.Value;
- string notes = txtNotes.Text.Trim();
- if(string.IsNullOrEmpty(samplingType) || string.IsNullOrWhiteSpace(samplingType))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasepletype.text"));
- return;
- }
- if (string.IsNullOrEmpty(samplingName) || string.IsNullOrWhiteSpace(samplingName))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasefillintlename.text"));
- return;
- }
- if (string.IsNullOrEmpty(fileName) || string.IsNullOrWhiteSpace(fileName))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasefillname.text"));
- return;
- }
- // TODO 需要保存成文件?
- string id = System.Guid.NewGuid().ToString("N");
- string insert_sql = "insert into mic_assay_history(id, tissue_id, tissue_name, assay_time, sampling_type, sampling_name, file_name, sampling_time, notes, delete_flag) values(?,?,?,?,?,?,?,?,?,?)"; //插入的SQL语句(带参数)
- SQLiteParameter[] para = new SQLiteParameter[10]; //构造并绑定参数
- string[] tag = {"id", "tissue_id", "tissue_name", "assay_time", "sampling_type", "sampling_name", "file_name", "sampling_time", "notes", "delete_flag" };
- Object[] value = { id, m_tissuesId, m_tissuesName, assayTime, samplingType, samplingName, fileName, samplingTime, notes, 0 };
- for (int i = 0; i < 10; i++)
- {
- para[i] = new SQLiteParameter(tag[i], value[i]);
- }
- int ret = m_sqlHelper.ExecuteNonQuery(insert_sql, para); //执行插入操作
- if (ret > 0)
- {
- for(int i=0;i< m_assayList.Rows.Count; ++i)
- {
- insert_sql = "insert into mic_assay_history_info (history_id, name, hot_key, color, count, ratio) values(?,?,?,?,?,?)"; //插入的SQL语句(带参数)
- para = new SQLiteParameter[6]; //构造并绑定参数
- string[] tag2 = { "history_id", "name", "hot_key", "color", "count", "ratio"};
- Object[] value2 = { id, m_assayList.Rows[i]["name"], m_assayList.Rows[i]["hot_key"], m_assayList.Rows[i]["color"], m_assayList.Rows[i]["count"], m_assayList.Rows[i]["ratio"] };
- for (int t = 0; t < 6; t++)
- {
- para[t] = new SQLiteParameter(tag2[t], value2[t]);
- }
- m_sqlHelper.ExecuteNonQuery(insert_sql, para); //执行插入操作
- }
- }
- MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text"));
- this.Close();
- }catch(Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void SavingDialog_FormClosing(object sender, FormClosingEventArgs e)
- {
- m_sqlHelper.DisConnect();
- }
- }
- }
|