FrmScrapNumHigh.cs 20 KB

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