FrmTHOrderManage.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Format;
  3. using Core.Mes.Client.Comm.Server;
  4. using Core.Mes.Client.Comm.Tool;
  5. using Core.StlMes.Client.GlBusiness.Models;
  6. using CoreFS.CA06;
  7. using Infragistics.Win;
  8. using Infragistics.Win.UltraWinGrid;
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System.ComponentModel;
  13. using System.Data;
  14. using System.Drawing;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Threading.Tasks;
  18. using System.Windows.Forms;
  19. namespace Core.StlMes.Client.GlBusiness
  20. {
  21. public partial class FrmTHOrderManage : FrmBase
  22. {
  23. public FrmTHOrderManage()
  24. {
  25. InitializeComponent();
  26. EntityHelper.ShowGridCaption<PlnOrderZgSEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  27. this.IsLoadUserView = true;
  28. }
  29. private void FrmTHOrderManage_Load(object sender, EventArgs e)
  30. {
  31. //默认查询当前日期-1月——当前日期数据。
  32. udtStart.DateTime = Convert.ToDateTime(DateTime.Now.AddMonths(-1).ToShortDateString());
  33. udtEnd.DateTime = Convert.ToDateTime(DateTime.Now.ToShortDateString());
  34. if (this.CustomInfo.ToString2().Equals("123504"))
  35. {
  36. ultraGrid1.DisplayLayout.Bands[0].Columns["thOrderNoSeq"].CellAppearance.BackColor = Color.FromArgb(255, 255, 128);
  37. ultraGrid1.DisplayLayout.Bands[0].Columns["OrderQty"].Hidden=true;
  38. ultraGrid1.DisplayLayout.Bands[0].Columns["Lengthdisc"].Hidden = true;
  39. }
  40. }
  41. private void craftImg_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  42. {
  43. string filePath = ultraGrid1.ActiveRow.GetValue("CraftFileNo");
  44. DataTable dt = ServerHelper.GetData("com.steering.pss.glbusiness.GlOrderManage.getFilePath", new Object[] { filePath }, this.ob);
  45. string file = dt.Rows[0]["CRAFT_PATH"].ToString3();
  46. dlgOrderAskDown askDown = new dlgOrderAskDown(this.ob, file);
  47. askDown.DeleteButton.Visible = false;
  48. askDown.Show();
  49. }
  50. public override void ToolBar_Click(object sender, string ToolbarKey)
  51. {
  52. switch (ToolbarKey)
  53. {
  54. case "doQuery":
  55. doQuery();//查询
  56. break;
  57. case "confirm":
  58. doConfirm();//确认
  59. break;
  60. case "cancel":
  61. doCancel();//取消
  62. break;
  63. case "updateField":
  64. updateField();//修改信息
  65. break;
  66. case "updateWeight":
  67. updateWeight();//修改重量
  68. break;
  69. case "update":
  70. doUpdateThOrder();//修改合同
  71. break;
  72. case "AddOrder": // 生成合同
  73. doAddOrder();
  74. break;
  75. case "Export":
  76. doExport();
  77. break;
  78. }
  79. }
  80. private void doAddOrder()
  81. {
  82. this.ultraGrid1.UpdateData();
  83. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True");
  84. if (checkRows.Count() == 0)
  85. {
  86. MessageUtil.ShowTips("请选择数据!");
  87. return;
  88. }
  89. ArrayList list = new ArrayList();
  90. foreach (UltraGridRow row in checkRows)
  91. {
  92. PlnOrderZgSEntity entity = row.ListObject as PlnOrderZgSEntity;
  93. if (!entity.ProductionThFlag.Equals("123506"))
  94. {
  95. MessageUtil.ShowTips(entity.ProPlanId + ",合同未确认!");
  96. return;
  97. }
  98. if (!String.IsNullOrEmpty(entity.ThOrderNoSeq))
  99. {
  100. MessageUtil.ShowTips(entity.ProPlanId + "天淮合同已存在!");
  101. return;
  102. }
  103. list.Add(JSONFormat.Format(entity));
  104. }
  105. CoreClientParam ccp = new CoreClientParam();
  106. ccp.ServerName = "com.steering.pss.glbusiness.FrmTHOrderManage";
  107. ccp.MethodName = "doAddOrder";
  108. ccp.ServerParams = new object[] { list };
  109. ccp.IfShowErrMsg = false;
  110. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  111. if (ccp != null)
  112. {
  113. if (ccp.ReturnCode == -1)
  114. {
  115. MessageUtil.ShowWarning(ccp.ReturnInfo);
  116. return;
  117. }
  118. MessageUtil.ShowTips("生成成功!");
  119. doQuery();
  120. }
  121. }
  122. private void doExport()
  123. {
  124. GridHelper.ulGridToExcel(ultraGrid1, "关联交易-半成品");
  125. }
  126. private void updateField()
  127. {
  128. this.ultraGrid1.UpdateData();
  129. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True");
  130. if (checkRows.Count() == 0)
  131. {
  132. MessageUtil.ShowTips("请选择数据!");
  133. return;
  134. }
  135. ArrayList list = new ArrayList();
  136. foreach (UltraGridRow row in checkRows)
  137. {
  138. PlnOrderZgSEntity entity = row.ListObject as PlnOrderZgSEntity;
  139. list.Add(JSONFormat.Format(entity));
  140. CoreClientParam ccp = new CoreClientParam();
  141. ccp.ServerName = "com.steering.pss.glbusiness.FrmTHOrderManage";
  142. ccp.MethodName = "doupdateField";
  143. ccp.ServerParams = new object[] { list };
  144. ccp.IfShowErrMsg = false;
  145. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  146. if (ccp != null)
  147. {
  148. if (ccp.ReturnCode == -1)
  149. {
  150. MessageUtil.ShowWarning(ccp.ReturnInfo);
  151. return;
  152. }
  153. MessageUtil.ShowTips("修改成功!");
  154. doQuery();
  155. }
  156. }
  157. }
  158. private void updateWeight()
  159. {
  160. this.ultraGrid1.UpdateData();
  161. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True");
  162. if (checkRows.Count() == 0)
  163. {
  164. MessageUtil.ShowTips("请选择数据!");
  165. return;
  166. }
  167. ArrayList list = new ArrayList();
  168. foreach (UltraGridRow row in checkRows)
  169. {
  170. PlnOrderZgSEntity entity = row.ListObject as PlnOrderZgSEntity;
  171. list.Add(JSONFormat.Format(entity));
  172. CoreClientParam ccp = new CoreClientParam();
  173. ccp.ServerName = "com.steering.pss.glbusiness.FrmTHOrderManage";
  174. ccp.MethodName = "doupdateWeight";
  175. ccp.ServerParams = new object[] { list };
  176. ccp.IfShowErrMsg = false;
  177. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  178. if (ccp != null)
  179. {
  180. if (ccp.ReturnCode == -1)
  181. {
  182. MessageUtil.ShowWarning(ccp.ReturnInfo);
  183. return;
  184. }
  185. MessageUtil.ShowTips("修改成功!");
  186. doQuery();
  187. }
  188. }
  189. }
  190. private void doUpdateThOrder()
  191. {
  192. this.ultraGrid1.UpdateData();
  193. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True");
  194. if (checkRows.Count() == 0)
  195. {
  196. MessageUtil.ShowTips("请选择数据!");
  197. return;
  198. }
  199. ArrayList list = new ArrayList();
  200. foreach (UltraGridRow row in checkRows)
  201. {
  202. PlnOrderZgSEntity entity = row.ListObject as PlnOrderZgSEntity;
  203. if (!entity.ProductionThFlag.Equals("123506"))
  204. {
  205. MessageUtil.ShowTips(entity.ProPlanId + ",合同未确认!");
  206. return;
  207. }
  208. if (String.IsNullOrEmpty(entity.ThOrderNoSeq))
  209. {
  210. MessageUtil.ShowTips(entity.ProPlanId + "天淮合同不能为空!");
  211. return;
  212. }
  213. list.Add(new object[] { entity.ThOrderNoSeq, entity.ProPlanId, entity.GxPlanNo });
  214. }
  215. CoreClientParam ccp = new CoreClientParam();
  216. ccp.ServerName = "com.steering.pss.glbusiness.FrmTHOrderManage";
  217. ccp.MethodName = "doUpdateThOrder";
  218. ccp.ServerParams = new object[] { list };
  219. ccp.IfShowErrMsg = false;
  220. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  221. if (ccp != null)
  222. {
  223. if (ccp.ReturnCode == -1)
  224. {
  225. MessageUtil.ShowWarning(ccp.ReturnInfo);
  226. return;
  227. }
  228. MessageUtil.ShowTips("修改成功!");
  229. doQuery();
  230. }
  231. }
  232. private void doCancel()
  233. {
  234. this.ultraGrid1.UpdateData();
  235. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True");
  236. if (checkRows.Count() == 0)
  237. {
  238. MessageUtil.ShowTips("请选择数据!");
  239. return;
  240. }
  241. ArrayList list = new ArrayList();
  242. foreach (UltraGridRow row in checkRows)
  243. {
  244. PlnOrderZgSEntity entity = row.ListObject as PlnOrderZgSEntity;
  245. string productionThFlag = "";
  246. // 制造部
  247. if (this.CustomInfo.ToString2().Equals("123501"))
  248. {
  249. if (!entity.ProductionThFlag.Equals("123502") && !entity.ProductionThFlag.Equals("123503"))
  250. {
  251. MessageUtil.ShowTips(entity.ProPlanId + "," + entity.ProductionThName+ "状态有误,无法撤销,请确认状态!");
  252. return;
  253. }
  254. else
  255. {
  256. productionThFlag = "123501";
  257. }
  258. }
  259. // 配套服务科
  260. if (this.CustomInfo.ToString2().Equals("123502"))
  261. {
  262. if (!entity.ProductionThFlag.Equals("123504") && !entity.ProductionThFlag.Equals("123505"))
  263. {
  264. MessageUtil.ShowTips(entity.ProPlanId + "," + entity.ProductionThName + ",状态有误,无法撤销,请确认状态!");
  265. return;
  266. }
  267. else
  268. {
  269. productionThFlag = "123503";
  270. }
  271. }
  272. // 天淮公司
  273. if (this.CustomInfo.ToString2().Equals("123504"))
  274. {
  275. if (!entity.ProductionThFlag.Equals("123506"))
  276. {
  277. MessageUtil.ShowTips(entity.ProPlanId + "," + entity.ProductionThName + ",状态有误,无法撤销,请确认状态!");
  278. return;
  279. }
  280. else
  281. {
  282. productionThFlag = "123505";
  283. }
  284. }
  285. list.Add(new object[] { productionThFlag, entity.ProPlanId, entity.GxPlanNo, this.CustomInfo.ToString2() });
  286. }
  287. CoreClientParam ccp = new CoreClientParam();
  288. ccp.ServerName = "com.steering.pss.glbusiness.FrmTHOrderManage";
  289. ccp.MethodName = "doUpdate";
  290. ccp.ServerParams = new object[] { list };
  291. ccp.IfShowErrMsg = false;
  292. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  293. if (ccp != null)
  294. {
  295. if (ccp.ReturnCode == -1)
  296. {
  297. MessageUtil.ShowWarning(ccp.ReturnInfo);
  298. return;
  299. }
  300. MessageUtil.ShowTips("取消确认成功!");
  301. doQuery();
  302. }
  303. }
  304. private void doConfirm()
  305. {
  306. this.ultraGrid1.UpdateData();
  307. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True");
  308. if (checkRows.Count() == 0)
  309. {
  310. MessageUtil.ShowTips("请选择数据!");
  311. return;
  312. }
  313. ArrayList list = new ArrayList();
  314. foreach(UltraGridRow row in checkRows){
  315. PlnOrderZgSEntity entity = row.ListObject as PlnOrderZgSEntity;
  316. string productionThFlag = "";
  317. // 制造部
  318. if (this.CustomInfo.ToString2().Equals("123501"))
  319. {
  320. if (!(entity.ProductionThFlag.Equals("") || entity.ProductionThFlag.Equals("123501") || entity.ProductionThFlag.Equals("123503")))
  321. {
  322. MessageUtil.ShowTips(entity.ProPlanId + "," + entity.ProductionThName + ",状态有误,无法确认,请确认状态!");
  323. return;
  324. }
  325. else
  326. {
  327. productionThFlag = "123502";
  328. }
  329. }
  330. // 配套服务科
  331. if (this.CustomInfo.ToString2().Equals("123502"))
  332. {
  333. if (!(entity.ProductionThFlag.Equals("123502") || entity.ProductionThFlag.Equals("123503") || entity.ProductionThFlag.Equals("123505")))
  334. {
  335. MessageUtil.ShowTips(entity.ProPlanId + "," + entity.ProductionThName + ",状态有误,无法确认,请确认状态!");
  336. return;
  337. }
  338. else
  339. {
  340. productionThFlag = "123504";
  341. }
  342. }
  343. // 天淮公司
  344. if (this.CustomInfo.ToString2().Equals("123504"))
  345. {
  346. if (!(entity.ProductionThFlag.Equals("123504") || entity.ProductionThFlag.Equals("123505")))
  347. {
  348. MessageUtil.ShowTips(entity.ProPlanId + "," + entity.ProductionThName + ",状态有误,无法确认,请确认状态!");
  349. return;
  350. }
  351. else
  352. {
  353. productionThFlag = "123506";
  354. }
  355. }
  356. list.Add(new object[] { productionThFlag, entity.ProPlanId, entity.GxPlanNo, this.CustomInfo.ToString2() });
  357. }
  358. CoreClientParam ccp = new CoreClientParam();
  359. ccp.ServerName = "com.steering.pss.glbusiness.FrmTHOrderManage";
  360. ccp.MethodName = "doUpdate";
  361. ccp.ServerParams = new object[] { list };
  362. ccp.IfShowErrMsg = false;
  363. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  364. if (ccp != null)
  365. {
  366. if (ccp.ReturnCode == -1)
  367. {
  368. MessageUtil.ShowWarning(ccp.ReturnInfo);
  369. return;
  370. }
  371. MessageUtil.ShowTips("确认成功!");
  372. doQuery();
  373. }
  374. }
  375. private void doQuery()
  376. {
  377. string orderNo = ""; //合同号
  378. string orderStart = "";
  379. string orderEnd = "";
  380. if (uchkOrderNo.Checked)
  381. {
  382. orderNo = utxtOrderNo.Text.Trim();
  383. }
  384. if (uchkDate.Checked)
  385. {
  386. orderStart = udtStart.DateTime.ToString("yyyy-MM-dd") + " 00:00:01";
  387. orderEnd = udtEnd.DateTime.ToString("yyyy-MM-dd") + " 23:59:59";
  388. }
  389. string productionThFlag = this.CustomInfo.ToString2().Equals("123501") ? "" : this.CustomInfo.ToString2();
  390. List<PlnOrderZgSEntity> listSource = EntityHelper.GetData<PlnOrderZgSEntity>(
  391. "com.steering.pss.glbusiness.FrmTHOrderManage.doQuery", new object[] { orderNo, orderStart, orderEnd, productionThFlag }, this.ob);
  392. plnOrderZgSEntityBindingSource.DataSource = listSource;
  393. }
  394. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  395. {
  396. this.ultraGrid1.UpdateData();
  397. UltraGridRow row = this.ultraGrid1.ActiveRow;
  398. if (row == null)
  399. {
  400. return;
  401. }
  402. FrmProInformation fp = new FrmProInformation(ob, row.Cells["PrdcrNo"].Text, row.Cells["IndexSeq"].Text, "D");
  403. fp.ShowDialog();
  404. }
  405. }
  406. }