FrmHeatProductionMesGXRZ.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using Core.Mes.Client.Comm.Control;
  11. using Core.Mes.Client.Comm.Format;
  12. using Core.Mes.Client.Comm.Server;
  13. using Core.Mes.Client.Comm.Tool;
  14. using Core.StlMes.Client.PlnSaleOrd.BaseMethod;
  15. using Core.StlMes.Client.PlnSaleOrd.工序排产;
  16. using Core.StlMes.Client.PlnSaleOrd.高新.entity;
  17. using CoreFS.CA06;
  18. using Infragistics.Win;
  19. using Infragistics.Win.UltraWinEditors;
  20. using Infragistics.Win.UltraWinGrid;
  21. using Core.StlMes.Client.PlnSaleOrd.OrderManage.froms;
  22. using Newtonsoft.Json;
  23. using Core.StlMes.Client.PlnSaleOrd.窗体;
  24. using Core.Mes.Client.Comm;
  25. using Core.StlMes.Client.PlnSaleOrd.PopupWindow;
  26. using Core.StlMes.Client.PlnSaleOrd.炉计划.Entity;
  27. using Core.StlMes.Client.PlnSaleOrd.炉计划.Tool;
  28. namespace Core.StlMes.Client.PlnSaleOrd
  29. {
  30. ///custominfo==0 表示轧管排产查询界面
  31. /// <summary>
  32. /// 加工高新
  33. /// </summary>
  34. public partial class FrmHeatProductionMesGXRZ : FrmBase
  35. {
  36. private string departm = "";//获取部门ID
  37. private string[] plineCode = null;//获取产线代码
  38. /// <summary>
  39. /// 订单编号
  40. /// </summary>
  41. private string _ProPlanId = "";
  42. DataTable dtPlinGroup = null;
  43. /// <summary>
  44. /// 排产序号
  45. /// </summary>
  46. private string _GxPlanNo = "";
  47. UltraComboEditor uceDimaM = new UltraComboEditor();//芯棒直径
  48. /// <summary>
  49. /// 行首背景色
  50. /// </summary>
  51. private Color _backColor = new Color();
  52. string proPlanId = "";
  53. string gxPlanNo = "";
  54. /// <summary>
  55. /// 调整行集合
  56. /// </summary>
  57. private ArrayList _entityList = null;
  58. public FrmHeatProductionMesGXRZ()
  59. {
  60. InitializeComponent();
  61. this.IsLoadUserView = true;
  62. }
  63. public override void ToolBar_Click(object sender, string ToolbarKey)
  64. {
  65. base.ToolBar_Click(sender, ToolbarKey);
  66. switch (ToolbarKey)
  67. {
  68. case "Query"://查询
  69. Query();
  70. break;
  71. case "Recalculate"://设置高新
  72. Recalculate();
  73. break;
  74. case "Recalculate2"://撤销高新
  75. Recalculate2();
  76. break;
  77. case "Export": //导出
  78. //GridHelper.ulGridToExcel(ultraJGGX, "热处理高新");
  79. ExportData();
  80. break;
  81. case "Close": //关闭
  82. this.Close();
  83. break;
  84. default:
  85. break;
  86. }
  87. }
  88. /// <summary>
  89. /// 导出
  90. /// </summary>
  91. private void ExportData()
  92. {
  93. GridHelper.ulGridToExcel(ultraJGGX, "热轧高新");
  94. }
  95. private void FrmPlnOrderZgS_Load(object sender, EventArgs e)
  96. {
  97. if (CustomInfo == null) { CustomInfo = ""; }
  98. //设置列头名称
  99. EntityHelper.ShowGridCaption<HotProductionMesRZEntity>(ultraJGGX.DisplayLayout.Bands[0]);
  100. if (CustomInfo == "0")
  101. {
  102. PlanComm.setGridActivation(this.ultraJGGX.DisplayLayout.Bands[0], "CHC");//, "OutsBilletFl"
  103. }
  104. else
  105. {
  106. BaseHelper.setOtherColumnReadOnly(ultraJGGX, new string[] { "CHC", "HighProdWeight", "HighMateWeight", "EstimatedUnitPrice", "EstimatedCost", "HighTechCode" });
  107. //tzh 后续改颜色
  108. BaseHelper.setColumnBackColor(ultraJGGX, new string[] { "HighProdWeight", "HighMateWeight", "EstimatedUnitPrice", "EstimatedCost", "HighTechCode" });
  109. //BaseHelper.setOtherColumnReadOnly(ultraJGGX, new string[] { "CHC"});
  110. //BaseHelper.setOtherColumnReadOnly(ultraRCLGX, new string[] { "CHC", "Mgcd", "DiameterMandrel", "Zzcd", "Ggfqs", "Cpcd", "Qt", "Qw", "Bcs", "Dbcplcd", "Gpzj", "WgH", "WgD", "QuantityPurchased", "RulerLength", "Ssl", "Mz", "Jhlc" });
  111. //tzh 后续改颜色
  112. // BaseHelper.setColumnBackColor(ultraRCLGX, new string[] { "Pass", "Mgcd", "DiameterMandrel", "Zzcd", "Ggfqs", "Cpcd", "Qt", "Qw", "Bcs", "Dbcplcd", "Gpzj", "WgH", "WgD", "HtcgzlMax", "HtcgzlMin", "QuantityPurchased", "RulerLength", "Dbcplzl", "Ssl", "Mz", "Jhlc", "Zzzl", "Zzcd", "Dbcplcd", "QuantityPurchased" });
  113. //BaseHelper.setColumnBackColor2(ultraGridZgS, new string[] { "Mgbh", "Mgwj" });
  114. }
  115. //BaseHelper.SetGroupBySum(ultraJGGX, new string[] { "HighMateWeight", "EstimatedCost" }, "CxNo");
  116. //if (CustomInfo != "0") { BaseHelper.ForbidSort(ultraJGGX); }
  117. _backColor = ultraJGGX.DisplayLayout.Override.RowSelectorAppearance.BackColor;
  118. InitColorStyle();
  119. BaseHelper.GridColumnSum(ultraJGGX, new string[] { "HighMateWeight", "EstimatedCost", "ProdWeight", "MateWeight", "SteelWaste", "EstimatedUnitPrice" });
  120. }
  121. /// <summary>
  122. /// 初始化列状态
  123. /// </summary>
  124. private void InitColorStyle()
  125. {
  126. UltraNumericEditor[] uneArr = new UltraNumericEditor[3];
  127. for (int i = 0; i < uneArr.Length; i++)
  128. {
  129. uneArr [i]= new UltraNumericEditor();
  130. uneArr[i].NumericType =NumericType.Double;
  131. if (i == 1)
  132. {
  133. uneArr[i].MaskInput = "nnnnn";
  134. }
  135. else
  136. {
  137. uneArr[i].MaskInput = "nnnnn.nn";
  138. }
  139. uneArr[i].SpinButtonDisplayStyle = Infragistics.Win.ButtonDisplayStyle.Always;
  140. this.Controls.Add(uneArr[i]);
  141. uneArr[i].Visible = false;
  142. }
  143. decisionFlsg(false);
  144. }
  145. private void decisionFlsg( Boolean b) {
  146. //if (b)
  147. //{
  148. // UltraComboEditor uceAbc = new UltraComboEditor();
  149. // ultraJGGX.DisplayLayout.Bands[0].Columns["Pass"].EditorComponent = uceAbc;
  150. // ultraJGGX.DisplayLayout.Bands[0].Columns["Pass"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  151. // ultraJGGX.DisplayLayout.Bands[0].Columns["DiameterMandrel"].EditorComponent = uceAbc;
  152. // ultraJGGX.DisplayLayout.Bands[0].Columns["DiameterMandrel"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  153. // ValueList vlistSteel1 = new ValueList(); ;
  154. // vlistSteel1.ValueListItems.Insert(0, "1", "1");
  155. // vlistSteel1.ValueListItems.Insert(1, "2", "2");
  156. // vlistSteel1.ValueListItems.Insert(2, "3", "3");
  157. // vlistSteel1.ValueListItems.Insert(3, "4", "4");
  158. // vlistSteel1.ValueListItems.Insert(4, "5", "5");
  159. // vlistSteel1.ValueListItems.Insert(5, "6", "6");
  160. // ultraJGGX.DisplayLayout.Bands[0].Columns["Ggfqs"].ValueList = vlistSteel1;
  161. // ultraJGGX.DisplayLayout.Bands[0].Columns["Ggfqs"].CellActivation = Activation.AllowEdit;
  162. // ultraJGGX.DisplayLayout.Bands[0].Columns["Bcs"].ValueList = vlistSteel1;
  163. // ultraJGGX.DisplayLayout.Bands[0].Columns["Bcs"].CellActivation = Activation.AllowEdit;
  164. // DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.queryMandrelSpec",
  165. // new object[] { "1" }, this.ob);
  166. // if (dt != null && dt.Rows.Count > 0)
  167. // {
  168. // ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt, "XX", "XX");
  169. // //vlistSteel.ValueListItems.Insert(0, "", "");
  170. // ultraJGGX.DisplayLayout.Bands[0].Columns["DiameterMandrel"].ValueList = vlistSteel;
  171. // ultraJGGX.DisplayLayout.Bands[0].Columns["DiameterMandrel"].CellActivation = Activation.AllowEdit;
  172. // }
  173. // DataTable dt1 = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.queryMandrelSpec",
  174. // new object[] { "2" }, this.ob);
  175. // if (dt1 != null && dt1.Rows.Count > 0)
  176. // {
  177. // ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt1, "XX", "XX");
  178. // //vlistSteel.ValueListItems.Insert(0, "", "");
  179. // ultraJGGX.DisplayLayout.Bands[0].Columns["Pass"].ValueList = vlistSteel;
  180. // ultraJGGX.DisplayLayout.Bands[0].Columns["Pass"].CellActivation = Activation.AllowEdit;
  181. // }
  182. // DataTable dt2 = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.queryMandrelSpec",
  183. // new object[] { "3" }, this.ob);
  184. // if (dt2 != null && dt2.Rows.Count > 0)
  185. // {
  186. // ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt2, "XX", "XX");
  187. // //vlistSteel.ValueListItems.Insert(0, "", "");
  188. // ultraJGGX.DisplayLayout.Bands[0].Columns["Mgwj"].ValueList = vlistSteel;
  189. // ultraJGGX.DisplayLayout.Bands[0].Columns["Mgwj"].CellActivation = Activation.AllowEdit;
  190. // }
  191. // DataTable dt3 = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.queryMandrelSpec",
  192. // new object[] { "4" }, this.ob);
  193. // if (dt3 != null && dt3.Rows.Count > 0)
  194. // {
  195. // ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt3, "XX", "XX");
  196. // //vlistSteel.ValueListItems.Insert(0, "", "");
  197. // ultraJGGX.DisplayLayout.Bands[0].Columns["Mgbh"].ValueList = vlistSteel;
  198. // ultraJGGX.DisplayLayout.Bands[0].Columns["Mgbh"].CellActivation = Activation.AllowEdit;
  199. // }
  200. //}
  201. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.GpOptimize.CorePlnZgMStoGp.queryCXcode", new object[] { "1" }, this.ob);
  202. if (dt != null && dt.Rows.Count > 0)
  203. {
  204. ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt, "GX_CODE", "GX_NAME");
  205. ultraJGGX.DisplayLayout.Bands[0].Columns["HighTechCode"].ValueList = vlistSteel;
  206. ultraJGGX.DisplayLayout.Bands[0].Columns["HighTechCode"].CellActivation = Activation.AllowEdit;
  207. }
  208. }
  209. private void InitTime()
  210. {
  211. DateTime now = DateTime.Now;
  212. DateTime d1 = new DateTime(now.Year, now.Month, 1);
  213. DateTime d2 = d1.AddMonths(1).AddSeconds(-1);
  214. }
  215. /// <summary>
  216. /// 查询
  217. /// </summary>
  218. private void Query()
  219. {
  220. WaitingForm2 wf3 = new WaitingForm2("正在刷新,请稍候....");
  221. try
  222. {
  223. this.Cursor = Cursors.WaitCursor;
  224. //执行状态
  225. // string[] statusArr = contorlPlanStatus1.statusArr;
  226. //查询时间
  227. string acctPeriod = "";
  228. acctPeriod = txtAcctPeriod.Text.Trim();
  229. List<HotProductionMesRZEntity> listSource = EntityHelper.GetData<HotProductionMesRZEntity>
  230. ("com.steering.pss.plnsaleord.GpOptimize.CorePlnZgMStoGp.selectrzgx", new object[] { acctPeriod }, this.ob);
  231. HotHeatProductionMesGxEntityBindingSource.DataSource = listSource;
  232. _entityList = null;
  233. _ProPlanId = "";
  234. _ProPlanId = "";
  235. }
  236. finally
  237. {
  238. wf3.Close();
  239. this.Cursor = Cursors.Default;
  240. }
  241. }
  242. private void ultraRCLGX_CellChange(object sender, CellEventArgs e)
  243. {
  244. try
  245. {
  246. ultraJGGX.UpdateData();
  247. //if (e.Cell.Column.Key.Equals("CHC"))
  248. //{
  249. // IQueryable<UltraGridRow> chcRows = ultraJGGX.Rows.AsQueryable().Where(a => a.GetValue("CHC") == "True");
  250. // if (chcRows != null && chcRows.Count() > 0)
  251. // {
  252. // decisionFlsg(true);
  253. // }
  254. // else
  255. // {
  256. // decisionFlsg(false);
  257. // }
  258. //}
  259. foreach (var ultraGridRow in ultraJGGX.Rows)
  260. {
  261. if ((bool)ultraGridRow.Cells["CHC"].Value)
  262. {
  263. decimal HighProdWeight = 0;
  264. if (ultraGridRow.Cells["HighProdWeight"].Value.ToString() != "")
  265. {
  266. HighProdWeight = decimal.Parse((ultraGridRow.Cells["HighProdWeight"].Value.ToString()));//高新成品
  267. }
  268. decimal HighMateWeight = 0;
  269. if (ultraGridRow.Cells["HighMateWeight"].Value.ToString() != "")
  270. {
  271. HighMateWeight = decimal.Parse(ultraGridRow.Cells["HighMateWeight"].Value.ToString());//高新坯料
  272. }
  273. decimal EstimatedUnitPrice = 0;
  274. if (ultraGridRow.Cells["HighMateWeight"].Value.ToString() != "" && ultraGridRow.Cells["EstimatedUnitPrice"].Value.ToString() != "")
  275. {
  276. EstimatedUnitPrice = decimal.Parse(ultraGridRow.Cells["EstimatedUnitPrice"].Value.ToString());//单价
  277. ultraGridRow.Cells["estimatedCost"].Value = HighMateWeight * EstimatedUnitPrice;
  278. }
  279. decimal ProdWeight = 0;
  280. if (ultraGridRow.Cells["ProdWeight"].Value.ToString() != "")
  281. {
  282. ProdWeight = decimal.Parse((ultraGridRow.Cells["ProdWeight"].Value.ToString()));//正常成品
  283. }
  284. decimal MateWeight = 0;
  285. if (ultraGridRow.Cells["MateWeight"].Value.ToString() != "")
  286. {
  287. MateWeight = decimal.Parse(ultraGridRow.Cells["MateWeight"].Value.ToString());//正常来料
  288. }
  289. /* if (HighMateWeight > MateWeight)
  290. {
  291. MessageUtil.ShowTips("高新的来料不能大于正常的来料!");
  292. ultraGridRow.Cells["HighMateWeight"].Value = "0";
  293. }*/
  294. if (HighProdWeight > ProdWeight)
  295. {
  296. MessageUtil.ShowTips("高新的成品不能大于正常的成品!");
  297. ultraGridRow.Cells["HighProdWeight"].Value = "0";
  298. }
  299. if (ultraGridRow.Cells["HighTechCode"].Value.ToString() != "")
  300. {
  301. ultraGridRow.Cells["HighTechName"].Value = ultraGridRow.Cells["HighTechCode"].Text;
  302. }
  303. }
  304. }
  305. }
  306. catch (Exception)
  307. {
  308. }
  309. }
  310. /// <summary>
  311. /// 设置高新
  312. /// </summary>
  313. private void Recalculate()
  314. {
  315. try
  316. {
  317. ArrayList messageErr = new ArrayList();
  318. ultraJGGX.UpdateData();
  319. ArrayList list = ProducHelper.GetChcRows<HotProductionMesRZEntity>(ultraJGGX);
  320. if (list == null || list.Count == 0)
  321. {
  322. MessageUtil.ShowTips("请选择数据!");
  323. return;
  324. }
  325. ArrayList jsonList = new ArrayList();
  326. foreach (HotProductionMesRZEntity entity in list)
  327. {
  328. jsonList.Add(JSONFormat.Format(entity));
  329. }
  330. if (MessageUtil.ShowYesNoAndQuestion("是否保存高新?") == DialogResult.No)
  331. {
  332. return;
  333. }
  334. // PlanComm.WaitFromOpen(this.Cursor);
  335. CoreClientParam ccp = new CoreClientParam();
  336. ccp.ServerName = "com.steering.pss.plnsaleord.GpOptimize.CorePlnZgMStoGp";
  337. ccp.MethodName = "recalculateRZ";
  338. ccp.ServerParams = new object[] { jsonList,"1" };
  339. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  340. //PlanComm.WaitFromColse(this.Cursor);
  341. if (ccp.ReturnCode == -1) return;
  342. MessageUtil.ShowTips(ccp.ReturnInfo);
  343. if (ccp.ReturnInfo.Equals("保存成功!"))
  344. {
  345. Query();
  346. }
  347. }
  348. catch (Exception ex)
  349. {
  350. // PlanComm.WaitFromColse(this.Cursor);
  351. if (!(ex is MESException))
  352. {
  353. MessageUtil.ShowError(ex.Message);
  354. }
  355. }
  356. }
  357. /// <summary>
  358. /// 撤销高新
  359. /// </summary>
  360. private void Recalculate2()
  361. {
  362. try
  363. {
  364. ArrayList messageErr = new ArrayList();
  365. ultraJGGX.UpdateData();
  366. ArrayList list = ProducHelper.GetChcRows<HotProductionMesRZEntity>(ultraJGGX);
  367. if (list == null || list.Count == 0)
  368. {
  369. MessageUtil.ShowTips("请选择数据!");
  370. return;
  371. }
  372. ArrayList jsonList = new ArrayList();
  373. foreach (HotProductionMesRZEntity entity in list)
  374. {
  375. jsonList.Add(JSONFormat.Format(entity));
  376. }
  377. if (MessageUtil.ShowYesNoAndQuestion("是否撤销高新?") == DialogResult.No)
  378. {
  379. return;
  380. }
  381. // PlanComm.WaitFromOpen(this.Cursor);
  382. CoreClientParam ccp = new CoreClientParam();
  383. ccp.ServerName = "com.steering.pss.plnsaleord.GpOptimize.CorePlnZgMStoGp";
  384. ccp.MethodName = "recalculateRZ";
  385. ccp.ServerParams = new object[] { jsonList,"0" };
  386. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  387. // PlanComm.WaitFromColse(this.Cursor);
  388. if (ccp.ReturnCode == -1) return;
  389. MessageUtil.ShowTips(ccp.ReturnInfo);
  390. if (ccp.ReturnInfo.Equals("保存成功!"))
  391. {
  392. Query();
  393. }
  394. }
  395. catch (Exception ex)
  396. {
  397. // PlanComm.WaitFromColse(this.Cursor);
  398. if (!(ex is MESException))
  399. {
  400. MessageUtil.ShowError(ex.Message);
  401. }
  402. }
  403. }
  404. }
  405. }