FrmGroupSetting.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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 Core.Mes.Client.Comm.Format;
  10. using Core.Mes.Client.Comm.Tool;
  11. using Core.StlMes.Client.Mcp.Control.Entity;
  12. using Core.StlMes.Client.Mcp.Mch.Entity;
  13. using CoreFS.CA06;
  14. using Infragistics.Win;
  15. using Infragistics.Win.UltraWinGrid;
  16. using NPOI.SS.Formula.Functions;
  17. namespace Core.StlMes.Client.Mcp.Mch.MchResult
  18. {
  19. public partial class FrmGroupSetting : FrmBase
  20. {
  21. private string _orderNo = "";
  22. private string _heatPlanID = "";
  23. public FrmGroupSetting(string OrderNo,string HeatPlanId, OpeBase _ob)
  24. {
  25. InitializeComponent();
  26. this.ob = _ob;
  27. _orderNo = OrderNo;
  28. _heatPlanID = HeatPlanId;
  29. Query();
  30. }
  31. private void Query()
  32. {
  33. mchGroupnoEntityBindingSource.DataSource = EntityHelper.GetData<MchGroupnoEntity>(
  34. "com.steering.mes.mcp.Mch.FrmGroupSetting.doQuery",
  35. new object[] { _orderNo },
  36. ob);
  37. }
  38. protected override void OnLoad(EventArgs e)
  39. {
  40. base.OnLoad(e);
  41. EntityHelper.ShowGridCaption<MchGroupnoEntity>(ultraGridDetailDes1.DisplayLayout.Bands[0]);
  42. ultraGridDetailDes1.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
  43. ultraGridDetailDes1.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default;
  44. }
  45. private void ultraGridDetailDes1_AfterRowInsert(object sender, RowEventArgs e)
  46. {
  47. e.Row.Cells["OrderNo"].Value = _orderNo;
  48. }
  49. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  50. {
  51. switch (e.Tool.Key)
  52. {
  53. case "Save": // ButtonTool
  54. Save();
  55. break;
  56. case "SystemLen": // ButtonTool
  57. case "R1Len": // ButtonTool
  58. case "R2Len":
  59. case "R3Len": // ButtonTool
  60. case "lr2Len":
  61. var ccp = new CoreClientParam();
  62. ccp.ServerName = "com.steering.mes.mcp.Mch.FrmGroupSetting";
  63. ccp.MethodName = "DoChange";
  64. ccp.ServerParams = new object[]
  65. {
  66. _orderNo,
  67. _heatPlanID,
  68. e.Tool.Key
  69. };
  70. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  71. if (ccp.ReturnCode != -1)
  72. {
  73. MessageUtil.ShowTips(ccp.ReturnInfo);
  74. if (ccp.ReturnInfo.Equals("修改成功!"))
  75. {
  76. Query();
  77. }
  78. }
  79. // Place code here
  80. break;
  81. case "Close": // ButtonTool
  82. this.DialogResult = DialogResult.Cancel;
  83. break;
  84. }
  85. }
  86. private void Save()
  87. {
  88. //无效
  89. ultraGridDetailDes1.UpdateData();
  90. var list = mchGroupnoEntityBindingSource.DataSource as List<MchGroupnoEntity>;
  91. list = list.Where(p => p.Chk).ToList();
  92. if (!list.Any())
  93. {
  94. MessageBox.Show("规则不能为空");
  95. return;
  96. }
  97. if (list.Any(p => p.GroupMax != null && string.IsNullOrWhiteSpace(p.GroupMaxSign)))
  98. {
  99. MessageBox.Show("请维护最大值符号");
  100. return;
  101. }
  102. if (list.Any(p => p.GroupMax == null && !string.IsNullOrWhiteSpace(p.GroupMaxSign)))
  103. {
  104. MessageBox.Show("不能只维护最大值符号");
  105. return;
  106. }
  107. if (list.Any(p => p.GroupMin != null && string.IsNullOrWhiteSpace(p.GroupMinSign)))
  108. {
  109. MessageBox.Show("请维护最最小值符号");
  110. return;
  111. }
  112. if (list.Any(p => p.GroupMin == null && !string.IsNullOrWhiteSpace(p.GroupMinSign)))
  113. {
  114. MessageBox.Show("不能只维护最小值符号");
  115. return;
  116. }
  117. if (list.Any(p => p.GroupMin == null && p.GroupMax == null))
  118. {
  119. MessageBox.Show("请维护最最小值或最大值");
  120. return;
  121. }
  122. if (list.Count(p => p.GroupMax == null) != 1)
  123. {
  124. MessageBox.Show("范围未设置完全!");
  125. return;
  126. }
  127. if (list.Count(p => p.GroupMax == null) != 1)
  128. {
  129. MessageBox.Show("范围未设置完全!");
  130. return;
  131. }
  132. if (list.Count(p => p.GroupMin == null) != 1)
  133. {
  134. MessageBox.Show("范围未设置完全!");
  135. return;
  136. }
  137. int MaxGroup = list.Max(p => int.Parse(p.GroupNo.ToString3()));
  138. foreach (var data in list.Where(p => string.IsNullOrWhiteSpace(p.GroupNo)))
  139. {
  140. data.GroupNo = (++MaxGroup).ToString("000");
  141. }
  142. foreach (var data in list)
  143. {
  144. if (data.GroupMax != null)
  145. {
  146. var e1 = list.Where(p => p.GroupNo != data.GroupNo && p.GroupMin == data.GroupMax).ToList();
  147. if (e1.Count != 1 ||
  148. e1[0].GroupMinSign.Replace('>', ' ').Trim() == data.GroupMaxSign.Replace('<', ' ').Trim())
  149. {
  150. MessageBox.Show("范围未设置完全或范围重叠!");
  151. return;
  152. }
  153. }
  154. if (data.GroupMin != null)
  155. {
  156. var e1 = list.Where(p => p.GroupNo != data.GroupNo && p.GroupMax == data.GroupMin).ToList();
  157. if (e1.Count != 1 ||
  158. e1[0].GroupMaxSign.Replace('<', ' ').Trim() == data.GroupMinSign.Replace('>', ' ').Trim())
  159. {
  160. MessageBox.Show("范围未设置完全或范围重叠!");
  161. return;
  162. }
  163. }
  164. }
  165. var ccp = new CoreClientParam();
  166. ccp.ServerName = "com.steering.mes.mcp.Mch.FrmGroupSetting";
  167. ccp.MethodName = "DoSave";
  168. ccp.ServerParams = new object[]
  169. {
  170. _orderNo,
  171. list.Select(JSONFormat.Format).ToList()
  172. };
  173. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  174. if (ccp.ReturnCode != -1)
  175. {
  176. MessageUtil.ShowTips(ccp.ReturnInfo);
  177. if (ccp.ReturnInfo.Equals("保存成功!"))
  178. {
  179. Query();
  180. }
  181. }
  182. }
  183. private void ultraGridDetailDes1_InitializeRow(object sender, InitializeRowEventArgs e)
  184. {
  185. MchGroupnoEntity entity = e.Row.ListObject as MchGroupnoEntity;
  186. if(entity==null) return;
  187. if (string.IsNullOrEmpty(entity.InstoreData))
  188. {
  189. e.Row.Cells["Chk"].Activation = Activation.AllowEdit;
  190. e.Row.Cells["Chk"].IgnoreRowColActivation = true;
  191. }
  192. else
  193. {
  194. e.Row.Cells["Chk"].Value = true;
  195. e.Row.Cells["Chk"].Activation = Activation.ActivateOnly;
  196. e.Row.Cells["Chk"].IgnoreRowColActivation = true;
  197. }
  198. }
  199. }
  200. }