| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Server;
- using System;
- using System.Collections;
- using System.Data;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm
- {
- class DtPhyRStd : DtBaseQcm
- {
- private FrmPhyRStd _frm;
- public DtPhyRStd(FrmPhyRStd frm)
- {
- _frm = frm;
- 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()
- {
- ArrayList list = new ArrayList();
- list.Add(_frm.LblIsDelete.Checked ? "0" : "1");
- list.Add(_frm.CmbPhyType2.SelecteValue == null ? "" : _frm.CmbPhyType2.SelecteValue.ToString());
- list.Add(_frm.CmbPhyType2.SelecteValue == null ? "" : _frm.CmbPhyType2.SelecteValue.ToString());
- list.Add(_frm.CmbPhyType2.SelecteValue == null ? "" : _frm.CmbPhyType2.SelecteValue.ToString());
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBasePhyRStdMng.query", new object[] { list }, _frm.ob);
- GridHelper.CopyDataToDatatable(dt, _frm.DataTable, true);
- GridHelper.RefreshAndAutoSize(_frm.Grid);
- }
- protected bool Add()
- {
- bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(_frm.FileList);
- if (isSuccess)
- {
- //MessageBox.Show("上传成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- //return pathList;
- int count = ServerHelper.SetData("com.steering.pss.qcm.ComBasePhyRStdMng.insert",
- new object[] { Parm }, _frm.ob);
- if (count > 0)
- return true;
- else
- {
- //删掉上传的图片。
- Core.Mes.Client.Comm.Server.FileHelper.Delete(_frm.FilePath);
- return false;
- }
- }
- else
- {
- MessageBox.Show("文件上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- }
- protected bool Modify()
- {
- bool flag = Core.Mes.Client.Comm.Server.FileHelper.Delete(_frm.OldfilePath);
- if (flag)
- {
- bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(_frm.FileList);
- if (isSuccess)
- {
- int count = ServerHelper.SetData("com.steering.pss.qcm.ComBasePhyRStdMng.update",
- new object[] { Parm }, _frm.ob);
- if (count > 0)
- return true;
- else
- {
- //删掉上传的图片。
- Core.Mes.Client.Comm.Server.FileHelper.Delete(_frm.FilePath);
- return false;
- }
- }
- return false;
- }
- else
- {
- return false;
- }
- }
- protected bool Save()
- {
- throw new NotImplementedException();
- }
- protected bool Group()
- {
- throw new NotImplementedException();
- }
- protected bool Delete()
- {
- ArrayList list = new ArrayList();
- list.Add(_frm.Grid.ActiveRow.Cells["PHY_STD_ID"].Value.ToString());
- list.Add(_frm.UserInfo.GetUserName());
- list.Add("0");
- ServerHelper.SetData("com.steering.pss.qcm.ComBasePhyRStdMng.deleteOrResume",
- new object[] { list }, _frm.ob);
- return true;
- }
- protected bool Resume()
- {
- ArrayList list = new ArrayList();
- list.Add(_frm.Grid.ActiveRow.Cells["PHY_STD_ID"].Value.ToString());
- list.Add(_frm.UserInfo.GetUserName());
- list.Add("1");
- ServerHelper.SetData("com.steering.pss.qcm.ComBasePhyRStdMng.deleteOrResume",
- new object[] { list }, _frm.ob);
- return true;
- }
- protected bool SubMitAudit()
- {
- throw new NotImplementedException();
- }
- protected bool Audit()
- {
- throw new NotImplementedException();
- }
- protected override bool CheckData(ActionType actionType, out ArrayList parm, out string msg)
- {
- msg = "";
- parm = new ArrayList();
- if (actionType != ActionType.Add && actionType != ActionType.Modify) return true;
- ComBasePhyRStdEntity comBasePhyRStdEntity = GetParm(actionType);
- if (comBasePhyRStdEntity == null) return false;
- string strObj = JSONFormat.Format(comBasePhyRStdEntity);
- if (IsExistPhyStdId(strObj))
- {
- string newPhyStdId = _frm.CmbPhyType.SelecteValue.ToString()
- + _frm.CmbStdName.SelecteValue.ToString()
- + _frm.CmbStdAlpha.SelecteValue.ToString()
- + _frm.CmbPhyStd.SelecteValue.ToString();
- string oldPhyStdId = _frm.Grid.ActiveRow.Cells["PHY_STD_ID"].Value.ToString();
- if (actionType == ActionType.Add)
- {
- msg = "系统已经存在检验项和标准的对应关系!";
- return false;
- }
- else if (actionType == ActionType.Modify && newPhyStdId != oldPhyStdId)
- {
- msg = "系统已经存在检验项和标准的对应关系!";
- return false;
- }
- }
- parm.Add(strObj);
- return true;
- }
- protected ComBasePhyRStdEntity GetParm(ActionType actionType)
- {
- if (actionType == ActionType.Modify || actionType == ActionType.Add)
- {
- FrmDtConverter<ComBasePhyRStdEntity> convert = new FrmDtConverter<ComBasePhyRStdEntity>();
- ComBasePhyRStdEntity comBasePhyRStdEntity = convert.Convert(_frm.FlowPanel, _frm.UserInfo, ControlAttributeType.NoQueryControl);
- if (comBasePhyRStdEntity == null)
- {
- return null;
- }
- comBasePhyRStdEntity.StdFilePath = _frm.UltraTextEditor1.Text.Trim();
- if (_frm.Grid.ActiveRow != null)
- comBasePhyRStdEntity.PhyStdId = _frm.Grid.ActiveRow.Cells["PHY_STD_ID"].Value.ToString();
- return comBasePhyRStdEntity;
- }
- return null;
- }
- protected override bool IsSelectData(ActionType actionType, out string msg)
- {
- msg = "";
- if (actionType != ActionType.Add)
- {
- if (_frm.Grid.ActiveRow == null)
- {
- return false;
- }
- }
- return true;
- }
- private bool IsExistPhyStdId(string strJSON)
- {
- try
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBasePhyRStdMng.isExistPhyStdId",
- new object[] { strJSON }, _frm.ob);
- if (dt.Rows[0][0].ToString() == "0")
- {
- return false;
- }
- }
- catch { }
- return true;
- }
- }
- }
|