FrmOrderStatusSet.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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.plan.order.model;
  14. using Core.StlMes.Client.Plan.Order.PopupWindow;
  15. using Infragistics.Win.UltraWinGrid;
  16. using Core.Mes.Client.Comm;
  17. using Infragistics.Win.UltraWinEditors;
  18. namespace Core.StlMes.Client.Plan.Order
  19. {
  20. public partial class FrmOrderStatusSet : FrmBase
  21. {
  22. UltraComboEditor uceA = new UltraComboEditor();
  23. public FrmOrderStatusSet()
  24. {
  25. this.IsLoadUserView = true;
  26. InitializeComponent();
  27. }
  28. private void FrmOrderStatusSet_Load(object sender, EventArgs e)
  29. {
  30. EntityHelper.ShowGridCaption<PlnSaleorderSetEntity>(ultraGridStatus.DisplayLayout.Bands[0]);
  31. ultraDateTimeImportTime.DateTime = DateTime.Now;
  32. ultraDateTimeImportTimeTo.DateTime = DateTime.Now;
  33. ultraComboOrderStatusSet.SelectedIndex = 0;
  34. this.Controls.Add(uceA);
  35. uceA.Visible = false;
  36. DataTable dt = ServerHelper.GetData("com.steering.pss.plan.order.CoreOrderStatusSet.getBaseInfSort",
  37. new object[] { "1001" }, this.ob);
  38. uceA.DataSource = dt;
  39. uceA.DisplayMember = "BASENAME";
  40. uceA.ValueMember = "BASECODE";
  41. //ultraGridStatus.DisplayLayout.Bands[0].Columns["Orderfrom"].ValueList = PlanComm.GeneralValuelist(ref dt, "BASECODE", "BASENAME");
  42. ultraGridStatus.DisplayLayout.Bands[0].Columns["Orderfrom"].EditorComponent = uceA;
  43. ultraGridStatus.DisplayLayout.Bands[0].Columns["Orderfrom"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  44. DoQuery();
  45. }
  46. /// <summary>
  47. /// 重写基类toolBar方法
  48. /// </summary>
  49. /// <param name="sender"></param>
  50. /// <param name="ToolbarKey"></param>
  51. public override void ToolBar_Click(object sender, string ToolbarKey)
  52. {
  53. switch (ToolbarKey)
  54. {
  55. case "Query":
  56. DoQuery();
  57. break;
  58. case "Import":
  59. DoImport();
  60. break;
  61. case "Modefiy":
  62. DoModefiy();
  63. break;
  64. case "ModefiyMonth":
  65. DoModefiyMonth();
  66. break;
  67. case "Delete":
  68. doDelete();
  69. DoQuery();
  70. break;
  71. case "ModefiyProSort":
  72. DoModefiyProSort();
  73. break;
  74. case "ModefiyOrderFrom":
  75. DoModefiyOrderFrom();
  76. break;
  77. case "Close":
  78. this.Close();
  79. break;
  80. }
  81. }
  82. /// <summary>
  83. /// 查询
  84. /// </summary>
  85. private void DoQuery()
  86. {
  87. ArrayList param = new ArrayList();
  88. if (checkBoxForReqORDER_NO.Checked)
  89. {
  90. param.Add(this.ctrlForQueryORDER_NO.Value.ToString());
  91. }
  92. else
  93. {
  94. param.Add("");
  95. }
  96. if (checkBoxIsRollMonth.Checked)
  97. {
  98. param.Add("0");
  99. param.Add("0");
  100. }
  101. else
  102. {
  103. param.Add("");
  104. param.Add("");
  105. }
  106. if (checkBoxIsNot.Checked)
  107. {
  108. param.Add("0");
  109. param.Add("0");
  110. }
  111. else
  112. {
  113. param.Add("");
  114. param.Add("");
  115. }
  116. param.Add(this.ultraDateTimeImportTime.DateTime.ToString("yyyy-MM-dd"));
  117. param.Add(this.ultraDateTimeImportTimeTo.DateTime.ToString("yyyy-MM-dd"));
  118. List<PlnSaleorderSetEntity> listSorce = EntityHelper.GetData<PlnSaleorderSetEntity>(
  119. "com.steering.pss.plan.order.CoreOrderStatusSet.queryOrderSetLog", new object[] { param }, this.ob);
  120. this.slmbindingSourcePlnSaleorderSetEntity.DataSource = listSorce;
  121. PlanComm.setGridActivation(ultraGridStatus.DisplayLayout.Bands[0], "CHC");
  122. }
  123. /// <summary>
  124. /// 导入
  125. /// </summary>
  126. private void DoImport()
  127. {
  128. try
  129. {
  130. OpenFileDialog dialog = new OpenFileDialog();
  131. if (dialog.ShowDialog() == DialogResult.OK)
  132. {
  133. FrmImportSetOrder import = new FrmImportSetOrder(this.ob);
  134. import.ModelPatch = dialog.FileName;
  135. import.ShowDialog();
  136. }
  137. }
  138. catch (Exception ex)
  139. {
  140. MessageBox.Show(ex.Message);
  141. }
  142. DoQuery();
  143. }
  144. /// <summary>
  145. /// 同步
  146. /// </summary>
  147. private void DoModefiy()
  148. {
  149. try
  150. {
  151. ultraGridStatus.UpdateData();
  152. ArrayList list = new ArrayList();
  153. IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
  154. if (checkedRows.Count() == 0)
  155. {
  156. MessageUtil.ShowTips("未勾选任何行!");
  157. return;
  158. }
  159. WaitFromOpen();
  160. foreach (UltraGridRow uRow in checkedRows)
  161. {
  162. PlnSaleorderSetEntity entity = new PlnSaleorderSetEntity();
  163. entity.EndStatus = ultraComboOrderStatusSet.Value.ToString();
  164. entity.OrderNoSeq = uRow.Cells["OrderNoSeq"].Value.ToString();
  165. entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
  166. list.Add(entity);
  167. }
  168. int succed = ServerHelper.SetData("com.steering.pss.plan.order.CoreOrderStatusSet.updateOrderStatus",
  169. new object[] { list }, this.ob);
  170. WaitFromColse();
  171. if (succed > 0)
  172. {
  173. if (MessageUtil.ShowYesNoAndQuestion("同步成功!\n是否删除同步记录?") == DialogResult.Yes)
  174. {
  175. doDelete();
  176. }
  177. }
  178. else
  179. {
  180. MessageUtil.ShowTips("同步失败!");
  181. }
  182. }
  183. catch (Exception ex)
  184. {
  185. WaitFromColse();
  186. if (ex is MESException)
  187. {
  188. }
  189. else
  190. {
  191. MessageBox.Show(ex.Message);
  192. }
  193. }
  194. DoQuery();
  195. }
  196. /// <summary>
  197. /// 同步月份
  198. /// </summary>
  199. private void DoModefiyMonth()
  200. {
  201. try
  202. {
  203. ultraGridStatus.UpdateData();
  204. ArrayList list = new ArrayList();
  205. IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
  206. if (checkedRows.Count() == 0)
  207. {
  208. MessageUtil.ShowTips("未勾选任何行!");
  209. return;
  210. }
  211. WaitFromOpen();
  212. foreach (UltraGridRow uRow in checkedRows)
  213. {
  214. PlnSaleorderSetEntity entity = new PlnSaleorderSetEntity();
  215. entity.RollMonth = uRow.Cells["RollMonth"].Value.ToString();
  216. entity.IfSetMonth = "1";
  217. entity.OrderNoSeq = uRow.Cells["OrderNoSeq"].Value.ToString();
  218. entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
  219. list.Add(entity);
  220. }
  221. int succed = ServerHelper.SetData("com.steering.pss.plan.order.CoreOrderStatusSet.updateOrderStatusMonth",
  222. new object[] { list }, this.ob);
  223. WaitFromColse();
  224. if (succed > 0)
  225. {
  226. if (MessageUtil.ShowYesNoAndQuestion("同步成功!\n是否删除同步记录?") == DialogResult.Yes)
  227. {
  228. doDelete();
  229. }
  230. }
  231. else
  232. {
  233. MessageUtil.ShowTips("同步失败!");
  234. }
  235. }
  236. catch (Exception ex)
  237. {
  238. WaitFromColse();
  239. if (ex is MESException)
  240. {
  241. }
  242. else
  243. {
  244. MessageBox.Show(ex.Message);
  245. }
  246. }
  247. DoQuery();
  248. }
  249. /// <summary>
  250. /// 同步生产分类
  251. /// </summary>
  252. private void DoModefiyProSort()
  253. {
  254. try
  255. {
  256. ultraGridStatus.UpdateData();
  257. ArrayList list = new ArrayList();
  258. IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
  259. if (checkedRows.Count() == 0)
  260. {
  261. MessageUtil.ShowTips("未勾选任何行!");
  262. return;
  263. }
  264. WaitFromOpen();
  265. foreach (UltraGridRow uRow in checkedRows)
  266. {
  267. PlnSaleorderSetEntity entity = new PlnSaleorderSetEntity();
  268. entity.ProduceSort = uRow.Cells["ProduceSort"].Value.ToString();
  269. entity.OrderNoSeq = uRow.Cells["OrderNoSeq"].Value.ToString();
  270. entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
  271. list.Add(entity);
  272. }
  273. int succed = ServerHelper.SetData("com.steering.pss.plan.order.CoreOrderStatusSet.updateProSort",
  274. new object[] { list }, this.ob);
  275. WaitFromColse();
  276. if (succed > 0)
  277. {
  278. if (MessageUtil.ShowYesNoAndQuestion("同步成功!\n是否删除同步记录?") == DialogResult.Yes)
  279. {
  280. doDelete();
  281. }
  282. }
  283. else
  284. {
  285. MessageUtil.ShowTips("同步失败!");
  286. }
  287. }
  288. catch (Exception ex)
  289. {
  290. WaitFromColse();
  291. if (ex is MESException)
  292. {
  293. }
  294. else
  295. {
  296. MessageBox.Show(ex.Message);
  297. }
  298. }
  299. DoQuery();
  300. }
  301. /// <summary>
  302. /// 同步来源
  303. /// </summary>
  304. private void DoModefiyOrderFrom()
  305. {
  306. try
  307. {
  308. ultraGridStatus.UpdateData();
  309. ArrayList list = new ArrayList();
  310. IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
  311. if (checkedRows.Count() == 0)
  312. {
  313. MessageUtil.ShowTips("未勾选任何行!");
  314. return;
  315. }
  316. WaitFromOpen();
  317. foreach (UltraGridRow uRow in checkedRows)
  318. {
  319. PlnSaleorderSetEntity entity = new PlnSaleorderSetEntity();
  320. entity.Orderfrom = uRow.Cells["Orderfrom"].Value.ToString();
  321. entity.OrderNoSeq = uRow.Cells["OrderNoSeq"].Value.ToString();
  322. entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
  323. list.Add(entity);
  324. }
  325. int succed = ServerHelper.SetData("com.steering.pss.plan.order.CoreOrderStatusSet.updateOrderfrom",
  326. new object[] { list }, this.ob);
  327. WaitFromColse();
  328. if (succed > 0)
  329. {
  330. if (MessageUtil.ShowYesNoAndQuestion("同步成功!\n是否删除同步记录?") == DialogResult.Yes)
  331. {
  332. doDelete();
  333. }
  334. }
  335. else
  336. {
  337. MessageUtil.ShowTips("同步失败!");
  338. }
  339. }
  340. catch (Exception ex)
  341. {
  342. WaitFromColse();
  343. if (ex is MESException)
  344. {
  345. }
  346. else
  347. {
  348. MessageBox.Show(ex.Message);
  349. }
  350. }
  351. DoQuery();
  352. }
  353. /// <summary>
  354. /// 删除
  355. /// </summary>
  356. private void doDelete()
  357. {
  358. try
  359. {
  360. ultraGridStatus.UpdateData();
  361. ArrayList list = new ArrayList();
  362. IQueryable<UltraGridRow> checkedRows = ultraGridStatus.Rows.AsQueryable().Where(" CHC = True");
  363. if (checkedRows.Count() == 0)
  364. {
  365. MessageUtil.ShowTips("未勾选任何行!");
  366. return;
  367. }
  368. WaitFromOpen();
  369. foreach (UltraGridRow uRow in checkedRows)
  370. {
  371. PlnSaleorderSetEntity entity = new PlnSaleorderSetEntity();
  372. entity.OrderNoSeq = uRow.Cells["OrderNoSeq"].Value.ToString();
  373. entity.OrdLnDlyPk = uRow.Cells["OrdLnDlyPk"].Value.ToString();
  374. list.Add(entity);
  375. }
  376. int succed = ServerHelper.SetData("com.steering.pss.plan.order.CoreOrderStatusSet.deleteOrderStatus",
  377. new object[] { list }, this.ob);
  378. WaitFromColse();
  379. if (succed > 0)
  380. {
  381. MessageUtil.ShowTips("删除成功!");
  382. }
  383. else
  384. {
  385. MessageUtil.ShowTips("删除失败!");
  386. }
  387. }
  388. catch (Exception ex)
  389. {
  390. WaitFromColse();
  391. if (ex is MESException)
  392. {
  393. }
  394. else
  395. {
  396. MessageBox.Show(ex.Message);
  397. }
  398. }
  399. }
  400. private void checkBoxForReqORDER_NO_CheckedChanged(object sender, EventArgs e)
  401. {
  402. if (checkBoxForReqORDER_NO.Checked)
  403. {
  404. ctrlForQueryORDER_NO.Enabled = true;
  405. }
  406. else
  407. {
  408. ctrlForQueryORDER_NO.Enabled = false;
  409. }
  410. }
  411. private void ultraDateTimeImportTime_ValueChanged(object sender, EventArgs e)
  412. {
  413. ultraDateTimeImportTimeTo.MinDate = ultraDateTimeImportTime.DateTime.Date;
  414. }
  415. private void ultraDateTimeImportTimeTo_ValueChanged(object sender, EventArgs e)
  416. {
  417. ultraDateTimeImportTime.MaxDate = ultraDateTimeImportTimeTo.DateTime.AddDays(1).Date.AddSeconds(-1);
  418. }
  419. private void ultraGridStatus_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
  420. {
  421. foreach (UltraGridRow uRow in ultraGridStatus.Selected.Rows)
  422. {
  423. if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
  424. {
  425. uRow.Cells["CHC"].Value = true;
  426. }
  427. }
  428. }
  429. /// <summary>
  430. /// 等待窗口
  431. /// </summary>
  432. private void WaitFromOpen()
  433. {
  434. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  435. if (Constant.WaitingForm == null)
  436. {
  437. Constant.WaitingForm = new WaitingForm();
  438. }
  439. Constant.WaitingForm.ShowToUser = true;
  440. Constant.WaitingForm.Show();
  441. Constant.WaitingForm.Update();
  442. }
  443. /// <summary>
  444. /// 关闭等待
  445. /// </summary>
  446. private void WaitFromColse()
  447. {
  448. this.Cursor = Cursors.Default;
  449. Constant.WaitingForm.ShowToUser = false;
  450. Constant.WaitingForm.Close();
  451. Constant.WaitingForm = null;
  452. }
  453. }
  454. }