using System; using System.Collections.Generic; using System.Linq; using System.Text; using QMAPP.BLL; using QMFrameWork.Log; using QMAPP.Entity; using QMAPP.MD.Entity; using QMAPP.MD.DAL; using QMFrameWork.Data; using QMAPP.MD.BLL.Dict; using QMAPP.FJC.Entity.Basic; namespace QMAPP.MD.BLL { class ParameterConfigEntityBLL : BaseBLL { #region 获取信息 public DataResult Get(ParameterConfigEntity model) { DataResult result = new DataResult(); try { result.Result = new ParameterConfigEntityDAL().Get(model); } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } #endregion #region 获取列表 /// /// 获取列表 /// /// 条件 /// 数据页 /// 数据页 public DataResult GetList(ParameterConfigEntity condition, DataPage page) { DataResult result = new DataResult(); try { //获取信息列表 DataPage dataPage = new ParameterConfigEntityDAL().GetList(condition, page); result.Result = dataPage; } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } #endregion #region 信息是否重复 /// /// 判断设备编码是否存在 /// /// /// true:已存在;fasel:不存在。 public DataResult IsExistsParameterConfigEntity(ParameterConfigEntity model) { DataResult result = new DataResult(); try { if (new ParameterConfigEntityDAL().ExistsParameterConfigEntity(model) == true) { result.IsSuccess = false; result.Msg = "相同的设备编码已经存在"; return result; } } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } #endregion #region 插入信息 /// /// 插入信息(单表) /// /// 信息 /// 插入行数 public DataResult Insert(ParameterConfigEntity model) { DataResult result = new DataResult(); MachineInfo info = new ParameterConfigEntityDAL().GetCoddeByName(model.MACHINECODDE); if (info != null) { model.MACHINENAME = info.MACHINENAME; } else { result.IsSuccess = false; result.Msg = "设备信息未设置名称"; return result; } try { DataResult isExist = new DataResult(); isExist = IsExistsParameterConfigEntity(model); if (isExist.IsSuccess == false) { result.IsSuccess = false; result.Msg = isExist.Msg; return result; } result.Result = new ParameterConfigEntityDAL().Insert(model); } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } #endregion #region 更新信息 /// /// 更新信息 /// /// /// 更新行数 public DataResult Update(ParameterConfigEntity model) { DataResult result = new DataResult(); try { DataResult isExist = new DataResult(); isExist = IsExistsParameterConfigEntity(model); if (isExist.IsSuccess == false) { result.IsSuccess = false; result.Msg = isExist.Msg; return result; } result.Result = new ParameterConfigEntityDAL().Update(model); } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } #endregion #region 删除 /// /// 删除信息 /// /// /// 删除个数 public DataResult Delete(string strs) { DataResult result = new DataResult(); string[] list = strs.Split(":".ToCharArray()); try { //if (new ParameterConfigEntityDAL().IsUsedParameterConfigEntityCode(list) == true) //{ // result.IsSuccess = false; // result.Msg = "准备删除的数据已被使用,删除不可!"; // return result; //} foreach (string str in list) { result.Result += this.DeleteProcessInfo(new ParameterConfigEntity { PID = str }); } } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } /// /// 删除信息 /// /// 信息 /// 删除个数 public int DeleteProcessInfo(ParameterConfigEntity model) { int count = 0; try { count = new ParameterConfigEntityDAL().Delete(model); return count; } catch (Exception ex) { throw ex; } } #endregion } }