FrmScrapNumApp.cs 19 KB

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