FrmScrapNumQuen.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. using com.steering.mes.mcp.entity;
  2. using Core.Mes.Client.Comm.Control;
  3. using Core.Mes.Client.Comm.Server;
  4. using Core.Mes.Client.Comm.Tool;
  5. using Core.StlMes.Client.Mcp.Control;
  6. using CoreFS.CA06;
  7. using Infragistics.Win;
  8. using Infragistics.Win.UltraWinGrid;
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System.ComponentModel;
  13. using System.Data;
  14. using System.Drawing;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Windows.Forms;
  18. using Core.Mes.Client.Comm.Format;
  19. namespace Core.StlMes.Client.Mcp.Treatment
  20. {
  21. public partial class FrmScrapNumQuen : FrmBase
  22. {
  23. private ArrayList list = null;
  24. private string plineCode = "";
  25. private string SLGx = "";
  26. private string heatPlanNo = "";
  27. private string resultNo = "";
  28. public string reslNo = "";
  29. public string groudno = "";
  30. public string cutnum = "";
  31. private string StorageNo = "";
  32. private string save = "0";
  33. private string Linenum = "";
  34. private string PlineName = "";
  35. private int ProcessSeq = 1;
  36. HttQuenchingResultEntity result1 = new HttQuenchingResultEntity();//高温炉
  37. public FrmScrapNumQuen(HttQuenchingResultEntity result, string heatNo, string slgx, string batchgroudno, string outnumcut, string storageNo, string pline_Code, string ResultNo, string linenum, string plineName, int processSeq, OpeBase ob)
  38. {
  39. InitializeComponent();
  40. //list = arr;
  41. this.ob = ob;
  42. plineCode = pline_Code;
  43. SLGx = slgx;
  44. groudno = batchgroudno;
  45. cutnum = outnumcut;
  46. StorageNo = storageNo;
  47. heatPlanNo = heatNo;
  48. resultNo = ResultNo;
  49. result1 = result;
  50. Linenum = linenum;
  51. PlineName = plineName;
  52. ProcessSeq = processSeq;
  53. }
  54. /// <summary>
  55. /// 查询所有合格管序号
  56. /// </summary>
  57. //private void QuerySeq(ArrayList list)
  58. //{
  59. // DataTable ds = ServerHelper.GetData("com.steering.mes.zgmil.coup.EddyCurrentTestingResult.doQuerySeq", new object[] { list }, ob);
  60. // GridHelper.CopyDataToDatatable(ref ds, ref dataTable4, true);
  61. //}
  62. public string alamNum = "";
  63. public string scrapNum = "";
  64. public string testOfflineNum = "";
  65. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  66. {
  67. switch (e.Tool.Key)
  68. {
  69. case "Save":
  70. Save();
  71. break;
  72. case "Close":
  73. CloseFrm();
  74. break;
  75. }
  76. }
  77. int alarmTotalNum = 0;//可疑总支数
  78. int scarpTotalNum = 0;//废品总支数
  79. int offlineTotalNum = 0;//下线总支数
  80. private void CloseFrm()
  81. {
  82. alamNum = alarmTotalNum.ToString();
  83. scrapNum = scarpTotalNum.ToString();
  84. testOfflineNum = offlineTotalNum.ToString();
  85. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  86. this.Close();
  87. }
  88. /// <summary>
  89. /// 保存离线
  90. /// </summary>
  91. private void Save()
  92. {
  93. this.ultraGridDetailDes1.UpdateData();
  94. alarmTotalNum = 0;
  95. scarpTotalNum = 0;
  96. offlineTotalNum = 0;
  97. IQueryable<UltraGridRow> checkAlarmRows = this.ultraGridDetailDes1.Rows.AsQueryable().Where(" CHK = 'True'");
  98. // IQueryable<UltraGridRow> checkOffineRow = this.ultraGridDetailDes3.Rows.AsQueryable().Where(" CHK = 'True'");
  99. List<string> alarmlist = new DataSourceList<string>();
  100. ArrayList scraplist = new ArrayList();
  101. //foreach (UltraGridRow uRow in checkAlarmRows)
  102. //{
  103. // ArrayList list1 = new ArrayList();
  104. // if (uRow.Cells["FAIL_TYPE_NAME"].Value.ToString() == "")
  105. // {
  106. // MessageUtil.ShowTips("可疑支数原因不能为空,请选择!");
  107. // return;
  108. // }
  109. // if (uRow.Cells["FAIL_NUM"].Value.ToString() == "" || uRow.Cells["FAIL_NUM"].Value.ToString() == "0")
  110. // {
  111. // MessageUtil.ShowTips("可疑支数不能为空或者为零支,请输入!");
  112. // return;
  113. // }
  114. // if (!uRow.Cells["FAIL_NUM"].Value.ToString().TryParseInt())
  115. // {
  116. // MessageUtil.ShowTips("可疑支数请输入整数!");
  117. // return;
  118. // }
  119. // alarmTotalNum = alarmTotalNum + int.Parse(uRow.Cells["FAIL_NUM"].Value.ToString3());
  120. // //list1.Add(uRow.Cells["FAIL_TYPE_NAME"].Text.Trim());
  121. // //list1.Add(uRow.Cells["FAIL_NUM"].Value.ToString3());
  122. // //list1.Add(alarmTotalNum.ToString());
  123. // //alarmlist.Add(list1);
  124. // MchBugDentity resultD = getRowData(uRow);
  125. // resultD.ResultNo = uRow.Cells["FAIL_BILL"].Value.ToString();
  126. // alarmlist.Add(resultD);
  127. //}
  128. //CoreClientParam ccp = new CoreClientParam();
  129. //ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMchBugD";
  130. //ccp.MethodName = "addPerson";
  131. //ccp.ServerParams = new object[] { alarmlist, scraplist, SLGx, plineCode, heatPlanNo };
  132. //ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  133. //if (ccp.ReturnCode != -1)
  134. //{
  135. // MessageUtil.ShowTips(ccp.ReturnInfo);
  136. // if (ccp.ReturnInfo.Equals("保存成功!"))
  137. // {
  138. // alamNum = alarmTotalNum.ToString();
  139. // scrapNum = scarpTotalNum.ToString();
  140. // //testOfflineNum = offlineTotalNum.ToString();
  141. // //UltraGridRow urg = ultraGridDetailDes2.ActiveRow;
  142. // //if(urg!=null)
  143. // //{
  144. // // reslNo = urg.Cells["RESULT_NO"].Value.ToString();
  145. // //}
  146. // this.DialogResult = System.Windows.Forms.DialogResult.OK;
  147. // }
  148. // else
  149. // {
  150. // MessageUtil.ShowTips(ccp.ReturnInfo);
  151. // }
  152. //}
  153. //MchUtResultEntity result = this.crackDetectControl1.Value;
  154. //foreach (UltraGridRow uRow in checkAlarmRows)
  155. //{
  156. // ArrayList list1 = new ArrayList();
  157. // if (uRow.Cells["FAIL_TYPE_NAME"].Value.ToString() == "")
  158. // {
  159. // MessageUtil.ShowTips("可疑支数原因不能为空,请选择!");
  160. // return;
  161. // }
  162. // if (uRow.Cells["FAIL_NUM"].Value.ToString() == "" || uRow.Cells["FAIL_NUM"].Value.ToString() == "0")
  163. // {
  164. // MessageUtil.ShowTips("可疑支数不能为空或者为零支,请输入!");
  165. // return;
  166. // }
  167. // if (!uRow.Cells["FAIL_NUM"].Value.ToString().TryParseInt())
  168. // {
  169. // MessageUtil.ShowTips("可疑支数请输入整数!");
  170. // return;
  171. // }
  172. int num = 0;
  173. foreach (UltraGridRow urrg in ultraGridDetailDes1.Rows)
  174. {
  175. num = num + int.Parse(urrg.Cells["OFFLINE_NUM"].Text.ToString());
  176. }
  177. string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  178. ArrayList list = new ArrayList();
  179. list.Add(heatPlanNo);
  180. list.Add(SLGx);
  181. list.Add("");
  182. list.Add(this.UserInfo.GetUserName());
  183. list.Add(time);
  184. list.Add(this.UserInfo.GetUserOrder());
  185. list.Add(this.UserInfo.GetUserGroup());
  186. list.Add(num.ToString());
  187. if (MessageUtil.ShowYesNoAndQuestion("是否离线?") == DialogResult.No) return;
  188. foreach (UltraGridRow uRow in checkAlarmRows)
  189. {
  190. ArrayList list1 = new ArrayList();
  191. if (uRow.Cells["GOWHERE_NAME"].Value.ToString() == "")
  192. {
  193. MessageUtil.ShowTips("去向不能为空,请选择!");
  194. return;
  195. }
  196. if (uRow.Cells["OFFLINE_NUM"].Value.ToString() == "" || uRow.Cells["OFFLINE_NUM"].Value.ToString() == "0")
  197. {
  198. MessageUtil.ShowTips("支数不能为空或者为零支,请输入!");
  199. return;
  200. }
  201. if (!uRow.Cells["OFFLINE_NUM"].Value.ToString().TryParseInt())
  202. {
  203. MessageUtil.ShowTips("支数请输入整数!");
  204. return;
  205. }
  206. //alarmTotalNum = alarmTotalNum + int.Parse(uRow.Cells["FAIL_NUM"].Value.ToString3());
  207. //list1.Add(uRow.Cells["FAIL_TYPE_NAME"].Text.Trim());
  208. //list1.Add(uRow.Cells["FAIL_NUM"].Value.ToString3());
  209. //list1.Add(alarmTotalNum.ToString());
  210. //alarmlist.Add(list1);
  211. HttOfflineResultDentity resultD = getRowData(uRow);
  212. resultD.ResultNo = uRow.Cells["FAIL_BILL"].Value.ToString();
  213. resultD.GowhereName = uRow.Cells["GOWHERE_NAME"].Text.ToString().Trim();
  214. resultD.OfflineNum = uRow.Cells["OFFLINE_NUM"].Value.ToString().Trim();
  215. alarmlist.Add(JSONFormat.Format(resultD));
  216. }
  217. CoreClientParam ccp = new CoreClientParam();
  218. try
  219. {
  220. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  221. if (Constant.WaitingForm == null)
  222. {
  223. Constant.WaitingForm = new WaitingForm();
  224. }
  225. Constant.WaitingForm.ShowToUser = true;
  226. Constant.WaitingForm.Show();
  227. Constant.WaitingForm.Update();
  228. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HeatTreatmentService";
  229. ccp.MethodName = "offLineExpandResult2";
  230. ccp.ServerParams = new Object[] { alarmlist, JSONFormat.Format(result1), list, plineCode, StorageNo, groudno,ProcessSeq };
  231. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  232. this.Cursor = Cursors.Default;
  233. Constant.WaitingForm.ShowToUser = false;
  234. Constant.WaitingForm.Close();
  235. Constant.WaitingForm = null;
  236. }
  237. catch (Exception ex)
  238. {
  239. this.Cursor = Cursors.Default;
  240. Constant.WaitingForm.ShowToUser = false;
  241. Constant.WaitingForm.Close();
  242. Constant.WaitingForm = null;
  243. }
  244. if (ccp.ReturnCode != -1)
  245. {
  246. MessageUtil.ShowTips(ccp.ReturnInfo);
  247. if (ccp.ReturnInfo.Equals("离线成功!"))
  248. {
  249. save = "1";
  250. alamNum = alarmTotalNum.ToString();
  251. scrapNum = scarpTotalNum.ToString();
  252. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  253. }
  254. else
  255. {
  256. MessageUtil.ShowTips(ccp.ReturnInfo);
  257. }
  258. }
  259. }
  260. public HttOfflineResultDentity getRowData(UltraGridRow checkrow)
  261. {
  262. HttOfflineResultDentity resultD = new HttOfflineResultDentity();
  263. resultD.GowhereName = checkrow.Cells["GOWHERE_NAME"].Value.ToString().Trim();
  264. resultD.OfflineNum = checkrow.Cells["OFFLINE_NUM"].Value.ToString().Trim();
  265. return resultD;
  266. }
  267. /// <summary>
  268. /// 查询仓库信息
  269. /// </summary>
  270. /// <param name="plineCode"></param>
  271. /// <returns></returns>
  272. private DataTable getStoreNo(string plineCode)
  273. {
  274. DataTable ds = ServerHelper.GetData("com.steering.mes.signature.FrmInOnlineStore.doQueryStoreNo", new object[] { plineCode }, ob);
  275. if (ds.Rows.Count > 0)
  276. {
  277. return ds;
  278. }
  279. else
  280. {
  281. return null;
  282. }
  283. }
  284. private void FrmScrap_Load(object sender, EventArgs e)
  285. {
  286. doQuery();
  287. }
  288. /// <summary>
  289. /// 查询离线去向
  290. /// </summary>
  291. public void doQuery()
  292. {
  293. dataTable1.Clear();
  294. dataTable2.Clear();
  295. dataTable3.Clear();
  296. ////下拉选离线去向
  297. //DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerydirect", new object[] { "G", "002001006" }, this.ob);
  298. ////comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", "");
  299. //kreason.DataSource = dt2;
  300. //kreason.DisplayMember = "PLINE_NAME";
  301. //kreason.ValueMember = "PLINE_CODE";
  302. //YdmBaseClass.SetComboItemHeight(kreason);
  303. //下拉选离线去向
  304. DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerydirectOffline", new object[] { plineCode }, this.ob);
  305. //comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", "");
  306. kreason.DataSource = dt2;
  307. kreason.DisplayMember = "PLINE_NAME";
  308. kreason.ValueMember = "PLINE_CODE";
  309. YdmBaseClass.SetComboItemHeight(kreason);
  310. foreach (UltraGridRow urg in ultraGridDetailDes1.Rows)
  311. {
  312. GridEdite(urg);
  313. }
  314. }
  315. private void ultraGridDetailDes1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  316. {
  317. UltraGrid ug = (UltraGrid)sender;
  318. this.ultraGridDetailDes1.UpdateData();
  319. GridEdite(e.Cell.Row);
  320. if (e.Cell.Column.Key == "REASON")
  321. {
  322. if (e.Cell.Value == "")
  323. {
  324. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  325. return;
  326. }
  327. int temp = 0;
  328. for (int i = 0; i < ug.Rows.Count(); i++)
  329. {
  330. UltraGridRow ugr = ug.Rows[i];
  331. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()))
  332. {
  333. temp = temp + 1;
  334. }
  335. }
  336. if (temp > 1)
  337. {
  338. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  339. e.Cell.Row.Cells["REASON"].Value = "";
  340. }
  341. }
  342. }
  343. private void ultraGridDetailDes2_CellChange(object sender, CellEventArgs e)
  344. {
  345. UltraGrid ug = (UltraGrid)sender;
  346. if (e.Cell.Column.Key == "REASON")
  347. {
  348. if (e.Cell.Value == "")
  349. {
  350. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  351. return;
  352. }
  353. int temp = 0;
  354. for (int i = 0; i < ug.Rows.Count(); i++)
  355. {
  356. UltraGridRow ugr = ug.Rows[i];
  357. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()) && e.Cell.Row.Cells["REASON1"].Value.ToString2().Equals(ugr.Cells["REASON1"].Value.ToString2()))
  358. {
  359. temp = temp + 1;
  360. }
  361. }
  362. if (temp > 1)
  363. {
  364. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  365. e.Cell.Row.Cells["REASON"].Value = "";
  366. }
  367. }
  368. if (e.Cell.Column.Key == "REASON1")
  369. {
  370. if (e.Cell.Value == "")
  371. {
  372. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  373. return;
  374. }
  375. int temp1 = 0;
  376. for (int i = 0; i < ug.Rows.Count(); i++)
  377. {
  378. UltraGridRow ugr = ug.Rows[i];
  379. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON1"].Value.ToString()) && e.Cell.Row.Cells["REASON"].Value.ToString2().Equals(ugr.Cells["REASON"].Value.ToString2()))
  380. {
  381. temp1 = temp1 + 1;
  382. }
  383. }
  384. if (temp1 > 1)
  385. {
  386. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  387. e.Cell.Row.Cells["REASON"].Value = "";
  388. }
  389. }
  390. }
  391. private void FrmScrapNum_FormClosing(object sender, FormClosingEventArgs e)
  392. {
  393. UltraGridRow urg = ultraGridDetailDes1.ActiveRow;
  394. if (urg != null)
  395. {
  396. if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true && urg.Cells["GOWHERE_NAME"].Text != "")
  397. {
  398. if (save == "0")
  399. {
  400. MessageUtil.ShowTips("请点保存按钮!");
  401. e.Cancel = true;
  402. }
  403. }
  404. }
  405. }
  406. /// <summary>
  407. ///
  408. /// ulltragrid控件受勾影响(打钩可编辑,不打勾不能编辑)**
  409. /// </summary>
  410. /// <param name="row"></param>
  411. private void GridEdite(UltraGridRow row)
  412. {
  413. if (row.GetValue("CHK") == "True")
  414. {
  415. foreach (UltraGridCell cell in row.Cells)
  416. {
  417. if (cell.Column.CellActivation == Activation.AllowEdit)
  418. {
  419. cell.Activation = Activation.AllowEdit;
  420. }
  421. }
  422. }
  423. else
  424. {
  425. foreach (UltraGridCell cell in row.Cells)
  426. {
  427. if (cell.Column.Key.Contains("CHK")) continue;
  428. if (cell.Column.CellActivation == Activation.AllowEdit)
  429. {
  430. cell.Activation = Activation.ActivateOnly;
  431. }
  432. }
  433. }
  434. ultraGridDetailDes1.UpdateData();
  435. }
  436. private void ultraGridDetailDes1_AfterRowInsert(object sender, RowEventArgs e)
  437. {
  438. this.ultraGridDetailDes1.UpdateData();
  439. GridEdite(e.Row);
  440. }
  441. }
  442. }