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

328 lines
9.6 KiB

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.Entity;
using QMAPP.Entity;
using QMFrameWork.Log;
namespace QMAPP.FJC.BLL.Basic
{
/// <summary>
/// 模块编号:M13-1
/// 作 用:零件基本类别
/// 作 者:王庆男
/// 编写日期:2015年06月09日
///</summary>
public class ProductBasicBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<ProductBasic> Get(ProductBasic model)
{
DataResult<ProductBasic> result = new DataResult<ProductBasic>();
try
{
result.Result = new ProductBasicDAL().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;
}
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public ProductBasic GetByCode(ProductBasic model)
{
try
{
List<ProductBasic> list = new ProductBasicDAL().GetList(model);
if (list.Count > 0)
{
return list[0];
}
return null;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取列表
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataResult<DataPage> GetList(ProductBasic condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取零件类别列表
DataPage dataPage = new ProductBasicDAL().GetList(condition, page);
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<ProductBasic> GetAllList(ProductBasic condition)
{
try
{
return new ProductBasicDAL().GetList(condition);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
/// <summary>
/// 判断名称是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool ExistsProductBasic(ProductBasic model)
{
try
{
return new ProductBasicDAL().ExistsProductBasic(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(ProductBasic model)
{
int number = new ProductBasicDAL().GetType(model);
DataResult<int> result = new DataResult<int>();
//基本信息
model.PID = Guid.NewGuid().ToString();
model.DELFLAG = "0";
model.PRODUCTTYPE = Convert.ToString(number + 1);
model.CREATEUSER = this.LoginUser.UserID;
model.CREATEDATE = DateTime.Now;
model.UPDATEUSER = model.CREATEUSER;
model.UPDATEDATE = model.CREATEDATE;
ProductBasicDAL cmdDAL = new ProductBasicDAL();
try
{
if (ExistsProductBasic(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.MaterielCodeIsHave;
return result;
}
result.Result = new ProductBasicDAL().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(ProductBasic model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
model.UPDATEUSER = this.LoginUser.UserID;
try
{
if (ExistsProductBasic(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.MaterielCodeIsHave;
return result;
}
result.Result = new ProductBasicDAL().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)
{
int count = 0;
DataResult<int> result = new DataResult<int>();
string[] list = strs.Split(":".ToCharArray());
try
{
foreach (string str in list)
{
count += this.DeleteProductBasic(new ProductBasic { PID = str });
}
if (count == 0)
{
result.IsSuccess = false;
return result;
}
result.Result = count;
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="">信息</param>
/// <returns>删除个数</returns>
public int DeleteProductBasic(ProductBasic model)
{
int count = 0;
int number = new ProductBasicDAL().DelCheck(model);
if (number > 0)
{
return count;
}
try
{
count = new ProductBasicDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取零件类别列表(绑定下拉列表使用)
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>全部集合</returns>
public DataResult<List<ProductBasic>> GetProductBasicList(ProductBasic condition)
{
DataResult<List<ProductBasic>> result = new DataResult<List<ProductBasic>>();
try
{
result.Result = new ProductBasicDAL().GetProductBasicList(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
}
}