using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; 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 HistoryDialog : PdnBaseForm { #region /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. 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.assay_time.HeaderText = PdnResources.GetString("Menu.Measuringtime.text"); this.sampling_type.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Integrator.Sampletype.text"); this.sampling_name.HeaderText = PdnResources.GetString("Menu.samplename.text"); this.file_name.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Integrator.filename.text"); this.sampling_time.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Integrator.Samplingtime.text"); this.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.HistoryView.text"); this.groupBox1.Text = PdnResources.GetString("Menu.operation.text"); this.label2.Text = PdnResources.GetString("Menu.Measuringtime.text") + ":"; this.label1.Text = PdnResources.GetString("Menu.organizationname.text") + ":"; this.btnSearch.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Inquire.text"); this.btnShow.Text = PdnResources.GetString("Menu.detailed.text"); this.btnDelete.Text = PdnResources.GetString("Menu.Edit.Delete.Text"); this.groupBox2.Text = PdnResources.GetString("Menu.operation.text"); this.tissue_name.HeaderText = PdnResources.GetString("Menu.organizationname.text"); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.groupBox1 = new System.Windows.Forms.GroupBox(); this.label3 = new System.Windows.Forms.Label(); this.dtpEnd = new System.Windows.Forms.DateTimePicker(); this.dtpBegin = new System.Windows.Forms.DateTimePicker(); this.label2 = new System.Windows.Forms.Label(); this.txtName = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.btnSearch = new System.Windows.Forms.Button(); this.btnShow = new System.Windows.Forms.Button(); this.btnDelete = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.dgvHistory = new System.Windows.Forms.DataGridView(); this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.tissue_name = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.assay_time = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.sampling_type = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.sampling_name = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.file_name = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.sampling_time = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgvHistory)).BeginInit(); this.SuspendLayout(); // // groupBox1 // this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox1.Controls.Add(this.label3); this.groupBox1.Controls.Add(this.dtpEnd); this.groupBox1.Controls.Add(this.dtpBegin); this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.txtName); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.btnSearch); this.groupBox1.Controls.Add(this.btnShow); this.groupBox1.Controls.Add(this.btnDelete); this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(994, 71); this.groupBox1.TabIndex = 2; this.groupBox1.TabStop = false; this.groupBox1.Text = "操作"; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(488, 37); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(11, 12); this.label3.TabIndex = 8; this.label3.Text = "~"; // // dtpEnd // this.dtpEnd.Location = new System.Drawing.Point(509, 27); this.dtpEnd.Name = "dtpEnd"; this.dtpEnd.Size = new System.Drawing.Size(154, 21); this.dtpEnd.TabIndex = 7; // // dtpBegin // this.dtpBegin.CustomFormat = ""; this.dtpBegin.Location = new System.Drawing.Point(328, 27); this.dtpBegin.Name = "dtpBegin"; this.dtpBegin.Size = new System.Drawing.Size(154, 21); this.dtpBegin.TabIndex = 6; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(249, 30); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(65, 12); this.label2.TabIndex = 5; this.label2.Text = "测定时间:"; // // txtName // this.txtName.Location = new System.Drawing.Point(94, 27); this.txtName.Name = "txtName"; this.txtName.Size = new System.Drawing.Size(133, 21); this.txtName.TabIndex = 4; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(9, 30); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(65, 12); this.label1.TabIndex = 3; this.label1.Text = "组织名称:"; // // btnSearch // this.btnSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnSearch.Location = new System.Drawing.Point(687, 24); this.btnSearch.Name = "btnSearch"; this.btnSearch.Size = new System.Drawing.Size(84, 31); this.btnSearch.TabIndex = 2; this.btnSearch.Text = "查询"; this.btnSearch.UseVisualStyleBackColor = true; this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click); // // btnShow // this.btnShow.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnShow.Location = new System.Drawing.Point(891, 24); this.btnShow.Name = "btnShow"; this.btnShow.Size = new System.Drawing.Size(84, 31); this.btnShow.TabIndex = 1; this.btnShow.Text = "详细"; this.btnShow.UseVisualStyleBackColor = true; this.btnShow.Click += new System.EventHandler(this.btnShow_Click); // // btnDelete // this.btnDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnDelete.Location = new System.Drawing.Point(789, 24); this.btnDelete.Name = "btnDelete"; this.btnDelete.Size = new System.Drawing.Size(84, 31); this.btnDelete.TabIndex = 0; this.btnDelete.Text = "删除"; this.btnDelete.UseVisualStyleBackColor = true; this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); // // groupBox2 // this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox2.Controls.Add(this.dgvHistory); this.groupBox2.Location = new System.Drawing.Point(12, 89); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(994, 458); this.groupBox2.TabIndex = 3; this.groupBox2.TabStop = false; this.groupBox2.Text = "操作"; // // dgvHistory // this.dgvHistory.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dgvHistory.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dgvHistory.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvHistory.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.id, this.tissue_name, this.assay_time, this.sampling_type, this.sampling_name, this.file_name, this.sampling_time}); this.dgvHistory.Location = new System.Drawing.Point(9, 24); this.dgvHistory.Name = "dgvHistory"; this.dgvHistory.RowHeadersVisible = false; this.dgvHistory.RowHeadersWidth = 20; this.dgvHistory.RowTemplate.Height = 27; this.dgvHistory.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgvHistory.Size = new System.Drawing.Size(979, 424); this.dgvHistory.TabIndex = 0; // // id // this.id.DataPropertyName = "id"; this.id.HeaderText = "id"; this.id.MinimumWidth = 6; this.id.Name = "id"; this.id.Visible = false; // // tissue_name // this.tissue_name.DataPropertyName = "tissue_name"; this.tissue_name.MinimumWidth = 6; this.tissue_name.Name = "tissue_name"; this.tissue_name.ReadOnly = true; // // assay_time // this.assay_time.DataPropertyName = "assay_time"; this.assay_time.MinimumWidth = 6; this.assay_time.Name = "assay_time"; this.assay_time.ReadOnly = true; // // sampling_type // this.sampling_type.DataPropertyName = "sampling_type"; this.sampling_type.MinimumWidth = 6; this.sampling_type.Name = "sampling_type"; this.sampling_type.ReadOnly = true; // // sampling_name // this.sampling_name.DataPropertyName = "sampling_name"; this.sampling_name.MinimumWidth = 6; this.sampling_name.Name = "sampling_name"; this.sampling_name.ReadOnly = true; // // file_name // this.file_name.DataPropertyName = "file_name"; this.file_name.MinimumWidth = 6; this.file_name.Name = "file_name"; this.file_name.ReadOnly = true; // // sampling_time // this.sampling_time.DataPropertyName = "sampling_time"; this.sampling_time.MinimumWidth = 6; this.sampling_time.Name = "sampling_time"; this.sampling_time.ReadOnly = true; // // HistoryDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1018, 555); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Name = "HistoryDialog"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "历史查看"; this.Controls.SetChildIndex(this.groupBox1, 0); this.Controls.SetChildIndex(this.groupBox2, 0); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dgvHistory)).EndInit(); this.ResumeLayout(false); } #endregion private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Label label3; private System.Windows.Forms.DateTimePicker dtpEnd; private System.Windows.Forms.DateTimePicker dtpBegin; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox txtName; private System.Windows.Forms.Label label1; private System.Windows.Forms.Button btnSearch; private System.Windows.Forms.Button btnShow; private System.Windows.Forms.Button btnDelete; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.DataGridView dgvHistory; private System.Windows.Forms.DataGridViewTextBoxColumn id; private System.Windows.Forms.DataGridViewTextBoxColumn tissue_name; private System.Windows.Forms.DataGridViewTextBoxColumn assay_time; private System.Windows.Forms.DataGridViewTextBoxColumn sampling_type; private System.Windows.Forms.DataGridViewTextBoxColumn sampling_name; private System.Windows.Forms.DataGridViewTextBoxColumn file_name; private System.Windows.Forms.DataGridViewTextBoxColumn sampling_time; #endregion private SQLiteHelper m_sqlHelper; public HistoryDialog(string tissuesId) { InitializeComponent(); InitializeLanguageText(); InitializeData(); } private void InitializeData() { dgvHistory.AutoGenerateColumns = false; dgvHistory.AllowUserToAddRows = false; m_sqlHelper = new SQLiteHelper(); //连接数据库 m_sqlHelper.Connect(); string select_sql = "select * from mic_assay_history where delete_flag = 0"; //查询的SQL语句 DataTable dt = m_sqlHelper.ExecuteDataTable(select_sql, null); //执行查询操作,结果存放在dt中 BindingSource bs = new BindingSource(); bs.DataSource = dt; dgvHistory.DataSource = bs; } private void btnSearch_Click(object sender, EventArgs e) { string name = txtName.Text.Trim(); string beginTime = dtpBegin.Value.ToString("yyyy-MM-dd 00:00:00"); string endTime = dtpEnd.Value.ToString("yyyy-MM-dd 23:59:59"); string select_sql = "select * from mic_assay_history where delete_flag = 0 and tissue_name LIKE '%"+ name + "%' and assay_time >= '"+ beginTime + "' and assay_time <= '" + endTime + "'"; //查询的SQL语句 DataTable dt = m_sqlHelper.ExecuteDataTable(select_sql, null); //执行查询操作,结果存放在dt中 BindingSource bs = new BindingSource(); bs.DataSource = dt; dgvHistory.DataSource = bs; } private void btnDelete_Click(object sender, EventArgs e) { if (dgvHistory.SelectedRows.Count <= 0) { MessageBox.Show(PdnResources.GetString("Menu.Pleasesobedeleted.text")); return; } DialogResult result = MessageBox.Show(PdnResources.GetString("Menu.Verifythattordisdeleted.text")+"?", PdnResources.GetString("Menu.Tips.text"), MessageBoxButtons.OKCancel); if (result == DialogResult.OK) { //执行删除 foreach (DataGridViewRow r in dgvHistory.SelectedRows) { if (!r.IsNewRow) { string id = r.Cells["id"].Value.ToString(); string sql = "delete from mic_assay_history where id ='" + id + "'"; m_sqlHelper.ExecuteNonQuery(sql, null); sql = "delete from mic_assay_history_info where history_id ='" + id + "'"; m_sqlHelper.ExecuteNonQuery(sql, null); dgvHistory.Rows.Remove(r); } } //MessageBox.Show(PdnResources.GetString("Menu.successfullydeleted.text")+"!"); } } private void btnShow_Click(object sender, EventArgs e) { if (dgvHistory.SelectedRows.Count != 1) { MessageBox.Show(PdnResources.GetString("Menu.Selectwofdata.text")); return; } string id = ""; foreach (DataGridViewRow r in dgvHistory.SelectedRows) { if (!r.IsNewRow) { id = r.Cells["id"].Value.ToString(); } } DetailDialog dg = new DetailDialog(id); dg.ShowDialog(); } } }