天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

226 lines
6.9 KiB

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<ParameterConfigEntity> Get(ParameterConfigEntity model)
{
DataResult<ParameterConfigEntity> result = new DataResult<ParameterConfigEntity>();
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 获取列表
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataResult<DataPage> GetList(ParameterConfigEntity condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
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 信息是否重复
/// <summary>
/// 判断设备编码是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;fasel:不存在。</returns>
public DataResult<bool> IsExistsParameterConfigEntity(ParameterConfigEntity model)
{
DataResult<bool> result = new DataResult<bool>();
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 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(ParameterConfigEntity model)
{
DataResult<int> result = new DataResult<int>();
MachineInfo info = new ParameterConfigEntityDAL().GetCoddeByName(model.MACHINECODDE);
if (info != null)
{
model.MACHINENAME = info.MACHINENAME;
}
else
{
result.IsSuccess = false;
result.Msg = "设备信息未设置名称";
return result;
}
try
{
DataResult<bool> isExist = new DataResult<bool>();
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 更新信息
/// <summary>
/// 更新信息
/// </summary>
/// <param name=""></param>
/// <returns>更新行数</returns>
public DataResult<int> Update(ParameterConfigEntity model)
{
DataResult<int> result = new DataResult<int>();
try
{
DataResult<bool> isExist = new DataResult<bool>();
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 删除
/// <summary>
/// 删除信息
/// </summary>
/// <param name=""></param>
/// <returns>删除个数</returns>
public DataResult<int> Delete(string strs)
{
DataResult<int> result = new DataResult<int>();
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;
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="">信息</param>
/// <returns>删除个数</returns>
public int DeleteProcessInfo(ParameterConfigEntity model)
{
int count = 0;
try
{
count = new ParameterConfigEntityDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}