FrmScrapNumLow.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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 FrmScrapNumLow : 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. HttLheatResultEntity result1 = new HttLheatResultEntity();//高温炉
  37. public FrmScrapNumLow(HttLheatResultEntity 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. /* if(Convert.ToInt32(Linenum)<=Convert.ToInt32(uRow.Cells["OFFLINE_NUM"].Value.ToString()))
  207. {
  208. MessageUtil.ShowTips("离线支数不允许大于加工支数!");
  209. return;
  210. }*/
  211. //alarmTotalNum = alarmTotalNum + int.Parse(uRow.Cells["FAIL_NUM"].Value.ToString3());
  212. //list1.Add(uRow.Cells["FAIL_TYPE_NAME"].Text.Trim());
  213. //list1.Add(uRow.Cells["FAIL_NUM"].Value.ToString3());
  214. //list1.Add(alarmTotalNum.ToString());
  215. //alarmlist.Add(list1);
  216. HttOfflineResultDentity resultD = getRowData(uRow);
  217. resultD.ResultNo = uRow.Cells["FAIL_BILL"].Value.ToString();
  218. resultD.GowhereName = uRow.Cells["GOWHERE_NAME"].Text.ToString().Trim();
  219. resultD.OfflineNum = uRow.Cells["OFFLINE_NUM"].Value.ToString().Trim();
  220. alarmlist.Add(JSONFormat.Format(resultD));
  221. }
  222. CoreClientParam ccp = new CoreClientParam();
  223. try
  224. {
  225. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  226. if (Constant.WaitingForm == null)
  227. {
  228. Constant.WaitingForm = new WaitingForm();
  229. }
  230. Constant.WaitingForm.ShowToUser = true;
  231. Constant.WaitingForm.Show();
  232. Constant.WaitingForm.Update();
  233. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HeatTreatmentService";
  234. ccp.MethodName = "offLineExpandResult3";
  235. ccp.ServerParams = new Object[] { alarmlist, JSONFormat.Format(result1), list, plineCode, StorageNo, groudno,ProcessSeq };
  236. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  237. this.Cursor = Cursors.Default;
  238. Constant.WaitingForm.ShowToUser = false;
  239. Constant.WaitingForm.Close();
  240. Constant.WaitingForm = null;
  241. }
  242. catch (Exception ex)
  243. {
  244. this.Cursor = Cursors.Default;
  245. Constant.WaitingForm.ShowToUser = false;
  246. Constant.WaitingForm.Close();
  247. Constant.WaitingForm = null;
  248. }
  249. if (ccp.ReturnCode != -1)
  250. {
  251. MessageUtil.ShowTips(ccp.ReturnInfo);
  252. if (ccp.ReturnInfo.Equals("离线成功!"))
  253. {
  254. save = "1";
  255. alamNum = alarmTotalNum.ToString();
  256. scrapNum = scarpTotalNum.ToString();
  257. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  258. }
  259. else
  260. {
  261. MessageUtil.ShowTips(ccp.ReturnInfo);
  262. }
  263. }
  264. }
  265. public HttOfflineResultDentity getRowData(UltraGridRow checkrow)
  266. {
  267. HttOfflineResultDentity resultD = new HttOfflineResultDentity();
  268. resultD.GowhereName = checkrow.Cells["GOWHERE_NAME"].Value.ToString().Trim();
  269. resultD.OfflineNum = checkrow.Cells["OFFLINE_NUM"].Value.ToString().Trim();
  270. return resultD;
  271. }
  272. /// <summary>
  273. /// 查询仓库信息
  274. /// </summary>
  275. /// <param name="plineCode"></param>
  276. /// <returns></returns>
  277. private DataTable getStoreNo(string plineCode)
  278. {
  279. DataTable ds = ServerHelper.GetData("com.steering.mes.signature.FrmInOnlineStore.doQueryStoreNo", new object[] { plineCode }, ob);
  280. if (ds.Rows.Count > 0)
  281. {
  282. return ds;
  283. }
  284. else
  285. {
  286. return null;
  287. }
  288. }
  289. private void FrmScrap_Load(object sender, EventArgs e)
  290. {
  291. doQuery();
  292. }
  293. /// <summary>
  294. /// 查询离线去向
  295. /// </summary>
  296. public void doQuery()
  297. {
  298. dataTable1.Clear();
  299. dataTable2.Clear();
  300. dataTable3.Clear();
  301. ////下拉选离线去向
  302. //DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerydirect", new object[] { "G", "002001006" }, this.ob);
  303. ////comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", "");
  304. //kreason.DataSource = dt2;
  305. //kreason.DisplayMember = "PLINE_NAME";
  306. //kreason.ValueMember = "PLINE_CODE";
  307. //YdmBaseClass.SetComboItemHeight(kreason);
  308. //下拉选离线去向
  309. DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerydirectOffline", new object[] { plineCode }, this.ob);
  310. //comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", "");
  311. kreason.DataSource = dt2;
  312. kreason.DisplayMember = "PLINE_NAME";
  313. kreason.ValueMember = "PLINE_CODE";
  314. YdmBaseClass.SetComboItemHeight(kreason);
  315. foreach (UltraGridRow urg in ultraGridDetailDes1.Rows)
  316. {
  317. GridEdite(urg);
  318. }
  319. }
  320. private void ultraGridDetailDes1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  321. {
  322. UltraGrid ug = (UltraGrid)sender;
  323. this.ultraGridDetailDes1.UpdateData();
  324. GridEdite(e.Cell.Row);
  325. if (e.Cell.Column.Key == "REASON")
  326. {
  327. if (e.Cell.Value == "")
  328. {
  329. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  330. return;
  331. }
  332. int temp = 0;
  333. for (int i = 0; i < ug.Rows.Count(); i++)
  334. {
  335. UltraGridRow ugr = ug.Rows[i];
  336. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()))
  337. {
  338. temp = temp + 1;
  339. }
  340. }
  341. if (temp > 1)
  342. {
  343. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  344. e.Cell.Row.Cells["REASON"].Value = "";
  345. }
  346. }
  347. }
  348. private void ultraGridDetailDes2_CellChange(object sender, CellEventArgs e)
  349. {
  350. UltraGrid ug = (UltraGrid)sender;
  351. if (e.Cell.Column.Key == "REASON")
  352. {
  353. if (e.Cell.Value == "")
  354. {
  355. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  356. return;
  357. }
  358. int temp = 0;
  359. for (int i = 0; i < ug.Rows.Count(); i++)
  360. {
  361. UltraGridRow ugr = ug.Rows[i];
  362. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()) && e.Cell.Row.Cells["REASON1"].Value.ToString2().Equals(ugr.Cells["REASON1"].Value.ToString2()))
  363. {
  364. temp = temp + 1;
  365. }
  366. }
  367. if (temp > 1)
  368. {
  369. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  370. e.Cell.Row.Cells["REASON"].Value = "";
  371. }
  372. }
  373. if (e.Cell.Column.Key == "REASON1")
  374. {
  375. if (e.Cell.Value == "")
  376. {
  377. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  378. return;
  379. }
  380. int temp1 = 0;
  381. for (int i = 0; i < ug.Rows.Count(); i++)
  382. {
  383. UltraGridRow ugr = ug.Rows[i];
  384. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON1"].Value.ToString()) && e.Cell.Row.Cells["REASON"].Value.ToString2().Equals(ugr.Cells["REASON"].Value.ToString2()))
  385. {
  386. temp1 = temp1 + 1;
  387. }
  388. }
  389. if (temp1 > 1)
  390. {
  391. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  392. e.Cell.Row.Cells["REASON"].Value = "";
  393. }
  394. }
  395. }
  396. private void FrmScrapNum_FormClosing(object sender, FormClosingEventArgs e)
  397. {
  398. UltraGridRow urg = ultraGridDetailDes1.ActiveRow;
  399. if (urg != null)
  400. {
  401. if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true && urg.Cells["GOWHERE_NAME"].Text != "")
  402. {
  403. if (save == "0")
  404. {
  405. MessageUtil.ShowTips("请点保存按钮!");
  406. e.Cancel = true;
  407. }
  408. }
  409. }
  410. }
  411. /// <summary>
  412. ///
  413. /// ulltragrid控件受勾影响(打钩可编辑,不打勾不能编辑)**
  414. /// </summary>
  415. /// <param name="row"></param>
  416. private void GridEdite(UltraGridRow row)
  417. {
  418. if (row.GetValue("CHK") == "True")
  419. {
  420. foreach (UltraGridCell cell in row.Cells)
  421. {
  422. if (cell.Column.CellActivation == Activation.AllowEdit)
  423. {
  424. cell.Activation = Activation.AllowEdit;
  425. }
  426. }
  427. }
  428. else
  429. {
  430. foreach (UltraGridCell cell in row.Cells)
  431. {
  432. if (cell.Column.Key.Contains("CHK")) continue;
  433. if (cell.Column.CellActivation == Activation.AllowEdit)
  434. {
  435. cell.Activation = Activation.ActivateOnly;
  436. }
  437. }
  438. }
  439. ultraGridDetailDes1.UpdateData();
  440. }
  441. private void ultraGridDetailDes1_AfterRowInsert(object sender, RowEventArgs e)
  442. {
  443. this.ultraGridDetailDes1.UpdateData();
  444. GridEdite(e.Row);
  445. }
  446. }
  447. }