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.
242 lines
5.8 KiB
242 lines
5.8 KiB
4 years ago
|
using System;
|
||
|
using System.Data;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using QMFrameWork.Data;
|
||
|
using QMAPP.Entity.Example;
|
||
|
using QMAPP.DAL;
|
||
|
using QMAPP.DAL.Example;
|
||
|
using QMAPP.BLL.Dict;
|
||
|
using QMAPP.Entity.Sys;
|
||
|
using QMAPP.BLL.Sys;
|
||
|
|
||
|
|
||
|
namespace QMAPP.BLL.Example
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 用户管理逻辑层对象(单表操作示例程序)
|
||
|
/// 创建者:李炳海
|
||
|
/// 创建时间:2012.11.21
|
||
|
/// </summary>
|
||
|
public class UserManageBLL:BaseBLL
|
||
|
{
|
||
|
|
||
|
#region 插入用户信息
|
||
|
|
||
|
/// <summary>
|
||
|
/// 插入用户信息
|
||
|
/// </summary>
|
||
|
/// <param name="user">用户信息</param>
|
||
|
/// <returns>插入行数</returns>
|
||
|
public int Insert(UserInfo user)
|
||
|
{
|
||
|
int count = 0;
|
||
|
try
|
||
|
{
|
||
|
user.UserID = Guid.NewGuid().ToString();
|
||
|
count = new UserManageDAL().Insert(user);
|
||
|
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 插入用户信息(主、子表)
|
||
|
/// </summary>
|
||
|
/// <param name="user">用户信息</param>
|
||
|
/// <returns>插入行数</returns>
|
||
|
public int InsertWithDetails(UserInfo user)
|
||
|
{
|
||
|
int count = 0;
|
||
|
try
|
||
|
{
|
||
|
user.UserID = Guid.NewGuid().ToString();
|
||
|
|
||
|
foreach (UserAndRole role in user.RoleList)
|
||
|
{
|
||
|
role.UserID = user.UserID;
|
||
|
}
|
||
|
|
||
|
count = new UserManageDAL().InsertWithDetails(user);
|
||
|
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 更新用户信息
|
||
|
|
||
|
/// <summary>
|
||
|
/// 更新用户信息
|
||
|
/// </summary>
|
||
|
/// <param name="user">用户信息</param>
|
||
|
/// <returns>更新行数</returns>
|
||
|
public int Update(UserInfo user)
|
||
|
{
|
||
|
int count = 0;
|
||
|
try
|
||
|
{
|
||
|
count = new UserManageDAL().Update(user);
|
||
|
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 删除用户信息
|
||
|
|
||
|
/// <summary>
|
||
|
/// 删除用户信息
|
||
|
/// </summary>
|
||
|
/// <param name="users">用户列表</param>
|
||
|
/// <returns>删除用户数</returns>
|
||
|
public int Delete(string[] users,UserInfo user)
|
||
|
{
|
||
|
int count = 0;
|
||
|
try
|
||
|
{
|
||
|
foreach (string userID in users)
|
||
|
{
|
||
|
count += this.Delete(new UserInfo {UserID=userID });
|
||
|
}
|
||
|
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 删除用户信息
|
||
|
/// </summary>
|
||
|
/// <param name="user">用户信息</param>
|
||
|
/// <returns>删除行数</returns>
|
||
|
public int Delete(UserInfo user)
|
||
|
{
|
||
|
int count = 0;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
count = new UserManageDAL().Delete(user);
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 获取单个用户信息
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取单个用户信息
|
||
|
/// </summary>
|
||
|
/// <param name="user">查询条件</param>
|
||
|
/// <returns>用户信息</returns>
|
||
|
public UserInfo Get(UserInfo user)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return new UserManageDAL().Get(user);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 获取用户列表
|
||
|
|
||
|
///// <summary>
|
||
|
///// 获取用户列表
|
||
|
///// </summary>
|
||
|
///// <param name="user">查询条件</param>
|
||
|
///// <returns>用户列表</returns>
|
||
|
//public List<UserInfo> GetList(UserInfo user)
|
||
|
//{
|
||
|
// try
|
||
|
// {
|
||
|
// return new UserManageDAL().GetList(user);
|
||
|
// }
|
||
|
// catch (Exception ex)
|
||
|
// {
|
||
|
// throw ex;
|
||
|
// }
|
||
|
//}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取用户列表(数据库端分页)
|
||
|
/// </summary>
|
||
|
/// <param name="user">查询条件</param>
|
||
|
/// <returns>数据页</returns>
|
||
|
public DataPage GetList(UserInfo user, DataPage page)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
page = new UserManageDAL().GetMyList(user, page);
|
||
|
|
||
|
////处理字典信息
|
||
|
//DictManagerBLL dictBll = new DictManagerBLL(DictKind.Sex);
|
||
|
//List<UserInfo> list=page.Result as List<UserInfo>;
|
||
|
//foreach (UserInfo info in list)
|
||
|
//{
|
||
|
// //替换性别显示值
|
||
|
// info.Sex = dictBll.GetDictValue(info.Sex);
|
||
|
//}
|
||
|
|
||
|
return page;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 获取导出的数据
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取导出的数据
|
||
|
/// </summary>
|
||
|
/// <param name="user">查询条件</param>
|
||
|
/// <returns>数据</returns>
|
||
|
public DataTable GetExportData(UserInfo user)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return new UserManageDAL().GetExportData(user);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|