| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- 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
- {
- public class DtBaseStdRSpec : DtBaseQcm
- {
- private CtrlBaseStdRSpec _ctrlBaseStdRSpec;
- private string _rlcMinD = null;
- private string _rlcMaxD = null;
- private string _rlcMinH = null;
- private string _rlcMaxH = null;
- private string _rlcSpecCode = "";
- public DtBaseStdRSpec(CtrlBaseStdRSpec ctrlBaseStdRSpec)
- {
- _ctrlBaseStdRSpec = ctrlBaseStdRSpec;
- this.DefaultQueryKey = "Query";
- this.RegistQuery(Query, "Query");
- this.RegistAction(NoQuery, ActionType.Save);
- this.RegistAction(NoQuery, ActionType.Delete);
- this.RegistAction(NoQuery, ActionType.Resume);
- }
- protected override bool CheckData(ActionType actionType, out System.Collections.ArrayList parm, out string msg)
- {
- parm = new ArrayList();
- msg = "";
- ArrayList list = new ArrayList();
- UltraGridRow[] rows = _ctrlBaseStdRSpec.QueryableRows.ToArray();
- foreach (UltraGridRow row in rows)
- {
- BaseStdRSpecEntity baseStdRSpecEntity = EntityHelper.CopyEntity<BaseStdRSpecEntity>((BaseStdRSpecEntity)row.ListObject);
- if (CheckData(baseStdRSpecEntity, row, actionType, out msg) == false)
- {
- return false;
- }
- string strJSON = JSONFormat.Format(baseStdRSpecEntity);
- list.Add(strJSON);
- _rlcMinD = string.Format("{0:####.00}", baseStdRSpecEntity.MinD);
- _rlcMaxD = string.Format("{0:####.00}", baseStdRSpecEntity.MaxD);
- _rlcMinH = string.Format("{0:####.00}", baseStdRSpecEntity.MinH);
- _rlcMaxH = string.Format("{0:####.00}", baseStdRSpecEntity.MaxH);
- _rlcSpecCode = baseStdRSpecEntity.SpecCode.ToString();
- }
- parm.Add(list);
- string strAction = Enum.GetName(typeof(ActionType), actionType);
- parm.Add(strAction);
- return true;
- }
- private bool CheckData(BaseStdRSpecEntity baseStdRSpecEntity, UltraGridRow row,
- ActionType actionType, out string msg)
- {
- msg = "";
- if (actionType == ActionType.Save)
- {
- if (baseStdRSpecEntity.MscStyle.ToString() == "")
- {
- msg = "请选择规格类型";
- row.SetCellActive("MscStyle");
- return false;
- }
- if (baseStdRSpecEntity.MscStyle.ToString() == "A")
- {
- if (baseStdRSpecEntity.MinD.ToString() == "")
- {
- msg = "请输入外径(下限)!";
- row.SetCellActive("MinD");
- return false;
- }
- if (baseStdRSpecEntity.MaxD.ToString() == "")
- {
- msg = "请输入外径(上限)!";
- row.SetCellActive("MaxD");
- return false;
- }
- if (baseStdRSpecEntity.MinH.ToString() == "")
- {
- msg = "请输入壁厚(下限)!";
- row.SetCellActive("MinH");
- return false;
- }
- if (baseStdRSpecEntity.MaxH.ToString() == "")
- {
- msg = "请输入壁厚(上限)!";
- row.SetCellActive("MaxH");
- return false;
- }
- if (decimal.Parse(baseStdRSpecEntity.MinD.ToString()) <= 0)
- {
- msg = "外径(下限)不能小于或者等于0!";
- row.SetCellActive("MinD");
- return false;
- }
- if (decimal.Parse(baseStdRSpecEntity.MaxD.ToString()) <= 0)
- {
- msg = "外径(上限)不能小于或者等于0!";
- row.SetCellActive("MaxD");
- return false;
- }
- if (decimal.Parse(baseStdRSpecEntity.MinH.ToString()) <= 0)
- {
- msg = "壁厚(下限)不能小于或者等于0!";
- row.SetCellActive("MinH");
- return false;
- }
- if (decimal.Parse(baseStdRSpecEntity.MaxH.ToString()) <= 0)
- {
- msg = "壁厚(上限)不能小于或者等于0!";
- row.SetCellActive("MaxH");
- return false;
- }
- if (decimal.Parse(baseStdRSpecEntity.MaxD.ToString())
- < decimal.Parse(baseStdRSpecEntity.MinD.ToString()))
- {
- msg = "外径(上限)不能小于外径(下限)!";
- row.SetCellActive("MaxD");
- return false;
- }
- if (decimal.Parse(baseStdRSpecEntity.MaxH.ToString())
- < decimal.Parse(baseStdRSpecEntity.MinH.ToString()))
- {
- msg = "壁厚(上限)不能小于壁厚(下限)!";
- row.SetCellActive("MaxH");
- return false;
- }
- }
- else if (baseStdRSpecEntity.MscStyle.ToString() == "B")
- {
- if (baseStdRSpecEntity.MinD.ToString() == "")
- {
- msg = "请输入外径(下限)!";
- row.SetCellActive("MinD");
- return false;
- }
- if (baseStdRSpecEntity.MaxD.ToString() == "")
- {
- msg = "请输入外径(上限)!";
- row.SetCellActive("MaxD");
- return false;
- }
- if (decimal.Parse(baseStdRSpecEntity.MinD.ToString()) <= 0)
- {
- msg = "外径(下限)不能小于或者等于0!";
- row.SetCellActive("MinD");
- return false;
- }
- if (decimal.Parse(baseStdRSpecEntity.MaxD.ToString()) <= 0)
- {
- msg = "外径(上限)不能小于或者等于0!";
- row.SetCellActive("MaxD");
- return false;
- }
- if (decimal.Parse(baseStdRSpecEntity.MaxD.ToString())
- < decimal.Parse(baseStdRSpecEntity.MinD.ToString()))
- {
- msg = "外径(上限)不能小于外径(下限)!";
- row.SetCellActive("MaxD");
- return false;
- }
- }
- else if (baseStdRSpecEntity.MscStyle.ToString() == "C")
- {
- if (baseStdRSpecEntity.SpecCode.ToString() == "")
- {
- msg = "请选择其它规格!";
- row.SetCellActive("SpecCode");
- return false;
- }
- }
- if (IsExistSpec(baseStdRSpecEntity) == true)
- {
- msg = "该标准下已存在相同的规格范围,请检查后再进行保存!";
- row.Activate();
- return false;
- }
- }
- else if (actionType == ActionType.Delete)
- {
- baseStdRSpecEntity.Validflag = "0";
- }
- else if (actionType == ActionType.Resume)
- {
- baseStdRSpecEntity.Validflag = "1";
- }
- baseStdRSpecEntity.CreateName = CoreUserInfo.UserInfo.GetUserName();
- baseStdRSpecEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- baseStdRSpecEntity.DeleteName = CoreUserInfo.UserInfo.GetUserName();
- return true;
- }
- protected override bool IsSelectData(ActionType actionType, out string msg)
- {
- msg = "";
- return true;
- }
- public void Query()
- {
- string strJSON = JSONFormat.Format(_ctrlBaseStdRSpec.QueryCondition);
- List<BaseStdRSpecEntity> listSource = EntityHelper.GetData<BaseStdRSpecEntity>(
- "com.steering.pss.qcm.BaseStdRSpec.query", new object[] { strJSON }, _ctrlBaseStdRSpec.Ob);
- _ctrlBaseStdRSpec.BaseStdRSpecEntityBindingSource.DataSource = listSource;
- if ((_rlcMinD + _rlcMaxD + _rlcMinH + _rlcMaxH + _rlcSpecCode) != "")
- {
- UltraGridRow[] rows = _ctrlBaseStdRSpec.UltraGrid1.Rows.AsQueryable().Where(
- a => string.Format("{0:####.00}", a.Cells["MinD"].Value) == _rlcMinD && string.Format("{0:####.00}", a.Cells["MaxD"].Value) == _rlcMaxD
- && string.Format("{0:####.00}", a.Cells["MinH"].Value) == _rlcMinH
- && string.Format("{0:####.00}", a.Cells["MaxH"].Value) == _rlcMaxH && a.GetValue("SpecCode") == _rlcSpecCode).ToArray();
- if (rows.Length > 0)
- {
- rows[0].Activate();
- }
- _rlcMinD = "";
- _rlcMaxD = "";
- _rlcMinH = "";
- _rlcMaxH = "";
- _rlcSpecCode = "";
- }
- else
- {
- if (_ctrlBaseStdRSpec.UltraGrid1.Rows.Count > 0)
- {
- _ctrlBaseStdRSpec.UltraGrid1.Rows[0].Activate();
- }
- }
- foreach (UltraGridRow row in _ctrlBaseStdRSpec.UltraGrid1.Rows)
- {
- _ctrlBaseStdRSpec.ControlGridEdit(row);
- }
- //GridHelper.RefreshAndAutoSize(_ctrlBaseStdRSpec.UltraGrid1);
- }
- public bool NoQuery()
- {
- ArrayList list = (ArrayList)Parm[0];
- string strAction = Parm[1].ToString();
- ServerHelper.SetData("com.steering.pss.qcm.BaseStdRSpec.noQuery",
- new object[] { list, strAction }, _ctrlBaseStdRSpec.Ob);
- return true;
- }
- public ArrayList GetNoQueryParms(ActionType actionType, out string msg)
- {
- msg = "";
- ArrayList list = new ArrayList();
- if (IsSelectData(actionType, out msg) == false)
- {
- return null;
- }
- else
- {
- if (CheckData(actionType, out list, out msg) == false)
- {
- return null;
- }
- else
- {
- return (ArrayList)list[0];
- }
- }
- }
- private bool IsExistSpec(BaseStdRSpecEntity baseStdRSpecEntity)
- {
- string strJSON = JSONFormat.Format(baseStdRSpecEntity);
- string newPrimaryKey = baseStdRSpecEntity.StdCode.ToString() + baseStdRSpecEntity.MinD.ToString() +
- baseStdRSpecEntity.MaxD.ToString() + baseStdRSpecEntity.MinH.ToString() + baseStdRSpecEntity.MaxH.ToString()
- + baseStdRSpecEntity.SpecCode.ToString();
- string oldPrimaryKey = baseStdRSpecEntity.StdCodeOld.ToString() + baseStdRSpecEntity.MinDOld.ToString() +
- baseStdRSpecEntity.MaxDOld.ToString() + baseStdRSpecEntity.MinHOld.ToString() + baseStdRSpecEntity.MaxHOld.ToString()
- + baseStdRSpecEntity.SpecCodeOld.ToString();
- if (baseStdRSpecEntity.Validflag.ToString() != ""
- && newPrimaryKey == oldPrimaryKey)
- {
- return false;
- }
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.BaseStdRSpec.isExistSpec",
- new object[] { strJSON }, _ctrlBaseStdRSpec.Ob);
- if (dt.Rows[0][0].ToString() == "0")
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- }
- }
|