using System;
using System.Collections.Generic;
using QMAPP.BLL;
using QMAPP.Entity;
using QMAPP.MD.DAL;
using QMFrameWork.Data;
using WorkCellEquipment = QMAPP.MD.Entity.WorkCellEquipment;
using WorkLoc = QMAPP.MD.Entity.WorkLoc;
namespace QMAPP.MD.BLL
{
///
/// 模块名称:工位
/// 作 者:郭兆福
/// 编写日期:2017年05月11日
///
public class WorkLocBLL : BaseBLL
{
#region 获取信息
///
/// 获取信息
///
/// 条件
/// 信息
public DataResult Get(WorkLoc model)
{
DataResult result = new DataResult();
try
{
result.Result = new WorkLocDAL().Get(model);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 获取列表
///
/// 获取列表
///
/// 条件
/// 数据页
/// 数据页
public DataResult GetList(WorkLoc condition, DataPage page)
{
DataResult result = new DataResult();
try
{
//获取信息列表
DataPage dataPage = new WorkLocDAL().GetList(condition, page);
result.Result = dataPage;
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
///
/// 获取列表
///
/// 条件
/// 全部集合
public List GetAllList(WorkLoc condition)
{
try
{
//获取物料信息列表
List list = new WorkLocDAL().GetList(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
///
/// 判断编码名称是否存在
///
///
/// true:不存在;false:已存在
public DataResult IsExistsWorkLoc(WorkLoc model)
{
DataResult result = new DataResult();
try
{
if (new WorkLocDAL().IsExistsWorkLocCode(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(WorkLoc model)
{
DataResult result = new DataResult();
WorkLocDAL cmdDAL = new WorkLocDAL();
//基本信息
model.FLGDEL = "0";
model.PID = Guid.NewGuid().ToString();
model.CREATEUSER = this.LoginUser.UserID;
model.UPDATEUSER = model.CREATEUSER;
try
{
DataResult isExist = new DataResult();
isExist = IsExistsWorkLoc(model);
if (isExist.IsSuccess == false)
{
result.IsSuccess = false;
result.Msg = isExist.Msg;
return result;
}
result.Result = new WorkLocDAL().Insert(model);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 更新信息
///
/// 更新信息
///
///
/// 更新行数
public DataResult Update(WorkLoc model)
{
DataResult result = new DataResult();
//基本信息
model.UPDATEUSER = this.LoginUser.UserID;
try
{
DataResult isExist = new DataResult();
isExist = IsExistsWorkLoc(model);
if (isExist.IsSuccess == false)
{
result.IsSuccess = false;
result.Msg = isExist.Msg;
return result;
}
result.Result = new WorkLocDAL().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 WorkLocDAL().IsUsedWorkLocCode(list) == true)
{
result.IsSuccess = false;
result.Msg = "准备删除的数据已被使用,删除不可!";
return result;
}
foreach (string str in list)
{
result.Result += this.DeleteProcessInfo(new WorkLoc { PID = str });
}
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
///
/// 删除信息
///
/// 信息
/// 删除个数
public int DeleteProcessInfo(WorkLoc model)
{
int count = 0;
try
{
count = new WorkLocDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 工位设备相关操作
///
/// 得到工位设备信息
///
/// 工位设备信息
///
///
public DataResult GetWorkLocEquipmentList(WorkCellEquipment model, DataPage page)
{
DataResult result = new DataResult();
try
{
result.Result = new WorkLocDAL().GetWorkLocEquipmentList(model, page);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
///
/// 插入工位设备信息
///
/// 工位设备信息
///
public DataResult InsertWorkLocEquip(WorkCellEquipment model)
{
DataResult result = new DataResult();
WorkLocDAL cmdDAL = new WorkLocDAL();
//基本信息
model.FLGDEL = "0";
model.PID = Guid.NewGuid().ToString();
model.CREATEUSER = this.LoginUser.UserID;
model.UPDATEUSER = model.CREATEUSER;
try
{
DataResult isExist = new DataResult();
isExist = IsExistsWorkLocEquip(model);
if (isExist.IsSuccess == false)
{
result.IsSuccess = false;
result.Msg = isExist.Msg;
return result;
}
result.Result = new WorkLocDAL().InsertWorkLocEquip(model);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
///
/// 判断编码名称是否存在
///
/// 工位设备信息
/// true:不存在;false:已存在
public DataResult IsExistsWorkLocEquip(WorkCellEquipment model)
{
DataResult result = new DataResult();
try
{
if (new WorkLocDAL().IsExistsWorkLocEquip(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;
}
///
/// 删除信息
///
///
/// 删除个数
public DataResult DeleteWorkLocEquip(string strs)
{
DataResult result = new DataResult();
string[] list = strs.Split(":".ToCharArray());
try
{
foreach (string str in list)
{
result.Result += this.DeleteWorkLocEquipInfo(new WorkCellEquipment { PID = str });
}
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
///
/// 删除信息
///
/// 信息
/// 删除个数
public int DeleteWorkLocEquipInfo(WorkCellEquipment model)
{
int count = 0;
try
{
count = new WorkLocDAL().DeleteWorkLocEquip(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取(联动)工位下拉列表数据
///
/// 获取工序下拉列表数据
///
///
///
public List GetWorkLocFromWorkCellList(WorkLoc model, string routecode)
{
try
{
return new WorkLocDAL().GetWorkLocFromWorkCellList(model, routecode);
}
catch (Exception ex)
{
throw ex;
}
}
public List GetWorkLocFromWorkCenterCodeList(string workCenterCode)
{
try
{
return new WorkLocDAL().GetWorkLocFromWorkCenterCodeList(workCenterCode);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 根据工位信息获得工序信息
///
/// 获取工序下拉列表数据
///
///
///
public List GetWorkCellFromWorkLocList(WorkLoc model, string routecode)
{
try
{
return new WorkLocDAL().GetWorkCellFromWorkLocList(model, routecode);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}