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

292 lines
8.5 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.BLL;
using QMAPP.MD.Entity;
using QMAPP.Entity;
using QMAPP.MD.DAL;
using QMFrameWork.Data;
using QMAPP.MD.BLL.Dict;
namespace QMAPP.MD.BLL
{
public class ProjectBLL : BaseBLL
{
#region 获取设备下拉列表
/// <summary>
/// 获取设备下拉列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>数据页</returns>
public DataResult<List<Project>> GetProjectList(Project condition)
{
DataResult<List<Project>> result = new DataResult<List<Project>>();
try
{
result.Result = new ProjectDAL().GetList(condition);
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
return result;
}
}
#endregion
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<Project> Get(Project model)
{
DataResult<Project> result = new DataResult<Project>();
try
{
result.Result = new ProjectDAL().Get(model);
}
catch (Exception ex)
{
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(Project condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取信息列表
DataPage dataPage = new ProjectDAL().GetList(condition, page);
result.Result = dataPage;
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>全部集合</returns>
public List<Project> GetAllList(Project condition)
{
try
{
List<Project> list = new ProjectDAL().GetList(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
/// <summary>
/// 判断项目号是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;fasel:不存在。</returns>
public DataResult<bool> IsExistsProject(Project model)
{
DataResult<bool> result = new DataResult<bool>();
try
{
if (new ProjectDAL().IsExistsProjectCodeName(model) == true)
{
result.IsSuccess = false;
result.Msg = "相同的项目号已经存在";
return result;
}
}
catch (Exception ex)
{
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> Insert(Project 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;
ProjectDAL cmdDAL = new ProjectDAL();
try
{
DataResult<bool> isExist = new DataResult<bool>();
isExist = IsExistsProject(model);
if (isExist.IsSuccess == false)
{
result.IsSuccess = false;
result.Msg = isExist.Msg;
return result;
}
result.Result = new ProjectDAL().Insert(model);
}
catch (Exception ex)
{
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(Project model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
model.UPDATEUSER = this.LoginUser.UserID;
model.UPDATEDATE = DateTime.Now;
try
{
DataResult<bool> isExist = new DataResult<bool>();
isExist = IsExistsProject(model);
if (isExist.IsSuccess == false)
{
result.IsSuccess = false;
result.Msg = isExist.Msg;
return result;
}
result.Result = new ProjectDAL().Update(model);
}
catch (Exception ex)
{
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(list) == true)
{
result.IsSuccess = false;
result.Msg = "项目号已经在使用无法删除";
return result;
}
}
foreach (string str in list)
{
result.Result += this.DeleteProject(new Project { PID = str });
}
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="">信息</param>
/// <returns>删除个数</returns>
public int DeleteProject(Project model)
{
int count = 0;
try
{
count = new ProjectDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 项目号是否使用
/// <summary>
/// 项目号是否使用
/// </summary>
/// <param name="info"></param>
/// <returns>true:已使用;fasel:未使用。</returns>
public bool IsUsing(string[] pid)
{
try
{
return new ProjectDAL().IsUsing(pid);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}