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
{
///
/// 模块名称:班组信息
/// 作 者:郭兆福
/// 编写日期:2017年05月17日
///
public class TeamBLL : BaseBLL
{
#region 获取信息
///
/// 获取信息
///
/// 条件
/// 信息
public DataResult Get(Team model)
{
DataResult result = new DataResult();
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 获取列表
///
/// 获取列表
///
/// 条件
/// 数据页
/// 数据页
public DataResult GetList(Team condition, DataPage page)
{
DataResult result = new DataResult();
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
//
/// 获取全部用户
///
/// 获取条件
/// 用户信息列表
public List GetAllTeam(Team condition)
{
return new TeamDAL().GetAllTeam(condition);
}
#region 信息是否重复
///
/// 判断名称是否存在
///
///
/// true:已存在;false:不存在。
public bool ExistsTeam(Team model)
{
try
{
return new TeamDAL().ExistsTeam(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
///
/// 插入信息(单表)
///
/// 信息
/// 插入行数
public DataResult Insert(Team model)
{
DataResult result = new DataResult();
//基本信息
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;
}
///
/// 基础信息
///
///
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 更新信息
///
/// 更新信息
///
///
/// 更新行数
public DataResult Update(Team model)
{
DataResult result = new DataResult();
//基本信息
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 删除
///
/// 删除信息
///
///
/// 删除个数
public DataResult Delete(string strs)
{
DataResult result = new DataResult();
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;
}
///
/// 删除信息
///
/// 信息
/// 删除个数
public int DeleteWorkTeam(Team model)
{
int count = 0;
try
{
count = new TeamDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 班组是否使用
///
/// 班组是否使用
///
///
/// true:已使用;false:未使用。
public bool IsUsing(Team model)
{
try
{
//return new TeamDAL().IsUsing(model);
// TODO
return false;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取班组人员列表
/////
///// 获取班组人员列表
/////
///// 条件
///// 数据页
///// 数据页
//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 插入班组人员信息
///
/// 插入班组人员信息(单表)
///
/// 信息
/// 插入行数
//public DataResult SaveTeamWorker(List data, string TEAMID)
//{
// DataResult result = new DataResult();
// 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 twList = new TeamDAL().GetTeamWorker(new TeamMember { TEAM_PID = TEAMID });
// using (IDataSession session = AppDataFactory.CreateMainSession())
// {
// session.OpenTs();
// session.Delete(twList);
// session.Insert(data);
// session.CommitTs();
// }
// result.IsSuccess = true;
// }
// catch (Exception ex)
// {
// result.IsSuccess = false;
// result.Msg = Resource.SystemException;
// throw ex;
// }
// return result;
//}
#endregion
}
}