FrmOrderStatusSet.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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 CoreFS.CA06;
  10. using System.Collections;
  11. using Core.Mes.Client.Comm.Tool;
  12. using Core.Mes.Client.Comm.Server;
  13. using com.steering.pss.plnsaleord.order.model;
  14. using Core.StlMes.Client.PlnSaleOrd.PopupWindow;
  15. using Infragistics.Win.UltraWinGrid;
  16. using Core.Mes.Client.Comm;
  17. using Infragistics.Win.UltraWinEditors;
  18. using System.Globalization;
  19. namespace Core.StlMes.Client.PlnSaleOrd
  20. {
  21. public partial class FrmOrderStatusSet : FrmBase
  22. {
  23. public FrmOrderStatusSet()
  24. {
  25. this.IsLoadUserView = true;
  26. InitializeComponent();
  27. EntityHelper.ShowGridCaption<PlnSaleordSetEntity>(ultraGridStatus.DisplayLayout.Bands[0]);
  28. }
  29. private void FrmOrderStatusSet_Load(object sender, EventArgs e)
  30. {
  31. ultraDateTimeImportTime.DateTime = DateTime.Now;
  32. ultraDateTimeImportTimeTo.DateTime = DateTime.Now;
  33. ultraComboOrderStatusSet.SelectedIndex = 0;
  34. PlanComm.setGridActivation(ultraGridStatus.DisplayLayout.Bands[0], "CHC");
  35. PlanComm.setGridDigitalCol(ultraGridStatus.DisplayLayout.Bands[0], 5, 0, "NumSetStatus");
  36. DoQuery();
  37. }
  38. /// <summary>
  39. /// 重写基类toolBar方法
  40. /// </summary>
  41. /// <param name="sender"></param>
  42. /// <param name="ToolbarKey"></param>
  43. public override void ToolBar_Click(object sender, string ToolbarKey)
  44. {
  45. switch (ToolbarKey)
  46. {
  47. case "Query":
  48. DoQuery();
  49. break;
  50. case "Import":
  51. DoImport();
  52. break;
  53. case "Modefiy":
  54. DoModefiy();
  55. break;
  56. case "ModefiyMonth":
  57. DoModefiyMonth();
  58. break;
  59. case"ModefiyCheckMoth":
  60. doModefiyCheckMoth();
  61. break;
  62. case "ModifyPrio":
  63. doModifyPrio();
  64. break;
  65. case "Delete":
  66. doDelete();
  67. DoQuery();
  68. break;
  69. case "Close":
  70. this.Close();
  71. break;
  72. }
  73. }
  74. /// <summary>
  75. /// 查询
  76. /// </summary>
  77. private void DoQuery()
  78. {
  79. ArrayList param = new ArrayList();
  80. if (checkBoxForReqORDER_NO.Checked)
  81. {
  82. param.Add(this.ctrlForQueryORDER_NO.Value.ToString());
  83. }
  84. else
  85. {
  86. param.Add("");
  87. }
  88. if (checkBoxIsRollMonth.Checked)
  89. {
  90. param.Add("0");
  91. param.Add("0");
  92. }
  93. else
  94. {
  95. param.Add("");
  96. param.Add("");
  97. }
  98. if (checkBoxIsNot.Checked)
  99. {
  100. param.Add("0");
  101. param.Add("0");
  102. }
  103. else
  104. {
  105. param.Add("");
  106. param.Add("");
  107. }
  108. param.Add(this.ultraDateTimeImportTime.DateTime.ToString("yyyy-MM-dd"));
  109. param.Add(this.ultraDateTimeImportTimeTo.DateTime.ToString("yyyy-MM-dd"));
  110. List<PlnSaleordSetEntity> listSorce = EntityHelper.GetData<PlnSaleordSetEntity>(
  111. "com.steering.pss.plnsaleord.order.CoreOrderStatusSet.queryOrderSetLog", new object[] { param }, this.ob);
  112. this.slmbindingSourcePlnSaleordSetEntity.DataSource = listSorce;
  113. }
  114. /// <summary>
  115. /// 导入
  116. /// </summary>
  117. private void DoImport()
  118. {
  119. try
  120. {
  121. OpenFileDialog dialog = new OpenFileDialog();
  122. if (dialog.ShowDialog() == DialogResult.OK)
  123. {
  124. FrmImportSetOrder import = new FrmImportSetOrder(this.ob);
  125. import.ModelPatch = dialog.FileName;
  126. import.ShowDialog();
  127. }
  128. }
  129. catch (Exception ex)
  130. {
  131. MessageBox.Show(ex.Message);
  132. }
  133. DoQuery();
  134. }
  135. /// <summary>
  136. /// 同步状态
  137. /// </summary>
  138. private void DoModefiy()
  139. {
  140. try
  141. {
  142. ultraGridStatus.UpdateData();
  143. ArrayList list = new ArrayList();
  144. IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
  145. if (checkedRows.Count() == 0)
  146. {
  147. MessageUtil.ShowTips("未勾选任何行!");
  148. return;
  149. }
  150. WaitFromOpen();
  151. foreach (UltraGridRow uRow in checkedRows)
  152. {
  153. PlnSaleordSetEntity entity = new PlnSaleordSetEntity();
  154. entity.UpdateMan = UserInfo.GetUserName();
  155. entity.EndStatus = ultraComboOrderStatusSet.Value.ToString();
  156. entity.PlnDivideId = uRow.Cells["PlnDivideId"].Value.ToString();
  157. entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
  158. list.Add(entity);
  159. }
  160. CoreClientParam ccp = new CoreClientParam();
  161. ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreOrderStatusSet";
  162. ccp.MethodName = "updateOrderStatus";
  163. ccp.ServerParams = new object[] { list };
  164. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  165. WaitFromColse();
  166. if (ccp.ReturnCode != -1)
  167. {
  168. if (MessageUtil.ShowYesNoAndQuestion(ccp.ReturnInfo + "\n是否删除同步记录?") == DialogResult.Yes)
  169. {
  170. doDelete();
  171. }
  172. }
  173. else
  174. {
  175. MessageUtil.ShowTips("同步失败!\n" + ccp.ReturnInfo);
  176. }
  177. }
  178. catch (Exception ex)
  179. {
  180. WaitFromColse();
  181. if (!(ex is MESException))
  182. {
  183. MessageBox.Show(ex.Message);
  184. }
  185. }
  186. DoQuery();
  187. }
  188. /// <summary>
  189. /// 同步考核月份
  190. /// </summary>
  191. private void doModefiyCheckMoth()
  192. {
  193. try
  194. {
  195. ultraGridStatus.UpdateData();
  196. ArrayList list = new ArrayList();
  197. IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
  198. if (checkedRows.Count() == 0)
  199. {
  200. MessageUtil.ShowTips("未勾选任何行!");
  201. return;
  202. }
  203. WaitFromOpen();
  204. foreach (UltraGridRow uRow in checkedRows)
  205. {
  206. PlnSaleordSetEntity entity = new PlnSaleordSetEntity();
  207. entity.UpdateMan = UserInfo.GetUserName();
  208. entity.CheckMoth = uRow.Cells["CheckMoth"].Text.ToString();
  209. entity.PlnDivideId = uRow.Cells["PlnDivideId"].Value.ToString();
  210. entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
  211. list.Add(entity);
  212. }
  213. CoreClientParam ccp = new CoreClientParam();
  214. ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreOrderStatusSet";
  215. ccp.MethodName = "updateOrderCheckMoth";
  216. ccp.ServerParams = new object[] { list };
  217. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  218. WaitFromColse();
  219. if (ccp.ReturnCode != -1)
  220. {
  221. if (MessageUtil.ShowYesNoAndQuestion(ccp.ReturnInfo + "\n是否删除同步记录?") == DialogResult.Yes)
  222. {
  223. doDelete();
  224. }
  225. }
  226. else
  227. {
  228. MessageUtil.ShowTips("同步失败!\n" + ccp.ReturnInfo);
  229. }
  230. }
  231. catch (Exception ex)
  232. {
  233. WaitFromColse();
  234. if (!(ex is MESException))
  235. {
  236. MessageBox.Show(ex.Message);
  237. }
  238. }
  239. DoQuery();
  240. }
  241. /// <summary>
  242. /// 同步月份
  243. /// </summary>
  244. private void DoModefiyMonth()
  245. {
  246. try
  247. {
  248. int defailNum = 0;
  249. ultraGridStatus.UpdateData();
  250. string messageErr = "";
  251. ArrayList list = new ArrayList();
  252. IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
  253. if (checkedRows.Count() == 0)
  254. {
  255. MessageUtil.ShowTips("未勾选任何行!");
  256. return;
  257. }
  258. WaitFromOpen();
  259. foreach (UltraGridRow uRow in checkedRows)
  260. {
  261. PlnSaleordSetEntity entity = new PlnSaleordSetEntity();
  262. DateTime date = new DateTime();
  263. if (DateTime.TryParseExact(uRow.Cells["RollMonth"].Value.ToString(),
  264. "yyyy-MM", null, DateTimeStyles.None, out date))
  265. {
  266. entity.RollMonth = date.ToString("yyyy-MM");
  267. }
  268. else
  269. {
  270. messageErr = "月份格式有误!";
  271. defailNum++;
  272. continue;
  273. }
  274. entity.IfSetMonth = "1";
  275. entity.PlnDivideId = uRow.Cells["PlnDivideId"].Value.ToString();
  276. entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
  277. list.Add(entity);
  278. }
  279. if (list.Count <= 0)
  280. {
  281. WaitFromColse();
  282. MessageUtil.ShowTips("0条同步成功," + defailNum + "条同步失败。" + messageErr);
  283. return;
  284. }
  285. CoreClientParam ccp = new CoreClientParam();
  286. ccp.ServerName = "com.steering.pss.plnsaleord.order.CoreOrderStatusSet";
  287. ccp.MethodName = "updateOrderStatusMonth";
  288. ccp.ServerParams = new object[] { list };
  289. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  290. WaitFromColse();
  291. if (ccp.ReturnCode != -1)
  292. {
  293. if (MessageUtil.ShowYesNoAndQuestion(list.Count + "条同步成功," + defailNum + "条同步失败。\n"
  294. + messageErr + "\n是否删除同步记录?") == DialogResult.Yes)
  295. {
  296. doDelete();
  297. }
  298. }
  299. else
  300. {
  301. MessageUtil.ShowTips("同步失败!");
  302. }
  303. }
  304. catch (Exception ex)
  305. {
  306. WaitFromColse();
  307. if (!(ex is MESException))
  308. {
  309. MessageBox.Show(ex.Message);
  310. }
  311. }
  312. DoQuery();
  313. }
  314. /// <summary>
  315. /// 同步生产分类
  316. /// </summary>
  317. //private void DoModefiyProSort()
  318. //{
  319. // try
  320. // {
  321. // ultraGridStatus.UpdateData();
  322. // ArrayList list = new ArrayList();
  323. // IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
  324. // if (checkedRows.Count() == 0)
  325. // {
  326. // MessageUtil.ShowTips("未勾选任何行!");
  327. // return;
  328. // }
  329. // WaitFromOpen();
  330. // foreach (UltraGridRow uRow in checkedRows)
  331. // {
  332. // PlnSaleordSetEntity entity = new PlnSaleordSetEntity();
  333. // entity.ProduceSort = uRow.Cells["ProduceSort"].Value.ToString();
  334. // entity.OrderNoSeq = uRow.Cells["OrderNoSeq"].Value.ToString();
  335. // entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
  336. // list.Add(entity);
  337. // }
  338. // int succed = ServerHelper.SetData("com.steering.pss.plnsaleord.order.CoreOrderStatusSet.updateProSort",
  339. // new object[] { list }, this.ob);
  340. // WaitFromColse();
  341. // if (succed > 0)
  342. // {
  343. // if (MessageUtil.ShowYesNoAndQuestion("同步成功!\n是否删除同步记录?") == DialogResult.Yes)
  344. // {
  345. // doDelete();
  346. // }
  347. // }
  348. // else
  349. // {
  350. // MessageUtil.ShowTips("同步失败!");
  351. // }
  352. // }
  353. // catch (Exception ex)
  354. // {
  355. // WaitFromColse();
  356. // if (ex is MESException)
  357. // {
  358. // }
  359. // else
  360. // {
  361. // MessageBox.Show(ex.Message);
  362. // }
  363. // }
  364. // DoQuery();
  365. //}
  366. /// <summary>
  367. /// 同步来源
  368. /// </summary>
  369. //private void DoModefiyOrderFrom()
  370. //{
  371. // try
  372. // {
  373. // ultraGridStatus.UpdateData();
  374. // ArrayList list = new ArrayList();
  375. // IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
  376. // if (checkedRows.Count() == 0)
  377. // {
  378. // MessageUtil.ShowTips("未勾选任何行!");
  379. // return;
  380. // }
  381. // WaitFromOpen();
  382. // foreach (UltraGridRow uRow in checkedRows)
  383. // {
  384. // PlnSaleordSetEntity entity = new PlnSaleordSetEntity();
  385. // entity.Orderfrom = uRow.Cells["Orderfrom"].Value.ToString();
  386. // entity.OrderNoSeq = uRow.Cells["OrderNoSeq"].Value.ToString();
  387. // entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
  388. // list.Add(entity);
  389. // }
  390. // int succed = ServerHelper.SetData("com.steering.pss.plnsaleord.order.CoreOrderStatusSet.updateOrderfrom",
  391. // new object[] { list }, this.ob);
  392. // WaitFromColse();
  393. // if (succed > 0)
  394. // {
  395. // if (MessageUtil.ShowYesNoAndQuestion("同步成功!\n是否删除同步记录?") == DialogResult.Yes)
  396. // {
  397. // doDelete();
  398. // }
  399. // }
  400. // else
  401. // {
  402. // MessageUtil.ShowTips("同步失败!");
  403. // }
  404. // }
  405. // catch (Exception ex)
  406. // {
  407. // WaitFromColse();
  408. // if (ex is MESException)
  409. // {
  410. // }
  411. // else
  412. // {
  413. // MessageBox.Show(ex.Message);
  414. // }
  415. // }
  416. // DoQuery();
  417. //}
  418. /// <summary>
  419. /// 删除
  420. /// </summary>
  421. private void doDelete()
  422. {
  423. try
  424. {
  425. ultraGridStatus.UpdateData();
  426. ArrayList list = new ArrayList();
  427. IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
  428. if (checkedRows.Count() == 0)
  429. {
  430. MessageUtil.ShowTips("未勾选任何行!");
  431. return;
  432. }
  433. WaitFromOpen();
  434. foreach (UltraGridRow uRow in checkedRows)
  435. {
  436. PlnSaleordSetEntity entity = new PlnSaleordSetEntity();
  437. entity.PlnDivideId = uRow.Cells["PlnDivideId"].Value.ToString();
  438. entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
  439. list.Add(entity);
  440. }
  441. int succed = ServerHelper.SetData("com.steering.pss.plnsaleord.order.CoreOrderStatusSet.deleteOrderStatus",
  442. new object[] { list }, this.ob);
  443. WaitFromColse();
  444. if (succed > 0)
  445. {
  446. MessageUtil.ShowTips("删除成功!");
  447. }
  448. else
  449. {
  450. MessageUtil.ShowTips("删除失败!");
  451. }
  452. }
  453. catch (Exception ex)
  454. {
  455. WaitFromColse();
  456. if (!(ex is MESException))
  457. {
  458. MessageBox.Show(ex.Message);
  459. }
  460. }
  461. }
  462. /// <summary>
  463. /// 紧急度修改
  464. /// </summary>
  465. private void doModifyPrio()
  466. {
  467. try
  468. {
  469. int defailNum = 0;
  470. string messageErr = "";
  471. this.ultraGridStatus.UpdateData();
  472. ArrayList list = new ArrayList();
  473. IQueryable<UltraGridRow> checkRows = ultraGridStatus.Rows.AsQueryable().Where("CHC = 'True'");
  474. if (checkRows.Count() == 0)
  475. {
  476. MessageUtil.ShowTips("未勾选任何合同!");
  477. return;
  478. }
  479. PlanComm.WaitFromOpen(this.Cursor);
  480. foreach (UltraGridRow uRow in checkRows)
  481. {
  482. ArrayList param = new ArrayList();
  483. DataTable dtStatus = ServerHelper.GetData("com.steering.pss.plnsaleord.order.CorePlnOrdPriority.querySaleStatus",
  484. new object[] { uRow.Cells["OrdLnDlyPk"].Value.ToString(), uRow.Cells["PlnDivideId"].Value.ToString() }, this.ob);
  485. if (dtStatus == null || dtStatus.Rows.Count <= 0)
  486. {
  487. defailNum++;
  488. messageErr = "未找到" + uRow.Cells["OrderNoSeq"].Value.ToString() + "/"
  489. + uRow.Cells["DeliveryNo"].Value.ToString() + "的记录!";
  490. continue;
  491. }
  492. param.Add(uRow.Cells["Priority"].Value.ToString());
  493. param.Add(uRow.Cells["PriorityMemo"].Value.ToString());
  494. param.Add(uRow.Cells["OrdLnDlyPk"].Value.ToString());
  495. param.Add(uRow.Cells["PlnDivideId"].Value.ToString());
  496. param.Add(uRow.Cells["Priority"].Value.ToString());
  497. param.Add(uRow.Cells["PriorityMemo"].Value.ToString());
  498. param.Add(uRow.Cells["OrdLnDlyPk"].Value.ToString());
  499. param.Add(uRow.Cells["Priority"].Value.ToString());
  500. param.Add(uRow.Cells["PriorityMemo"].Value.ToString());
  501. param.Add(uRow.Cells["OrdLnDlyPk"].Value.ToString());
  502. param.Add(uRow.Cells["Priority"].Value.ToString());
  503. param.Add(uRow.Cells["PriorityMemo"].Value.ToString());
  504. param.Add(uRow.Cells["OrdLnDlyPk"].Value.ToString());
  505. param.Add(uRow.Cells["Priority"].Value.ToString());
  506. param.Add(uRow.Cells["PriorityMemo"].Value.ToString());
  507. param.Add(uRow.Cells["OrdLnDlyPk"].Value.ToString());
  508. list.Add(param);
  509. }
  510. if (list.Count == 0)
  511. {
  512. PlanComm.WaitFromColse(this.Cursor);
  513. MessageUtil.ShowTips("0条保存成功," + defailNum + "条保存失败。\n" + messageErr);
  514. return;
  515. }
  516. int succeed = ServerHelper.SetData("com.steering.pss.plnsaleord.order.CorePlnOrdPriority.savePlnOrdPriority",
  517. new object[] { list }, this.ob);
  518. PlanComm.WaitFromColse(this.Cursor);
  519. if (succeed > 0)
  520. {
  521. if (defailNum == 0)
  522. {
  523. if (MessageUtil.ShowYesNoAndQuestion("保存成功,共" + list.Count + "条。" + "\n是否删除同步记录?") == DialogResult.Yes)
  524. {
  525. doDelete();
  526. }
  527. }
  528. else
  529. {
  530. MessageUtil.ShowTips(list.Count + "条保存成功," + defailNum + "条保存失败。\n" + messageErr);
  531. }
  532. }
  533. }
  534. catch (Exception ex)
  535. {
  536. PlanComm.WaitFromColse(this.Cursor);
  537. if (!(ex is MESException))
  538. {
  539. MessageUtil.ShowError(ex.Message);
  540. }
  541. }
  542. DoQuery();
  543. }
  544. private void checkBoxForReqORDER_NO_CheckedChanged(object sender, EventArgs e)
  545. {
  546. if (checkBoxForReqORDER_NO.Checked)
  547. {
  548. ctrlForQueryORDER_NO.Enabled = true;
  549. }
  550. else
  551. {
  552. ctrlForQueryORDER_NO.Enabled = false;
  553. }
  554. }
  555. private void ultraDateTimeImportTime_ValueChanged(object sender, EventArgs e)
  556. {
  557. ultraDateTimeImportTimeTo.MinDate = ultraDateTimeImportTime.DateTime.Date;
  558. }
  559. private void ultraDateTimeImportTimeTo_ValueChanged(object sender, EventArgs e)
  560. {
  561. ultraDateTimeImportTime.MaxDate = ultraDateTimeImportTimeTo.DateTime.AddDays(1).Date.AddSeconds(-1);
  562. }
  563. private void ultraGridStatus_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
  564. {
  565. foreach (UltraGridRow uRow in ultraGridStatus.Selected.Rows)
  566. {
  567. if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
  568. {
  569. uRow.Cells["CHC"].Value = true;
  570. }
  571. }
  572. }
  573. /// <summary>
  574. /// 等待窗口
  575. /// </summary>
  576. private void WaitFromOpen()
  577. {
  578. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  579. if (Constant.WaitingForm == null)
  580. {
  581. Constant.WaitingForm = new WaitingForm();
  582. }
  583. Constant.WaitingForm.ShowToUser = true;
  584. Constant.WaitingForm.Show();
  585. Constant.WaitingForm.Update();
  586. }
  587. /// <summary>
  588. /// 关闭等待
  589. /// </summary>
  590. private void WaitFromColse()
  591. {
  592. this.Cursor = Cursors.Default;
  593. Constant.WaitingForm.ShowToUser = false;
  594. Constant.WaitingForm.Close();
  595. Constant.WaitingForm = null;
  596. }
  597. }
  598. }