📄 hoteluserbll.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using IDAL;
using Factory;
using Model;
using System.Data;
//51aspx
namespace BLL
{
public class HotelUserBLL
{
private readonly IHotelUser userOp = null;
public HotelUserBLL()
{
userOp = AbstractFactory.GetFactory().CreateHotelUser();
}
/// <summary>
/// 按用户名得到用户密码
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public string GetUserPasswordByUserName(string name)
{
try
{
return userOp.GetUserPasswordByUserName(name);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 添加用户
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
public bool AddUser(HotelUser user)
{
try
{
return userOp.AddUser(user);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 得到所有的用户信息
/// </summary>
/// <returns></returns>
public DataTable GetAllUsers()
{
IList<HotelUser> lists = new List<HotelUser>();
try
{
lists = userOp.GetAllUsers();
}
catch (Exception ex)
{
throw ex;
}
return GetTable(lists);
}
/// <summary>
/// 分解IList得到DataTable
/// </summary>
/// <param name="hotelUser"></param>
/// <returns></returns>
private DataTable GetTable(IList<HotelUser> hotelUser)
{
DataTable table = new DataTable("HotelUser");
if (hotelUser != null)
{
try
{
table.Columns.Add("UserName");
table.Columns.Add("Password");
foreach (HotelUser temp in hotelUser)
{
object[] num = new object[2];
num[0] = temp.UserName as object;
num[1] = temp.PassWord as object;
DataRow row = table.NewRow();
row.ItemArray = num;
table.Rows.Add(row);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message + ex.StackTrace);
}
}
return table;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -