| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.Mcp.Control.Entity;
- using Core.StlMes.Client.Mcp.Mch.Entity;
- using CoreFS.CA06;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- using NPOI.SS.Formula.Functions;
- namespace Core.StlMes.Client.Mcp.Mch.MchResult
- {
- public partial class FrmGroupSetting : FrmBase
- {
- private string _orderNo = "";
- private string _heatPlanID = "";
- public FrmGroupSetting(string OrderNo,string HeatPlanId, OpeBase _ob)
- {
- InitializeComponent();
- this.ob = _ob;
- _orderNo = OrderNo;
- _heatPlanID = HeatPlanId;
- Query();
- }
- private void Query()
- {
- mchGroupnoEntityBindingSource.DataSource = EntityHelper.GetData<MchGroupnoEntity>(
- "com.steering.mes.mcp.Mch.FrmGroupSetting.doQuery",
- new object[] { _orderNo },
- ob);
- }
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- EntityHelper.ShowGridCaption<MchGroupnoEntity>(ultraGridDetailDes1.DisplayLayout.Bands[0]);
- ultraGridDetailDes1.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
- ultraGridDetailDes1.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default;
- }
-
- private void ultraGridDetailDes1_AfterRowInsert(object sender, RowEventArgs e)
- {
- e.Row.Cells["OrderNo"].Value = _orderNo;
- }
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "Save": // ButtonTool
- Save();
- break;
- case "SystemLen": // ButtonTool
- case "R1Len": // ButtonTool
- case "R2Len":
- case "R3Len": // ButtonTool
- case "lr2Len":
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.mcp.Mch.FrmGroupSetting";
- ccp.MethodName = "DoChange";
- ccp.ServerParams = new object[]
- {
- _orderNo,
- _heatPlanID,
- e.Tool.Key
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("修改成功!"))
- {
- Query();
- }
- }
- // Place code here
- break;
- case "Close": // ButtonTool
- this.DialogResult = DialogResult.Cancel;
- break;
- }
- }
- private void Save()
- {
- //无效
- ultraGridDetailDes1.UpdateData();
- var list = mchGroupnoEntityBindingSource.DataSource as List<MchGroupnoEntity>;
- list = list.Where(p => p.Chk).ToList();
- if (!list.Any())
- {
- MessageBox.Show("规则不能为空");
- return;
- }
- if (list.Any(p => p.GroupMax != null && string.IsNullOrWhiteSpace(p.GroupMaxSign)))
- {
- MessageBox.Show("请维护最大值符号");
- return;
- }
- if (list.Any(p => p.GroupMax == null && !string.IsNullOrWhiteSpace(p.GroupMaxSign)))
- {
- MessageBox.Show("不能只维护最大值符号");
- return;
- }
- if (list.Any(p => p.GroupMin != null && string.IsNullOrWhiteSpace(p.GroupMinSign)))
- {
- MessageBox.Show("请维护最最小值符号");
- return;
- }
- if (list.Any(p => p.GroupMin == null && !string.IsNullOrWhiteSpace(p.GroupMinSign)))
- {
- MessageBox.Show("不能只维护最小值符号");
- return;
- }
- if (list.Any(p => p.GroupMin == null && p.GroupMax == null))
- {
- MessageBox.Show("请维护最最小值或最大值");
- return;
- }
- if (list.Count(p => p.GroupMax == null) != 1)
- {
- MessageBox.Show("范围未设置完全!");
- return;
- }
- if (list.Count(p => p.GroupMax == null) != 1)
- {
- MessageBox.Show("范围未设置完全!");
- return;
- }
- if (list.Count(p => p.GroupMin == null) != 1)
- {
- MessageBox.Show("范围未设置完全!");
- return;
- }
- int MaxGroup = list.Max(p => int.Parse(p.GroupNo.ToString3()));
- foreach (var data in list.Where(p => string.IsNullOrWhiteSpace(p.GroupNo)))
- {
- data.GroupNo = (++MaxGroup).ToString("000");
- }
- foreach (var data in list)
- {
- if (data.GroupMax != null)
- {
- var e1 = list.Where(p => p.GroupNo != data.GroupNo && p.GroupMin == data.GroupMax).ToList();
- if (e1.Count != 1 ||
- e1[0].GroupMinSign.Replace('>', ' ').Trim() == data.GroupMaxSign.Replace('<', ' ').Trim())
- {
- MessageBox.Show("范围未设置完全或范围重叠!");
- return;
- }
- }
- if (data.GroupMin != null)
- {
- var e1 = list.Where(p => p.GroupNo != data.GroupNo && p.GroupMax == data.GroupMin).ToList();
- if (e1.Count != 1 ||
- e1[0].GroupMaxSign.Replace('<', ' ').Trim() == data.GroupMinSign.Replace('>', ' ').Trim())
- {
- MessageBox.Show("范围未设置完全或范围重叠!");
- return;
- }
- }
- }
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.mcp.Mch.FrmGroupSetting";
- ccp.MethodName = "DoSave";
- ccp.ServerParams = new object[]
- {
- _orderNo,
- list.Select(JSONFormat.Format).ToList()
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("保存成功!"))
- {
- Query();
- }
- }
- }
- private void ultraGridDetailDes1_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- MchGroupnoEntity entity = e.Row.ListObject as MchGroupnoEntity;
- if(entity==null) return;
- if (string.IsNullOrEmpty(entity.InstoreData))
- {
- e.Row.Cells["Chk"].Activation = Activation.AllowEdit;
- e.Row.Cells["Chk"].IgnoreRowColActivation = true;
- }
- else
- {
- e.Row.Cells["Chk"].Value = true;
- e.Row.Cells["Chk"].Activation = Activation.ActivateOnly;
- e.Row.Cells["Chk"].IgnoreRowColActivation = true;
- }
- }
-
- }
- }
|