QCM030808.cs 17 KB

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