FrmPlanStoveH.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Format;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.PlnSaleOrd.BaseMethod;
  5. using Core.StlMes.Client.PlnSaleOrd.工序排产;
  6. using Core.StlMes.Client.PlnSaleOrd.炉计划.Entity;
  7. using Core.StlMes.Client.PlnSaleOrd.炉计划.Tool;
  8. using CoreFS.CA06;
  9. using Infragistics.Win;
  10. using Infragistics.Win.UltraWinGrid;
  11. using System;
  12. using System.Collections;
  13. using System.Collections.Generic;
  14. using System.ComponentModel;
  15. using System.Data;
  16. using System.Drawing;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Windows.Forms;
  20. namespace Core.StlMes.Client.PlnSaleOrd.炉计划
  21. {
  22. public partial class FrmPlanStoveH : FrmBase
  23. {
  24. private ArrayList _EntityList = null;
  25. private string[] plineCode = null;//获取产线代码
  26. /// <summary>
  27. /// 虚拟炉计划id
  28. /// </summary>
  29. private string _heatPlanNo = "";
  30. /// <summary>
  31. /// 行首背景色
  32. /// </summary>
  33. private Color _backColor = new Color();
  34. public FrmPlanStoveH()
  35. {
  36. this.IsLoadUserView = true;
  37. InitializeComponent();
  38. }
  39. private void FrmPlanStoveG_Load(object sender, EventArgs e)
  40. {
  41. //订单排产
  42. EntityHelper.ShowGridCaption<PlnZyJgMEntity>(ultraGridZy.DisplayLayout.Bands[0]);
  43. EntityHelper.ShowGridCaption<PlnZyJgReadyEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  44. BaseHelper.setOtherColumnReadOnly(ultraGridZy, new string[] { "CHC" });
  45. BaseHelper.setUltraGridColumnMaxInput(ultraGridZy, new string[] { "PlanBlWt","Singleweight" });
  46. BaseHelper.setUltraGridColumnBits(ultraGridZy, new string[] { "SingleCutNun", "PlanBlNum", "PlanJgNum"});
  47. BaseHelper.InitCellPosition(ultraGridZy, new string[] { "GxProSeq", "GxPlanNo","PlanBlWt", "Diameter", "SingleCutNun","PlanBlNum","PlanJgNum","Aimlength","CheckJVal","Outdiameter","Wallthick",
  48. "LengthMax","LengthMin","AimCutLen","AimlengthBl","MinH","MinD"});
  49. BaseHelper.GridColumnSum(ultraGridZy, new string[] { "PlanBlWt" });
  50. BaseHelper.GridColumnCount(ultraGridZy, new string[] { "PlanBlNum", "PlanJgNum"});
  51. plineCode = PlanHelper.InitDropPlinePower("H", txtLine, this.ValidDataPurviewIds, this.ob);
  52. StoveHelper.ForbidSort(ultraGridZy);
  53. BaseHelper.setOtherColumnReadOnly(ultraGrid1, new string[] { "CHC" });
  54. BaseHelper.setUltraGridColumnMaxInput(ultraGrid1, new string[] { "PlanBlWt", "Singleweight", "UseBlWt" });
  55. BaseHelper.setUltraGridColumnBits(ultraGrid1, new string[] { "SingleCutNun", "PlanBlNum", "PlanJgNum", "UseBlNum", "OutJgNum" });
  56. BaseHelper.InitCellPosition(ultraGrid1, new string[] { "GxProSeq", "GxPlanNo","PlanBlWt", "Diameter", "SingleCutNun","PlanBlNum","PlanJgNum","Aimlength","CheckJVal","Outdiameter","Wallthick",
  57. "LengthMax","LengthMin","AimCutLen","AimlengthBl","MinH","MinD","UseBlNum", "UseBlWt", "OutJgNum"});
  58. BaseHelper.GridColumnSum(ultraGrid1, new string[] { "UseBlWt"});
  59. BaseHelper.GridColumnCount(ultraGrid1, new string[] { "OutJgNum", "UseBlNum" });
  60. StoveHelper.ForbidSort(ultraGrid1);
  61. InitDate();
  62. BaseHelper.SetGroupBySum(ultraGrid1, new string[] { "PlanBlWt", "PlanBlNum", "PlanJgNum" }, "HeatPlanNo");
  63. }
  64. private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e)
  65. {
  66. StoveHelper.CustomMergedCellEvaluator merge = new StoveHelper.CustomMergedCellEvaluator("HeatPlanNo");
  67. e.Layout.Bands[0].Columns["HeatPlanNo"].MergedCellStyle = MergedCellStyle.Always;
  68. e.Layout.Bands[0].Columns["HeatPlanNo"].MergedCellEvaluator = merge;
  69. e.Layout.Bands[0].Columns["JudgeStoveNo"].MergedCellStyle = MergedCellStyle.Always;
  70. e.Layout.Bands[0].Columns["JudgeStoveNo"].MergedCellEvaluator = merge;
  71. e.Layout.Bands[0].Columns["StoveNo"].MergedCellStyle = MergedCellStyle.Always;
  72. e.Layout.Bands[0].Columns["StoveNo"].MergedCellEvaluator = merge;
  73. e.Layout.Bands[0].Columns["PlanBlNum"].MergedCellStyle = MergedCellStyle.Always;
  74. e.Layout.Bands[0].Columns["PlanBlNum"].MergedCellEvaluator = merge;
  75. e.Layout.Bands[0].Columns["PlanBlWt"].MergedCellStyle = MergedCellStyle.Always;
  76. e.Layout.Bands[0].Columns["PlanBlWt"].MergedCellEvaluator = merge;
  77. e.Layout.Bands[0].Columns["PlanJgNum"].MergedCellStyle = MergedCellStyle.Always;
  78. e.Layout.Bands[0].Columns["PlanJgNum"].MergedCellEvaluator = merge;
  79. e.Layout.Bands[0].Columns["FlagStoveNo"].MergedCellStyle = MergedCellStyle.Always;
  80. e.Layout.Bands[0].Columns["FlagStoveNo"].MergedCellEvaluator = merge;
  81. e.Layout.Bands[0].Columns["GxProSeq"].MergedCellStyle = MergedCellStyle.Always;
  82. e.Layout.Bands[0].Columns["GxProSeq"].MergedCellEvaluator = merge;
  83. e.Layout.Bands[0].Columns["Planstatus"].MergedCellStyle = MergedCellStyle.Always;
  84. e.Layout.Bands[0].Columns["Planstatus"].MergedCellEvaluator = merge;
  85. }
  86. /// <summary>
  87. /// 初始时间
  88. /// </summary>
  89. private void InitDate()
  90. {
  91. DateTime datetime = DateTime.Now;
  92. dateBegin.Value = datetime.AddDays(1 - datetime.Day);
  93. dateEnd.Value = datetime.AddDays(1 - datetime.Day).AddMonths(1).AddDays(-1);
  94. }
  95. private void chcLine_CheckedChanged(object sender, EventArgs e)
  96. {
  97. if (chcLine.Checked) { txtLine.Enabled = true; } else { txtLine.Enabled = false; }
  98. if (chcProPlanId.Checked) { txtProPlanId.Enabled = true; } else { txtProPlanId.Enabled = false; }
  99. if (chcOrderNo.Checked) { txtOrderNo.Enabled = true; } else { txtOrderNo.Enabled = false; }
  100. if (chcId.Checked) { txtId.Enabled = true; } else { txtId.Enabled = false; }
  101. if (chcTime.Checked) { dateBegin.Enabled = true; dateEnd.Enabled = true; } else { dateBegin.Enabled = false; dateEnd.Enabled = false; }
  102. if (chcJudgeNo.Checked) { txtJudgeNo.Enabled = true; } else { txtJudgeNo.Enabled = false; }
  103. }
  104. public override void ToolBar_Click(object sender, string ToolbarKey)
  105. {
  106. base.ToolBar_Click(sender, ToolbarKey);
  107. switch (ToolbarKey)
  108. {
  109. case "Query"://查询
  110. Query();
  111. break;
  112. case "Export": //导出
  113. Export();
  114. break;
  115. case "UpdateLoadFlag":
  116. updateLoadFlag();
  117. break;
  118. case "Close": //关闭
  119. this.Close();
  120. break;
  121. default:
  122. break;
  123. }
  124. }
  125. /// <summary>
  126. /// 标识库位不变
  127. /// </summary>
  128. private void updateLoadFlag()
  129. {
  130. this.ultraGridZy.UpdateData();
  131. UltraGridRow row = this.ultraGridZy.ActiveRow;
  132. if (row == null)
  133. {
  134. return;
  135. }
  136. ArrayList parmList = new ArrayList();
  137. PlnZyJgMEntity plnDbkTity = (PlnZyJgMEntity)row.ListObject;
  138. string plnZgEntity = JSONFormat.Format(plnDbkTity);
  139. parmList.Add(plnZgEntity);
  140. CoreClientParam ccp = new CoreClientParam();
  141. ccp.ServerName = "com.steering.pss.plnsaleord.planStove.FrmPlanStoveH";
  142. ccp.MethodName = "updateLoadFlag";
  143. ccp.ServerParams = new object[] { parmList };
  144. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  145. if (ccp.ReturnCode != -1)
  146. {
  147. if (ccp.ReturnInfo.Equals("修改成功!"))
  148. {
  149. QueryM();
  150. MessageUtil.ShowTips(ccp.ReturnInfo);
  151. }
  152. else
  153. {
  154. MessageUtil.ShowTips(ccp.ReturnInfo);
  155. }
  156. }
  157. }
  158. private void Query()
  159. {
  160. if (ultraExpandableGroupBox1.Expanded == false)
  161. {
  162. QueryC();
  163. }
  164. else
  165. {
  166. QueryM();
  167. }
  168. }
  169. private int activation = 0;
  170. /// <summary>
  171. /// 导出
  172. /// </summary>
  173. private void Export()
  174. {
  175. if (activation < 2)
  176. {
  177. GridHelper.ulGridToExcel(ultraGridZy, "接箍炉计划主信息");
  178. }
  179. else
  180. {
  181. GridHelper.ulGridToExcel(ultraGrid1, "接箍炉计划详情");
  182. }
  183. }
  184. /// <summary>
  185. /// 查询接箍虚拟炉计划
  186. /// </summary>
  187. private void QueryM()
  188. { //产线
  189. string plineCode = "";
  190. if (chcLine.Checked)
  191. {
  192. plineCode = txtLine.Value == null ? "" : txtLine.Value.ToString();
  193. }
  194. //if (txtLine.Text.Equals(""))
  195. //{
  196. // MessageUtil.ShowTips("请选择产线!");
  197. // return;
  198. //}
  199. string timeBegin = "";
  200. string timeEnd = "";
  201. if (chcTime.Checked && dateBegin.Value != null && dateEnd.Value != null)
  202. {
  203. timeBegin = DateTime.Parse(dateBegin.Value.ToString()).ToString("yyyy-MM-dd");
  204. timeEnd = DateTime.Parse(dateEnd.Value.ToString()).ToString("yyyy-MM-dd");
  205. }
  206. string orderNo = "";
  207. if (chcOrderNo.Checked) { orderNo = txtOrderNo.Text.Trim(); }
  208. string proPlanId = "";
  209. if (chcProPlanId.Checked) { proPlanId = txtProPlanId.Text.Trim(); }
  210. string heatId = "";
  211. if (chcId.Checked) { heatId = txtId.Text.Trim(); }
  212. string judgeNo = "";
  213. if (chcJudgeNo.Checked) { judgeNo = txtJudgeNo.Text.Trim(); }
  214. //执行状态
  215. string[] statusArr = contorlPlanStatusZy1.statusArr;
  216. List<PlnZyJgMEntity> listSource = EntityHelper.GetData<PlnZyJgMEntity>
  217. ("com.steering.pss.plnsaleord.planStove.FrmPlanStoveH.queryPlanStoveYzH", new object[] { timeBegin, timeEnd, plineCode, orderNo, proPlanId, heatId, statusArr, judgeNo, "" }, this.ob);
  218. plnZyJgMEntityBindingSource.DataSource = listSource;
  219. foreach (UltraGridRow ugr in ultraGridZy.Rows)
  220. {
  221. int countMess = 0;
  222. if (!_heatPlanNo.Equals(""))
  223. {
  224. if (ugr.Cells["HeatPlanNo"].Text.Trim().Equals(_heatPlanNo))
  225. {
  226. ugr.Activate();
  227. break;
  228. }
  229. }
  230. if (_EntityList != null)
  231. {
  232. for (int i = 0; i < _EntityList.Count; i++)
  233. {
  234. PlnZyJgxMEntity entity = (PlnZyJgxMEntity)_EntityList[i];
  235. if (ugr.Cells["HeatPlanNo"].Text.Trim().Equals(entity.HeatPlanNo))
  236. {
  237. ugr.Appearance.BackColor = Color.Wheat;
  238. ugr.Activate();
  239. }
  240. }
  241. }
  242. }
  243. _EntityList = null;
  244. _heatPlanNo = "";
  245. }
  246. /// <summary>
  247. /// 查询镦拔扩实际炉计划
  248. /// </summary>
  249. private void QueryC()
  250. {
  251. //产线
  252. string plineCode = "";
  253. if (chcLine.Checked)
  254. {
  255. plineCode = txtLine.Value == null ? "" : txtLine.Value.ToString();
  256. }
  257. //if (txtLine.Text.Equals(""))
  258. //{
  259. // MessageUtil.ShowTips("请选择产线!");
  260. // return;
  261. //}
  262. string timeBegin = "";
  263. string timeEnd = "";
  264. if (chcTime.Checked && dateBegin.Value != null && dateEnd.Value != null)
  265. {
  266. timeBegin = DateTime.Parse(dateBegin.Value.ToString()).ToString("yyyy-MM-dd");
  267. timeEnd = DateTime.Parse(dateEnd.Value.ToString()).ToString("yyyy-MM-dd");
  268. }
  269. string orderNo = "";
  270. if (chcOrderNo.Checked) { orderNo = txtOrderNo.Text.Trim(); }
  271. string proPlanId = "";
  272. if (chcProPlanId.Checked) { proPlanId = txtProPlanId.Text.Trim(); }
  273. string heatId = "";
  274. if (chcId.Checked) { heatId = txtId.Text.Trim(); }
  275. string judgeNo = "";
  276. if (chcJudgeNo.Checked) { judgeNo = txtJudgeNo.Text.Trim(); }
  277. string feedNo = "";
  278. //执行状态
  279. string[] statusArr = contorlPlanStatusZy1.statusArr;
  280. List<PlnZyJgReadyEntity> listSource = EntityHelper.GetData<PlnZyJgReadyEntity>
  281. ("com.steering.pss.plnsaleord.planStove.FrmPlanStoveH.queryPlnZyDbkReadyById", new object[] { timeBegin, timeEnd, plineCode, orderNo, proPlanId, heatId, statusArr, judgeNo, "" }, this.ob);
  282. plnZyJgReadyEntityBindingSource.DataSource = listSource;
  283. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  284. {
  285. //没有实际炉计划,主炉计划变颜色
  286. if (ugr.Cells["HeatPlanSqe"].Value.ToString().Equals(""))
  287. {
  288. ugr.Appearance.BackColor = Color.Orange;
  289. }
  290. }
  291. }
  292. private void ultraGridZy_AfterRowActivate(object sender, EventArgs e)
  293. {
  294. UltraGridRow row = ultraGridZy.ActiveRow;
  295. if (row == null) return;
  296. QueryMRow(row.Cells["HeatPlanNo"].Text.ToString().Trim());
  297. }
  298. private void QueryMRow(string heatPlanNo)
  299. {
  300. List<PlnZyJgReadyEntity> listSourceM = EntityHelper.GetData<PlnZyJgReadyEntity>
  301. ("com.steering.pss.plnsaleord.planStove.FrmPlanStoveH.queryPlanStoveRow", new object[] { heatPlanNo }, ob);
  302. plnZyJgReadyEntityBindingSource.DataSource = listSourceM;
  303. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  304. {
  305. //没有实际炉计划,主炉计划变颜色
  306. if (ugr.Cells["HeatPlanSqe"].Value.ToString().Equals(""))
  307. {
  308. //ugr.RowSelectorAppearance.BackColor = Color.GreenYellow;
  309. ugr.Appearance.BackColor = Color.Orange;
  310. }
  311. }
  312. }
  313. private int splitterDistance = 0;
  314. int count1 = 0;
  315. int count2 = 0;
  316. private void ultraExpandableGroupBox1_ExpandedStateChanged(object sender, EventArgs e)
  317. {
  318. if (ultraExpandableGroupBox1.Expanded == false)
  319. {
  320. this.splitContainer1.SplitterDistance = 26;
  321. count1 = 26;
  322. }
  323. else
  324. {
  325. if (ultraExpandableGroupBox2.Expanded == false)
  326. {
  327. this.splitContainer1.SplitterDistance = splitContainer1.Size.Height - 26;
  328. }
  329. else
  330. {
  331. this.splitContainer1.SplitterDistance = splitterDistance == 0 ? splitContainer1.Size.Height / 2 : splitterDistance;
  332. }
  333. count1 = splitContainer1.Size.Height - 26;
  334. }
  335. }
  336. private void ultraExpandableGroupBox2_ExpandedStateChanged(object sender, EventArgs e)
  337. {
  338. if (ultraExpandableGroupBox2.Expanded == false)
  339. {
  340. if (count1 == 0) { count1 = splitContainer1.Size.Height - 26; }
  341. this.splitContainer1.SplitterDistance = count1;
  342. }
  343. else
  344. {
  345. if (ultraExpandableGroupBox1.Expanded == false)
  346. {
  347. this.splitContainer1.SplitterDistance = 26;
  348. }
  349. else
  350. {
  351. //this.splitContainer1.SplitterDistance = count1;
  352. this.splitContainer1.SplitterDistance = splitterDistance == 0 ? splitContainer1.Size.Height / 2 : splitterDistance;
  353. }
  354. }
  355. }
  356. private void ultraGridZy_Click(object sender, EventArgs e)
  357. {
  358. activation = 1;
  359. }
  360. private void ultraGridZy_ClickCell(object sender, ClickCellEventArgs e)
  361. {
  362. activation = 1;
  363. }
  364. private void ultraGrid1_Click(object sender, EventArgs e)
  365. {
  366. activation = 2;
  367. }
  368. private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)
  369. {
  370. activation = 2;
  371. }
  372. }
  373. }