예제 #1
0
 public ActionResult Edit(FormCollection fc, CSF_Users user)
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         //Xóa nhóm hiện tại của người dùng
         CSF_UserRole_DAO objUserRoleDAO = new CSF_UserRole_DAO();
         objUserRoleDAO.DelRoleByUserID(user.ID);
         CSF_Users_DAO objUsersDAO = new CSF_Users_DAO();
         if (objUsersDAO.Update(user))
         {
             if (fc["chkRole_"] != null)
             {
                 string[] arrRoleCheckBox = fc["chkRole_"].Split(',');
                 int      intRoleID       = 0;
                 for (int i = 0; i < arrRoleCheckBox.Length; i++)
                 {
                     intRoleID = Convert.ToInt32(arrRoleCheckBox[i].ToString());
                     objUserRoleDAO.Insert(user.ID, intRoleID);
                 }
             }
             SetAlert("Cập nhật người dùng thành công", AlertType.Success);
             return(RedirectToAction("Index", "QT_Users"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật người dùng không thành công");
         }
         return(View("Index"));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
예제 #2
0
 public ActionResult UpdateInformation(FormCollection fc, CSF_Users user)
 {
     try
     {
         CSF_Users_DAO objUsersDAO = new CSF_Users_DAO();
         if (objUsersDAO.Update(user))
         {
             SetAlert("Cập nhật thông tin thành công", AlertType.Success);
             ViewBag.ID = user.ID;
             return(View());
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật thông tin không thành công");
         }
         return(View());
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }