天津投入产出系统后端
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.
 
 
 
 
 
 

252 lines
7.7 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.BLL;
using QMAPP.Entity;
using QMFrameWork.Log;
using QMAPP.MD.Entity;
using QMFrameWork.Data;
using QMAPP.MD.DAL;
using QMAPP.MD.BLL.Dict;
namespace QMAPP.MD.BLL
{
/// <summary>
/// 模块名称:设备
/// 作 者:郭兆福
/// 编写日期:2017年05月10日
/// </summary>
public class EquipmentBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<Equipment> Get(Equipment model)
{
DataResult<Equipment> result = new DataResult<Equipment>();
try
{
result.Result = new EquipmentDAL().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(Equipment condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取信息列表
DataPage dataPage = new EquipmentDAL().GetList(condition, page);
List<Equipment> equipmentList = dataPage.Result as List<Equipment>;
DictManageBLL dictEquipmentFlagBll = new DictManageBLL(DictKind.EquipmentFlag);
DictManageBLL dictEquipmentTypeBll = new DictManageBLL(DictKind.EquipmentType);
foreach (Equipment m in equipmentList)
{
//关键设备
m.FLAG_EQUIPMENT_NAME = dictEquipmentFlagBll.GetDictValue(m.FLAG_EQUIPMENT);
//设备类型
m.EQUIPMENT_TYPE_NAME = dictEquipmentTypeBll.GetDictValue(m.EQUIPMENT_TYPE);
}
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 bool ExistsMachineInfo(Equipment model)
{
try
{
return new EquipmentDAL().ExistsMachineInfo(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(Equipment model)
{
DataResult<int> result = new DataResult<int>();
EquipmentDAL cmdDAL = new EquipmentDAL();
//基本信息
model.PID = Guid.NewGuid().ToString();
model.FLGDEL = "0";
model.CREATEUSER = this.LoginUser.UserID;
model.UPDATEUSER = model.CREATEUSER;
try
{
if (ExistsMachineInfo(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.MachineCodeIsHave;
return result;
}
result.Result = new EquipmentDAL().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(Equipment model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
model.UPDATEUSER = this.LoginUser.UserID;
try
{
if (ExistsMachineInfo(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.MachineCodeIsHave;
return result;
}
result.Result = new EquipmentDAL().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 EquipmentDAL().IsUsedEquipmentLocCode(list) == true)
{
result.IsSuccess = false;
result.Msg = "准备删除的数据已被使用,删除不可!";
return result;
}
foreach (string str in list)
{
result.Result += this.DeleteMachineInfo(new Equipment { 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 DeleteMachineInfo(Equipment model)
{
int count = 0;
try
{
count = new EquipmentDAL().Delete(model, this.LoginUser.LoginUserID);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取设备下拉列表
/// <summary>
/// 获取设备下拉列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>数据页</returns>
public DataResult<List<Equipment>> GetEquipmentList(Equipment condition)
{
DataResult<List<Equipment>> result = new DataResult<List<Equipment>>();
try
{
result.Result = new EquipmentDAL().GetList(condition);
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
return result;
}
}
#endregion
}
}