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 QMAPP.FJC.BLL.Dict;
using QMFrameWork.Data;
using QMAPP.FJC.Entity;
using QMAPP.Entity;
namespace QMAPP.FJC.BLL.Basic
{
///
/// 模块编号:M13-1
/// 作 用:先决条件校验规则
/// 作 者:王庆男
/// 编写日期:2015年06月09日
///
public class ProcessRuleBLL : BaseBLL
{
#region 获取信息
///
/// 获取信息
///
/// 条件
/// 信息
public ProcessRule Get(ProcessRule model)
{
try
{
return new ProcessRuleDAL().Get(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取列表
///
/// 获取列表
///
/// 条件
/// 数据页
/// 数据页
public DataPage GetList(ProcessRule condition, DataPage page)
{
try
{
DictManageBLL processTypedict = new DictManageBLL(DictKind.PROCESSTYPE);
page = new ProcessRuleDAL().GetList(condition, page);
return page;
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 冷却工序
///
///
///
///
public DataPage GetListForSet(ProcessRule condition, DataPage page)
{
try
{
DictManageBLL processTypedict = new DictManageBLL(DictKind.PROCESSTYPE);
DictManageBLL ruleTypedict = new DictManageBLL(DictKind.RULETYPE);
page = new ProcessRuleDAL().GetListForSet(condition, page);
List list = page.Result as List;
foreach (var p in list)
{
p.RULECONTENT = processTypedict.GetDictValue(p.RULECONTENT);
p.RULETYPE = ruleTypedict.GetDictValue(p.RULETYPE);
}
page.Result = list;
return page;
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 获取列表
///
/// 条件
/// 数据
public List GetAllList(ProcessRule condition)
{
try
{
#region 转换设备状态、接收控制指令、工序类别显示类型
List list = new ProcessRuleDAL().GetList(condition);
DictManageBLL dictRuleType = new DictManageBLL(DictKind.RULETYPE);
foreach (ProcessRule m in list)
{
//设备状态
m.RULETYPETEXT = dictRuleType.GetDictValue(m.RULETYPE);
}
#endregion
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
///
/// 判断名称是否存在
///
///
/// true:已存在;fasel:不存在。
public bool ExistsProcessRule(ProcessRule model)
{
try
{
return new ProcessRuleDAL().ExistsRule(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
///
/// 插入信息(单表)
///
/// 信息
/// 插入行数
public int Insert(ProcessRule model)
{
try
{
//基本信息
model.PID = Guid.NewGuid().ToString();
model.CREATEUSER = this.LoginUser.UserID;
model.CREATEDATE = DateTime.Now;
model.UPDATEUSER = model.CREATEUSER;
model.UPDATEDATE = model.CREATEDATE;
ProcessRuleDAL cmdDAL = new ProcessRuleDAL();
if (ExistsProcessRule(model) == true)
return -1;
return new ProcessRuleDAL().Insert(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 更新信息
///
/// 更新信息
///
///
/// 更新行数
public DataResult Update(ProcessRule model)
{
try
{
DataResult result = new DataResult();
result.IsSuccess = true;
model.UPDATEUSER = this.LoginUser.UserID;
int i = new ProcessRuleDAL().Update(model);
if (i == 0)
{
result.IsSuccess = false;
}
result.Result = i;
return result;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 删除
///
/// 删除信息
///
///
/// 删除个数
public int Delete(string strs)
{
int count = 0;
string[] list = strs.Split(":".ToCharArray());
try
{
foreach (string str in list)
{
count += this.DeleteProcessRule(new ProcessRule { PID = str });
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 删除信息
///
/// 信息
/// 删除个数
public int DeleteProcessRule(ProcessRule model)
{
int count = 0;
try
{
count = new ProcessRuleDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}