public bool CheckUser(int userId) { T_UserModel model = new T_UserDAL().Get(userId); if (model == null || model.UserId == 0) { return(false); } else { return(true); } }
public void ChangePassword(int id, string oldpwd, string newpwd) { T_UserDAL userDAL = new T_UserDAL(); T_User user = userDAL.Get(id); if (user == null) { throw new Exception("不存在的UserId"); } if (GetMD5(oldpwd) != user.Password) { throw new Exception("旧密码错误"); } user.Password = GetMD5(newpwd); userDAL.Update(user); }
// BLL可以有负责的判断操作 public bool ValidateUser(string username, string password) { T_UserDAL dal = new T_UserDAL(); T_User user = dal.GetByUserName(username); if (user == null) { // 不要在BLL中MessageBox return(false); } if (GetMD5(password) != user.Password) { return(false); } else { return(true); } }