FrmScrapNumMeasureFail.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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.StlMes.Client.Mcp.Control.Entity;
  19. namespace Core.StlMes.Client.Mcp.Mch
  20. {
  21. public partial class FrmScrapNumMeasureFail : FrmBase
  22. {
  23. private ArrayList list = null;
  24. private string[] plineCode;
  25. private string SLGx = "";
  26. private string SLGxname = "";
  27. private string resultNo = "";
  28. public string reslNo = "";
  29. public string groudno = "";
  30. public string cutnum = "";
  31. private string save = "0";
  32. private string Linenum = "";
  33. private string PlineName = "";
  34. private string heartno = "";
  35. public FrmScrapNumMeasureFail(string heartNo,string slgx, string slgxname, string batchgroudno, string outnumcut, string[] pline_Code, string ResultNo,string linenum,string plineName, OpeBase ob)
  36. {
  37. InitializeComponent();
  38. this.ob = ob;
  39. plineCode = pline_Code;
  40. SLGx = slgx;
  41. SLGxname = slgxname;
  42. groudno = batchgroudno;
  43. cutnum = outnumcut;
  44. resultNo = ResultNo;
  45. Linenum = linenum;
  46. PlineName = plineName;
  47. heartno = heartNo;
  48. }
  49. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  50. {
  51. switch (e.Tool.Key)
  52. {
  53. case "Save":
  54. Save();
  55. break;
  56. case "Close":
  57. CloseFrm();
  58. break;
  59. }
  60. }
  61. public static ArrayList CrName= null;//超声701302
  62. public static ArrayList CuName = null;//分切701303
  63. public static ArrayList TrName = null;//车丝701304
  64. public static ArrayList TsName = null;//螺纹检验701305
  65. public static ArrayList CoName = null;//拧接701306
  66. public static ArrayList DrName = null;//通径701307
  67. public static ArrayList HyName = null;//水压701308
  68. public static ArrayList ChName = null;//倒棱701309
  69. public static ArrayList MeName = null;//测量701310
  70. public static int CrNum = 0;//超声701302
  71. public static int CuNum = 0;//分切701303
  72. public static int TrNum = 0;//车丝701304
  73. public static int TsNum = 0;//螺纹检验701305
  74. public static int CoNum = 0;//拧接701306
  75. public static int DrNum = 0;//通径701307
  76. public static int HyNum = 0;//水压701308
  77. public static int ChNum = 0;//倒棱701309
  78. public static int MeNum = 0;//测量701310
  79. private void CloseFrm()
  80. {
  81. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  82. this.Close();
  83. }
  84. /// <summary>
  85. /// 录入绝废
  86. /// </summary>
  87. private void Save()
  88. {
  89. this.ultraGridDetailDes1.UpdateData();
  90. IQueryable<UltraGridRow> checkAlarmRows = this.ultraGridDetailDes1.Rows.AsQueryable().Where(" CHK = 'True'");
  91. ArrayList alarmlist = new ArrayList();
  92. ArrayList scraplist = new ArrayList();
  93. int num = 0;
  94. foreach (UltraGridRow urrg in ultraGridDetailDes1.Rows)
  95. {
  96. num = num + int.Parse(urrg.Cells["FAIL_NUM"].Value.ToString());
  97. }
  98. if (SLGx == "701302")
  99. {
  100. CrNum = num;
  101. }else if(SLGx == "701303")
  102. {
  103. CuNum = num;
  104. }else if(SLGx == "701304")
  105. {
  106. TrNum = num;
  107. }else if(SLGx == "701305")
  108. {
  109. TsNum = num;
  110. }else if(SLGx == "701306")
  111. {
  112. CoNum = num;
  113. }else if(SLGx == "701307")
  114. {
  115. DrNum = num;
  116. }else if (SLGx == "701308")
  117. {
  118. HyNum = num;
  119. }else if(SLGx == "701309")
  120. {
  121. ChNum = num;
  122. }else if(SLGx == "701310")
  123. {
  124. MeNum = num;
  125. }
  126. string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  127. ArrayList list = new ArrayList();
  128. list.Add(heartno);
  129. list.Add(SLGx);
  130. list.Add(SLGxname);
  131. list.Add(this.UserInfo.GetUserName());
  132. list.Add(time);
  133. list.Add(this.UserInfo.GetUserOrder());
  134. list.Add(this.UserInfo.GetUserGroup());
  135. list.Add(num.ToString());
  136. if (MessageUtil.ShowYesNoAndQuestion("是否录入废品?") == DialogResult.No) return;
  137. foreach (UltraGridRow uRow in checkAlarmRows)
  138. {
  139. ArrayList list1 = new ArrayList();
  140. if (uRow.Cells["FAIL_DIRECT"].Value.ToString() == "")
  141. {
  142. MessageUtil.ShowTips("去向不能为空,请选择!");
  143. return;
  144. }
  145. if (uRow.Cells["FAIL_NUM"].Value.ToString() == "" || uRow.Cells["FAIL_NUM"].Value.ToString() == "0")
  146. {
  147. MessageUtil.ShowTips("支数不能为空或者为零支,请输入!");
  148. return;
  149. }
  150. if (!uRow.Cells["FAIL_NUM"].Value.ToString().TryParseInt())
  151. {
  152. MessageUtil.ShowTips("支数请输入整数!");
  153. return;
  154. }
  155. //if (Convert.ToInt32(Linenum) <= Convert.ToInt32(uRow.Cells["FAIL_NUM"].Value.ToString()))
  156. //{
  157. // MessageUtil.ShowTips("绝废支数不允许大于加工支数!");
  158. // return;
  159. //}
  160. //list1.Add(uRow.Cells["FAIL_TYPE_NAME"].Text.Trim());
  161. //list1.Add(uRow.Cells["FAIL_NUM"].Value.ToString3());
  162. //list1.Add(alarmTotalNum.ToString());
  163. //alarmlist.Add(list1);
  164. MchBugDEntity resultD = getRowData(uRow);
  165. resultD.ResultNo = uRow.Cells["FAIL_BILL"].Value.ToString();
  166. resultD.FailDirect = uRow.Cells["FAIL_DIRECT"].Text.ToString().Trim();
  167. resultD.FailNum =decimal.Parse(uRow.Cells["FAIL_NUM"].Value.ToString().Trim());
  168. resultD.FailTypeName = uRow.Cells["FAIL_TYPE_NAME"].Value.ToString().Trim();
  169. alarmlist.Add(resultD);
  170. }
  171. if (SLGx == "701302")
  172. {
  173. CrName = alarmlist;
  174. if (CrName.Count != 0)
  175. {
  176. MessageUtil.ShowTips("添加成功!");
  177. save = "1";
  178. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  179. }
  180. }
  181. else if (SLGx == "701303")
  182. {
  183. CuName = alarmlist;
  184. if (CuName.Count != 0)
  185. {
  186. MessageUtil.ShowTips("添加成功!");
  187. save = "1";
  188. ultraGridDetailDes1.UpdateData();
  189. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  190. }
  191. }
  192. else if (SLGx == "701304")
  193. {
  194. TrName = alarmlist;
  195. if (TrName.Count != 0)
  196. {
  197. MessageUtil.ShowTips("添加成功!");
  198. save = "1";
  199. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  200. }
  201. }
  202. else if (SLGx == "701305")
  203. {
  204. TsName = alarmlist;
  205. if (TsName.Count != 0)
  206. {
  207. MessageUtil.ShowTips("添加成功!");
  208. save = "1";
  209. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  210. }
  211. }
  212. else if (SLGx == "701306")
  213. {
  214. CoName = alarmlist;
  215. if (CoName.Count != 0)
  216. {
  217. MessageUtil.ShowTips("添加成功!");
  218. save = "1";
  219. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  220. }
  221. }
  222. else if (SLGx == "701307")
  223. {
  224. DrName = alarmlist;
  225. if (DrName.Count != 0)
  226. {
  227. MessageUtil.ShowTips("添加成功!");
  228. save = "1";
  229. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  230. }
  231. }
  232. else if (SLGx == "701308")
  233. {
  234. HyName = alarmlist;
  235. if (HyName.Count != 0)
  236. {
  237. MessageUtil.ShowTips("添加成功!");
  238. save = "1";
  239. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  240. }
  241. }
  242. else if (SLGx == "701309")
  243. {
  244. ChName = alarmlist;
  245. if (ChName.Count != 0)
  246. {
  247. MessageUtil.ShowTips("添加成功!");
  248. save = "1";
  249. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  250. }
  251. }
  252. else if (SLGx == "701310")
  253. {
  254. MeName = alarmlist;
  255. if (MeName.Count != 0)
  256. {
  257. MessageUtil.ShowTips("添加成功!");
  258. save = "1";
  259. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  260. }
  261. }
  262. //CoreClientParam ccp = new CoreClientParam();
  263. //try
  264. //{
  265. // this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  266. // if (Constant.WaitingForm == null)
  267. // {
  268. // Constant.WaitingForm = new WaitingForm();
  269. // }
  270. // Constant.WaitingForm.ShowToUser = true;
  271. // Constant.WaitingForm.Show();
  272. // Constant.WaitingForm.Update();
  273. // ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMeasureResult";
  274. // ccp.MethodName = "FailExpandResult";
  275. // ccp.ServerParams = new Object[] { alarmlist, result1, list, plineCode, groudno, cutnum, resultNo };
  276. // ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  277. // this.Cursor = Cursors.Default;
  278. // Constant.WaitingForm.ShowToUser = false;
  279. // Constant.WaitingForm.Close();
  280. // Constant.WaitingForm = null;
  281. //}
  282. //catch (Exception ex)
  283. //{
  284. // this.Cursor = Cursors.Default;
  285. // Constant.WaitingForm.ShowToUser = false;
  286. // Constant.WaitingForm.Close();
  287. // Constant.WaitingForm = null;
  288. //}
  289. //if (ccp.ReturnCode != -1)
  290. //{
  291. // MessageUtil.ShowTips(ccp.ReturnInfo);
  292. // if (ccp.ReturnInfo.Equals("录入绝废成功!"))
  293. // {
  294. // Fname =
  295. // save = "1";
  296. // this.DialogResult = System.Windows.Forms.DialogResult.OK;
  297. // }
  298. // else
  299. // {
  300. // MessageUtil.ShowTips(ccp.ReturnInfo);
  301. // }
  302. //}
  303. }
  304. public static void query(string heatNo)
  305. {
  306. CrNum = 0;//超声701302
  307. CuNum = 0;//分切701303
  308. TrNum = 0;//车丝701304
  309. TsNum = 0;//螺纹检验701305
  310. CoNum = 0;//拧接701306
  311. DrNum = 0;//通径701307
  312. HyNum = 0;//水压701308
  313. ChNum = 0;//倒棱701309
  314. MeNum = 0;//测量701310
  315. }
  316. public MchBugDEntity getRowData(UltraGridRow checkrow)
  317. {
  318. MchBugDEntity resultD = new MchBugDEntity();
  319. resultD.FailDirect = checkrow.Cells["FAIL_DIRECT"].Value.ToString().Trim();
  320. resultD.FailNum =decimal.Parse(checkrow.Cells["FAIL_NUM"].Value.ToString().Trim());
  321. resultD.FailTypeName = checkrow.Cells["FAIL_TYPE_NAME"].Value.ToString().Trim();
  322. return resultD;
  323. }
  324. private void ultraGridDetailDes1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  325. {
  326. UltraGrid ug = (UltraGrid)sender;
  327. this.ultraGridDetailDes1.UpdateData();
  328. GridEdite(e.Cell.Row);
  329. if (e.Cell.Column.Key == "REASON")
  330. {
  331. if (e.Cell.Value == "")
  332. {
  333. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  334. return;
  335. }
  336. int temp = 0;
  337. for (int i = 0; i < ug.Rows.Count(); i++)
  338. {
  339. UltraGridRow ugr = ug.Rows[i];
  340. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()))
  341. {
  342. temp = temp + 1;
  343. }
  344. }
  345. if (temp > 1)
  346. {
  347. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  348. e.Cell.Row.Cells["REASON"].Value = "";
  349. }
  350. }
  351. }
  352. private void ultraGridDetailDes2_CellChange(object sender, CellEventArgs e)
  353. {
  354. UltraGrid ug = (UltraGrid)sender;
  355. if (e.Cell.Column.Key == "REASON")
  356. {
  357. if (e.Cell.Value == "")
  358. {
  359. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  360. return;
  361. }
  362. int temp = 0;
  363. for (int i = 0; i < ug.Rows.Count(); i++)
  364. {
  365. UltraGridRow ugr = ug.Rows[i];
  366. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()) && e.Cell.Row.Cells["REASON1"].Value.ToString2().Equals(ugr.Cells["REASON1"].Value.ToString2()))
  367. {
  368. temp = temp + 1;
  369. }
  370. }
  371. if (temp > 1)
  372. {
  373. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  374. e.Cell.Row.Cells["REASON"].Value = "";
  375. }
  376. }
  377. if (e.Cell.Column.Key == "REASON1")
  378. {
  379. if (e.Cell.Value == "")
  380. {
  381. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  382. return;
  383. }
  384. int temp1 = 0;
  385. for (int i = 0; i < ug.Rows.Count(); i++)
  386. {
  387. UltraGridRow ugr = ug.Rows[i];
  388. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON1"].Value.ToString()) && e.Cell.Row.Cells["REASON"].Value.ToString2().Equals(ugr.Cells["REASON"].Value.ToString2()))
  389. {
  390. temp1 = temp1 + 1;
  391. }
  392. }
  393. if (temp1 > 1)
  394. {
  395. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  396. e.Cell.Row.Cells["REASON"].Value = "";
  397. }
  398. }
  399. }
  400. private void FrmScrapNumMeasure_FormClosing(object sender, FormClosingEventArgs e)
  401. {
  402. UltraGridRow urg = ultraGridDetailDes1.ActiveRow;
  403. if (urg != null)
  404. {
  405. if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true && urg.Cells["FAIL_DIRECT"].Text != "")
  406. {
  407. if (save == "0")
  408. {
  409. MessageUtil.ShowTips("请点保存按钮!");
  410. e.Cancel = true;
  411. }
  412. }
  413. }
  414. }
  415. /// <summary>
  416. ///
  417. /// ulltragrid控件受勾影响(打钩可编辑,不打勾不能编辑)**
  418. /// </summary>
  419. /// <param name="row"></param>
  420. private void GridEdite(UltraGridRow row)
  421. {
  422. if (row.GetValue("CHK") == "True")
  423. {
  424. foreach (UltraGridCell cell in row.Cells)
  425. {
  426. if (cell.Column.CellActivation == Activation.AllowEdit)
  427. {
  428. cell.Activation = Activation.AllowEdit;
  429. }
  430. }
  431. }
  432. else
  433. {
  434. foreach (UltraGridCell cell in row.Cells)
  435. {
  436. if (cell.Column.Key.Contains("CHK")) continue;
  437. if (cell.Column.CellActivation == Activation.AllowEdit)
  438. {
  439. cell.Activation = Activation.ActivateOnly;
  440. }
  441. }
  442. }
  443. ultraGridDetailDes1.UpdateData();
  444. }
  445. private void ultraGridDetailDes1_AfterRowInsert(object sender, RowEventArgs e)
  446. {
  447. this.ultraGridDetailDes1.UpdateData();
  448. GridEdite(e.Row);
  449. }
  450. }
  451. }