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

288 lines
8.5 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.BLL;
using QMAPP.Entity;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.DAL.Basic;
using QMFrameWork.Log;
using QMAPP.FJC.Entity;
using QMFrameWork.Data;
namespace QMAPP.FJC.BLL.Basic
{
public class CorpBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<Corp> Get(Corp model)
{
DataResult<Corp> result = new DataResult<Corp>();
try
{
result.Result = new CorpDAL().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(Corp condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取公司信息列表
DataPage dataPage = new CorpDAL().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<Corp> GetAllList(Corp condition)
{
try
{
//获取公司信息列表
List<Corp> list = new CorpDAL().GetAllList(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
/// <summary>
/// 判断名称是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool ExistsPlant(Corp model)
{
try
{
return new CorpDAL().ExistsCorp(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(Corp model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
model.PID = Guid.NewGuid().ToString();
model.CREATEUSER = this.LoginUser.UserID;
model.CREATEDATE = DateTime.Now;
model.UPDATEUSER = model.CREATEUSER;
model.UPDATEDATE = model.CREATEDATE;
CorpDAL cmdDAL = new CorpDAL();
try
{
if (ExistsPlant(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.MaterielCodeIsHave;
return result;
}
result.Result = new CorpDAL().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(Corp model)
{
DataResult<int> result = new DataResult<int>();
model.UPDATEUSER = this.LoginUser.UserID;
try
{
if (ExistsPlant(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.MaterielCodeIsHave;
return result;
}
result.Result = new CorpDAL().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;
string[] list = strs.Split(":".ToCharArray());
DataResult<int> result = new DataResult<int>();
try
{
foreach (string str in list)
{
count += this.DeletePlant(new Corp { 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 DeletePlant(Corp model)
{
int count = 0;
//int number = new CorpDAL().DelCheck(model);
//if (number > 0)
//{
//return count;
//}
//try
//{
count = new CorpDAL().Delete(model);
return count;
//}
//catch (Exception ex)
//{
//throw ex;
///}
}
#endregion
#region 获取公司列表(下拉列表使用)
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>全部集合</returns>
public DataResult<List<Corp>> GetCorpList(Corp condition)
{
DataResult<List<Corp>> result = new DataResult<List<Corp>>();
try
{
result.Result = new CorpDAL().GetCorpList(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
}
}