using System;
using System.Collections.Generic;
using QMAPP.BLL;
using QMAPP.Entity;
using QMAPP.MD.BLL.Dict;
using QMAPP.MD.DAL;
using QMAPP.MD.Entity;
using QMFrameWork.Data;
namespace QMAPP.MD.BLL
{
///
/// 模块名称:工序
/// 作 者:郭兆福
/// 编写日期:2017年05月11日
///
public class WorkCellBLL : BaseBLL
{
#region 获取信息
///
/// 获取信息
///
/// 条件
/// 信息
public DataResult Get(WorkCell model)
{
DataResult result = new DataResult();
try
{
result.Result = new WorkCellDAL().Get(model);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 获取列表
///
/// 获取列表
///
/// 条件
/// 数据页
/// 数据页
public DataResult GetList(WorkCell condition, DataPage page)
{
DataResult result = new DataResult();
try
{
//获取信息列表
DataPage dataPage = new WorkCellDAL().GetList(condition, page);
List workCellList = dataPage.Result as List;
DictManageBLL dictBackFlushFlagBll = new DictManageBLL(DictKind.BackFlushFlag);
foreach (WorkCell m in workCellList)
{
//反冲标识
m.FLAG_BACKFLUSH_NAME = dictBackFlushFlagBll.GetDictValue(m.FLAG_BACKFLUSH);
}
result.Result = dataPage;
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
///
/// 获取列表
///
/// 条件
/// 全部集合
public List GetAllList(WorkCell condition)
{
try
{
//获取物料信息列表
List list = new WorkCellDAL().GetList(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
///
/// 判断编码名称是否存在
///
///
/// true:不存在;false:已存在
public DataResult ExistsWorkCell(WorkCell model)
{
DataResult result = new DataResult();
try
{
if (new WorkCellDAL().IsExistsWorkCellCodeName(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(WorkCell model)
{
DataResult result = new DataResult();
WorkCellDAL cmdDAL = new WorkCellDAL();
//基本信息
model.FLGDEL = "0";
model.PID = Guid.NewGuid().ToString();
model.CREATEUSER = this.LoginUser.UserID;
model.UPDATEUSER = model.CREATEUSER;
try
{
DataResult isExist = new DataResult();
isExist = ExistsWorkCell(model);
if (isExist.IsSuccess == false)
{
result.IsSuccess = false;
result.Msg = isExist.Msg;
return result;
}
result.Result = new WorkCellDAL().Insert(model);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 更新信息
///
/// 更新信息
///
///
/// 更新行数
public DataResult Update(WorkCell model)
{
DataResult result = new DataResult();
//基本信息
model.UPDATEUSER = this.LoginUser.UserID;
try
{
DataResult isExist = new DataResult();
isExist = ExistsWorkCell(model);
if (isExist.IsSuccess == false)
{
result.IsSuccess = false;
result.Msg = isExist.Msg;
return result;
}
result.Result = new WorkCellDAL().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
{
foreach (string str in list)
{
result.Result += this.DeleteProcessInfo(new WorkCell { PID = str });
}
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
///
/// 删除信息
///
/// 信息
/// 删除个数
public int DeleteProcessInfo(WorkCell model)
{
int count = 0;
try
{
count = new WorkCellDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取工序下拉列表数据
///
/// 获取工序下拉列表数据
///
///
///
public List GetWorkCellList(WorkCell model)
{
try
{
return new WorkCellDAL().GetWorkCellList(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取(联动)工序下拉列表数据
///
/// 获取工序下拉列表数据
///
///
///
public List GetNewWorkCellList(WorkCell model,string routecode)
{
try
{
return new WorkCellDAL().GetWorkCellWithRouteList(model,routecode);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取(联动)工序下拉列表数据排序
///
/// 获取工序下拉列表数据
///
///
///
public List GetNewWorkCellListSeq(string routecode)
{
try
{
return new WorkCellDAL().GetWorkCellWithRouteListSeq(routecode);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}