/// <summary> /// 更新状态 /// </summary> /// <param name="book"></param> /// <returns></returns> public bool Update(LMS_Admin admin) { // update LMS_Admin set Bookstatu = 1 where Bookname = '在人间'; string sql = string.Format(@"update LMS_Admin set Adminname='{0}',Adminuid='{1}',Adminpwd='{2}' where Adminnumber={3} ", admin.Adminname, admin.Adminuid, admin.Adminpwd, admin.Adminnumber); return(DBHeper.SQL(sql)); }
public LMS_Admin FindPwd(string name, string uid) { string sql = string.Format("select* from LMS_Admin where AdminUid = '{0}' and adminname ='{1}'", uid, name); LMS_Admin admin = _dal.Select(sql); //判断用户是否存在 return(admin); }
/// <summary> /// 用户登录 /// </summary> /// <param name="code"></param> /// <param name="pwd"></param> /// <returns></returns> public LMS_Admin Login(string code, string pwd) { //拼接SQL string sql = string.Format("select* from LMS_Admin where AdminUid = '{0}' and AdminPwd = '{1}'", code, pwd); //执行SQL 从数据库获取信息 LMS_Admin admin = _dal.Select(sql); //返回用户信息 return(admin); }
public LMS_Admin Select(string sql) { LMS_Admin LMS_Admin = new LMS_Admin(); //从数据库获取信息 DataTable data = DBHeper.Select(sql); //如果有数据 将DataTable载入到LMS_Admin对象 if (data.Rows.Count > 0) { var row = data.Rows[0]; LMS_Admin.Adminname = row["Adminname"].ToString(); LMS_Admin.Adminnumber = (int)row["Adminnumber"]; LMS_Admin.Adminuid = row["Adminuid"].ToString(); LMS_Admin.Adminpwd = row["Adminpwd"].ToString(); } //返回书籍信息 return(LMS_Admin); }
public bool Insert(LMS_Admin admin) { //拼接SQL string sql = string.Format(@"Insert into LMS_Admin ( Adminname, Adminuid, Adminpwd ) values('{0}', '{1}', '{2}')", admin.Adminname, admin.Adminuid, admin.Adminpwd ); //连接数据库 执行SQL return(DBHeper.SQL(sql)); }
public List <LMS_Admin> SelectList(string sql) { List <LMS_Admin> list = new List <LMS_Admin>(); //从数据库获取信息 DataTable data = DBHeper.Select(sql); foreach (DataRow row in data.Rows) { //利用将当前行数据 新建用户对象 LMS_Admin LMS_Admin = new LMS_Admin(); LMS_Admin.Adminname = row["Adminname"].ToString(); LMS_Admin.Adminnumber = (int)row["Adminnumber"]; LMS_Admin.Adminuid = row["Adminuid"].ToString(); LMS_Admin.Adminpwd = row["Adminpwd"].ToString(); //将用户对象 存入列表 list.Add(LMS_Admin); } //返回列表 return(list); }
/// <summary> /// 注册用户 /// </summary> /// <param name="name"></param> /// <param name="pwd"></param> /// <param name="UID"></param> /// <returns></returns> public bool Resist(string name, string pwd, string UID) { //拼接SQL string sql = string.Format("select* from LMS_Admin where AdminUid = '{0}'", UID); LMS_Admin admin = _dal.Select(sql); //判断用户是否存在 if (admin.Adminnumber > 0) { return(false); } else { admin.Adminname = name; admin.Adminpwd = pwd; admin.Adminuid = UID; _dal.Insert(admin); return(true); } }