QCM030802.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  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 QCM030802 : FrmBase
  16. {
  17. public QCM030802()
  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. List<UltraGridRow> lists = new List<UltraGridRow>();
  44. HashSet<String> hashSet = new HashSet<String>();
  45. int num = 0;
  46. String hno = "";
  47. foreach (UltraGridRow row in this.ultraGrid1.Rows)
  48. {
  49. if (row.Cells["check"].Text.ToString() == "True")
  50. {
  51. String HEAT_NO = row.Cells["HEAT_NO"].Value.ToString();
  52. hashSet.Add(HEAT_NO);
  53. hno = HEAT_NO;
  54. num++;
  55. }
  56. }
  57. if (hashSet.Count != 1)
  58. {
  59. this.alert("只能同炉多选判定!请核实炉号数据!");
  60. return;
  61. }
  62. if (num>=2)
  63. {
  64. List<string> list1 = new List<string>();
  65. string assay_no = "";
  66. foreach (UltraGridRow ugrs in this.ultraGrid2.Rows)
  67. {
  68. if (ugrs.Cells["CHECKBOX"].Text.ToString() == "True")
  69. {
  70. assay_no = ugrs.Cells["STD_TYPE"].Value.ToString();
  71. list1.Add(assay_no);
  72. }
  73. }
  74. if (list1.Count == 0)
  75. {
  76. MessageBox.Show("请选择检验实绩!");
  77. return;
  78. }
  79. //判定是否是同炉的
  80. if (!assay_no.Contains(hno))
  81. {
  82. MessageBox.Show("请选择正确的检验实绩!请核实当前选择的炉号是:" + hno + ",实绩是:" + assay_no+",炉号和实绩不符!");
  83. DoQuery();
  84. return;
  85. }
  86. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  87. {
  88. if (ugr.Cells["check"].Text.ToString() == "True")
  89. {
  90. lists.Add(ugr);
  91. string heat_no = ugr.Cells["HEAT_NO"].Value.ToString();
  92. string material_no = ugr.Cells["MATERIAL_NO"].Value.ToString();
  93. string design_key = ugr.Cells["DESIGN_KEY"].Value.ToString();
  94. string grade_name = ugr.Cells["GRADE_NAME"].Value.ToString();
  95. string username = this.UserInfo.GetUserName();
  96. CoreClientParam ccp = new CoreClientParam();
  97. ccp.ServerName = "QCM.QCM03.QCM0301.QcmJhyElementsServiceImpl";
  98. ccp.MethodName = "RlChemJudgeByHuman";
  99. ccp.ServerParams = new object[] { heat_no, material_no, design_key, username, grade_name, list1 };
  100. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  101. if (ccp.ReturnCode == -1)
  102. {
  103. this.DoQuery();
  104. return;
  105. }
  106. }
  107. }
  108. for (int i = 0; i < lists.Count; i++)
  109. {
  110. lists[i].Delete(false);
  111. }
  112. }else{
  113. UltraGridRow ugr = this.ultraGrid1.ActiveRow;
  114. List<string> list1 = new List<string>();
  115. if (ugr == null)
  116. return;
  117. string heat_no = ugr.Cells["HEAT_NO"].Value.ToString();
  118. string material_no = ugr.Cells["MATERIAL_NO"].Value.ToString();
  119. string design_key = ugr.Cells["DESIGN_KEY"].Value.ToString();
  120. string grade_name = ugr.Cells["GRADE_NAME"].Value.ToString();
  121. string username = this.UserInfo.GetUserName();
  122. string assay_no = "";
  123. foreach (UltraGridRow ugrs in this.ultraGrid2.Rows)
  124. {
  125. if (ugrs.Cells["CHECKBOX"].Text.ToString() == "True")
  126. {
  127. assay_no = ugrs.Cells["STD_TYPE"].Value.ToString();
  128. list1.Add(assay_no);
  129. }
  130. }
  131. if (list1.Count == 0)
  132. {
  133. MessageBox.Show("请选择检验实绩!");
  134. return;
  135. }
  136. CoreClientParam ccp = new CoreClientParam();
  137. ccp.ServerName = "QCM.QCM03.QCM0301.QcmJhyElementsServiceImpl";
  138. ccp.MethodName = "RlChemJudgeByHuman";
  139. ccp.ServerParams = new object[] { heat_no,material_no,design_key, username,grade_name,list1 };
  140. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  141. if (ccp.ReturnCode == -1)
  142. {
  143. return;
  144. }
  145. ugr.Delete(false);
  146. }
  147. MessageBox.Show("判定成功!");
  148. }
  149. catch(Exception EX)
  150. {
  151. MessageBox.Show(EX.ToString());
  152. }
  153. //DoQuery();
  154. }
  155. private void Cancel()
  156. {
  157. try
  158. {
  159. UltraGridRow ugr = this.ultraGrid4.ActiveRow;
  160. if (ugr == null)
  161. return;
  162. string material_no = ugr.Cells["material_no"].Value.ToString();
  163. string username = this.UserInfo.GetUserName();
  164. CoreClientParam ccp = new CoreClientParam();
  165. ccp.ServerName = "QCM.QCM03.QCM0301.QcmJudgeChemicalServiceImpl";
  166. ccp.MethodName = "CancelRJudge";
  167. ccp.ServerParams = new object[] { material_no,username };
  168. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  169. if (ccp.ReturnCode != -1)
  170. {
  171. MessageBox.Show("取消判定成功!");
  172. }
  173. }
  174. catch (Exception ex)
  175. {
  176. System.Diagnostics.Debug.WriteLine(ex.ToString());
  177. MessageBox.Show("系统出错,请联系管理人员", "警告");
  178. }
  179. }
  180. private void DoQuery()
  181. {
  182. if (this.ultraTabControl1.Tabs[0].Selected) //待判信息
  183. {
  184. checkBox2.Checked = false;
  185. DoQueryMe();
  186. }
  187. if (this.ultraTabControl1.Tabs[1].Selected) //判定记录
  188. {
  189. DoQueryRe();
  190. }
  191. }
  192. //查询待判信息
  193. private void DoQueryMe()
  194. {
  195. try
  196. {
  197. this.dataSet5.Clear();
  198. string sbatchno = this.textBox1.Text.Trim();
  199. string ebatchno = this.textBox2.Text.Trim();
  200. string orderno = this.textBox3.Text.Trim();// 订单号
  201. string psc = textBox4.Text.Trim(); //产品描述
  202. string prodline = comboBox3.Text.ToString();
  203. string sbatchno1 = "";
  204. string ebatchno1 = "";
  205. sbatchno1 = this.textBox5.Text.Trim();
  206. if (textBox5.Text.ToString() == "" || textBox6.Text.ToString() != "")
  207. {
  208. ebatchno1 = this.textBox6.Text.Trim();
  209. }
  210. else
  211. {
  212. ebatchno1 = this.textBox5.Text.Trim();
  213. }
  214. CoreClientParam ccp = new CoreClientParam();
  215. ccp.ServerName = "QCM.QCM03.QCM0303.QcmJudgeMeasureServiceImpl";
  216. ccp.MethodName = "doQueryMaterialDetailsXR";
  217. ccp.ServerParams = new object[] { this.dateTimePicker1.Value.ToString("yyyyMMdd"), this.dateTimePicker2.Value.ToString("yyyyMMdd"), sbatchno, ebatchno, orderno, psc, "R",prodline,sbatchno1,ebatchno1 };
  218. ccp.SourceDataTable = this.dataSet5.Tables[0];
  219. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  220. }
  221. catch (Exception ex)
  222. {
  223. System.Diagnostics.Debug.WriteLine(ex.ToString());
  224. MessageBox.Show("系统出错,请联系管理人员", "警告");
  225. }
  226. }
  227. //查询判定记录
  228. private void DoQueryRe()
  229. {
  230. try
  231. {
  232. this.dataSet1.Clear();
  233. string heatno = textBox1.Text.Trim();
  234. string BOARD_NO = textBox2.Text.Trim();
  235. string design_key = textBox3.Text.Trim();
  236. string psc = textBox4.Text.Trim();
  237. string prodline = comboBox3.Text.ToString();
  238. string sbatchno1 = "";
  239. string ebatchno1 = "";
  240. sbatchno1 = this.textBox5.Text.Trim();
  241. if (textBox5.Text.ToString() == "" || textBox6.Text.ToString() != "")
  242. {
  243. ebatchno1 = this.textBox6.Text.Trim();
  244. }
  245. else
  246. {
  247. ebatchno1 = this.textBox5.Text.Trim();
  248. }
  249. CoreClientParam ccp = new CoreClientParam();
  250. ccp.ServerName = "QCM.QCM03.QCM0301.QcmJudgeChemicalServiceImpl";
  251. ccp.MethodName = "GetJudgeRChemRecord";
  252. ccp.ServerParams = new object[] { this.dateTimePicker1.Value.ToString("yyyyMMdd"), this.dateTimePicker2.Value.ToString("yyyyMMdd"), heatno, BOARD_NO, design_key, psc,"2",prodline,sbatchno1,ebatchno1 };
  253. ccp.SourceDataTable = this.dataSet1.Tables[0];
  254. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  255. }
  256. catch (Exception ex)
  257. {
  258. System.Diagnostics.Debug.WriteLine(ex.ToString());
  259. MessageBox.Show("系统出错,请联系管理人员", "警告");
  260. }
  261. }
  262. private void ultraGrid4_AfterRowActivate(object sender, EventArgs e)
  263. {
  264. try
  265. {
  266. UltraGridRow ugr = this.ultraGrid4.ActiveRow;
  267. if (ugr == null)
  268. return;
  269. this.dataSet4.Clear();
  270. string cic_id = ugr.Cells["CIC_ID"].Value.ToString();
  271. CoreClientParam ccp = new CoreClientParam();
  272. ccp.ServerName = "QCM.QCM03.QCM0301.QcmJhyElementsServiceImpl";
  273. ccp.MethodName = "GetRChemeResult";
  274. ccp.ServerParams = new object[] { cic_id };
  275. ccp.SourceDataTable = this.dataSet4.Tables[0];
  276. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  277. ccp = new CoreClientParam();
  278. ccp.ServerName = "QCM.QCM03.QCM0301.QcmJhyElementsServiceImpl";
  279. ccp.MethodName = "GetCheme";
  280. ccp.ServerParams = new object[] { cic_id };
  281. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  282. for (int i = 0; i < ccp.SourceDataTable.Rows.Count; i++)
  283. {
  284. foreach (UltraGridRow ugr5 in this.ultraGrid5.Rows)
  285. {
  286. if (ugr5.Cells[ccp.SourceDataTable.Rows[i]["phy_code_s"].ToString()].Value.ToString().Contains(ccp.SourceDataTable.Rows[i]["stdmin"].ToString()) && ugr5.Cells[ccp.SourceDataTable.Rows[i]["phy_code_s"].ToString()].Value.ToString().Contains(ccp.SourceDataTable.Rows[i]["stdmax"].ToString()))
  287. {
  288. ugr5.Cells[ccp.SourceDataTable.Rows[i]["phy_code_s"].ToString()].Appearance.BackColor = Color.Red;
  289. }
  290. }
  291. }
  292. }
  293. catch (Exception ex)
  294. {
  295. //System.Diagnostics.Debug.WriteLine(ex.ToString());
  296. //MessageBox.Show("系统出错,请联系管理人员", "警告");
  297. }
  298. }
  299. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  300. {
  301. try
  302. {
  303. UltraGridRow ugr = this.ultraGrid1.ActiveRow;
  304. if (ugr == null)
  305. return;
  306. this.dataSet3.Clear();
  307. string design_key = ugr.Cells["DESIGN_KEY"].Value.ToString();
  308. string smp_no = ugr.Cells["HEAT_NO"].Value.ToString();
  309. string grade_name = ugr.Cells["GRADE_NAME"].Text.ToString();
  310. CoreClientParam ccp = new CoreClientParam();
  311. ccp.ServerName = "QCM.QCM03.QCM0301.QcmJhyElementsServiceImpl";
  312. ccp.MethodName = "GetRChemeInfo";
  313. ccp.ServerParams = new object[] { design_key, smp_no,grade_name };
  314. ccp.SourceDataTable = this.dataSet3.Tables[0];
  315. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  316. UltraGridRow judge_row = null;
  317. foreach (UltraGridRow ugs in this.ultraGrid2.Rows)
  318. {
  319. ugs.Cells["CHECKBOX"].Value = ugs.Cells["CHECKBOXS"].Text.ToString();
  320. if (!string.IsNullOrEmpty(ugs.Cells["CHECKBOXS"].Text) && ugs.Cells["CHECKBOXS"].Text.ToString() == "True")
  321. {
  322. judge_row = ugs;
  323. }
  324. }
  325. if (judge_row != null)
  326. {
  327. foreach (UltraGridRow ugs in this.ultraGrid2.Rows)
  328. {
  329. if (!string.IsNullOrEmpty(ugs.Cells["STD_TYPE"].Text) && ugs.Cells["STD_TYPE"].Text.ToString() == "放行标准(熔炼)")
  330. {
  331. for (int i = 0; i < ugs.Cells.Count; i++)
  332. {
  333. if (!string.IsNullOrEmpty(ugs.Cells[i].Text) && ugs.Cells[i].Text.ToString().Contains(" "))
  334. {
  335. string[] str_arr = ugs.Cells[i].Text.ToString().Replace(" ", "#").Split('#');
  336. if (str_arr.Length == 1)
  337. {
  338. if (str_arr[0].Contains("<=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  339. {
  340. if (double.Parse(str_arr[0].Replace("<=", "")) < double.Parse(judge_row.Cells[i].Text.ToString()))
  341. {
  342. ugs.Cells[i].Appearance.BackColor = Color.Red;
  343. }
  344. }
  345. else if (str_arr[0].Contains(">=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  346. {
  347. if (double.Parse(str_arr[0].Replace(">=", "")) > double.Parse(judge_row.Cells[i].Text.ToString()))
  348. {
  349. ugs.Cells[i].Appearance.BackColor = Color.Red;
  350. }
  351. }
  352. }
  353. else if (str_arr.Length == 2)
  354. {
  355. if (str_arr[0].Contains("<=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  356. {
  357. if (double.Parse(str_arr[0].Replace("<=", "")) < double.Parse(judge_row.Cells[i].Text.ToString()))
  358. {
  359. ugs.Cells[i].Appearance.BackColor = Color.Red;
  360. }
  361. }
  362. else if (str_arr[0].Contains(">=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  363. {
  364. if (double.Parse(str_arr[0].Replace(">=", "")) > double.Parse(judge_row.Cells[i].Text.ToString()))
  365. {
  366. ugs.Cells[i].Appearance.BackColor = Color.Red;
  367. }
  368. }
  369. if (str_arr[1].Contains("<=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  370. {
  371. if (double.Parse(str_arr[1].Replace("<=", "")) < double.Parse(judge_row.Cells[i].Text.ToString()))
  372. {
  373. ugs.Cells[i].Appearance.BackColor = Color.Red;
  374. }
  375. }
  376. else if (str_arr[1].Contains(">=") && !string.IsNullOrEmpty(judge_row.Cells[i].Text))
  377. {
  378. if (double.Parse(str_arr[1].Replace(">=", "")) > double.Parse(judge_row.Cells[i].Text.ToString()))
  379. {
  380. ugs.Cells[i].Appearance.BackColor = Color.Red;
  381. }
  382. }
  383. }
  384. }
  385. }
  386. }
  387. }
  388. }
  389. }
  390. catch (Exception ex)
  391. {
  392. System.Diagnostics.Debug.WriteLine(ex.ToString());
  393. MessageBox.Show("系统出错,请联系管理人员", "警告");
  394. }
  395. }
  396. private void QCM030802_Load(object sender, EventArgs e)
  397. {
  398. this.comboBox3.SelectedIndex = 0;
  399. this.ultraGrid4.DisplayLayout.Override.FilterUIType = FilterUIType.HeaderIcons;
  400. this.ultraGrid1.DisplayLayout.Override.FilterUIType = FilterUIType.HeaderIcons;
  401. this.dateTimePicker1.Value = System.DateTime.Now.AddDays(-7);
  402. this.DoQuery();
  403. }
  404. private void ultraTabControl1_Click(object sender, EventArgs e)
  405. {
  406. if (this.ultraTabControl1.Tabs[1].Selected) //判定记录
  407. {
  408. this.label6.Text = "判定时间";
  409. }
  410. if (this.ultraTabControl1.Tabs[0].Selected) //判定记录
  411. {
  412. this.label6.Text = "生产时间";
  413. }
  414. }
  415. private void DoExport()
  416. {
  417. try
  418. {
  419. if (this.ultraGrid4.Rows.Count == 0)
  420. {
  421. MessageBox.Show("没有可以导出的数据", "提示");
  422. return;
  423. }
  424. if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
  425. {
  426. string fName = this.saveFileDialog1.FileName;
  427. this.ultraGridExcelExporter1.Export(this.ultraGrid4, fName);
  428. Process.Start(fName);
  429. }
  430. }
  431. catch (Exception ex)
  432. {
  433. System.Diagnostics.Debug.WriteLine(ex.ToString());
  434. }
  435. }
  436. private void ultraGrid2_ClickCell(object sender, ClickCellEventArgs e)
  437. {
  438. }
  439. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  440. {
  441. if (this.ultraTabControl1.Tabs[0].Selected)
  442. {
  443. foreach (UltraGridRow ugr in this.ultraGrid1.Rows.Where(p => p.IsFilteredOut == false).ToList())
  444. {
  445. if (checkBox2.Checked)
  446. {
  447. ugr.Cells["check"].Value = "True";
  448. }
  449. else
  450. {
  451. ugr.Cells["check"].Value = "False";
  452. }
  453. }
  454. }
  455. }
  456. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  457. {
  458. if (ultraTabControl1.SelectedTab.Index == 0)
  459. {
  460. checkBox2.Checked = false;
  461. }
  462. else if (ultraTabControl1.SelectedTab.Index == 1)
  463. {
  464. checkBox2.Checked = false;
  465. }
  466. }
  467. }
  468. }