QCM030101.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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.Windows.Forms;
  9. using CoreFS.CA06;
  10. using System.Collections;
  11. using Infragistics.Win.UltraWinGrid;
  12. using System.Diagnostics;
  13. namespace Core.LZMes.Client.QCM
  14. {
  15. public partial class QCM030101 : FrmBase
  16. {
  17. public QCM030101()
  18. {
  19. InitializeComponent();
  20. }
  21. public override void ToolBar_Click(object sender, string ToolbarKey)
  22. {
  23. switch (ToolbarKey)
  24. {
  25. case"Query":
  26. this.DoQuery();
  27. break;
  28. case "Judge":
  29. this.Judge();
  30. break;
  31. case "Cancel":
  32. this.Cancel();
  33. break;
  34. case "Export":
  35. this.DoExport();
  36. break;
  37. }
  38. }
  39. private void Judge()
  40. {
  41. try
  42. {
  43. UltraGridRow ugr = this.ultraGrid1.ActiveRow;
  44. List<string> list1 = new List<string>();
  45. if (ugr == null)
  46. return;
  47. string smp_no = ugr.Cells["SMP_NO"].Value.ToString();
  48. string material_no = ugr.Cells["MATERIAL_NO"].Value.ToString();
  49. string design_key = ugr.Cells["DESIGN_KEY"].Value.ToString();
  50. string grade_name = ugr.Cells["GRADE_NAME"].Value.ToString();
  51. string username = this.UserInfo.GetUserName();
  52. string assay_no = "";
  53. foreach (UltraGridRow ugrs in this.ultraGrid2.Rows)
  54. {
  55. if (ugrs.Cells["CHECKBOX"].Text.ToString() == "True")
  56. {
  57. assay_no = ugrs.Cells["STD_TYPE"].Value.ToString();
  58. list1.Add(assay_no);
  59. }
  60. }
  61. if (list1.Count == 0)
  62. {
  63. MessageBox.Show("请选择检验实绩!");
  64. return;
  65. }
  66. CoreClientParam ccp = new CoreClientParam();
  67. ccp.ServerName = "QCM.QCM03.QCM0301.QcmJhyElementsServiceImpl";
  68. ccp.MethodName = "JudgeByHuman1";
  69. ccp.ServerParams = new object[] { smp_no, username, list1 };
  70. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  71. if (ccp.ReturnCode == -1)
  72. {
  73. return;
  74. }
  75. ugr.Delete(false);
  76. MessageBox.Show("判定成功!");
  77. }
  78. catch (Exception EX)
  79. {
  80. MessageBox.Show(EX.ToString());
  81. }
  82. }
  83. private void Cancel()
  84. {
  85. try
  86. {
  87. UltraGridRow ugr = this.ultraGrid4.ActiveRow;
  88. if (ugr == null)
  89. return;
  90. string inspection_lot = ugr.Cells["inspection_lot"].Value.ToString();
  91. string smp_no = ugr.Cells["smp_no"].Value.ToString();
  92. string username = this.UserInfo.GetUserName();
  93. CoreClientParam ccp = new CoreClientParam();
  94. ccp.ServerName = "QCM.QCM03.QCM0301.QcmJudgeChemicalServiceImpl";
  95. ccp.MethodName = "CancelJudge";
  96. ccp.ServerParams = new object[] { inspection_lot,smp_no,username };
  97. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  98. if (ccp.ReturnCode == -1)
  99. {
  100. return;
  101. }
  102. MessageBox.Show("取消判定成功!");
  103. }
  104. catch (Exception ex)
  105. {
  106. System.Diagnostics.Debug.WriteLine(ex.ToString());
  107. MessageBox.Show("系统出错,请联系管理人员", "警告");
  108. }
  109. }
  110. private void DoQuery()
  111. {
  112. if (this.ultraTabControl1.Tabs[0].Selected) //待判信息
  113. {
  114. DoQueryMe();
  115. }
  116. if (this.ultraTabControl1.Tabs[1].Selected) //判定记录
  117. {
  118. DoQueryRe();
  119. }
  120. }
  121. //查询待判信息
  122. private void DoQueryMe()
  123. {
  124. try
  125. {
  126. if (comboBox1.SelectedIndex == 2)
  127. {
  128. MessageBox.Show("请选择委托生成或者发送时间!");
  129. return;
  130. }
  131. this.dataSet2.Clear();
  132. string heatno = textBox1.Text.Trim();
  133. string BOARD_NO = textBox2.Text.Trim();
  134. string design_key = textBox3.Text.Trim();
  135. string psc = textBox4.Text.Trim();
  136. string prodline = comboBox3.Text.ToString();
  137. string status = this.comboBox1.SelectedIndex.ToString();
  138. CoreClientParam ccp = new CoreClientParam();
  139. ccp.ServerName = "QCM.QCM03.QCM0301.QcmJhyElementsServiceImpl";
  140. ccp.MethodName = "getRejudgeInfo";
  141. ccp.ServerParams = new object[] { this.dateTimePicker1.Value.ToString("yyyyMMdd"), this.dateTimePicker2.Value.ToString("yyyyMMdd"),heatno, BOARD_NO, design_key, psc,"1" ,prodline,status};
  142. ccp.SourceDataTable = this.dataSet2.Tables[0];
  143. this.ExecuteQueryToDataTable(ccp,CoreInvokeType.Internal);
  144. }
  145. catch (Exception ex)
  146. {
  147. System.Diagnostics.Debug.WriteLine(ex.ToString());
  148. MessageBox.Show("系统出错,请联系管理人员", "警告");
  149. }
  150. }
  151. //查询判定记录
  152. private void DoQueryRe()
  153. {
  154. try
  155. {
  156. if (comboBox1.SelectedIndex != 2)
  157. {
  158. MessageBox.Show("请选择判定时间!");
  159. return;
  160. }
  161. this.dataSet1.Clear();
  162. string heatno = textBox1.Text.Trim();
  163. string BOARD_NO = textBox2.Text.Trim();
  164. string design_key = textBox3.Text.Trim();
  165. string psc = textBox4.Text.Trim();
  166. string prodline = comboBox3.Text.ToString();
  167. CoreClientParam ccp = new CoreClientParam();
  168. ccp.ServerName = "QCM.QCM03.QCM0301.QcmJudgeChemicalServiceImpl";
  169. ccp.MethodName = "GetJudgeChemRecord";
  170. ccp.ServerParams = new object[] { this.dateTimePicker1.Value.ToString("yyyyMMdd"), this.dateTimePicker2.Value.ToString("yyyyMMdd"), heatno, BOARD_NO, design_key, psc,"1",prodline };
  171. ccp.SourceDataTable = this.dataSet1.Tables[0];
  172. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  173. }
  174. catch (Exception ex)
  175. {
  176. System.Diagnostics.Debug.WriteLine(ex.ToString());
  177. MessageBox.Show("系统出错,请联系管理人员", "警告");
  178. }
  179. }
  180. private void ultraGrid4_AfterRowActivate(object sender, EventArgs e)
  181. {
  182. try
  183. {
  184. UltraGridRow ugr = this.ultraGrid4.ActiveRow;
  185. if (ugr == null)
  186. return;
  187. this.dataSet4.Clear();
  188. string cic_id = ugr.Cells["CIC_ID"].Value.ToString();
  189. CoreClientParam ccp = new CoreClientParam();
  190. ccp.ServerName = "QCM.QCM03.QCM0301.QcmJhyElementsServiceImpl";
  191. ccp.MethodName = "GetChemeResult";
  192. ccp.ServerParams = new object[] { cic_id };
  193. ccp.SourceDataTable = this.dataSet4.Tables[0];
  194. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  195. ccp = new CoreClientParam();
  196. ccp.ServerName = "QCM.QCM03.QCM0301.QcmJhyElementsServiceImpl";
  197. ccp.MethodName = "GetCheme";
  198. ccp.ServerParams = new object[] { cic_id };
  199. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  200. UltraGridRow judge_row = null;
  201. foreach (UltraGridRow ugst in this.ultraGrid5.Rows)
  202. {
  203. if (!ugst.Cells["STD_TYPE"].Text.ToString().Contains("标准") && !ugst.Cells["STD_TYPE"].Text.ToString().Contains("要求"))
  204. {
  205. judge_row = ugst;
  206. }
  207. if (judge_row != null)
  208. {
  209. foreach (UltraGridRow ugs in this.ultraGrid5.Rows)
  210. {
  211. if (!string.IsNullOrEmpty(ugs.Cells["STD_TYPE"].Text) && (ugs.Cells["STD_TYPE"].Text.ToString() == "交付标准(成品成分)" || ugs.Cells["STD_TYPE"].Text.ToString() == "特殊要求(成品成分)"))
  212. {
  213. for (int i = 0; i < ugs.Cells.Count; i++)
  214. {
  215. if (!string.IsNullOrEmpty(ugs.Cells[i].Text) && ugs.Cells[i].Text.ToString().Contains(" "))
  216. {
  217. string[] str_arr = ugs.Cells[i].Text.ToString().Replace(" ", "#").Split('#');
  218. if (str_arr.Length == 1)
  219. {
  220. if (str_arr[0].Contains("<=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  221. {
  222. if (double.Parse(str_arr[0].Replace("<=", "")) < double.Parse(judge_row.Cells[i].Text.ToString()))
  223. {
  224. judge_row.Cells[i].Appearance.BackColor = Color.Red;
  225. judge_row.Cells["STD_TYPE"].Appearance.BackColor = Color.Red;
  226. }
  227. }
  228. else if (str_arr[0].Contains(">=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  229. {
  230. if (double.Parse(str_arr[0].Replace(">=", "")) > double.Parse(judge_row.Cells[i].Text.ToString()))
  231. {
  232. judge_row.Cells[i].Appearance.BackColor = Color.Red;
  233. judge_row.Cells["STD_TYPE"].Appearance.BackColor = Color.Red;
  234. }
  235. }
  236. }
  237. else if (str_arr.Length == 2)
  238. {
  239. if (str_arr[0].Contains("<=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  240. {
  241. if (double.Parse(str_arr[0].Replace("<=", "")) < double.Parse(judge_row.Cells[i].Text.ToString()))
  242. {
  243. judge_row.Cells[i].Appearance.BackColor = Color.Red;
  244. judge_row.Cells["STD_TYPE"].Appearance.BackColor = Color.Red;
  245. }
  246. }
  247. else if (str_arr[0].Contains(">=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  248. {
  249. if (double.Parse(str_arr[0].Replace(">=", "")) > double.Parse(judge_row.Cells[i].Text.ToString()))
  250. {
  251. judge_row.Cells[i].Appearance.BackColor = Color.Red;
  252. judge_row.Cells["STD_TYPE"].Appearance.BackColor = Color.Red;
  253. }
  254. }
  255. if (str_arr[1].Contains("<=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  256. {
  257. if (double.Parse(str_arr[1].Replace("<=", "")) < double.Parse(judge_row.Cells[i].Text.ToString()))
  258. {
  259. judge_row.Cells[i].Appearance.BackColor = Color.Red;
  260. judge_row.Cells["STD_TYPE"].Appearance.BackColor = Color.Red;
  261. }
  262. }
  263. else if (str_arr[1].Contains(">=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  264. {
  265. if (double.Parse(str_arr[1].Replace(">=", "")) > double.Parse(judge_row.Cells[i].Text.ToString()))
  266. {
  267. judge_row.Cells[i].Appearance.BackColor = Color.Red;
  268. judge_row.Cells["STD_TYPE"].Appearance.BackColor = Color.Red;
  269. }
  270. }
  271. }
  272. }
  273. }
  274. }
  275. }
  276. }
  277. }
  278. }
  279. catch (Exception ex)
  280. {
  281. System.Diagnostics.Debug.WriteLine(ex.ToString());
  282. MessageBox.Show("系统出错,请联系管理人员", "警告");
  283. }
  284. }
  285. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  286. {
  287. try
  288. {
  289. UltraGridRow ugr = this.ultraGrid1.ActiveRow;
  290. if (ugr == null)
  291. return;
  292. this.dataSet3.Clear();
  293. string design_key = ugr.Cells["DESIGN_KEY"].Value.ToString();
  294. string smp_no = ugr.Cells["SMP_NO"].Value.ToString();
  295. CoreClientParam ccp = new CoreClientParam();
  296. ccp.ServerName = "QCM.QCM03.QCM0301.QcmJhyElementsServiceImpl";
  297. ccp.MethodName = "GetChemeInfo";
  298. ccp.ServerParams = new object[] { design_key, smp_no };
  299. ccp.SourceDataTable = this.dataSet3.Tables[0];
  300. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  301. foreach (UltraGridRow ugs in this.ultraGrid2.Rows)
  302. {
  303. ugs.Cells["CHECKBOX"].Value = ugs.Cells["CHECKBOXS"].Text.ToString();
  304. }
  305. UltraGridRow judge_row = null;
  306. foreach (UltraGridRow ugst in this.ultraGrid2.Rows)
  307. {
  308. if (!ugst.Cells["STD_TYPE"].Text.ToString().Contains("标准") && !ugst.Cells["STD_TYPE"].Text.ToString().Contains("要求"))
  309. {
  310. judge_row = ugst;
  311. }
  312. if (judge_row != null)
  313. {
  314. foreach (UltraGridRow ugs in this.ultraGrid2.Rows)
  315. {
  316. if (!string.IsNullOrEmpty(ugs.Cells["STD_TYPE"].Text) && (ugs.Cells["STD_TYPE"].Text.ToString() == "交付标准(成品成分)" || ugs.Cells["STD_TYPE"].Text.ToString() == "特殊要求(成品成分)"))
  317. {
  318. for (int i = 0; i < ugs.Cells.Count; i++)
  319. {
  320. if (!string.IsNullOrEmpty(ugs.Cells[i].Text) && ugs.Cells[i].Text.ToString().Contains(" "))
  321. {
  322. string[] str_arr = ugs.Cells[i].Text.ToString().Replace(" ", "#").Split('#');
  323. if (str_arr.Length == 1)
  324. {
  325. if (str_arr[0].Contains("<=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  326. {
  327. if (double.Parse(str_arr[0].Replace("<=", "")) < double.Parse(judge_row.Cells[i].Text.ToString()))
  328. {
  329. judge_row.Cells[i].Appearance.BackColor = Color.Red;
  330. judge_row.Cells["STD_TYPE"].Appearance.BackColor = Color.Red;
  331. }
  332. }
  333. else if (str_arr[0].Contains(">=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  334. {
  335. if (double.Parse(str_arr[0].Replace(">=", "")) > double.Parse(judge_row.Cells[i].Text.ToString()))
  336. {
  337. judge_row.Cells[i].Appearance.BackColor = Color.Red;
  338. judge_row.Cells["STD_TYPE"].Appearance.BackColor = Color.Red;
  339. }
  340. }
  341. }
  342. else if (str_arr.Length == 2)
  343. {
  344. if (str_arr[0].Contains("<=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  345. {
  346. if (double.Parse(str_arr[0].Replace("<=", "")) < double.Parse(judge_row.Cells[i].Text.ToString()))
  347. {
  348. judge_row.Cells[i].Appearance.BackColor = Color.Red;
  349. judge_row.Cells["STD_TYPE"].Appearance.BackColor = Color.Red;
  350. }
  351. }
  352. else if (str_arr[0].Contains(">=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  353. {
  354. if (double.Parse(str_arr[0].Replace(">=", "")) > double.Parse(judge_row.Cells[i].Text.ToString()))
  355. {
  356. judge_row.Cells[i].Appearance.BackColor = Color.Red;
  357. judge_row.Cells["STD_TYPE"].Appearance.BackColor = Color.Red;
  358. }
  359. }
  360. if (str_arr[1].Contains("<=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  361. {
  362. if (double.Parse(str_arr[1].Replace("<=", "")) < double.Parse(judge_row.Cells[i].Text.ToString()))
  363. {
  364. judge_row.Cells[i].Appearance.BackColor = Color.Red;
  365. judge_row.Cells["STD_TYPE"].Appearance.BackColor = Color.Red;
  366. }
  367. }
  368. else if (str_arr[1].Contains(">=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  369. {
  370. if (double.Parse(str_arr[1].Replace(">=", "")) > double.Parse(judge_row.Cells[i].Text.ToString()))
  371. {
  372. judge_row.Cells[i].Appearance.BackColor = Color.Red;
  373. judge_row.Cells["STD_TYPE"].Appearance.BackColor = Color.Red;
  374. }
  375. }
  376. }
  377. }
  378. }
  379. }
  380. }
  381. }
  382. }
  383. }
  384. catch (Exception ex)
  385. {
  386. System.Diagnostics.Debug.WriteLine(ex.ToString());
  387. MessageBox.Show("系统出错,请联系管理人员", "警告");
  388. }
  389. }
  390. private void QCM030101_Load(object sender, EventArgs e)
  391. {
  392. this.comboBox3.SelectedIndex = 0;
  393. this.comboBox1.SelectedIndex = 1;
  394. this.ultraGrid1.DisplayLayout.Override.FilterUIType = FilterUIType.HeaderIcons;
  395. this.ultraGrid4.DisplayLayout.Override.FilterUIType = FilterUIType.HeaderIcons;
  396. this.dateTimePicker1.Value = System.DateTime.Now.AddDays(-7);
  397. this.DoQuery();
  398. }
  399. private void ultraTabControl1_Click(object sender, EventArgs e)
  400. {
  401. if (this.ultraTabControl1.Tabs[1].Selected) //判定记录
  402. {
  403. this.comboBox1.SelectedIndex = 2;
  404. }
  405. if (this.ultraTabControl1.Tabs[0].Selected) //判定记录
  406. {
  407. this.comboBox1.SelectedIndex = 1;
  408. }
  409. }
  410. private void DoExport()
  411. {
  412. try
  413. {
  414. if (this.ultraGrid4.Rows.Count == 0)
  415. {
  416. MessageBox.Show("没有可以导出的数据", "提示");
  417. return;
  418. }
  419. if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
  420. {
  421. string fName = this.saveFileDialog1.FileName;
  422. this.ultraGridExcelExporter1.Export(this.ultraGrid4, fName);
  423. Process.Start(fName);
  424. }
  425. }
  426. catch (Exception ex)
  427. {
  428. System.Diagnostics.Debug.WriteLine(ex.ToString());
  429. }
  430. }
  431. }
  432. }