using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.BLL;
using QMAPP.Entity;
using QMAPP.MD.DAL;
using QMFrameWork.Log;
using QMAPP.MD.Entity;
using QMFrameWork.Data;
namespace QMAPP.MD.BLL
{
///
/// 模块名称:公司
/// 作 者:郭兆福
/// 编写日期:2017年05月05日
///
public class CorpBLL : BaseBLL
{
#region 获取信息
///
/// 获取信息
///
/// 信息
public DataResult Get(Corp model)
{
DataResult result = new DataResult();
try
{
result.Result = new CorpDAL().Get();
}
catch (Exception ex)
{
result.IsSuccess = false;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 判断公司是否被使用
///
/// 判断公司是否被使用
///
/// 公司编码
/// true:使用 false:未使用
public bool IsCorpUsed(string corpCode)
{
try
{
return new CorpDAL().IsCorpUsed(corpCode);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
///
/// 判断名称是否存在
///
///
/// true:已存在;false:不存在。
public bool ExistsCorp()
{
try
{
return new CorpDAL().ExistsCorp();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
///
/// 插入信息(单表)
///
/// 信息
/// 插入行数
public DataResult Insert(Corp model)
{
DataResult result = new DataResult();
//基本信息
model.PID = Guid.NewGuid().ToString();
model.CREATEUSER = this.LoginUser.UserID;
model.UPDATEUSER = model.CREATEUSER;
model.CREATEDATE = DateTime.Now;
model.UPDATEDATE = model.CREATEDATE;
CorpDAL cmdDAL = new CorpDAL();
try
{
if (ExistsCorp() == true)
{
result.IsSuccess = false;
result.Msg = Resource.CorpExists;
return result;
}
result.Result = new CorpDAL().Insert(model);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 更新信息
///
/// 更新信息
///
///
/// 更新行数
public DataResult Update(Corp model)
{
DataResult result = new DataResult();
try
{
if (model.CORP_CODE_OLD != model.CORP_CODE)
{
if (IsCorpUsed(model.CORP_CODE_OLD) == true)
{
result.IsSuccess = false;
result.Msg = Resource.CorpUsed;
return result;
}
}
model.UPDATEUSER = this.LoginUser.UserID;
model.UPDATEDATE = DateTime.Now;
result.Result = new CorpDAL().Update(model);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
}
}