HistoryDialog.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using PaintDotNet.Base.CommTool;
  11. namespace PaintDotNet.GeneralAnalysis.Countometer
  12. {
  13. public partial class HistoryDialog : PdnBaseForm
  14. {
  15. #region
  16. /// <summary>
  17. /// Required designer variable.
  18. /// </summary>
  19. private System.ComponentModel.IContainer components = null;
  20. /// <summary>
  21. /// Clean up any resources being used.
  22. /// </summary>
  23. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  24. protected override void Dispose(bool disposing)
  25. {
  26. if (disposing && (components != null))
  27. {
  28. components.Dispose();
  29. }
  30. base.Dispose(disposing);
  31. }
  32. #region Windows Form Designer generated code
  33. private void InitializeLanguageText()
  34. {
  35. this.assay_time.HeaderText = PdnResources.GetString("Menu.Measuringtime.text");
  36. this.sampling_type.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Integrator.Sampletype.text");
  37. this.sampling_name.HeaderText = PdnResources.GetString("Menu.samplename.text");
  38. this.file_name.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Integrator.filename.text");
  39. this.sampling_time.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Integrator.Samplingtime.text");
  40. this.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.HistoryView.text");
  41. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  42. this.label2.Text = PdnResources.GetString("Menu.Measuringtime.text") + ":";
  43. this.label1.Text = PdnResources.GetString("Menu.organizationname.text") + ":";
  44. this.btnSearch.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Inquire.text");
  45. this.btnShow.Text = PdnResources.GetString("Menu.detailed.text");
  46. this.btnDelete.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  47. this.groupBox2.Text = PdnResources.GetString("Menu.operation.text");
  48. this.tissue_name.HeaderText = PdnResources.GetString("Menu.organizationname.text");
  49. }
  50. /// <summary>
  51. /// Required method for Designer support - do not modify
  52. /// the contents of this method with the code editor.
  53. /// </summary>
  54. private void InitializeComponent()
  55. {
  56. this.groupBox1 = new System.Windows.Forms.GroupBox();
  57. this.label3 = new System.Windows.Forms.Label();
  58. this.dtpEnd = new System.Windows.Forms.DateTimePicker();
  59. this.dtpBegin = new System.Windows.Forms.DateTimePicker();
  60. this.label2 = new System.Windows.Forms.Label();
  61. this.txtName = new System.Windows.Forms.TextBox();
  62. this.label1 = new System.Windows.Forms.Label();
  63. this.btnSearch = new System.Windows.Forms.Button();
  64. this.btnShow = new System.Windows.Forms.Button();
  65. this.btnDelete = new System.Windows.Forms.Button();
  66. this.groupBox2 = new System.Windows.Forms.GroupBox();
  67. this.dgvHistory = new System.Windows.Forms.DataGridView();
  68. this.id = new System.Windows.Forms.DataGridViewTextBoxColumn();
  69. this.tissue_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
  70. this.assay_time = new System.Windows.Forms.DataGridViewTextBoxColumn();
  71. this.sampling_type = new System.Windows.Forms.DataGridViewTextBoxColumn();
  72. this.sampling_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
  73. this.file_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
  74. this.sampling_time = new System.Windows.Forms.DataGridViewTextBoxColumn();
  75. this.groupBox1.SuspendLayout();
  76. this.groupBox2.SuspendLayout();
  77. ((System.ComponentModel.ISupportInitialize)(this.dgvHistory)).BeginInit();
  78. this.SuspendLayout();
  79. //
  80. // groupBox1
  81. //
  82. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  83. | System.Windows.Forms.AnchorStyles.Right)));
  84. this.groupBox1.Controls.Add(this.label3);
  85. this.groupBox1.Controls.Add(this.dtpEnd);
  86. this.groupBox1.Controls.Add(this.dtpBegin);
  87. this.groupBox1.Controls.Add(this.label2);
  88. this.groupBox1.Controls.Add(this.txtName);
  89. this.groupBox1.Controls.Add(this.label1);
  90. this.groupBox1.Controls.Add(this.btnSearch);
  91. this.groupBox1.Controls.Add(this.btnShow);
  92. this.groupBox1.Controls.Add(this.btnDelete);
  93. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  94. this.groupBox1.Name = "groupBox1";
  95. this.groupBox1.Size = new System.Drawing.Size(994, 71);
  96. this.groupBox1.TabIndex = 2;
  97. this.groupBox1.TabStop = false;
  98. this.groupBox1.Text = "操作";
  99. //
  100. // label3
  101. //
  102. this.label3.AutoSize = true;
  103. this.label3.Location = new System.Drawing.Point(488, 37);
  104. this.label3.Name = "label3";
  105. this.label3.Size = new System.Drawing.Size(11, 12);
  106. this.label3.TabIndex = 8;
  107. this.label3.Text = "~";
  108. //
  109. // dtpEnd
  110. //
  111. this.dtpEnd.Location = new System.Drawing.Point(509, 27);
  112. this.dtpEnd.Name = "dtpEnd";
  113. this.dtpEnd.Size = new System.Drawing.Size(154, 21);
  114. this.dtpEnd.TabIndex = 7;
  115. //
  116. // dtpBegin
  117. //
  118. this.dtpBegin.CustomFormat = "";
  119. this.dtpBegin.Location = new System.Drawing.Point(328, 27);
  120. this.dtpBegin.Name = "dtpBegin";
  121. this.dtpBegin.Size = new System.Drawing.Size(154, 21);
  122. this.dtpBegin.TabIndex = 6;
  123. //
  124. // label2
  125. //
  126. this.label2.AutoSize = true;
  127. this.label2.Location = new System.Drawing.Point(249, 30);
  128. this.label2.Name = "label2";
  129. this.label2.Size = new System.Drawing.Size(65, 12);
  130. this.label2.TabIndex = 5;
  131. this.label2.Text = "测定时间:";
  132. //
  133. // txtName
  134. //
  135. this.txtName.Location = new System.Drawing.Point(94, 27);
  136. this.txtName.Name = "txtName";
  137. this.txtName.Size = new System.Drawing.Size(133, 21);
  138. this.txtName.TabIndex = 4;
  139. //
  140. // label1
  141. //
  142. this.label1.AutoSize = true;
  143. this.label1.Location = new System.Drawing.Point(9, 30);
  144. this.label1.Name = "label1";
  145. this.label1.Size = new System.Drawing.Size(65, 12);
  146. this.label1.TabIndex = 3;
  147. this.label1.Text = "组织名称:";
  148. //
  149. // btnSearch
  150. //
  151. this.btnSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  152. this.btnSearch.Location = new System.Drawing.Point(687, 24);
  153. this.btnSearch.Name = "btnSearch";
  154. this.btnSearch.Size = new System.Drawing.Size(84, 31);
  155. this.btnSearch.TabIndex = 2;
  156. this.btnSearch.Text = "查询";
  157. this.btnSearch.UseVisualStyleBackColor = true;
  158. this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
  159. //
  160. // btnShow
  161. //
  162. this.btnShow.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  163. this.btnShow.Location = new System.Drawing.Point(891, 24);
  164. this.btnShow.Name = "btnShow";
  165. this.btnShow.Size = new System.Drawing.Size(84, 31);
  166. this.btnShow.TabIndex = 1;
  167. this.btnShow.Text = "详细";
  168. this.btnShow.UseVisualStyleBackColor = true;
  169. this.btnShow.Click += new System.EventHandler(this.btnShow_Click);
  170. //
  171. // btnDelete
  172. //
  173. this.btnDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  174. this.btnDelete.Location = new System.Drawing.Point(789, 24);
  175. this.btnDelete.Name = "btnDelete";
  176. this.btnDelete.Size = new System.Drawing.Size(84, 31);
  177. this.btnDelete.TabIndex = 0;
  178. this.btnDelete.Text = "删除";
  179. this.btnDelete.UseVisualStyleBackColor = true;
  180. this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
  181. //
  182. // groupBox2
  183. //
  184. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  185. | System.Windows.Forms.AnchorStyles.Left)
  186. | System.Windows.Forms.AnchorStyles.Right)));
  187. this.groupBox2.Controls.Add(this.dgvHistory);
  188. this.groupBox2.Location = new System.Drawing.Point(12, 89);
  189. this.groupBox2.Name = "groupBox2";
  190. this.groupBox2.Size = new System.Drawing.Size(994, 458);
  191. this.groupBox2.TabIndex = 3;
  192. this.groupBox2.TabStop = false;
  193. this.groupBox2.Text = "操作";
  194. //
  195. // dgvHistory
  196. //
  197. this.dgvHistory.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  198. | System.Windows.Forms.AnchorStyles.Left)
  199. | System.Windows.Forms.AnchorStyles.Right)));
  200. this.dgvHistory.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  201. this.dgvHistory.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  202. this.dgvHistory.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  203. this.id,
  204. this.tissue_name,
  205. this.assay_time,
  206. this.sampling_type,
  207. this.sampling_name,
  208. this.file_name,
  209. this.sampling_time});
  210. this.dgvHistory.Location = new System.Drawing.Point(9, 24);
  211. this.dgvHistory.Name = "dgvHistory";
  212. this.dgvHistory.RowHeadersVisible = false;
  213. this.dgvHistory.RowHeadersWidth = 20;
  214. this.dgvHistory.RowTemplate.Height = 27;
  215. this.dgvHistory.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  216. this.dgvHistory.Size = new System.Drawing.Size(979, 424);
  217. this.dgvHistory.TabIndex = 0;
  218. //
  219. // id
  220. //
  221. this.id.DataPropertyName = "id";
  222. this.id.HeaderText = "id";
  223. this.id.MinimumWidth = 6;
  224. this.id.Name = "id";
  225. this.id.Visible = false;
  226. //
  227. // tissue_name
  228. //
  229. this.tissue_name.DataPropertyName = "tissue_name";
  230. this.tissue_name.MinimumWidth = 6;
  231. this.tissue_name.Name = "tissue_name";
  232. this.tissue_name.ReadOnly = true;
  233. //
  234. // assay_time
  235. //
  236. this.assay_time.DataPropertyName = "assay_time";
  237. this.assay_time.MinimumWidth = 6;
  238. this.assay_time.Name = "assay_time";
  239. this.assay_time.ReadOnly = true;
  240. //
  241. // sampling_type
  242. //
  243. this.sampling_type.DataPropertyName = "sampling_type";
  244. this.sampling_type.MinimumWidth = 6;
  245. this.sampling_type.Name = "sampling_type";
  246. this.sampling_type.ReadOnly = true;
  247. //
  248. // sampling_name
  249. //
  250. this.sampling_name.DataPropertyName = "sampling_name";
  251. this.sampling_name.MinimumWidth = 6;
  252. this.sampling_name.Name = "sampling_name";
  253. this.sampling_name.ReadOnly = true;
  254. //
  255. // file_name
  256. //
  257. this.file_name.DataPropertyName = "file_name";
  258. this.file_name.MinimumWidth = 6;
  259. this.file_name.Name = "file_name";
  260. this.file_name.ReadOnly = true;
  261. //
  262. // sampling_time
  263. //
  264. this.sampling_time.DataPropertyName = "sampling_time";
  265. this.sampling_time.MinimumWidth = 6;
  266. this.sampling_time.Name = "sampling_time";
  267. this.sampling_time.ReadOnly = true;
  268. //
  269. // HistoryDialog
  270. //
  271. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  272. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  273. this.ClientSize = new System.Drawing.Size(1018, 555);
  274. this.Controls.Add(this.groupBox2);
  275. this.Controls.Add(this.groupBox1);
  276. this.Name = "HistoryDialog";
  277. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  278. this.Text = "历史查看";
  279. this.Controls.SetChildIndex(this.groupBox1, 0);
  280. this.Controls.SetChildIndex(this.groupBox2, 0);
  281. this.groupBox1.ResumeLayout(false);
  282. this.groupBox1.PerformLayout();
  283. this.groupBox2.ResumeLayout(false);
  284. ((System.ComponentModel.ISupportInitialize)(this.dgvHistory)).EndInit();
  285. this.ResumeLayout(false);
  286. }
  287. #endregion
  288. private System.Windows.Forms.GroupBox groupBox1;
  289. private System.Windows.Forms.Label label3;
  290. private System.Windows.Forms.DateTimePicker dtpEnd;
  291. private System.Windows.Forms.DateTimePicker dtpBegin;
  292. private System.Windows.Forms.Label label2;
  293. private System.Windows.Forms.TextBox txtName;
  294. private System.Windows.Forms.Label label1;
  295. private System.Windows.Forms.Button btnSearch;
  296. private System.Windows.Forms.Button btnShow;
  297. private System.Windows.Forms.Button btnDelete;
  298. private System.Windows.Forms.GroupBox groupBox2;
  299. private System.Windows.Forms.DataGridView dgvHistory;
  300. private System.Windows.Forms.DataGridViewTextBoxColumn id;
  301. private System.Windows.Forms.DataGridViewTextBoxColumn tissue_name;
  302. private System.Windows.Forms.DataGridViewTextBoxColumn assay_time;
  303. private System.Windows.Forms.DataGridViewTextBoxColumn sampling_type;
  304. private System.Windows.Forms.DataGridViewTextBoxColumn sampling_name;
  305. private System.Windows.Forms.DataGridViewTextBoxColumn file_name;
  306. private System.Windows.Forms.DataGridViewTextBoxColumn sampling_time;
  307. #endregion
  308. private SQLiteHelper m_sqlHelper;
  309. public HistoryDialog(string tissuesId)
  310. {
  311. InitializeComponent();
  312. InitializeLanguageText();
  313. InitializeData();
  314. }
  315. private void InitializeData()
  316. {
  317. dgvHistory.AutoGenerateColumns = false;
  318. dgvHistory.AllowUserToAddRows = false;
  319. m_sqlHelper = new SQLiteHelper(); //连接数据库
  320. m_sqlHelper.Connect();
  321. string select_sql = "select * from mic_assay_history where delete_flag = 0"; //查询的SQL语句
  322. DataTable dt = m_sqlHelper.ExecuteDataTable(select_sql, null); //执行查询操作,结果存放在dt中
  323. BindingSource bs = new BindingSource();
  324. bs.DataSource = dt;
  325. dgvHistory.DataSource = bs;
  326. }
  327. private void btnSearch_Click(object sender, EventArgs e)
  328. {
  329. string name = txtName.Text.Trim();
  330. string beginTime = dtpBegin.Value.ToString("yyyy-MM-dd 00:00:00");
  331. string endTime = dtpEnd.Value.ToString("yyyy-MM-dd 23:59:59");
  332. 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语句
  333. DataTable dt = m_sqlHelper.ExecuteDataTable(select_sql, null); //执行查询操作,结果存放在dt中
  334. BindingSource bs = new BindingSource();
  335. bs.DataSource = dt;
  336. dgvHistory.DataSource = bs;
  337. }
  338. private void btnDelete_Click(object sender, EventArgs e)
  339. {
  340. if (dgvHistory.SelectedRows.Count <= 0)
  341. {
  342. MessageBox.Show(PdnResources.GetString("Menu.Pleasesobedeleted.text"));
  343. return;
  344. }
  345. DialogResult result = MessageBox.Show(PdnResources.GetString("Menu.Verifythattordisdeleted.text")+"?", PdnResources.GetString("Menu.Tips.text"), MessageBoxButtons.OKCancel);
  346. if (result == DialogResult.OK)
  347. {
  348. //执行删除
  349. foreach (DataGridViewRow r in dgvHistory.SelectedRows)
  350. {
  351. if (!r.IsNewRow)
  352. {
  353. string id = r.Cells["id"].Value.ToString();
  354. string sql = "delete from mic_assay_history where id ='" + id + "'";
  355. m_sqlHelper.ExecuteNonQuery(sql, null);
  356. sql = "delete from mic_assay_history_info where history_id ='" + id + "'";
  357. m_sqlHelper.ExecuteNonQuery(sql, null);
  358. dgvHistory.Rows.Remove(r);
  359. }
  360. }
  361. //MessageBox.Show(PdnResources.GetString("Menu.successfullydeleted.text")+"!");
  362. }
  363. }
  364. private void btnShow_Click(object sender, EventArgs e)
  365. {
  366. if (dgvHistory.SelectedRows.Count != 1)
  367. {
  368. MessageBox.Show(PdnResources.GetString("Menu.Selectwofdata.text"));
  369. return;
  370. }
  371. string id = "";
  372. foreach (DataGridViewRow r in dgvHistory.SelectedRows)
  373. {
  374. if (!r.IsNewRow)
  375. {
  376. id = r.Cells["id"].Value.ToString();
  377. }
  378. }
  379. DetailDialog dg = new DetailDialog(id);
  380. dg.ShowDialog();
  381. }
  382. }
  383. }