using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using CoreFS.CA06; using CoreFS.SA06; using Infragistics.Win.UltraWinGrid; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Linq; namespace Core.StlMes.Client.Qcm { class DtMscRBlSpec : DtBaseQcm { private CtrlMscRBlSpec _ctrlMscRBlSpec; public DtMscRBlSpec(CtrlMscRBlSpec ctrlMscRBlSpec) { _ctrlMscRBlSpec = ctrlMscRBlSpec; this.DefaultQueryKey = "Get"; RegistQuery(Get, "Get"); RegistQuery(GetHead, "GetHead"); RegistAction(Set, ActionType.Save); RegistAction(UpdateState, ActionType.Delete); RegistAction(UpdateState, ActionType.Resume); } protected override bool CheckData(ActionType actionType, out System.Collections.ArrayList parm, out string msg) { msg = ""; parm = new ArrayList(); ArrayList list = new ArrayList(); UltraGridRow[] rows = _ctrlMscRBlSpec.QueryableRows.ToArray(); foreach (UltraGridRow row in rows) { ComMscRBlSpecEntity mscRBlSpecEntity = EntityHelper.CopyEntity((ComMscRBlSpecEntity)row.ListObject); bool result = CheckData(mscRBlSpecEntity, row, actionType, out msg); if (result == false) return false; string strJSON = JSONFormat.Format(mscRBlSpecEntity); list.Add(strJSON); } parm.Add(list); string strAction = Enum.GetName(typeof(ActionType), actionType); parm.Add(strAction); return true; } private bool CheckData(ComMscRBlSpecEntity mscRBlSpecEntity, UltraGridRow row, ActionType actionType, out string msg) { msg = ""; switch (actionType) { case ActionType.Save: //if (mscRBlSpecEntity.SpecCode.ToString() != "" && // _ctrlMscRBlSpec.CmbSpec.IsItemInList(mscRBlSpecEntity.SpecCode.ToString()) == false) //{ // msg = "输入的规格不在基础数据中,请重新选择规格!"; // row.SetCellActive("SpecCode"); // return false; //} if (mscRBlSpecEntity.SpecCode.ToString2() == "" && mscRBlSpecEntity.MinD == null && mscRBlSpecEntity.MaxD == null && mscRBlSpecEntity.MinH == null && mscRBlSpecEntity.MaxH == null) { msg = "请维护适用规格"; row.Activate(); return false; } else if (mscRBlSpecEntity.SpecCode.ToString2() != "" && (mscRBlSpecEntity.MinD != null || mscRBlSpecEntity.MaxD != null || mscRBlSpecEntity.MinH != null && mscRBlSpecEntity.MaxH != null)) { msg = "不能同时维护其他规格与适用成品规格"; row.Activate(); return false; } if (mscRBlSpecEntity.MinD != null && mscRBlSpecEntity.MaxD != null && mscRBlSpecEntity.MinD > mscRBlSpecEntity.MaxD) { msg = "外径最小值不能大于最大值!"; row.SetCellActive("MinD"); return false; } if (mscRBlSpecEntity.MinH != null && mscRBlSpecEntity.MaxH != null && mscRBlSpecEntity.MinH > mscRBlSpecEntity.MaxH) { msg = "壁厚最小值不能大于最大值!"; row.SetCellActive("MinH"); return false; } break; case ActionType.Delete: if (mscRBlSpecEntity.RowIndex.ToString() == "") { msg = "系统不存在该条记录,不能作废!"; row.Activate(); return false; } break; case ActionType.Resume: if (mscRBlSpecEntity.RowIndex.ToString() == "") { msg = "系统不存在该条记录,不能恢复!"; row.Activate(); return false; } break; } mscRBlSpecEntity.Msc = _ctrlMscRBlSpec.QueryCondition.Msc.ToString(); mscRBlSpecEntity.GroupNum = _ctrlMscRBlSpec.QueryCondition.GroupNum.ToString(); mscRBlSpecEntity.CreateName = CoreUserInfo.UserInfo.GetUserName(); mscRBlSpecEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName(); mscRBlSpecEntity.DeleteName = CoreUserInfo.UserInfo.GetUserName(); return true; } protected override bool IsSelectData(ActionType actionType, out string msg) { msg = ""; int count = _ctrlMscRBlSpec.QueryableRows.Count(); if (count == 0) { msg = "请选择一条规格后,再进行操作!"; return false; } return true; } public void Get() { string strJSON = JSONFormat.Format(_ctrlMscRBlSpec.QueryCondition); List listSource = EntityHelper.GetData( "com.steering.pss.qcm.MscRBlSpec.get", new object[] { strJSON }, _ctrlMscRBlSpec.Ob); _ctrlMscRBlSpec.MscRBlSpecSrc.DataSource = listSource; foreach (UltraGridRow row in _ctrlMscRBlSpec.UltraGrid1.Rows) { _ctrlMscRBlSpec.ControlUltraGrid1Edit(row); _ctrlMscRBlSpec.SetInvalidColor(row); } } public void GetHead() { string strJSON = JSONFormat.Format(_ctrlMscRBlSpec.QueryCondition); List listSource = EntityHelper.GetData( "com.steering.pss.qcm.MscRBlSpec.getBlSpecHead", new object[] { strJSON }, _ctrlMscRBlSpec.Ob); _ctrlMscRBlSpec.MscRBlSpecSrc.DataSource = listSource; } public bool Set() { ArrayList list = (ArrayList)Parm[0]; ServerHelper.SetData("com.steering.pss.qcm.MscRBlSpec.set", new object[] { list }, _ctrlMscRBlSpec.Ob); return true; } public bool UpdateState() { ArrayList list = (ArrayList)Parm[0]; string strAction = Parm[1].ToString(); ServerHelper.SetData("com.steering.pss.qcm.MscRBlSpec.updateState", new object[] { list, strAction }, _ctrlMscRBlSpec.Ob); return true; } public DataTable GetGroupBl(string groupNum, string msc) { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.MscRBlSpec.getGroupBl", new object[] { groupNum, msc }, _ctrlMscRBlSpec.Ob); return dt; } /// /// 获取分组中备料的适用信息 /// /// /// /// /// /// public static DataTable GetGroupBlInfo(string msc, string groupNum, string pscBl, OpeBase ob) { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.MscRBlSpec.getGroupBlInfo", new object[] { msc, groupNum, pscBl }, ob); return dt; } } }