FrmScrapNumHydr.cs 19 KB

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