예제 #1
0
 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();
 }
예제 #2
0
 public int UpdateUser(Users user)
 {
     return UserDao.Update(user);
 }
예제 #3
0
 public IList<Users> GetUserList(Users users)
 {
     return UserDao.GetList(users);
 }
예제 #4
0
 public Users GetUser(Users users)
 {
     return UserDao.Get(users);
 }
예제 #5
0
 public int AddUser(Users user)
 {
     user.CreateDate = DateTime.Now;
     return UserDao.Add(user);
 }
예제 #6
0
 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);
 }
예제 #7
0
 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();
 }