using System;
using System.Collections.Generic;
using QMAPP.BLL;
using QMAPP.Entity;
using QMAPP.FJC.BLL.Dict;
using QMAPP.FJC.DAL.ProduceManage;
using QMAPP.FJC.Entity.ProduceManage;
using QMFrameWork.Data;
using QMFrameWork.Log;
using QMAPP.FJC.Entity;
using QMAPP.MD.Entity.Bucket;
using QMAPP.FJC.DAL.Bucket;
namespace QMAPP.FJC.BLL.Bucket
{
///
/// 模块名称:注塑投料记录
/// 作 者:张松男
/// 编写日期:2021年07月13日
///
public class RawMaterialBLL : BaseBLL
{
#region 获取信息
///
/// 获取信息
///
/// 条件
/// 信息
public DataResult Get(RawMaterial model)
{
DataResult result = new DataResult();
try
{
result.Result = new RawMaterialDAL().Get(model);
result.IsSuccess = true;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "获取异常!"
});
result.IsSuccess = false;
result.Ex = ex;
result.Msg = "获取异常";
}
return result;
}
#endregion
#region 获取列表
///
/// 获取列表
///
/// 条件
/// 数据页
/// 数据页
public DataResult GetList(RawMaterial condition, DataPage page)
{
//DataPage result = new DataPage();
DataResult result = new DataResult();
result.IsSuccess = true;
try
{
result.Result = new RawMaterialDAL().GetList(condition, page);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "获取列表异常!"
});
result.IsSuccess = false;
result.Msg = "获取数据异常";
}
return result;
}
///
/// 获取列表
///
/// 条件
/// 数据页
/// 数据页
public List GetListTo(RawMaterial condition)
{
try
{
return new RawMaterialDAL().GetListTo(condition);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "获取列表异常!"
});
}
return new List();
}
///
/// 获取列表
///
/// 条件
/// 数据页
/// 数据页
public List GetListRaw(RawMaterial condition)
{
try
{
return new RawMaterialDAL().GetListRaw(condition);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "获取列表异常!"
});
}
return new List();
}
///
/// 获取列表
///
/// 条件
/// 全部集合
public DataPage GetAllList(RawMaterial condition,DataPage page)
{
try
{
//获取信息列表
DataPage list = new RawMaterialDAL().GetList(condition, page);
return list;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "获取列表异常!"
});
throw ex;
}
}
#endregion
#region 插入信息
///
/// 插入信息(单表)
///
/// 信息
/// 插入行数
public DataResult Insert(RawMaterial info)
{
DataResult result = new DataResult();
try
{
//基本信息
info.PID = Guid.NewGuid().ToString();
info.CREATEUSER = this.LoginUser.UserID;
info.CREATEDATE = DateTime.Now.ToString();
info.UPDATEUSER = info.CREATEUSER;
info.UPDATEDATE = info.CREATEDATE;
info.IsCheck = "0";
RawMaterialDAL cmdDAL = new RawMaterialDAL();
result.Result = cmdDAL.Insert(info);
result.IsSuccess = true;
result.Msg = "保存成功";
return result;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 更新信息
///
/// 更新信息
///
///
/// 更新行数
public DataResult Update(RawMaterial model)
{
DataResult result = new DataResult();
result.IsSuccess = true;
result.Msg = "更新成功!";
try
{
RawMaterial info = new RawMaterialDAL().Get(model);
//基本信息
info.IsCheck = model.IsCheck;
info.BucketCode = model.BucketCode;
info.BatchCode = model.BatchCode;
info.PartCode = model.PartCode;
info.SerialCode = model.SerialCode;
info.CREATEUSER = model.CREATEUSER;
info.CREATEDATE = model.CREATEDATE;
info.UPDATEDATE = DateTime.Now.ToString();
info.UPDATEUSER = this.LoginUser.UserID;
int temp = new RawMaterialDAL().Update(info);
if (temp == 0)
{
result.IsSuccess = false;
result.Msg = "更新失败!";
return result;
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "更新异常!"
});
result.IsSuccess = false;
result.Ex = ex;
result.Msg = "更新异常";
}
return result;
}
#endregion
#region 删除
///
/// 删除信息
///
/// 信息
/// 删除个数
public int Delete(string model)
{
int count = 0;
try
{
count = new RawMaterialRecordDAL().GetMaterialCodeCount(model);
if (count <= 0)
{
count = new RawMaterialDAL().Delete(model);
return count;
}
else
return 0;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}