FrmMatJgMImport.cs 17 KB

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