| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- 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 Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm
- {
- class DtSpecificationsBasicsNew2 : DtBaseQcm
- {
- private FrmSpecificationsBasicsNew2 _frm = null;
- public DtSpecificationsBasicsNew2(FrmSpecificationsBasicsNew2 frm) : base()
- {
- _frm = frm;
- RegistQuery(GetDataChild, "Child");
- RegistQuery(Query, "DefaultQuery");
- RegistAction(Add, ActionType.Add);
- RegistAction(Modify, ActionType.Modify);
- RegistAction(Save, ActionType.Save);
- RegistAction(Delete, ActionType.Delete);
- RegistAction(Resume, ActionType.Resume);
- RegistAction(SubMitAudit, ActionType.SubMitAudit);
- RegistAction(Audit, ActionType.Audit);
- RegistAction(Group, ActionType.Group);
- }
- protected void Query()
- {
- try
- {
- _frm.Cursor = Cursors.WaitCursor;
- bool validFlag = _frm.chkValid.Checked;
- string titleName = _frm.txtTitleName.Text.Trim();
- string mscType = _frm.MscStyle;
- DataTable dt = null;
- dt = ServerHelper.GetData("com.steering.pss.qcm.CoreSpecBasicsNew.getLineList",
- new object[] { validFlag, titleName, mscType }, _frm.ob);
- GridHelper.CopyDataToDatatable(dt, _frm.dataTable1, true);
- //GridHelper.RefreshAndAutoSize(_frm.ultraGrid1);
- _frm.dataTable1.AcceptChanges();
- }
- finally
- {
- _frm.Cursor = Cursors.Default;
- }
- }
- protected bool Add()
- {
- throw new NotImplementedException();
- }
- protected bool Group()
- {
- throw new NotImplementedException();
- }
- protected bool Modify()
- {
- throw new NotImplementedException();
- }
- protected bool Save()
- {
- ArrayList specList;
- ArrayList specOrderList;
- ArrayList[] parms = GetParms(ActionType.Save);
- specList = parms[0];
- specOrderList = parms[1];
- ServerHelper.SetData("com.steering.pss.qcm.CoreSpecBasicsNew.save",
- new object[] { specList, specOrderList }, _frm.ob);
- return true;
- }
- protected bool Delete()
- {
- return DeleteOrResumeData(true);
- }
- protected bool Resume()
- {
- return DeleteOrResumeData(false);
- }
- protected bool SubMitAudit()
- {
- throw new NotImplementedException();
- }
- protected bool Audit()
- {
- throw new NotImplementedException();
- }
- public void GetDataChild()
- {
- bool validFlag = _frm.chkValid.Checked;
- string spec_code = _frm.UltraGrid1.ActiveRow.Cells["SPEC_CODE"].Value.ToString();
- DataTable dt = null;
- dt = ServerHelper.GetData("com.steering.pss.qcm.CoreSpecOrderBasics.getLineList",
- new object[] { spec_code, validFlag }, _frm.ob);
- GridHelper.CopyDataToDatatable(dt, _frm.dataTable2, true);
- //GridHelper.RefreshAndAutoSize(_frm.ultraGrid2);
- _frm.dataTable2.AcceptChanges();
- }
- private bool DeleteOrResumeData(bool isDelete)
- {
- ArrayList param = new ArrayList();
- ArrayList minParam = new ArrayList();
- DataRow[] drs = _frm.dataTable1.Select("CHK = 'True'");
- DataRow[] drs2 = _frm.dataTable2.Select("CHK = 'True'");
- foreach (DataRow dr in drs)
- {
- param.Add(dr["SPEC_CODE"].ToString());
- }
- foreach (DataRow dr in drs2)
- {
- minParam.Add(dr["ORDER_SPEC_CODE"].ToString());
- }
- if (param.Count > 0)
- {
- ServerHelper.SetData("com.steering.pss.qcm.CoreSpecBasicsNew.deleteLineInfo",
- new Object[] { param, _frm.UserInfo.GetUserName(), isDelete }, _frm.ob);
- }
- if (minParam.Count > 0)
- {
- ServerHelper.SetData("com.steering.pss.qcm.CoreSpecOrderBasics.deleteLineInfo",
- new Object[] { minParam, _frm.UserInfo.GetUserName(), isDelete }, _frm.ob);
- }
- return true;
- }
- protected override bool IsSelectData(ActionType actionType, out string msg)
- {
- msg = "";
- DataRow[] drs = _frm.dataTable1.Select("CHK = 'True'");
- DataRow[] drs2 = _frm.dataTable2.Select("CHK = 'True'");
- if (drs.Length == 0 && drs2.Length == 0)
- {
- return false;
- }
- return true;
- }
- protected ArrayList[] GetParms(ActionType actionType)
- {
- ArrayList[] lists = new ArrayList[] { new ArrayList(), new ArrayList() };
- if (actionType == ActionType.Save)
- {
- FrmDtConverter<ComBaseSpecEntity> convert = new FrmDtConverter<ComBaseSpecEntity>();
- UltraGridRow[] rows = GridHelper.GetRowsWithKey(_frm.UltraGrid1, new string[] { "CHK" }, new string[] { "True" });
- foreach (UltraGridRow row in rows)
- {
- ComBaseSpecEntity comBaseSpecEntity = convert.Convert(row, _frm.UserInfo, FieldAttributeType.NoQueryField);
- if (comBaseSpecEntity == null) return null;
- AdjustData(comBaseSpecEntity);
- string strObj = JSONFormat.Format(comBaseSpecEntity);
- lists[0].Add(strObj);
- }
- FrmDtConverter<ComBaseSpecOrderEntity> convert2 = new FrmDtConverter<ComBaseSpecOrderEntity>();
- UltraGridRow[] rows2 = GridHelper.GetRowsWithKey(_frm.UltraGrid2, new string[] { "CHK" }, new string[] { "True" });
- foreach (UltraGridRow row in rows2)
- {
- ComBaseSpecOrderEntity comBaseSpecOrderEntity = convert2.Convert(row, _frm.UserInfo, FieldAttributeType.NoQueryField);
- if (comBaseSpecOrderEntity == null) return null;
- string strObj = JSONFormat.Format(comBaseSpecOrderEntity);
- lists[1].Add(strObj);
- }
- }
- return lists;
- }
- private void AdjustData(ComBaseSpecEntity comBaseSpecEntity)
- {
- if (comBaseSpecEntity.MscStyle == "A")
- {
- comBaseSpecEntity.Dimater = Decimal.Parse(comBaseSpecEntity.Dimater).ToString("F2");
- comBaseSpecEntity.Height = Decimal.Parse(comBaseSpecEntity.Height).ToString("F2");
- comBaseSpecEntity.SpecName = comBaseSpecEntity.Dimater + "x" + comBaseSpecEntity.Height;
- }
- if (comBaseSpecEntity.Weight != "")
- {
- comBaseSpecEntity.Weight = Math.Round(Convert.ToDouble(comBaseSpecEntity.Weight), 4).ToString();
- }
- }
- protected override bool CheckData(ActionType actionType, out ArrayList parm, out string msg)
- {
- msg = "";
- parm = new ArrayList();
- UltraGridRow[] rows = GridHelper.GetRowsWithKey(_frm.UltraGrid1, new string[] { "CHK" }, new string[] { "True" });
- UltraGridRow[] rows2 = GridHelper.GetRowsWithKey(_frm.UltraGrid2, new string[] { "CHK" }, new string[] { "True" });
- if (actionType == ActionType.Resume)
- {
- if (rows2.Length > 0)
- {
- if (_frm.UltraGrid1.ActiveRow.Cells["VALIDFLAG"].Value.ToString() == "0"
- && _frm.UltraGrid1.ActiveRow.Cells["GRD_CHK"].Value.ToString() == "False")
- {
- MessageUtil.ShowWarning("请恢复产品规格后,再进行订货规格操作!");
- return false;
- }
- }
- }
- else if (actionType == ActionType.Delete)
- {
- return true;
- }
- else
- {
- return CheckSave(rows, rows2);
- }
- return true;
- }
- private bool CheckSave(UltraGridRow[] rows, UltraGridRow[] rows2)
- {
- List<string> insertSpecNames = new List<string>();
- List<string> insertOrder_SpecNames = new List<string>();
- foreach (UltraGridRow row in rows)
- {
- //if (dr["MSC_STYLE"].ToString() == "")
- //{
- // MessageUtil.ShowWarning("您所要保存的数据中,类型不能为空!");
- // return false;
- //}
- if (row.Cells["MSC_STYLE"].Value.ToString() == "A" && row.Cells["DIMATER"].Value.ToString() == "")
- {
- MessageUtil.ShowWarning("您所要保存的数据中,外径不能为空!");
- row.Cells["DIMATER"].Activate();
- return false;
- }
- else if (row.Cells["MSC_STYLE"].Value.ToString() == "A" && row.Cells["HEIGHT"].Value.ToString() == "")
- {
- MessageUtil.ShowWarning("您所要保存的数据中,壁厚不能为空!");
- row.Cells["HEIGHT"].Activate();
- return false;
- }
- if (row.Cells["DIMATER"].Value.ToString() != "" && row.Cells["HEIGHT"].Value.ToString() != "")
- {
- if (Convert.ToDouble(row.Cells["DIMATER"].Value) < Convert.ToDouble(row.Cells["HEIGHT"].Value))
- {
- MessageUtil.ShowWarning("您要保存的数据,外径不能小于壁厚");
- row.Cells["DIMATER"].Activate();
- return false;
- }
- }
- decimal dcm = 0.0M;
- if (row.Cells["DIMATER"].Value.ToString() != "" && decimal.TryParse(row.Cells["DIMATER"].Value.ToString(), out dcm) == false)
- {
- MessageUtil.ShowWarning("您所要保存的数据中,外径输入的不是数字类型!");
- row.Cells["DIMATER"].Activate();
- return false;
- }
- if (row.Cells["HEIGHT"].Value.ToString() != "" && decimal.TryParse(row.Cells["HEIGHT"].Value.ToString(), out dcm) == false)
- {
- MessageUtil.ShowWarning("您所要保存的数据中,壁厚输入的不是数字类型!");
- row.Cells["HEIGHT"].Activate();
- return false;
- }
- if (row.Cells["WEIGHT"].Value.ToString() != "" && decimal.TryParse(row.Cells["WEIGHT"].Value.ToString(), out dcm) == false)
- {
- MessageUtil.ShowWarning("您所要保存的数据中,米单重输入的不是数字类型!");
- row.Cells["WEIGHT"].Activate();
- return false;
- }
- if (row.Cells["SPEC_NAME"].Value.ToString() == "")
- {
- MessageUtil.ShowWarning("您所要保存的数据中,产品规格描述不能为空!");
- return false;
- }
- if (IsExistSpec(row.Cells["SPEC_NAME"].Value.ToString(), row.Cells["SPEC_CODE"].Value.ToString()) == true)
- {
- MessageUtil.ShowWarning("已存在产品规格描述-[" + row.Cells["SPEC_NAME"].Value.ToString() + "]!");
- row.Cells["SPEC_NAME"].Activate();
- return false;
- }
- if (insertSpecNames.Contains(row.Cells["SPEC_NAME"].Value.ToString()))
- {
- MessageUtil.ShowWarning("您所要保存的数据中,出现重复的产品规格描述-[" + row.Cells["SPEC_NAME"].Value.ToString() + "]!");
- row.Cells["SPEC_NAME"].Activate();
- return false;
- }
- insertSpecNames.Add(row.Cells["SPEC_NAME"].Value.ToString());
- }
- foreach (UltraGridRow row in rows2)
- {
- if (_frm.UltraGrid1.ActiveRow.Cells["VALIDFLAG"].Value.ToString() == "0")
- {
- MessageUtil.ShowWarning("请恢复产品规格后,再进行订货规格操作!");
- return false;
- }
- //if (dr["ORDER_SPEC_DESC"].ToString() == "")
- //{
- // MessageUtil.ShowWarning("您所要保存的数据中,订货规格描述不能为空!");
- // return false;
- //}
- //else if(IsExistOrderSpec(dr["ORDER_SPEC_DESC"].ToString(), dr["ORDER_SPEC_CODE"].ToString())
- // == true)
- //{
- // MessageUtil.ShowWarning("已存在订货规格描述-"+dr["ORDER_SPEC_DESC"].ToString()+"!");
- // return false;
- //}
- //if(insertOrder_SpecNames.Contains(dr["ORDER_SPEC_DESC"].ToString()))
- //{
- // MessageUtil.ShowWarning("您所要保存的数据中,出现重复的订货规格描述-["+ dr["ORDER_SPEC_DESC"].ToString() +"]!");
- // return false;
- //}
- //insertOrder_SpecNames.Add(dr["ORDER_SPEC_DESC"].ToString());
- }
- return true;
- }
- private bool IsExistSpec(string spec, string specCode)
- {
- if (specCode == "")
- {
- specCode = "NoCode";
- }
- ArrayList list = new ArrayList();
- list.Add(spec);
- list.Add(specCode);
- DataTable dt = null;
- dt = ServerHelper.GetData("com.steering.pss.qcm.CoreSpecBasicsNew.isExistSpec",
- new object[] { list }, _frm.ob);
- if (dt != null && dt.Rows[0][0].ToString() == "0")
- {
- return false;
- }
- return true;
- }
- private bool IsExistOrderSpec(string orderSpec, string orderSpecCode)
- {
- if (orderSpecCode == "")
- {
- orderSpecCode = "NoCode";
- }
- ArrayList list = new ArrayList();
- list.Add(orderSpec);
- list.Add(orderSpecCode);
- DataTable dt = null;
- dt = ServerHelper.GetData("com.steering.pss.qcm.CoreSpecBasicsNew.isExistOrderSpec",
- new object[] { list }, _frm.ob);
- if (dt != null && dt.Rows[0][0].ToString() == "0")
- {
- return false;
- }
- return true;
- }
- }
- }
|