FrmCouplingConfirm.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Core.Mes.Client.Comm.Server;
  10. using CoreFS.CA06;
  11. using System.Collections;
  12. using Core.Mes.Client.Comm.Control;
  13. using Infragistics.Win.UltraWinGrid;
  14. using Core.Mes.Client.Comm.Tool;
  15. using Infragistics.Win;
  16. using Infragistics.Win.UltraWinEditors;
  17. using Core.StlMes.Client.Mcp.Entity;
  18. using Core.StlMes.Client.Mcp.Control;
  19. namespace Core.StlMes.Client.Mcp.Coupling
  20. {
  21. public partial class FrmCouplingConfirm : FrmBase
  22. {
  23. public FrmCouplingConfirm()
  24. {
  25. InitializeComponent();
  26. this.IsLoadUserView = true;
  27. }
  28. public override void ToolBar_Click(object sender, string ToolbarKey)
  29. {
  30. switch (ToolbarKey)
  31. {
  32. case "DoQuery":
  33. DoQuery();
  34. break;
  35. case "Confirm":
  36. Confirm();
  37. break;
  38. case "CancelConfirm":
  39. cancelConfirm();
  40. break;
  41. case "DoDelete":
  42. DoDelete();
  43. break;
  44. case "Export":
  45. GridHelper.ulGridToExcel(ultraGrid1, "接箍入库确认");
  46. break;
  47. case "DoClose":
  48. this.Close();
  49. break;
  50. }
  51. }
  52. /// <summary>
  53. /// 查询
  54. /// </summary>
  55. private void DoQuery()
  56. {
  57. string[] starts = { };
  58. string woId = "";//工单号
  59. string judgeStoveNo = "";//炉号
  60. string txtShift = "";//班次
  61. string txtConfirm = "";//是否确认
  62. string startTim = "";
  63. string endTim = "";
  64. #region 条件
  65. if (chkTim2.Checked)
  66. {
  67. if (DateTime.Parse(this.StartTime.Value.ToString()) > DateTime.Parse(EndTime.Value.ToString()))
  68. {
  69. MessageUtil.ShowTips("选择的前面时间不能大于后面的时间!");
  70. return;
  71. }
  72. else
  73. {
  74. startTim = this.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  75. endTim = this.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  76. }
  77. }
  78. if (chkStarts.Checked)
  79. {
  80. if (string.IsNullOrEmpty(cmbStarts.Text.Trim()))
  81. {
  82. MessageUtil.ShowTips("请选择工单状态!");
  83. return;
  84. }
  85. else
  86. {
  87. starts = (cmbStarts.Value as List<object>).Select(p => p.ToString().Trim()).ToArray();
  88. }
  89. }
  90. if (chkwoId.Checked)
  91. {
  92. if (chkwoId.Checked && string.IsNullOrEmpty(txtWoId.Text.Trim()))
  93. {
  94. MessageUtil.ShowTips("请输入工单号!");
  95. return;
  96. }
  97. else
  98. {
  99. woId = txtWoId.Text.ToString().Trim();
  100. }
  101. }
  102. if (chkJuNo.Checked)
  103. {
  104. if (chkJuNo.Checked && string.IsNullOrEmpty(txtJudgeStoveNO.Text.Trim()))
  105. {
  106. MessageUtil.ShowTips("请输入炉号!");
  107. return;
  108. }
  109. else
  110. {
  111. judgeStoveNo = txtJudgeStoveNO.Text.ToString().Trim();
  112. }
  113. }
  114. if (chkshift.Checked)
  115. {
  116. if (chkshift.Checked && string.IsNullOrEmpty(shift.Text.Trim()))
  117. {
  118. MessageUtil.ShowTips("请输入班次!");
  119. return;
  120. }
  121. else
  122. {
  123. if (string.IsNullOrEmpty(shift.Text.Trim()))
  124. {
  125. txtShift = "";
  126. }
  127. else
  128. {
  129. txtShift = shift.Value.ToString().Trim();
  130. }
  131. }
  132. }
  133. if (chkconfirm.Checked && string.IsNullOrEmpty(confirm.Text.Trim()))
  134. {
  135. MessageUtil.ShowTips("请选择是否确认!");
  136. return;
  137. }
  138. else
  139. {
  140. if(confirm.Text.ToString().Trim().Equals("确认"))
  141. {
  142. txtConfirm = "1";
  143. }
  144. else if (confirm.Text.ToString().Trim().Equals("未确认"))
  145. {
  146. txtConfirm = "0";
  147. }
  148. else
  149. {
  150. txtConfirm = "";
  151. }
  152. }
  153. #endregion
  154. List<PlnZyJgWorkMidbillEntity> listSource1 = EntityHelper.GetData<PlnZyJgWorkMidbillEntity>
  155. ("com.steering.mes.mcp.coup.PhosphateResultService.getphosInResult", new object[] { startTim, endTim,starts, woId, judgeStoveNo, txtShift, txtConfirm }, this.ob);
  156. couplingbindingSource.DataSource = listSource1;
  157. GridHelper.RefreshAndAutoSize(ultraGrid1);
  158. foreach (UltraGridRow urg in ultraGrid1.Rows)
  159. {
  160. if (urg.Cells["Matconfirm"].Value.Equals("确认"))
  161. {
  162. urg.Appearance.BackColor = Color.LightGreen;
  163. }
  164. }
  165. }
  166. /// <summary>
  167. /// 确认
  168. /// </summary>
  169. private void Confirm()
  170. {
  171. ultraGrid1.UpdateData();
  172. UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  173. if (uRow == null) { MessageUtil.ShowTips("无数据!"); return; }
  174. ArrayList list1 = new ArrayList();
  175. int UpdaCount = 0;
  176. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  177. {
  178. if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  179. {
  180. if (ugr.Cells["Matconfirm"].Value.ToString().Equals("1"))
  181. {
  182. MessageUtil.ShowTips("选中有已确认实绩,不允许再次确认!");
  183. return;
  184. }
  185. string firm = "";
  186. string shift = "";
  187. if (ugr.Cells["Matconfirm"].Value.ToString().Equals("确认"))
  188. {
  189. firm = "1";
  190. }
  191. else
  192. {
  193. firm = "0";
  194. }
  195. if (ugr.Cells["ColShift"].Value.ToString().Equals("早班"))
  196. {
  197. shift = "1";
  198. }
  199. else if (ugr.Cells["ColShift"].Value.ToString().Equals("中班"))
  200. {
  201. shift = "2";
  202. }
  203. else if (ugr.Cells["ColShift"].Value.ToString().Equals("晚班"))
  204. {
  205. shift = "3";
  206. }
  207. else
  208. {
  209. shift = "4";
  210. }
  211. UpdaCount += 1;
  212. ArrayList list = new ArrayList();
  213. list.Add(ugr.Cells["WoId"].Text.ToString());
  214. list.Add(shift);
  215. list.Add(ugr.Cells["JudgeStoveNo"].Value.ToString());
  216. list.Add(ugr.Cells["BatchNo"].Value.ToString());
  217. list.Add(firm);
  218. list.Add(UserInfo.GetUserName());
  219. list.Add(DateTime.Now.ToString());
  220. list.Add(ugr.Cells["CreateTime"].Value.ToString());
  221. //list.Add(ugr.Cells[""])
  222. list1.Add(list);
  223. }
  224. }
  225. if (UpdaCount == 0) { MessageUtil.ShowTips("请选择确认数据!"); return; }
  226. if (MessageUtil.ShowYesNoAndQuestion("是否确认?") == DialogResult.No)
  227. {
  228. return;
  229. }
  230. CoreClientParam ccp = new CoreClientParam();
  231. try
  232. {
  233. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  234. if (Constant.WaitingForm == null)
  235. {
  236. Constant.WaitingForm = new WaitingForm();
  237. }
  238. Constant.WaitingForm.ShowToUser = true;
  239. Constant.WaitingForm.Show();
  240. Constant.WaitingForm.Update();
  241. ccp.ServerName = "com.steering.mes.mcp.coup.PhosphateResultService";
  242. ccp.MethodName = "getMatConfirm";
  243. ccp.ServerParams = new object[] { list1 };
  244. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  245. this.Cursor = Cursors.Default;
  246. Constant.WaitingForm.ShowToUser = false;
  247. Constant.WaitingForm.Close();
  248. Constant.WaitingForm = null;
  249. }
  250. catch (Exception ex)
  251. {
  252. this.Cursor = Cursors.Default;
  253. Constant.WaitingForm.ShowToUser = false;
  254. Constant.WaitingForm.Close();
  255. Constant.WaitingForm = null;
  256. }
  257. if (ccp.ReturnCode != -1)
  258. {
  259. MessageUtil.ShowTips(ccp.ReturnInfo);
  260. if (ccp.ReturnInfo.Equals("确认成功!"))
  261. {
  262. DoQuery();
  263. }
  264. }
  265. }
  266. ///
  267. /// 取消确认
  268. ///
  269. private void cancelConfirm()
  270. {
  271. ultraGrid1.UpdateData();
  272. UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  273. if (uRow == null) { MessageUtil.ShowTips("无数据!"); return; }
  274. ArrayList list1 = new ArrayList();
  275. int UpdaCount = 0;
  276. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  277. {
  278. if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  279. {
  280. if (ugr.Cells["Matconfirm"].Value.ToString().Equals("0"))
  281. {
  282. MessageUtil.ShowTips("选中有没确认实绩,不允许取消确认!");
  283. return;
  284. }
  285. UpdaCount += 1;
  286. string firm = "";
  287. string shift = "";
  288. if (ugr.Cells["Matconfirm"].Value.ToString().Equals("确认"))
  289. {
  290. firm = "1";
  291. }
  292. else
  293. {
  294. firm = "0";
  295. }
  296. if (ugr.Cells["ColShift"].Value.ToString().Equals("早班"))
  297. {
  298. shift = "1";
  299. }
  300. else if (ugr.Cells["ColShift"].Value.ToString().Equals("中班"))
  301. {
  302. shift = "2";
  303. }
  304. else
  305. {
  306. shift = "3";
  307. }
  308. ArrayList list = new ArrayList();
  309. list.Add(ugr.Cells["WoId"].Text.ToString());
  310. list.Add(shift);
  311. list.Add(ugr.Cells["JudgeStoveNo"].Value.ToString());
  312. list.Add(ugr.Cells["BatchNo"].Value.ToString());
  313. list.Add(firm);
  314. list.Add(UserInfo.GetUserName());
  315. list.Add(DateTime.Today.ToString());
  316. list.Add(ugr.Cells["CreateTime"].Value.ToString());
  317. list1.Add(list);
  318. }
  319. }
  320. if (UpdaCount == 0) { MessageUtil.ShowTips("请选择取消数据!"); return; }
  321. if (MessageUtil.ShowYesNoAndQuestion("是否取消确认?") == DialogResult.No)
  322. {
  323. return;
  324. }
  325. CoreClientParam ccp = new CoreClientParam();
  326. try
  327. {
  328. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  329. if (Constant.WaitingForm == null)
  330. {
  331. Constant.WaitingForm = new WaitingForm();
  332. }
  333. Constant.WaitingForm.ShowToUser = true;
  334. Constant.WaitingForm.Show();
  335. Constant.WaitingForm.Update();
  336. ccp.ServerName = "com.steering.mes.mcp.coup.PhosphateResultService";
  337. ccp.MethodName = "getCancelMatConfirm";
  338. ccp.ServerParams = new object[] { list1 };
  339. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  340. this.Cursor = Cursors.Default;
  341. Constant.WaitingForm.ShowToUser = false;
  342. Constant.WaitingForm.Close();
  343. Constant.WaitingForm = null;
  344. }
  345. catch (Exception ex)
  346. {
  347. this.Cursor = Cursors.Default;
  348. Constant.WaitingForm.ShowToUser = false;
  349. Constant.WaitingForm.Close();
  350. Constant.WaitingForm = null;
  351. }
  352. if (ccp.ReturnCode != -1)
  353. {
  354. MessageUtil.ShowTips(ccp.ReturnInfo);
  355. if (ccp.ReturnInfo.Equals("取消确认成功!"))
  356. {
  357. DoQuery();
  358. }
  359. }
  360. }
  361. /// <summary>
  362. /// 修改
  363. /// </summary>
  364. private void DoUpdate()
  365. {
  366. ultraGrid1.UpdateData();
  367. int updateCount = 0;
  368. ArrayList list1 = new ArrayList();
  369. string dtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  370. string flag = "";
  371. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  372. {
  373. if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  374. {
  375. flag = "1";
  376. if (ugr.Cells["MACHINE_NO"].Text.Trim().Equals("")) { MessageUtil.ShowTips("请输入机床编号!"); return; }
  377. updateCount += 1;
  378. ArrayList list = new ArrayList();
  379. list.Add(ugr.Cells["MACHINE_NO"].Text.ToString());
  380. list.Add(this.UserInfo.GetUserName());
  381. list.Add(dtime);
  382. list.Add(ugr.Cells["MACHINE_NO"].Value.ToString());
  383. list.Add(ugr.Cells["MACHINE_NO"].Value.ToString());
  384. list1.Add(list);
  385. }
  386. }
  387. ArrayList list2 = new ArrayList();
  388. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  389. {
  390. if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  391. {
  392. flag = "2";
  393. updateCount += 1;
  394. UltraGridRow row = ultraGrid1.ActiveRow;
  395. if (row == null) { MessageUtil.ShowTips("机床信息不能为空"); return; }
  396. ArrayList list = new ArrayList();
  397. if (ugr.Cells["PRO_BZ"].Text.ToString().Equals(""))
  398. {
  399. MessageUtil.ShowTips("班组不能为空");
  400. return;
  401. }
  402. list.Add(row.Cells["MACHINE_NO"].Value.ToString());
  403. //list.Add(row.Cells["PLINE_NO"].Value.ToString());
  404. list.Add("700305");
  405. list.Add(ugr.Cells["MACHINE_USER1"].Text.Trim().ToString());
  406. list.Add(ugr.Cells["MACHINE_USER2"].Text.Trim().ToString());
  407. list.Add(ugr.Cells["PRO_BZ"].Value.ToString());
  408. list.Add(this.UserInfo.GetUserName());
  409. list.Add(dtime);
  410. list.Add(ugr.Cells["ID"].Value.ToString());
  411. list2.Add(list);
  412. }
  413. }
  414. if (updateCount == 0) { MessageUtil.ShowTips("请选择修改数据!"); return; }
  415. if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No) { return; }
  416. CoreClientParam ccp = new CoreClientParam();
  417. ccp.ServerName = "com.steering.mes.mcp.coup.FrmMachine";
  418. ccp.MethodName = "getUpdatePhosphateItem";
  419. ccp.ServerParams = new object[] { list1, list2, flag };
  420. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  421. if (ccp.ReturnCode == -1) return;
  422. MessageUtil.ShowTips(ccp.ReturnInfo);
  423. if (ccp.ReturnInfo.Equals("修改成功!"))
  424. {
  425. DoQuery();
  426. }
  427. }
  428. /// <summary>
  429. /// 删除
  430. /// </summary>
  431. private void DoDelete()
  432. {
  433. ultraGrid1.UpdateData();
  434. int updateCount = 0;
  435. ArrayList list1 = new ArrayList();
  436. ArrayList list2 = new ArrayList();
  437. string flag = "";
  438. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  439. {
  440. if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  441. {
  442. flag = "1";
  443. updateCount += 1;
  444. ArrayList list = new ArrayList();
  445. list.Add(ugr.Cells["MACHINE_NO"].Value.ToString());
  446. //list.Add(ugr.Cells["PLINE_NO"].Value.ToString());
  447. list.Add("700305");
  448. list1.Add(list);
  449. }
  450. }
  451. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  452. {
  453. if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  454. {
  455. flag = "2";
  456. updateCount += 1;
  457. ArrayList list = new ArrayList();
  458. list.Add(ugr.Cells["ID"].Value.ToString());
  459. list2.Add(list);
  460. }
  461. }
  462. if (updateCount == 0) { MessageUtil.ShowTips("请选择要删除的数据!"); return; }
  463. if (MessageUtil.ShowYesNoAndQuestion("是否删除?") == DialogResult.No) { return; }
  464. CoreClientParam ccp = new CoreClientParam();
  465. ccp.ServerName = "com.steering.mes.mcp.coup.FrmMachine";
  466. ccp.MethodName = "getDeletePhosphateItem";
  467. ccp.ServerParams = new object[] { list1,list2, flag };
  468. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  469. if (ccp.ReturnCode == -1) return;
  470. MessageUtil.ShowTips(ccp.ReturnInfo);
  471. if (ccp.ReturnInfo.Equals("删除成功!"))
  472. {
  473. DoQuery();
  474. }
  475. }
  476. private void FrmCouplingConfirm_Load(object sender, EventArgs e)
  477. {
  478. EntityHelper.ShowGridCaption<PlnZyJgWorkMidbillEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  479. PipeManageClass.setUltraGridColumnInput(ultraGrid1, new string[] { "LhNum" });//支数
  480. this.IsLoadUserView = true;
  481. }
  482. private void chkStarts_CheckedChanged(object sender, EventArgs e)
  483. {
  484. if (chkStarts.Checked) { cmbStarts.Enabled = true; } else { cmbStarts.Enabled = false; }
  485. if (chkJuNo.Checked) { txtJudgeStoveNO.Enabled = true; } else { txtJudgeStoveNO.Enabled = false; }
  486. if (chkshift.Checked) { shift.Enabled = true; } else { shift.Enabled = false; }
  487. if (chkwoId.Checked) { txtWoId.Enabled = true; } else { txtWoId.Enabled = false; }
  488. }
  489. }
  490. }