FrmMatJgMImport.cs 19 KB

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