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( "com.steering.mes.mcp.Mch.FrmGroupSetting.doQuery", new object[] { _orderNo }, ob); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); EntityHelper.ShowGridCaption(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; 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; } } } }