using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.BLL;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.DAL.Basic;
using QMFrameWork.Data;
using QMAPP.FJC.BLL.Dict;
using QMAPP.Entity;
using QMFrameWork.Log;
using QMAPP.FJC.Entity;
namespace QMAPP.FJC.BLL.Basic
{
///
/// 模块编号:M2-6
/// 作 用:工序名称信息逻辑层
/// 作 者:王丹丹
/// 编写日期:2015年05月29日
///
public class ProcessInfoBLL : BaseBLL
{
#region 获取信息
///
/// 获取信息
///
/// 条件
/// 信息
public DataResult Get(ProcessInfo model)
{
DataResult result = new DataResult();
try
{
result.Result = new ProcessInfoDAL().Get(model);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工序名称信息逻辑层-获取信息!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 获取列表
///
/// 获取列表
///
/// 条件
/// 数据页
/// 数据页
public DataResult GetList(ProcessInfo condition, DataPage page)
{
DataResult result = new DataResult();
try
{
//获取信息列表
DataPage dataPage = new ProcessInfoDAL().GetList(condition, page);
#region 转换操作类别显示类型
List processInfoList = dataPage.Result as List;
DictManageBLL dictPoerateTypeBll = new DictManageBLL(DictKind.OPERATETYPE);
foreach (ProcessInfo m in processInfoList)
{
//操作类别
m.OPERATETYPETXT = dictPoerateTypeBll.GetDictValue(m.OPERATETYPE);
}
#endregion
result.Result = dataPage;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工序名称信息逻辑层-获取列表!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
///
/// 获取列表
///
/// 条件
/// 全部集合
public List GetAllList(ProcessInfo condition)
{
try
{
//获取物料信息列表
List list = new ProcessInfoDAL().GetList(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
///
/// 判断名称是否存在
///
///
/// true:已存在;fasel:不存在。
public DataResult ExistsProcess(ProcessInfo model)
{
DataResult result=new DataResult();
try
{
if (new ProcessInfoDAL().ExistsProcessName(model) == true)
{
result.IsSuccess=false;
result.Msg =Resource.ProcessNameIsHave;
return result;
}
if (new ProcessInfoDAL().ExistsProcessType(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.ProcessTypeIsHave;
return result;
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工序名称信息逻辑层-信息是否重复!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 插入信息
///
/// 插入信息(单表)
///
/// 信息
/// 插入行数
public DataResult Insert(ProcessInfo model)
{
DataResult result = new DataResult();
ProcessInfoDAL cmdDAL = new ProcessInfoDAL();
//基本信息
model.PID = Guid.NewGuid().ToString();
model.CREATEUSER = this.LoginUser.UserID;
model.CREATEDATE = DateTime.Now;
model.UPDATEUSER = model.CREATEUSER;
model.UPDATEDATE = model.CREATEDATE;
try
{
DataResult isExist = new DataResult();
isExist = this.ExistsProcess(model);
if (isExist.IsSuccess == false)
{
result.IsSuccess = false;
result.Msg = isExist.Msg;
return result;
}
result.Result = new ProcessInfoDAL().Insert(model);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工序名称信息逻辑层-插入信息!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 更新信息
///
/// 更新信息
///
///
/// 更新行数
public DataResult Update(ProcessInfo model)
{
DataResult result = new DataResult();
//基本信息
model.UPDATEUSER = this.LoginUser.UserID;
try
{
DataResult isExist = new DataResult();
isExist = this.ExistsProcess(model);
if (isExist.IsSuccess == false)
{
result.IsSuccess = false;
result.Msg = isExist.Msg;
return result;
}
result.Result = new ProcessInfoDAL().Update(model);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工序名称信息逻辑层-更新信息!"
});
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
{
foreach (string str in list)
{
result.Result += this.DeleteProcessInfo(new ProcessInfo { PID = str });
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工序名称信息逻辑层-删除!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
///
/// 删除信息
///
/// 信息
/// 删除个数
public int DeleteProcessInfo(ProcessInfo model)
{
int count = 0;
try
{
count = new ProcessInfoDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取工序下拉列表
///
///
///
///
///
public DataResult> GetProcessInfoBasicList(ProcessInfo condition)
{
DataResult> result = new DataResult>();
try
{
result.Result = new ProcessInfoDAL().GetProcessInfoList(condition);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工序信息逻辑层-获取列表(绑定下拉列表使用)!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 获取工序下拉列表数据
///
/// 获取工序下拉列表数据
///
///
///
public List GetProcessInfoList(ProcessInfo model)
{
try
{
return new ProcessInfoDAL().GetProcessInfoList(model);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工序信息逻辑层-获取工序下拉列表数据!"
});
throw ex;
}
}
#endregion
}
}