FrmHeatProductionMesGXJG.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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 FrmHeatProductionMesGXJG : 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 FrmHeatProductionMesGXJG()
  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<HotProductionMesJgEntity>(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"});
  107. BaseHelper.setOtherColumnReadOnly(ultraJGGX, new string[] { "CHC", "HighProdWeight", "HighMateWeight", "EstimatedUnitPrice", "EstimatedCost", "HighTechCode" });
  108. //tzh 后续改颜色
  109. BaseHelper.setColumnBackColor(ultraJGGX, new string[] { "HighProdWeight", "HighMateWeight", "EstimatedUnitPrice", "EstimatedCost", "HighTechCode" });
  110. //BaseHelper.setColumnBackColor2(ultraGridZgS, new string[] { "Mgbh", "Mgwj" });
  111. }
  112. //BaseHelper.SetGroupBySum(ultraJGGX, new string[] { "HighMateWeight", "EstimatedCost" }, "CxNo");
  113. BaseHelper.GridColumnSum(ultraJGGX, new string[] { "HighMateWeight", "EstimatedCost", "ProdWeight", "MateWeight", "SteelWaste", "EstimatedUnitPrice" });
  114. //if (CustomInfo != "0") { BaseHelper.ForbidSort(ultraJGGX); }
  115. _backColor = ultraJGGX.DisplayLayout.Override.RowSelectorAppearance.BackColor;
  116. InitColorStyle();
  117. }
  118. /// <summary>
  119. /// 初始化列状态
  120. /// </summary>
  121. private void InitColorStyle()
  122. {
  123. UltraNumericEditor[] uneArr = new UltraNumericEditor[3];
  124. for (int i = 0; i < uneArr.Length; i++)
  125. {
  126. uneArr [i]= new UltraNumericEditor();
  127. uneArr[i].NumericType =NumericType.Double;
  128. if (i == 1)
  129. {
  130. uneArr[i].MaskInput = "nnnnn";
  131. }
  132. else
  133. {
  134. uneArr[i].MaskInput = "nnnnn.nn";
  135. }
  136. uneArr[i].SpinButtonDisplayStyle = Infragistics.Win.ButtonDisplayStyle.Always;
  137. this.Controls.Add(uneArr[i]);
  138. uneArr[i].Visible = false;
  139. }
  140. decisionFlsg(false);
  141. }
  142. private void decisionFlsg( Boolean b) {
  143. //if (b)
  144. //{
  145. // UltraComboEditor uceAbc = new UltraComboEditor();
  146. // ultraJGGX.DisplayLayout.Bands[0].Columns["Pass"].EditorComponent = uceAbc;
  147. // ultraJGGX.DisplayLayout.Bands[0].Columns["Pass"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  148. // ultraJGGX.DisplayLayout.Bands[0].Columns["DiameterMandrel"].EditorComponent = uceAbc;
  149. // ultraJGGX.DisplayLayout.Bands[0].Columns["DiameterMandrel"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  150. // ValueList vlistSteel1 = new ValueList(); ;
  151. // vlistSteel1.ValueListItems.Insert(0, "1", "1");
  152. // vlistSteel1.ValueListItems.Insert(1, "2", "2");
  153. // vlistSteel1.ValueListItems.Insert(2, "3", "3");
  154. // vlistSteel1.ValueListItems.Insert(3, "4", "4");
  155. // vlistSteel1.ValueListItems.Insert(4, "5", "5");
  156. // vlistSteel1.ValueListItems.Insert(5, "6", "6");
  157. // ultraJGGX.DisplayLayout.Bands[0].Columns["Ggfqs"].ValueList = vlistSteel1;
  158. // ultraJGGX.DisplayLayout.Bands[0].Columns["Ggfqs"].CellActivation = Activation.AllowEdit;
  159. // ultraJGGX.DisplayLayout.Bands[0].Columns["Bcs"].ValueList = vlistSteel1;
  160. // ultraJGGX.DisplayLayout.Bands[0].Columns["Bcs"].CellActivation = Activation.AllowEdit;
  161. // DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.queryMandrelSpec",
  162. // new object[] { "1" }, this.ob);
  163. // if (dt != null && dt.Rows.Count > 0)
  164. // {
  165. // ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt, "XX", "XX");
  166. // //vlistSteel.ValueListItems.Insert(0, "", "");
  167. // ultraJGGX.DisplayLayout.Bands[0].Columns["DiameterMandrel"].ValueList = vlistSteel;
  168. // ultraJGGX.DisplayLayout.Bands[0].Columns["DiameterMandrel"].CellActivation = Activation.AllowEdit;
  169. // }
  170. // DataTable dt1 = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.queryMandrelSpec",
  171. // new object[] { "2" }, this.ob);
  172. // if (dt1 != null && dt1.Rows.Count > 0)
  173. // {
  174. // ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt1, "XX", "XX");
  175. // //vlistSteel.ValueListItems.Insert(0, "", "");
  176. // ultraJGGX.DisplayLayout.Bands[0].Columns["Pass"].ValueList = vlistSteel;
  177. // ultraJGGX.DisplayLayout.Bands[0].Columns["Pass"].CellActivation = Activation.AllowEdit;
  178. // }
  179. // DataTable dt2 = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.queryMandrelSpec",
  180. // new object[] { "3" }, this.ob);
  181. // if (dt2 != null && dt2.Rows.Count > 0)
  182. // {
  183. // ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt2, "XX", "XX");
  184. // //vlistSteel.ValueListItems.Insert(0, "", "");
  185. // ultraJGGX.DisplayLayout.Bands[0].Columns["Mgwj"].ValueList = vlistSteel;
  186. // ultraJGGX.DisplayLayout.Bands[0].Columns["Mgwj"].CellActivation = Activation.AllowEdit;
  187. // }
  188. // DataTable dt3 = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.queryMandrelSpec",
  189. // new object[] { "4" }, this.ob);
  190. // if (dt3 != null && dt3.Rows.Count > 0)
  191. // {
  192. // ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt3, "XX", "XX");
  193. // //vlistSteel.ValueListItems.Insert(0, "", "");
  194. // ultraJGGX.DisplayLayout.Bands[0].Columns["Mgbh"].ValueList = vlistSteel;
  195. // ultraJGGX.DisplayLayout.Bands[0].Columns["Mgbh"].CellActivation = Activation.AllowEdit;
  196. // }
  197. //}
  198. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.GpOptimize.CorePlnZgMStoGp.queryCXcode", new object[] { "1" }, this.ob);
  199. if (dt != null && dt.Rows.Count > 0)
  200. {
  201. ValueList vlistSteel = PlanComm.GeneralValuelist(ref dt, "GX_CODE", "GX_NAME");
  202. ultraJGGX.DisplayLayout.Bands[0].Columns["HighTechCode"].ValueList = vlistSteel;
  203. ultraJGGX.DisplayLayout.Bands[0].Columns["HighTechCode"].CellActivation = Activation.AllowEdit;
  204. }
  205. }
  206. private void InitTime()
  207. {
  208. DateTime now = DateTime.Now;
  209. DateTime d1 = new DateTime(now.Year, now.Month, 1);
  210. DateTime d2 = d1.AddMonths(1).AddSeconds(-1);
  211. }
  212. /// <summary>
  213. /// 查询
  214. /// </summary>
  215. private void Query()
  216. {
  217. WaitingForm2 wf3 = new WaitingForm2("正在刷新,请稍候....");
  218. try
  219. {
  220. this.Cursor = Cursors.WaitCursor;
  221. //执行状态
  222. // string[] statusArr = contorlPlanStatus1.statusArr;
  223. //查询时间
  224. string acctPeriod = "";
  225. acctPeriod = txtAcctPeriod.Text.Trim();
  226. List<HotProductionMesJgEntity> listSource = EntityHelper.GetData<HotProductionMesJgEntity>
  227. ("com.steering.pss.plnsaleord.GpOptimize.CorePlnZgMStoGp.selectjggx", new object[] { acctPeriod }, this.ob);
  228. HotHeatProductionMesGxEntityBindingSource.DataSource = listSource;
  229. _entityList = null;
  230. _ProPlanId = "";
  231. _ProPlanId = "";
  232. }
  233. finally
  234. {
  235. wf3.Close();
  236. this.Cursor = Cursors.Default;
  237. }
  238. }
  239. //private void SetStaticsInfo()
  240. //{
  241. // try
  242. // {
  243. // if (this.ultraJGGX.Rows.Count == 0)
  244. // {
  245. // this.ultraJGGX.DisplayLayout.Bands[0].Summaries.Clear();
  246. // }
  247. // else
  248. // {
  249. // ArrayList alist = new ArrayList();
  250. // alist.Add("HighMateWeight");
  251. // alist.Add("EstimatedCost");
  252. // SetStaticsInfoSum2(ref this.ultraJGGX, alist,true);
  253. // }
  254. // }
  255. // catch { }
  256. //}
  257. //public static void SetStaticsInfoSum2(ref UltraGrid myGrid1, ArrayList alistColumns, bool clearExists)
  258. //{
  259. // try
  260. // {
  261. // UltraGridBand band = myGrid1.DisplayLayout.Bands[0];
  262. // if (clearExists)
  263. // band.Summaries.Clear();
  264. // band.Override.SummaryFooterCaptionVisible = Infragistics.Win.DefaultableBoolean.False;
  265. // for (int i = 0; i < alistColumns.Count; i++)
  266. // {
  267. // try
  268. // {
  269. // SummarySettings summary = band.Summaries.Add(SummaryType.Sum, band.Columns[alistColumns[i].ToString()]);
  270. // summary.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
  271. // summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
  272. // if (alistColumns[i].ToString().Contains("COUNT"))
  273. // {
  274. // summary.DisplayFormat = "{0:N0}";
  275. // }
  276. // else
  277. // {
  278. // summary.DisplayFormat = "{0:N3}";
  279. // }
  280. // summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Right;
  281. // summary.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle;
  282. // summary.Appearance.FontData.Bold = DefaultableBoolean.True;
  283. // summary.Lines = 3;
  284. // }
  285. // catch { }
  286. // }
  287. // }
  288. // catch { }
  289. //}
  290. private void ultraRCLGX_CellChange(object sender, CellEventArgs e)
  291. {
  292. try
  293. {
  294. ultraJGGX.UpdateData();
  295. //if (e.Cell.Column.Key.Equals("CHC"))
  296. //{
  297. // IQueryable<UltraGridRow> chcRows = ultraJGGX.Rows.AsQueryable().Where(a => a.GetValue("CHC") == "True");
  298. // if (chcRows != null && chcRows.Count() > 0)
  299. // {
  300. // decisionFlsg(true);
  301. // }
  302. // else
  303. // {
  304. // decisionFlsg(false);
  305. // }
  306. //}
  307. foreach (var ultraGridRow in ultraJGGX.Rows)
  308. {
  309. if ((bool)ultraGridRow.Cells["CHC"].Value)
  310. {
  311. decimal HighProdWeight = 0;
  312. if (ultraGridRow.Cells["HighProdWeight"].Value.ToString() != "")
  313. {
  314. HighProdWeight = decimal.Parse((ultraGridRow.Cells["HighProdWeight"].Value.ToString()));//高新成品
  315. }
  316. decimal HighMateWeight = 0;
  317. if (ultraGridRow.Cells["HighMateWeight"].Value.ToString() != "")
  318. {
  319. HighMateWeight = decimal.Parse(ultraGridRow.Cells["HighMateWeight"].Value.ToString());//高新坯料
  320. }
  321. decimal EstimatedUnitPrice = 0;
  322. if (ultraGridRow.Cells["HighMateWeight"].Value.ToString() != "" && ultraGridRow.Cells["EstimatedUnitPrice"].Value.ToString() != "")
  323. {
  324. EstimatedUnitPrice = decimal.Parse(ultraGridRow.Cells["EstimatedUnitPrice"].Value.ToString());//单价
  325. ultraGridRow.Cells["estimatedCost"].Value = HighMateWeight * EstimatedUnitPrice;
  326. }
  327. decimal ProdWeight = 0;
  328. if (ultraGridRow.Cells["ProdWeight"].Value.ToString() != "")
  329. {
  330. ProdWeight = decimal.Parse((ultraGridRow.Cells["ProdWeight"].Value.ToString()));//正常成品
  331. }
  332. decimal MateWeight = 0;
  333. if (ultraGridRow.Cells["MateWeight"].Value.ToString() != "")
  334. {
  335. MateWeight = decimal.Parse(ultraGridRow.Cells["MateWeight"].Value.ToString());//正常来料
  336. }
  337. /* if (HighMateWeight > MateWeight)
  338. {
  339. MessageUtil.ShowTips("高新的来料不能大于正常的来料!");
  340. ultraGridRow.Cells["HighMateWeight"].Value = "0";
  341. }*/
  342. if (HighProdWeight > ProdWeight)
  343. {
  344. MessageUtil.ShowTips("高新的成品不能大于正常的成品!");
  345. ultraGridRow.Cells["HighProdWeight"].Value = "0";
  346. }
  347. if (ultraGridRow.Cells["HighTechCode"].Value.ToString() != "")
  348. {
  349. ultraGridRow.Cells["HighTechName"].Value = ultraGridRow.Cells["HighTechCode"].Text;
  350. }
  351. }
  352. }
  353. }
  354. catch (Exception)
  355. {
  356. }
  357. }
  358. /// <summary>
  359. /// 设置高新
  360. /// </summary>
  361. private void Recalculate()
  362. {
  363. try
  364. {
  365. ArrayList messageErr = new ArrayList();
  366. ultraJGGX.UpdateData();
  367. ArrayList list = ProducHelper.GetChcRows<HotProductionMesJgEntity>(ultraJGGX);
  368. if (list == null || list.Count == 0)
  369. {
  370. MessageUtil.ShowTips("请选择数据!");
  371. return;
  372. }
  373. ArrayList jsonList = new ArrayList();
  374. foreach (HotProductionMesJgEntity entity in list)
  375. {
  376. jsonList.Add(JSONFormat.Format(entity));
  377. }
  378. if (MessageUtil.ShowYesNoAndQuestion("是否保存高新?") == DialogResult.No)
  379. {
  380. return;
  381. }
  382. //PlanComm.WaitFromOpen(this.Cursor);
  383. CoreClientParam ccp = new CoreClientParam();
  384. ccp.ServerName = "com.steering.pss.plnsaleord.GpOptimize.CorePlnZgMStoGp";
  385. ccp.MethodName = "recalculateJG";
  386. ccp.ServerParams = new object[] { jsonList,"1"};
  387. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  388. // PlanComm.WaitFromColse(this.Cursor);
  389. if (ccp.ReturnCode == -1) return;
  390. MessageUtil.ShowTips(ccp.ReturnInfo);
  391. if (ccp.ReturnInfo.Equals("保存成功!"))
  392. {
  393. Query();
  394. }
  395. }
  396. catch (Exception ex)
  397. {
  398. //PlanComm.WaitFromColse(this.Cursor);
  399. if (!(ex is MESException))
  400. {
  401. MessageUtil.ShowError(ex.Message);
  402. }
  403. }
  404. }
  405. /// <summary>
  406. /// 撤销高新
  407. /// </summary>
  408. private void Recalculate2()
  409. {
  410. try
  411. {
  412. ArrayList messageErr = new ArrayList();
  413. ultraJGGX.UpdateData();
  414. ArrayList list = ProducHelper.GetChcRows<HotProductionMesJgEntity>(ultraJGGX);
  415. if (list == null || list.Count == 0)
  416. {
  417. MessageUtil.ShowTips("请选择数据!");
  418. return;
  419. }
  420. ArrayList jsonList = new ArrayList();
  421. foreach (HotProductionMesJgEntity entity in list)
  422. {
  423. jsonList.Add(JSONFormat.Format(entity));
  424. }
  425. if (MessageUtil.ShowYesNoAndQuestion("是否撤销高新?") == DialogResult.No)
  426. {
  427. return;
  428. }
  429. // PlanComm.WaitFromOpen(this.Cursor);
  430. CoreClientParam ccp = new CoreClientParam();
  431. ccp.ServerName = "com.steering.pss.plnsaleord.GpOptimize.CorePlnZgMStoGp";
  432. ccp.MethodName = "recalculateJG";
  433. ccp.ServerParams = new object[] { jsonList,"0" };
  434. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  435. //PlanComm.WaitFromColse(this.Cursor);
  436. if (ccp.ReturnCode == -1) return;
  437. MessageUtil.ShowTips(ccp.ReturnInfo);
  438. if (ccp.ReturnInfo.Equals("保存成功!"))
  439. {
  440. Query();
  441. }
  442. }
  443. catch (Exception ex)
  444. {
  445. //PlanComm.WaitFromColse(this.Cursor);
  446. if (!(ex is MESException))
  447. {
  448. MessageUtil.ShowError(ex.Message);
  449. }
  450. }
  451. }
  452. }
  453. }