FrmScrap.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  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 Core.StlMes.Client.ZGMil.Result;
  7. using CoreFS.CA06;
  8. using Infragistics.Win;
  9. using Infragistics.Win.UltraWinGrid;
  10. using System;
  11. using System.Collections;
  12. using System.Collections.Generic;
  13. using System.ComponentModel;
  14. using System.Data;
  15. using System.Drawing;
  16. using System.Linq;
  17. using System.Text;
  18. using System.Windows.Forms;
  19. using Core.StlMes.Client.Mcp.Control.Entity;
  20. namespace Core.StlMes.Client.Mcp.Control
  21. {
  22. public partial class FrmScrap : FrmBase
  23. {
  24. private ArrayList list = null;
  25. private string plineCode;
  26. private string SLGx = "";
  27. private string heatPlanNo = "";
  28. private string resultNo = "";
  29. public string reslNo = "";
  30. public string Open = "";
  31. private string save = "0";
  32. private string Fenum = "";
  33. public FrmScrap(string heatNo,string slgx,string pline_Code,string ResultNo,string open,string fenum,OpeBase ob)
  34. {
  35. InitializeComponent();
  36. //list = arr;
  37. this.ob = ob;
  38. plineCode = pline_Code;
  39. SLGx = slgx;
  40. heatPlanNo = heatNo;
  41. resultNo = ResultNo;
  42. Open = open;
  43. Fenum = fenum;
  44. }
  45. /// <summary>
  46. /// 查询所有合格管序号
  47. /// </summary>
  48. //private void QuerySeq(ArrayList list)
  49. //{
  50. // DataTable ds = ServerHelper.GetData("com.steering.mes.zgmil.coup.EddyCurrentTestingResult.doQuerySeq", new object[] { list }, ob);
  51. // GridHelper.CopyDataToDatatable(ref ds, ref dataTable4, true);
  52. //}
  53. public string alamNum = "";
  54. public string scrapNum = "";
  55. public string testOfflineNum = "";
  56. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  57. {
  58. switch (e.Tool.Key)
  59. {
  60. case "Save":
  61. Save();
  62. break;
  63. case "Update":
  64. Update();
  65. break;
  66. case "Delete":
  67. Delete();
  68. break;
  69. case "Close":
  70. CloseFrm();
  71. break;
  72. }
  73. }
  74. int alarmTotalNum = 0;//可疑总支数
  75. int scarpTotalNum = 0;//废品总支数
  76. int offlineTotalNum = 0;//下线总支数
  77. public static ArrayList dName = null;//怀疑
  78. public static ArrayList fName = null;//废品
  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. //修改可疑、废品
  88. private void Update()
  89. {
  90. this.ultraGridDetailDes1.UpdateData();
  91. this.ultraGridDetailDes2.UpdateData();
  92. IQueryable<UltraGridRow> checkAlarmRows = this.ultraGridDetailDes1.Rows.AsQueryable().Where(" CHK = 'True'");
  93. IQueryable<UltraGridRow> checkScrapRows = this.ultraGridDetailDes2.Rows.AsQueryable().Where(" CHK = 'True'");
  94. ArrayList alarmlist = new ArrayList();
  95. ArrayList scraplist = new ArrayList();
  96. foreach (UltraGridRow uRow in checkAlarmRows)
  97. {
  98. MchBugDEntity resultD = getRowData(uRow);
  99. resultD.ResultNo = uRow.Cells["RESULT_NO"].Text.ToString();
  100. resultD.FailBill = uRow.Cells["FAIL_BILL"].Text.ToString();
  101. resultD.FailBillSqe = uRow.Cells["FAIL_BILL_SQE"].Text.ToString();
  102. alarmlist.Add(resultD);
  103. alarmTotalNum = alarmTotalNum + int.Parse(uRow.Cells["FAIL_NUM"].Value.ToString3());
  104. }
  105. foreach (UltraGridRow uRow in checkScrapRows)
  106. {
  107. MchBugDEntity resultD = getRowData(uRow);
  108. resultD.ResultNo = uRow.Cells["RESULT_NO"].Text.ToString();
  109. resultD.FailBill = uRow.Cells["FAIL_BILL"].Text.ToString();
  110. resultD.FailBillSqe = uRow.Cells["FAIL_BILL_SQE"].Text.ToString();
  111. scraplist.Add(resultD);
  112. scarpTotalNum = scarpTotalNum + int.Parse(uRow.Cells["FAIL_NUM"].Value.ToString3());
  113. }
  114. CoreClientParam ccp = new CoreClientParam();
  115. ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMchBugD";
  116. ccp.MethodName = "UpdateFail";
  117. ccp.ServerParams = new object[] { alarmlist, scraplist, SLGx, plineCode, heatPlanNo };
  118. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  119. if (ccp.ReturnCode != -1)
  120. {
  121. MessageUtil.ShowTips(ccp.ReturnInfo);
  122. if (ccp.ReturnInfo.Equals("修改成功!"))
  123. {
  124. doQuery();
  125. alamNum = alarmTotalNum.ToString();
  126. scrapNum = scarpTotalNum.ToString();
  127. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  128. }
  129. else
  130. {
  131. MessageUtil.ShowTips(ccp.ReturnInfo);
  132. }
  133. }
  134. }
  135. //删除可疑、废品
  136. private void Delete()
  137. {
  138. this.ultraGridDetailDes1.UpdateData();
  139. this.ultraGridDetailDes2.UpdateData();
  140. IQueryable<UltraGridRow> checkAlarmRows = this.ultraGridDetailDes1.Rows.AsQueryable().Where(" CHK = 'True'");
  141. IQueryable<UltraGridRow> checkScrapRows = this.ultraGridDetailDes2.Rows.AsQueryable().Where(" CHK = 'True'");
  142. ArrayList alarmlist = new ArrayList();
  143. ArrayList scraplist = new ArrayList();
  144. foreach (UltraGridRow uRow in checkAlarmRows)
  145. {
  146. MchBugDEntity resultD = getRowData(uRow);
  147. resultD.ResultNo = uRow.Cells["RESULT_NO"].Text.ToString();
  148. resultD.FailBill = uRow.Cells["FAIL_BILL"].Text.ToString();
  149. resultD.FailBillSqe = uRow.Cells["FAIL_BILL_SQE"].Text.ToString();
  150. alarmlist.Add(resultD);
  151. }
  152. foreach (UltraGridRow uRow in checkScrapRows)
  153. {
  154. MchBugDEntity resultD = getRowData(uRow);
  155. resultD.ResultNo = uRow.Cells["RESULT_NO"].Text.ToString();
  156. resultD.FailBill = uRow.Cells["FAIL_BILL"].Text.ToString();
  157. resultD.FailBillSqe = uRow.Cells["FAIL_BILL_SQE"].Text.ToString();
  158. scraplist.Add(resultD);
  159. }
  160. CoreClientParam ccp = new CoreClientParam();
  161. ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMchBugD";
  162. ccp.MethodName = "deleteFail";
  163. ccp.ServerParams = new object[] { alarmlist, scraplist, SLGx, plineCode, heatPlanNo };
  164. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  165. if (ccp.ReturnCode != -1)
  166. {
  167. MessageUtil.ShowTips(ccp.ReturnInfo);
  168. if (ccp.ReturnInfo.Equals("删除成功!"))
  169. {
  170. doQuery();
  171. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  172. }
  173. else
  174. {
  175. MessageUtil.ShowTips(ccp.ReturnInfo);
  176. }
  177. }
  178. }
  179. /// <summary>
  180. /// 保存可疑、剔除品
  181. /// </summary>
  182. private void Save()
  183. {
  184. this.ultraGridDetailDes1.UpdateData();
  185. this.ultraGridDetailDes2.UpdateData();
  186. // this.ultraGridDetailDes3.UpdateData();
  187. // string strInbound = "800707";//入库类型
  188. //string strInMemo = "";
  189. alarmTotalNum = 0;
  190. scarpTotalNum = 0;
  191. offlineTotalNum = 0;
  192. IQueryable<UltraGridRow> checkAlarmRows = this.ultraGridDetailDes1.Rows.AsQueryable().Where(" CHK = 'True'");
  193. IQueryable<UltraGridRow> checkScrapRows = this.ultraGridDetailDes2.Rows.AsQueryable().Where(" CHK = 'True'");
  194. // IQueryable<UltraGridRow> checkOffineRow = this.ultraGridDetailDes3.Rows.AsQueryable().Where(" CHK = 'True'");
  195. ArrayList alarmlist = new ArrayList();
  196. ArrayList scraplist = new ArrayList();
  197. //ArrayList offlinelist = new ArrayList();
  198. foreach (UltraGridRow uRow in checkAlarmRows)
  199. {
  200. ArrayList list1 = new ArrayList();
  201. if (uRow.Cells["FAIL_TYPE_NAME"].Text.ToString() == "")
  202. {
  203. MessageUtil.ShowTips("可疑支数原因不能为空,请选择!");
  204. return;
  205. }
  206. if (uRow.Cells["FAIL_NUM"].Value.ToString() == "" || uRow.Cells["FAIL_NUM"].Value.ToString() == "0")
  207. {
  208. MessageUtil.ShowTips("可疑支数不能为空或者为零支,请输入!");
  209. return;
  210. }
  211. if (!uRow.Cells["FAIL_NUM"].Value.ToString().TryParseInt())
  212. {
  213. MessageUtil.ShowTips("可疑支数请输入整数!");
  214. return;
  215. }
  216. //if (Convert.ToInt32(Fenum) < Convert.ToInt32(uRow.Cells["FAIL_NUM"].Value.ToString()))
  217. //{
  218. // MessageUtil.ShowTips("可疑支数不能大于加工剩余支数!");
  219. // return;
  220. //}
  221. alarmTotalNum = alarmTotalNum + int.Parse(uRow.Cells["FAIL_NUM"].Value.ToString3());
  222. //list1.Add(uRow.Cells["FAIL_TYPE_NAME"].Text.Trim());
  223. //list1.Add(uRow.Cells["FAIL_NUM"].Value.ToString3());
  224. //list1.Add(alarmTotalNum.ToString());
  225. //alarmlist.Add(list1);
  226. MchBugDEntity resultD = getRowData(uRow);
  227. resultD.ResultNo = uRow.Cells["FAIL_BILL"].Value.ToString();
  228. alarmlist.Add(resultD);
  229. }
  230. dName = alarmlist;
  231. //int n = 0;
  232. //foreach (UltraGridRow ugr in checkScrapRows)
  233. //{
  234. // //string alarmReason = ugr.Cells["REASON1"].Text.Trim();
  235. // int num = 0;
  236. // foreach (UltraGridRow ugr1 in checkAlarmRows)
  237. // {
  238. // if (ugr1.Cells["FAIL_TYPE_NAME"].Text.Trim().Equals(alarmReason))
  239. // {
  240. // num = num + int.Parse(ugr1.Cells["FAIL_NUM"].Value.ToString3());
  241. // }
  242. // }
  243. // if (num < int.Parse(ugr.Cells["FAIL_NUM"].Value.ToString3()))
  244. // {
  245. // n = n + 1;
  246. // }
  247. //}
  248. //if (n > 0)
  249. //{
  250. // MessageUtil.ShowTips("废品支数不能超出对应的报警原因下的支数!");
  251. // return;
  252. //}
  253. foreach (UltraGridRow row in checkScrapRows)
  254. {
  255. ArrayList list2 = new ArrayList();
  256. //if (row.Cells["REASON1"].Value.ToString2() == "")
  257. //{
  258. // MessageUtil.ShowTips("报警原因不能为空,请选择!");
  259. // return;
  260. //}
  261. if (row.Cells["FAIL_TYPE_NAME"].Text.ToString() == "")
  262. {
  263. MessageUtil.ShowTips("废品原因不能为空,请选择!");
  264. return;
  265. }
  266. if (row.Cells["FAIL_NUM"].Value.ToString() == "" || row.Cells["FAIL_NUM"].Value.ToString() == "0")
  267. {
  268. MessageUtil.ShowTips("废品支数不能为空或者为零支,请输入!");
  269. return;
  270. }
  271. if (!row.Cells["FAIL_NUM"].Value.ToString().TryParseInt())
  272. {
  273. MessageUtil.ShowTips("废品支数请输入整数!");
  274. return;
  275. }
  276. //if (Convert.ToInt32(Fenum) < Convert.ToInt32(row.Cells["FAIL_NUM"].Value.ToString()))
  277. //{
  278. // MessageUtil.ShowTips("废品支数不能大于加工剩余支数!");
  279. // return;
  280. //}
  281. scarpTotalNum = scarpTotalNum + int.Parse(row.Cells["FAIL_NUM"].Value.ToString3());
  282. //list2.Add(row.Cells["FAIL_TYPE_NAME"].Text.Trim());
  283. //list2.Add(row.Cells["FAIL_NUM"].Value.ToString3());
  284. //list2.Add(scarpTotalNum.ToString());
  285. ////list2.Add(row.Cells["REASON1"].Text.Trim());
  286. //scraplist.Add(list2);
  287. MchBugDEntity resultD = getRowData(row);
  288. resultD.ResultNo = row.Cells["FAIL_BILL"].Value.ToString();
  289. scraplist.Add(resultD);
  290. }
  291. fName = scraplist;
  292. if (dName.Count != 0 || fName.Count != 0)
  293. {
  294. MessageUtil.ShowTips("添加成功!");
  295. save = "1";
  296. alamNum = alarmTotalNum.ToString();
  297. scrapNum = scarpTotalNum.ToString();
  298. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  299. }
  300. //CoreClientParam ccp = new CoreClientParam();
  301. //ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMchBugD";
  302. //ccp.MethodName = "addPerson";
  303. //ccp.ServerParams = new object[] { alarmlist, scraplist, SLGx, plineCode, heatPlanNo };
  304. //ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  305. //if (ccp.ReturnCode != -1)
  306. //{
  307. // MessageUtil.ShowTips(ccp.ReturnInfo);
  308. // if (ccp.ReturnInfo.Equals("保存成功!"))
  309. // {
  310. // save = "1";
  311. // alamNum = alarmTotalNum.ToString();
  312. // scrapNum = scarpTotalNum.ToString();
  313. // //testOfflineNum = offlineTotalNum.ToString();
  314. // //UltraGridRow urg = ultraGridDetailDes2.ActiveRow;
  315. // //if(urg!=null)
  316. // //{
  317. // // reslNo = urg.Cells["RESULT_NO"].Value.ToString();
  318. // //}
  319. // this.DialogResult = System.Windows.Forms.DialogResult.OK;
  320. // }
  321. // else
  322. // {
  323. // MessageUtil.ShowTips(ccp.ReturnInfo);
  324. // }
  325. //}
  326. }
  327. public MchBugDEntity getRowData(UltraGridRow checkrow)
  328. {
  329. MchBugDEntity resultD = new MchBugDEntity();
  330. resultD.FailTypeName = checkrow.Cells["FAIL_TYPE_NAME"].Text.ToString().Trim();
  331. resultD.FailDirect = checkrow.Cells["FAIL_DIRECT"].Text.ToString().Trim();
  332. resultD.FailNum =decimal.Parse(checkrow.Cells["FAIL_NUM"].Value.ToString().Trim());
  333. return resultD;
  334. }
  335. /// <summary>
  336. /// 查询仓库信息
  337. /// </summary>
  338. /// <param name="plineCode"></param>
  339. /// <returns></returns>
  340. private DataTable getStoreNo(string plineCode)
  341. {
  342. DataTable ds = ServerHelper.GetData("com.steering.mes.signature.FrmInOnlineStore.doQueryStoreNo", new object[] { plineCode }, ob);
  343. if (ds.Rows.Count > 0)
  344. {
  345. return ds;
  346. }
  347. else
  348. {
  349. return null;
  350. }
  351. }
  352. private void FrmScrap_Load(object sender, EventArgs e)
  353. {
  354. doQuery();
  355. if (Open == "0")
  356. {
  357. ultraGroupBox2.Hide();
  358. }
  359. //QuerySeq(list);
  360. }
  361. /// <summary>
  362. /// 查询可疑品、剔除品
  363. /// </summary>
  364. public void doQuery()
  365. {
  366. dataTable1.Clear();
  367. dataTable2.Clear();
  368. dataTable3.Clear();
  369. //查询可疑支数
  370. //DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchBugD.doQueryAlarmNum", new object[] { heatPlanNo,resultNo }, ob);
  371. //GridHelper.CopyDataToDatatable(ref dt,ref dataTable1,true);
  372. //查询废品支数
  373. //DataTable ds = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchBugD.doQueryScrapNum", new object[] { heatPlanNo, resultNo }, ob);
  374. //GridHelper.CopyDataToDatatable(ref ds, ref dataTable2, true);
  375. //DataTable dd = ServerHelper.GetData("com.steering.mes.zgmil.coup.EddyCurrentTestingResult.doQueryOffineNum", new object[] { list }, ob);
  376. //GridHelper.CopyDataToDatatable(ref dd, ref dataTable3, true);
  377. //下拉选探伤废品原因
  378. DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerybase", new object[] { "7004" }, this.ob);
  379. //comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", "");
  380. kreason.DataSource = dt2;
  381. kreason.DisplayMember = "BASENAME";
  382. kreason.ValueMember = "BASECODE";
  383. YdmBaseClass.SetComboItemHeight(kreason);
  384. reason.DataSource = dt2;
  385. reason.DisplayMember = "BASENAME";
  386. reason.ValueMember = "BASECODE";
  387. YdmBaseClass.SetComboItemHeight(reason);
  388. foreach (UltraGridRow urg in ultraGridDetailDes1.Rows)
  389. {
  390. GridEdite(urg);
  391. }
  392. foreach (UltraGridRow urg in ultraGridDetailDes2.Rows)
  393. {
  394. GridEdite(urg);
  395. }
  396. if(resultNo==null)
  397. {
  398. resultNo = "";
  399. }
  400. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchBugD.QueryFailData", new object[] { heatPlanNo, SLGx, resultNo, plineCode }, ob);
  401. GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);
  402. DataTable dt1 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchBugD.QueryKeyiFailData", new object[] { heatPlanNo, SLGx, resultNo, plineCode }, ob);
  403. GridHelper.CopyDataToDatatable(ref dt1, ref dataTable1, true);
  404. }
  405. private void ultraGridDetailDes1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  406. {
  407. this.ultraGridDetailDes1.UpdateData();
  408. GridEdite(e.Cell.Row);
  409. //UltraGrid ug = (UltraGrid)sender;
  410. //this.ultraGridDetailDes1.UpdateData();
  411. //if (e.Cell.Column.Key == "REASON")
  412. //{
  413. // if (e.Cell.Value == "")
  414. // {
  415. // MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  416. // return;
  417. // }
  418. // int temp = 0;
  419. // for (int i = 0; i < ug.Rows.Count(); i++)
  420. // {
  421. // UltraGridRow ugr = ug.Rows[i];
  422. // if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()))
  423. // {
  424. // temp = temp + 1;
  425. // }
  426. // }
  427. // if (temp > 1)
  428. // {
  429. // MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  430. // e.Cell.Row.Cells["REASON"].Value = "";
  431. // }
  432. //}
  433. //if(e.Cell.Column.Key == "ACT_COUNT")
  434. //{
  435. // int total = 0;
  436. // foreach(UltraGridRow row in this.ultraGridDetailDes1.Rows)
  437. // {
  438. // if (Convert.ToBoolean(row.Cells["CHK"].Text) == true)
  439. // {
  440. // total = total + int.Parse(row.Cells["ACT_COUNT"].Value.ToString3());
  441. // }
  442. // }
  443. // ultraGrid1.BeginUpdate();
  444. // foreach (UltraGridRow uRow in this.ultraGrid1.Rows)
  445. // {
  446. // if (total >= uRow.Index + 1)
  447. // {
  448. // uRow.Cells["CHK1"].Value = true;
  449. // }
  450. // else
  451. // {
  452. // uRow.Cells["CHK1"].Value = false;
  453. // }
  454. // }
  455. // ultraGrid1.EndUpdate();
  456. //}
  457. }
  458. private void ultraGridDetailDes2_CellChange(object sender, CellEventArgs e)
  459. {
  460. this.ultraGridDetailDes2.UpdateData();
  461. GridEdite(e.Cell.Row);
  462. //UltraGrid ug = (UltraGrid)sender;
  463. //this.ultraGridDetailDes2.UpdateData();
  464. //if (e.Cell.Column.Key == "REASON")
  465. //{
  466. // if (e.Cell.Value == "")
  467. // {
  468. // MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  469. // return;
  470. // }
  471. // int temp = 0;
  472. // for (int i = 0; i < ug.Rows.Count(); i++)
  473. // {
  474. // UltraGridRow ugr = ug.Rows[i];
  475. // if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()) && e.Cell.Row.Cells["REASON1"].Value.ToString2().Equals(ugr.Cells["REASON1"].Value.ToString2()))
  476. // {
  477. // temp = temp + 1;
  478. // }
  479. // }
  480. // if (temp > 1)
  481. // {
  482. // MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  483. // e.Cell.Row.Cells["REASON"].Value = "";
  484. // }
  485. //}
  486. //if (e.Cell.Column.Key == "REASON1")
  487. //{
  488. // if (e.Cell.Value == "")
  489. // {
  490. // MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  491. // return;
  492. // }
  493. // int temp1 = 0;
  494. // for (int i = 0; i < ug.Rows.Count(); i++)
  495. // {
  496. // UltraGridRow ugr = ug.Rows[i];
  497. // if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON1"].Value.ToString()) && e.Cell.Row.Cells["REASON"].Value.ToString2().Equals(ugr.Cells["REASON"].Value.ToString2()))
  498. // {
  499. // temp1 = temp1 + 1;
  500. // }
  501. // }
  502. // if (temp1 > 1)
  503. // {
  504. // MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  505. // e.Cell.Row.Cells["REASON"].Value = "";
  506. // }
  507. //}
  508. //if (e.Cell.Column.Key == "ACT_COUNT")
  509. //{
  510. // int total = 0;
  511. // foreach (UltraGridRow row in this.ultraGridDetailDes2.Rows)
  512. // {
  513. // if (Convert.ToBoolean(row.Cells["CHK"].Text) == true)
  514. // {
  515. // total = total + int.Parse(row.Cells["ACT_COUNT"].Value.ToString3());
  516. // }
  517. // }
  518. // ultraGrid1.BeginUpdate();
  519. // IQueryable<UltraGridRow> checkAlarmRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK1 = 'True' and CHK3 = 'False' ORDER BY TO_NUMBER(SEQ) ASC");
  520. // if (checkAlarmRows.Count() < total)
  521. // {
  522. // MessageUtil.ShowTips("废品总支数不能大于报警总支数");
  523. // return;
  524. // }
  525. // else
  526. // {
  527. // int i = 1;
  528. // foreach (UltraGridRow uRow in checkAlarmRows)
  529. // {
  530. // uRow.Cells["CHK2"].Value = false;
  531. // if (i <= total)
  532. // {
  533. // uRow.Cells["CHK2"].Value = true;
  534. // }
  535. // i++;
  536. // }
  537. // }
  538. // ultraGrid1.EndUpdate();
  539. //}
  540. }
  541. private void FrmScrap_FormClosing(object sender, FormClosingEventArgs e)
  542. {
  543. UltraGridRow urg = ultraGridDetailDes2.ActiveRow;
  544. if (urg != null)
  545. {
  546. if (urg.Cells["CHK"].Text != "")
  547. {
  548. if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true && urg.Cells["FAIL_TYPE_NAME"].Text != "")
  549. {
  550. if (save == "0")
  551. {
  552. MessageUtil.ShowTips("请点保存按钮!");
  553. e.Cancel = true;
  554. }
  555. }
  556. }
  557. }
  558. }
  559. private void ultraGridDetailDes1_AfterRowInsert(object sender, RowEventArgs e)
  560. {
  561. this.ultraGridDetailDes1.UpdateData();
  562. GridEdite(e.Row);
  563. }
  564. private void ultraGridDetailDes2_AfterRowInsert(object sender, RowEventArgs e)
  565. {
  566. this.ultraGridDetailDes2.UpdateData();
  567. GridEdite(e.Row);
  568. }
  569. /// <summary>
  570. ///
  571. /// ulltragrid控件受勾影响(打钩可编辑,不打勾不能编辑)**
  572. /// </summary>
  573. /// <param name="row"></param>
  574. private void GridEdite(UltraGridRow row)
  575. {
  576. if (row.GetValue("CHK") == "True")
  577. {
  578. foreach (UltraGridCell cell in row.Cells)
  579. {
  580. if (cell.Column.CellActivation == Activation.AllowEdit)
  581. {
  582. cell.Activation = Activation.AllowEdit;
  583. }
  584. }
  585. }
  586. else
  587. {
  588. foreach (UltraGridCell cell in row.Cells)
  589. {
  590. if (cell.Column.Key.Contains("CHK")) continue;
  591. if (cell.Column.CellActivation == Activation.AllowEdit)
  592. {
  593. cell.Activation = Activation.ActivateOnly;
  594. }
  595. }
  596. }
  597. ultraGridDetailDes1.UpdateData();
  598. ultraGridDetailDes2.UpdateData();
  599. }
  600. //private void ultraGridDetailDes3_CellChange(object sender, CellEventArgs e)
  601. //{
  602. // UltraGrid ug = (UltraGrid)sender;
  603. // this.ultraGridDetailDes3.UpdateData();
  604. // if (e.Cell.Column.Key == "REASON")
  605. // {
  606. // if (e.Cell.Value == "")
  607. // {
  608. // MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  609. // return;
  610. // }
  611. // int temp = 0;
  612. // for (int i = 0; i < ug.Rows.Count(); i++)
  613. // {
  614. // UltraGridRow ugr = ug.Rows[i];
  615. // if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()))
  616. // {
  617. // temp = temp + 1;
  618. // }
  619. // }
  620. // if (temp > 1)
  621. // {
  622. // MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  623. // e.Cell.Row.Cells["REASON"].Value = "";
  624. // }
  625. // }
  626. //}
  627. //private void FrmScrap_Leave(object sender, EventArgs e)
  628. //{
  629. // FrmTestingResult frmTestingResult = new FrmTestingResult();
  630. // frmTestingResult.ETResultSave();
  631. //}
  632. }
  633. }