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

302 lines
9.5 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.Entity;
using QMFrameWork.Data;
using QMAPP.FJC.DAL.Basic;
using QMAPP.FJC.Entity.Basic;
using QMFrameWork.Log;
using QMAPP.FJC.Entity;
using QMAPP.BLL;
namespace QMAPP.FJC.BLL.Basic
{
public class MaterielVersionBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<MaterielVersion> Get(MaterielVersion model)
{
DataResult<MaterielVersion> result = new DataResult<MaterielVersion>();
try
{
result.Result = new MaterielVersionDAL().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 获取列表
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataResult<DataPage> GetList(MaterielVersion condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取物料信息列表
DataPage dataPage = new MaterielVersionDAL().GetList(condition, page);
#region 转换物料类别、工序类别显示类型
//List<MaterielVersion> materielList = dataPage.Result as List<MaterielVersion>;
//DictManageBLL dictMaterielVersionTypeBll = new DictManageBLL(DictKind.MATERIALTYPE);
//DictManageBLL dictProcessTypeBll = new DictManageBLL(DictKind.PROCESSTYPE);
//foreach (MaterielVersion m in materielList)
//{
// //物料类别
// m.MATERIALTYPETXT = dictMaterielVersionTypeBll.GetDictValue(m.MATERIALTYPE);
// //工序类别
// m.PROCESSTYPETXT = dictProcessTypeBll.GetDictValue(m.PROCESSTYPE);
//}
#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;
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>全部集合</returns>
public List<MaterielVersion> GetAllList(MaterielVersion condition)
{
try
{
//获取物料信息列表
List<MaterielVersion> list = new MaterielVersionDAL().GetList(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
/// <summary>
/// 判断名称是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool ExistsMateriel(MaterielVersion model)
{
try
{
return new MaterielVersionDAL().ExistsMateriel(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(MaterielVersion model)
{
string materialcode = new MaterielVersionDAL().GetCode(model);
DataResult<int> result = new DataResult<int>();
//基本信息
model.PID = Guid.NewGuid().ToString();
model.FLAGDEL = "0";
model.MATERIAL_CODE = materialcode;
model.CREATEUSR = this.LoginUser.UserID;
model.CREATEDATE = DateTime.Now;
model.UPDATEUSR = model.CREATEUSR;
model.UPDATEDATE = model.CREATEDATE; ;
MaterielVersionDAL cmdDAL = new MaterielVersionDAL();
try
{
if (ExistsMateriel(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.MaterielCodeIsHave;
return result;
}
result.Result = new MaterielVersionDAL().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 更新信息
/// <summary>
/// 更新信息
/// </summary>
/// <param name=""></param>
/// <returns>更新行数</returns>
public DataResult<int> Update(MaterielVersion model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
model.UPDATEUSR = this.LoginUser.UserID;
try
{
if (ExistsMateriel(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.MaterielCodeIsHave;
return result;
}
result.Result = new MaterielVersionDAL().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 删除
/// <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
{
//foreach (string str in list)
//{
// if (IsUsing(new MaterielVersion { PID = str }) == true)
// {
// result.IsSuccess = false;
// result.Msg = Resource.MaterielIsUsing;
// return result;
// }
//}
foreach (string str in list)
{
result.Result += this.DeleteMateriel(new MaterielVersion { 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;
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="">信息</param>
/// <returns>删除个数</returns>
public int DeleteMateriel(MaterielVersion model)
{
int count = 0;
try
{
count = new MaterielVersionDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
//#region 物料号是否使用(删除校验)
///// <summary>
///// 物料号是否使用
///// </summary>
///// <param name="info"></param>
///// <returns>true:已使用;fasel:未使用。</returns>
//public bool IsUsing(MaterielVersion model)
//{
// try
// {
// return new MaterielVersionDAL().IsUsing(model);
// }
// catch (Exception ex)
// {
// throw ex;
// }
//}
//#endregion
}
}