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

323 lines
9.6 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.BLL;
using QMAPP.Entity;
using QMAPP.MD.Entity;
using QMFrameWork.Log;
using QMFrameWork.Data;
using QMAPP.MD.DAL;
namespace QMAPP.MD.BLL
{
/// <summary>
/// 模块名称:班组信息
/// 作 者:郭兆福
/// 编写日期:2017年05月17日
/// </summary>
public class TeamBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<Team> Get(Team model)
{
DataResult<Team> result = new DataResult<Team>();
try
{
result.Result = new TeamDAL().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(Team condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取班组信息列表
DataPage dataPage = new TeamDAL().GetList(condition, page);
result.Result = dataPage;
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
// <summary>
/// 获取全部用户
/// </summary>
/// <param name="condition">获取条件</param>
/// <returns>用户信息列表</returns>
public List<Team> GetAllTeam(Team condition)
{
return new TeamDAL().GetAllTeam(condition);
}
#region 信息是否重复
/// <summary>
/// 判断名称是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;false:不存在。</returns>
public bool ExistsTeam(Team model)
{
try
{
return new TeamDAL().ExistsTeam(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(Team model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
model = GetBaseInfo(model);
try
{
if (ExistsTeam(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.TeamCodeIsHave;
return result;
}
result.Result = new TeamDAL().Insert(model);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
/// <summary>
/// 基础信息
/// </summary>
/// <returns></returns>
public Team GetBaseInfo(Team model)
{
//----------------------基础信息--------------------
model.PID = Guid.NewGuid().ToString();
model.CREATEUSER = this.LoginUser.UserID;
model.UPDATEUSER = model.CREATEUSER;
model.FLGDEL = "0";
//--------------------------------------------------
return model;
}
#endregion
#region 更新信息
/// <summary>
/// 更新信息
/// </summary>
/// <param name=""></param>
/// <returns>更新行数</returns>
public DataResult<int> Update(Team model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
model.UPDATEUSER = this.LoginUser.UserID;
try
{
if (ExistsTeam(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.TeamCodeIsHave;
return result;
}
result.Result = new TeamDAL().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(new Team { PID = str }) == true)
{
result.IsSuccess = false;
result.Msg = Resource.WorkTeamIsUsing;
return result;
}
}
foreach (string str in list)
{
result.Result += this.DeleteWorkTeam(new Team { 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 DeleteWorkTeam(Team model)
{
int count = 0;
try
{
count = new TeamDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 班组是否使用
/// <summary>
/// 班组是否使用
/// </summary>
/// <param name="info"></param>
/// <returns>true:已使用;false:未使用。</returns>
public bool IsUsing(Team model)
{
try
{
//return new TeamDAL().IsUsing(model);
// TODO
return false;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取班组人员列表
///// <summary>
///// 获取班组人员列表
///// </summary>
///// <param name="condition">条件</param>
///// <param name="page">数据页</param>
///// <returns>数据页</returns>
//public DataPage GetTeamWorkerList(TeamMember condition, DataPage page)
//{
// DataPage result = new DataPage();
// try
// {
// //获取班组人员列表
// result = new TeamDAL().GetTeamWorkerList(condition, page);
// }
// catch (Exception ex)
// {
// throw ex;
// }
// return result;
//}
#endregion
#region 插入班组人员信息
/// <summary>
/// 插入班组人员信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
//public DataResult<int> SaveTeamWorker(List<TeamMember> data, string TEAMID)
//{
// DataResult<int> result = new DataResult<int>();
// try
// {
// foreach (var item in data)
// {
// item.PID = Guid.NewGuid().ToString();
// item.CREATEUSR = this.LoginUser.UserID;
// item.UPDATEUSR = item.CREATEUSR;
// item.CREATEDATE = DateTime.Now;
// item.UPDATEDATE = item.CREATEDATE;
// item.TEAM_PID = TEAMID;
// item.FLAGDEL = "0";
// }
// List<TeamMember> twList = new TeamDAL().GetTeamWorker(new TeamMember { TEAM_PID = TEAMID });
// using (IDataSession session = AppDataFactory.CreateMainSession())
// {
// session.OpenTs();
// session.Delete<TeamMember>(twList);
// session.Insert<TeamMember>(data);
// session.CommitTs();
// }
// result.IsSuccess = true;
// }
// catch (Exception ex)
// {
// result.IsSuccess = false;
// result.Msg = Resource.SystemException;
// throw ex;
// }
// return result;
//}
#endregion
}
}