QCM030801.cs 17 KB

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