using M = MODEL;
namespace BLL
public class User
{
DAL.User du = new DAL.User();
/// <summary>
/// 根据用户名和密码获取ID
/// </summary>
/// <param name="name">用户名</param>
/// <param name="pwd">密码</param>
/// <returns></returns>
public int GetId(string name,string pwd)
{
return du.GetId(name, pwd);
}
/// <summary>
/// 根据用户名和密码判断用户是否存在
/// </summary>
/// <param name="name">用户名</param>
/// <param name="pwd">密码</param>
/// <returns></returns>
public bool Exists(string name,string pwd)
{
MODEL.User mu = new MODEL.User();
mu.U_name = name;
mu.U_pwd = pwd;
return du.Exists(mu);
}
/// <summary>
/// 根据用户名和密码判断用户是否存在
/// </summary>
/// <param name="name">用户名</param>
/// <returns></returns>
public bool Exists(string name)
{
string where = "u_user='" + name + "'";
int i = du.Count(where);
if (i <= 0)
return false;
else
return true;
}
/// <summary>
/// 返回当前用户总数
/// </summary>
/// <returns></returns>
public int Count()
{
return du.Count();
}
/// <summary>
/// 返回系统中符合条件的数据行数量
/// </summary>
/// <param name="where">要查询的条件,例如 "name like '%thc%'"</param>
/// <returns></returns>
public int Count(string where)
{
return du.Count(where);
}
/// <summary>
///添加一个实体到数据库
/// </summary>
/// <param name="model">要添加的实体</param>
/// <returns></returns>
public int Add(M.User model)
{
if(!Exists(model.U_name))
return du.Add(model);
else
return 0;
}
/// <summary>
/// 根据用户名和密码添加一个用户
/// </summary>
/// <param name="name">用户名</param>
/// <param name="pwd">密码</param>
/// <returns></returns>
public int Add(string name,string pwd)
{
MODEL.User mu = new MODEL.User();
mu.U_name = name;
mu.U_pwd = pwd;
return du.Add(mu);
}
/// <summary>
/// 根据传入的实体对象更新数据库
/// </summary>
/// <param name="model">要更新的实体对象</param>
/// <returns></returns>
public bool Update(M.User model)
{
return du.Update(model);
}
/// <summary>
/// 删除指定的数据行
/// </summary>
/// <param name="u_id">要删除的对象ID</param>
/// <returns></returns>
public bool Delete(int u_id)
{
return du.Delete(u_id);
}
/// <summary>
/// 删除一个实体
/// </summary>
/// <param name="model">目标实体</param>
/// <returns></returns>
public bool Delete(M.User model)
{
return du.Delete(model.U_id);
}
/// <summary>
/// 根据条件进行删除
/// </summary>
/// <param name="where">要删除那些条件的数据行</param>
/// <returns></returns>
public int Delete(string where)
{
bool tf = true;
return du.Delete(where, tf);
}
/// <summary>
/// 查询指定ID的实体
/// </summary>
/// <param name="id">要查询的实体ID</param>
/// <returns></returns>
public MODEL.User GetModel(int id)
{
return du.GetModel(id);
}
/// <summary>
/// 根据用户名和密码获取该实体的全部内容
/// </summary>
/// <param name="name">用户名</param>
/// <param name="pwd">密码</param>
/// <returns></returns>
public MODEL.User GetModel(string name,string pwd)
{
int id=GetId(name, pwd);
return du.GetModel(id);
}
/// <summary>
/// 返回全部用户列表
/// </summary>
/// <returns></returns>
public DataSet GetAll()
{
return du.GetAll();
}
/// <summary>
/// 返回符合条件的数据行为一个DataSet
/// </summary>
/// <param name="where">要查询的条件,例如 "name like '%thc%'"</param>
/// <returns></returns>
public DataSet GetAll(string where)
{
return du.GetAll(where);
}
/// <summary>
/// 返回一个数据流
/// </summary>
/// <returns></returns>
public SqlDataReader GetReader()
{
return du.GetReader();
}
/// <summary>
/// 返回符合条件的数据行为一个DataReader
/// </summary>
/// <param name="where">要查询的条件,例如 "name like '%thc%'"</param>
/// <returns></returns>
public SqlDataReader GetReader(string where)
{
return du.GetReader(where);
}
}
}