| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.Qcm.model;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- namespace Core.StlMes.Client.Qcm
- {
- class DtGrandeRSpec : DtBaseQcm
- {
- private PopupGrandeRSpec _popGradeRSpec = null;
- public DtGrandeRSpec(PopupGrandeRSpec popGradeRSpec)
- {
- _popGradeRSpec = popGradeRSpec;
- this.RegistAction(SaveGradRSpec, ActionType.Save);
- this.RegistAction(DeleteSpec, ActionType.Delete);
- this.RegistAction(ResumeSpec, ActionType.Resume);
- this.RegistQuery(QueryGrade, "QueryGrade");
- this.RegistQuery(QueryGradeRSpec, "QueryGradeRSpec");
- this.DefaultQueryKey = "QueryGrade";
- }
- protected override bool CheckData(ActionType actionType, out ArrayList parm, out string msg)
- {
- _popGradeRSpec.UltraGrid2.UpdateData();
- parm = new ArrayList();
- msg = "";
- string gradeJson = JSONFormat.Format(_popGradeRSpec.UltraGrid1.ActiveRow.ListObject);
- ArrayList parmSpec = new ArrayList();
- foreach (UltraGridRow row in _popGradeRSpec.UltraGrid2.Rows)
- {
- if (row.GetValue("CHK") == "True")
- {
- ComMscGradeRSpecEntity comMscGradeRSpecEntity = EntityHelper.CopyEntity<ComMscGradeRSpecEntity>((ComMscGradeRSpecEntity)row.ListObject);
- comMscGradeRSpecEntity.CreateName = _popGradeRSpec.UserInfo.GetUserName();
- comMscGradeRSpecEntity.UpdateName = _popGradeRSpec.UserInfo.GetUserName();
- comMscGradeRSpecEntity.DeleteName = _popGradeRSpec.UserInfo.GetUserName();
- bool checkResult = CheckData(comMscGradeRSpecEntity, row, actionType, out msg);
- if (checkResult == false) return false;
- string strJSON = JSONFormat.Format(comMscGradeRSpecEntity);
- parmSpec.Add(strJSON);
- }
- }
- parm.Add(gradeJson);
- parm.Add(parmSpec);
- return true;
- }
- protected override bool IsSelectData(ActionType actionType, out string msg)
- {
- _popGradeRSpec.UltraGrid1.UpdateData();
- _popGradeRSpec.UltraGrid2.UpdateData();
- msg = "";
- return true;
- //UltraGridRow[] rows = _popGradeRSpec.UltraGrid2.Rows.AsQueryable().Where("CHK = 'True'").ToArray();
- //if(rows.Length == 0)
- //{
- // return false;
- //}
- //else
- //{
- // return true;
- //}
- }
- private bool CheckData(ComMscGradeRSpecEntity comMscGradeRSpecEntity, UltraGridRow row,
- ActionType actionType, out string msg)
- {
- msg = "";
- if (actionType == ActionType.Save)
- {
- if (comMscGradeRSpecEntity.DimaterMin.ToString() == "")
- {
- msg = "请输入外径(下限)!";
- row.SetCellActive("DimaterMin");
- return false;
- }
- if (comMscGradeRSpecEntity.DimaterMax.ToString() == "")
- {
- msg = "请输入外径(上限)!";
- row.SetCellActive("DimaterMax");
- return false;
- }
- if (comMscGradeRSpecEntity.HeightMin.ToString() == "")
- {
- msg = "请输入壁厚(下限)!";
- row.SetCellActive("HeightMin");
- return false;
- }
- if (comMscGradeRSpecEntity.HeightMiax.ToString() == "")
- {
- msg = "请输入壁厚(上限)!";
- row.SetCellActive("HeightMiax");
- return false;
- }
- if (comMscGradeRSpecEntity.DimaterMin.ToString().TryParseDecimal() == false)
- {
- msg = "外径(下限)不是有效数字!";
- row.SetCellActive("DimaterMin");
- return false;
- }
- if (comMscGradeRSpecEntity.DimaterMax.ToString().TryParseDecimal() == false)
- {
- msg = "外径(上限)不是有效数字!";
- row.SetCellActive("DimaterMax");
- return false;
- }
- if (comMscGradeRSpecEntity.HeightMin.ToString().TryParseDecimal() == false)
- {
- msg = "壁厚(下限)不是有效数字!";
- row.SetCellActive("HEIGHT_MIN");
- return false;
- }
- if (comMscGradeRSpecEntity.HeightMiax.ToString().TryParseDecimal() == false)
- {
- msg = "壁厚(上限)不是有效数字!";
- row.SetCellActive("HeightMiax");
- return false;
- }
- if (decimal.Parse(comMscGradeRSpecEntity.DimaterMin.ToString()) <= 0)
- {
- msg = "外径(下限)不能小于或者等于0!";
- row.SetCellActive("DimaterMin");
- return false;
- }
- if (decimal.Parse(comMscGradeRSpecEntity.DimaterMax.ToString()) <= 0)
- {
- msg = "外径(上限)不能小于或者等于0!";
- row.SetCellActive("DimaterMax");
- return false;
- }
- if (decimal.Parse(comMscGradeRSpecEntity.HeightMin.ToString()) <= 0)
- {
- msg = "壁厚(下限)不能小于或者等于0!";
- row.SetCellActive("HeightMin");
- return false;
- }
- if (decimal.Parse(comMscGradeRSpecEntity.HeightMiax.ToString()) <= 0)
- {
- msg = "壁厚(上限)不能小于或者等于0!";
- row.SetCellActive("HeightMiax");
- return false;
- }
- if (decimal.Parse(comMscGradeRSpecEntity.DimaterMax.ToString())
- < decimal.Parse(comMscGradeRSpecEntity.DimaterMin.ToString()))
- {
- msg = "外径(上限)不能小于外径(下限)!";
- row.SetCellActive("DimaterMax");
- return false;
- }
- if (decimal.Parse(comMscGradeRSpecEntity.HeightMiax.ToString())
- < decimal.Parse(comMscGradeRSpecEntity.HeightMin.ToString()))
- {
- msg = "壁厚(上限)不能小于壁厚(下限)!";
- row.SetCellActive("HeightMiax");
- return false;
- }
- if (IsExistSpec(comMscGradeRSpecEntity) == true)
- {
- msg = "该钢种下已存在相同的规格范围,请检查后再进行保存!";
- row.Activate();
- return false;
- }
- }
- else if (actionType == ActionType.Delete)
- {
- comMscGradeRSpecEntity.Validflag = "0";
- }
- else if (actionType == ActionType.Resume)
- {
- comMscGradeRSpecEntity.Validflag = "1";
- }
- return true;
- }
- private bool IsExistSpec(ComMscGradeRSpecEntity comMscGradeRSpecEntity)
- {
- string strJSON = JSONFormat.Format(comMscGradeRSpecEntity);
- string newPrimaryKey = comMscGradeRSpecEntity.Msc.ToString() + comMscGradeRSpecEntity.MscPline.ToString() +
- comMscGradeRSpecEntity.Gradecode.ToString() +
- comMscGradeRSpecEntity.HeightMin.ToString() + comMscGradeRSpecEntity.HeightMiax.ToString() +
- comMscGradeRSpecEntity.DimaterMin.ToString() + comMscGradeRSpecEntity.DimaterMax.ToString();
- if (comMscGradeRSpecEntity.CreateTime.ToString() != ""
- && newPrimaryKey == comMscGradeRSpecEntity.PrimaryKey.ToString())
- {
- return false;
- }
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.GrandeRSpec.isExitSpec",
- new object[] { strJSON }, _popGradeRSpec.ob);
- if (dt.Rows[0][0].ToString() == "0")
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- public void QueryGrade()
- {
- ComMscGradeEntity comMscGradeEntity = new ComMscGradeEntity();
- comMscGradeEntity.Msc = _popGradeRSpec.Msc;
- comMscGradeEntity.MscPline = _popGradeRSpec.MscPline;
- // comMscGradeEntity.Gradecode = _popGradeRSpec.GradeCode;
- string strJSON = JSONFormat.Format(comMscGradeEntity);
- List<ComMscGradeEntity> list = EntityHelper.GetData<ComMscGradeEntity>(
- "com.steering.pss.qcm.GrandeRSpec.queryGrade", new object[] { strJSON }, _popGradeRSpec.ob);
- _popGradeRSpec.ComMscGradeEntityBindingSource.DataSource = list;
- GridHelper.RefreshAndAutoSize(_popGradeRSpec.UltraGrid1);
- }
- public void QueryGradeRSpec()
- {
- ComMscGradeEntity comMscGradeEntity = (ComMscGradeEntity)_popGradeRSpec.UltraGrid1.ActiveRow.ListObject;
- string strJSON = JSONFormat.Format(comMscGradeEntity);
- string strIsDelete = _popGradeRSpec.CkbDelete.Checked ? "0" : "1";
- List<ComMscGradeRSpecEntity> list = EntityHelper.GetData<ComMscGradeRSpecEntity>(
- "com.steering.pss.qcm.GrandeRSpec.querySpec", new object[] { strJSON, strIsDelete }, _popGradeRSpec.ob);
- _popGradeRSpec.ComMscGradeRSpecEntityBindingSource.DataSource = list;
- GridHelper.RefreshAndAutoSize(_popGradeRSpec.UltraGrid2);
- }
- public bool SaveGradRSpec()
- {
- ServerHelper.SetData("com.steering.pss.qcm.GrandeRSpec.saveSpec",
- new object[] { Parm[0], Parm[1] }, _popGradeRSpec.ob);
- return true;
- }
- public bool DeleteSpec()
- {
- ServerHelper.SetData("com.steering.pss.qcm.GrandeRSpec.deleteOrResumeSpec",
- new object[] { Parm[1] }, _popGradeRSpec.ob);
- return true;
- }
- public bool ResumeSpec()
- {
- ServerHelper.SetData("com.steering.pss.qcm.GrandeRSpec.deleteOrResumeSpec",
- new object[] { Parm[1] }, _popGradeRSpec.ob);
- return true;
- }
- }
- }
|