public ActionResult ChangePassword(FormCollection collection) { var oldPassword = collection["OldPassword"]; var password = collection["Password"]; var password1 = collection["Password1"]; if (password != password1) { ModelState.AddModelError("", "两次密码不统一"); return View(); } var user = new Users { UserName = "******", Password = oldPassword, Conditaion = "user_name=[UserName];AND Password = [Password];" }; var userlist = UserService.GetUserList(user); if (userlist.Count > 0) { user.ID = userlist[0].ID; user.Conditaion = null; user.Password = password; UserService.UpdateUser(user); ModelState.AddModelError("", "密码修改成功"); } else { ModelState.AddModelError("", "旧密码错误"); } return View(); }
public int UpdateUser(Users user) { return UserDao.Update(user); }
public IList<Users> GetUserList(Users users) { return UserDao.GetList(users); }
public Users GetUser(Users users) { return UserDao.Get(users); }
public int AddUser(Users user) { user.CreateDate = DateTime.Now; return UserDao.Add(user); }
public JsonResult SaveUser(Users user) { var result = 0; user.UpdateDate = DateTime.Now; var flag = (user.ID != 0 ? UserService.UpdateUser(user) : UserService.AddUser(user)) > 0; if (flag) { result = 1; //RedirectToAction("List"); } return Json(result); }
public ActionResult Login(Users user) { user.Conditaion = "user_name=[UserName];AND Password = [Password];"; var model = UserService.GetUser(user); if (model != null) { Session["UserName"] = model.UserName; return RedirectToAction("Index", "Main"); } ModelState.AddModelError("", "用户名或密码错误!"); return View(); }