using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMFrameWork.Data;
using QMAPP.Entity.Sys;
using QMAPP.Entity.Sys.Entity;
using QMAPP.DAL.Sys;
using System.Collections;
using System.Data;
namespace QMAPP.BLL.Sys
{
/// 组织机构管理
/// 创建者:郭佳伟
/// 创建日期:2013.1.16
public class OrgaizationManageBLL : BaseBLL
{
#region 获取组织机构列表
///
/// 获取组织机构列表
///
/// 条件
/// 数据页
/// 数据页
public DataPage GetList(Orgaization condition, DataPage page)
{
List list = null;
try
{
new OrgaizationManageDAL().GetList(condition, page);
list = page.Result as List;
foreach (Orgaization o in list)
{
o.ACTIVATEFLG =o.ACTIVATEFLG=="1"?"是":"否";
}
page.Result = list;
return page;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取组织机构树形列表
///
/// 获取组织机构树形列表
///
/// 数据页
public List GetSubTreeList(Orgaization orga)
{
try
{
return new OrgaizationManageDAL().GetSubTreeList(orga);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 判断组织机构编号及名称是否重复
///
/// 判断组织机构编号及名称是否重复
///
/// 组织机构信息
/// true:已存在;fasel:不存在。
public bool ExistsOrga(Orgaization orga)
{
try
{
return new OrgaizationManageDAL().ExistsOrga(orga);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取组织机构数菜单列表
///
/// 获取所有组织机构数菜单列表
///
/// 条件
/// 同级别菜单列表
public List GetAllList()
{
try
{
return new OrgaizationManageDAL().GetAllList();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取组织机构信息
///
/// 获取组织机构所有的权限
///
/// 条件
/// 同级别菜单列表
public Orgaization GetOrgaAuthorityList(Orgaization orga)
{
try
{
return new OrgaizationManageDAL().GetOrgaAuthorityList(orga);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取组织机构信息
///
/// 获取组织机构信息
///
/// 条件
/// 组织机构信息
public Orgaization Get(Orgaization orga)
{
return new OrgaizationManageDAL().Get(orga);
}
///
/// 获取机构角色
///
/// 获取条件
/// 机构角色
public Orgaization GetOrganRoleList(Orgaization organ)
{
return new OrgaizationManageDAL().GetOrganRoleList(organ);
}
#endregion
#region 插入组织机构与人员信息
///
/// 插入组织机构与人员信息
///
/// 组织机构与人员信息
/// 插入数
public int InsertOrgaUser(UserOrgaization userorga)
{
try
{
userorga.CreateTime = DateTime.Now;
userorga.CreateUser = userorga.CreateUser;
userorga.UpdateTime = userorga.CreateTime;
userorga.UpdateUser = userorga.UpdateUser;
return new OrgaizationManageDAL().InsertOrgaUser(userorga);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入组织机构信息
///
/// 插入组织机构
///
/// 组织机构信息
/// 插入数
public int Insert(Orgaization orga)
{
try
{
if (orga.OrgaAuthorityList != null)
{
foreach (OrgaizationAuthority a in orga.OrgaAuthorityList)
{
a.OrgaID = orga.OrgaID;
a.CreateUser = this.LoginUser.UserID;
a.UpdateUser = this.LoginUser.UserID;
}
}
if (orga.RoleList != null)
{
foreach (T_QM_ORGANROLE a in orga.RoleList)
{
a.ORGANID = orga.OrgaID;
a.CREATEUSER = this.LoginUser.UserID;
a.UPDATEUSER = this.LoginUser.UserID;
}
}
orga.CreateUser = this.LoginUser.UserID;
orga.UpdateUser = this.LoginUser.UserID;
return new OrgaizationManageDAL().Insert(orga);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 删除组织机构与人员的关系
///
/// 删除组织机构与人员的关系
///
/// 组织机构信息
/// 删除个数
public int BatchDeleteOrgaUser(ArrayList users)
{
int count = 0;
try
{
foreach (string user in users)
{
count += this.DeleteOrgaUser(new UserOrgaization { UserID = user.Split(",".ToCharArray())[0], OrgaID = user.Split(",".ToCharArray())[1], IsMainOgra = user.Split(",".ToCharArray())[2] });
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 删除组织机构与人员的关系
///
/// 组织机构信息
/// 删除行数
public int DeleteOrgaUser(UserOrgaization orga)
{
int count = 0;
try
{
count = new OrgaizationManageDAL().DeleteOrgaUser(orga);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 删除组织机构
///
/// 删除组织机构信息
///
/// 组织机构信息
/// 删除个数
public int BatchDelete(ArrayList orgas)
{
int count = 0;
try
{
foreach (string orga in orgas)
{
count += this.Delete(new Orgaization { OrgaID = orga });
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 删除组织机构信息
///
/// 组织机构信息
/// 删除行数
public int Delete(Orgaization orga)
{
int count = 0;
try
{
count = new OrgaizationManageDAL().Delete(orga);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 更新组织机构
///
/// 更新组织机构
///
/// 组织机构信息
/// 更新个数
public int Update(Orgaization orga)
{
try
{
if (orga.OrgaAuthorityList != null)
{
foreach (OrgaizationAuthority a in orga.OrgaAuthorityList)
{
a.OrgaID = orga.OrgaID;
a.CreateUser = this.LoginUser.UserID;
a.UpdateUser = this.LoginUser.UserID;
}
}
if (orga.RoleList != null)
{
foreach (T_QM_ORGANROLE a in orga.RoleList)
{
a.ORGANID = orga.OrgaID;
a.CREATEUSER = this.LoginUser.UserID;
a.UPDATEUSER = this.LoginUser.UserID;
}
}
orga.UpdateUser = this.LoginUser.UserID;
orga.DelFlag = "0";
return new OrgaizationManageDAL().Update(orga);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取导出的数据
///
/// 获取导出的数据
///
/// 查询条件
/// 数据
public DataTable GetExportData(Orgaization condition)
{
return new OrgaizationManageDAL().GetExportData(condition);
}
#endregion
}
}