Пример #1
0
 public JsonResult Delete(int id)
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         CSF_Functions_DAO objFunctionsDAO = new CSF_Functions_DAO();
         if (objFunctionsDAO.CheckParentFunction(id))
         {
             return(Json(new { status = false, message = "Không thể xóa chức năng cha" }, JsonRequestBehavior.AllowGet));
         }
         if (objFunctionsDAO.Delete(id))
         {
             SetAlert("Xóa chức năng thành công", AlertType.Success);
             return(Json(new { status = true, message = "" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { status = false, message = "Lỗi xóa chức năng" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(Json(new { status = false, message = "Lỗi: " + ex }, JsonRequestBehavior.AllowGet));
     }
 }
Пример #2
0
 protected void ParentFunctionDropDownList()
 {
     try
     {
         CSF_Functions_DAO    objFunctionsDAO = new CSF_Functions_DAO();
         List <CSF_Functions> listFunction    = objFunctionsDAO.GetAll().OrderBy(o => o.ParentID).ToList();
         TempData["ddlFunctions"] = new SelectList(BuildTreeFunctions(listFunction, (int)listFunction.FirstOrDefault().ParentID), "ID", "Name");
         TempData.Keep("ddlFunctions");
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         throw;
     };
 }
Пример #3
0
 public ActionResult Index(string search, int?page)
 {
     try
     {
         CSF_Functions_DAO objFunctionsDAO = new CSF_Functions_DAO();
         List <CSF_Functions_LayTatCa_Result> functions = objFunctionsDAO.Search(search);
         ViewBag.search = search;
         int pageSize   = 15;
         int pageNumber = (page ?? 1);
         return(View(functions.ToPagedList(pageNumber, pageSize)));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), "error");
         Logs.WriteLog(ex);
         return(View());
     }
 }
Пример #4
0
 public JsonResult EditSubmit(string ID, string Name, string Description, string ParentID, string ModuleID, string Controller_Action)
 {
     try
     {
         CSF_Functions_DAO objFunctionsDAO = new CSF_Functions_DAO();
         CSF_Functions     objFunc         = new CSF_Functions();
         if (ParentID != "")
         {
             objFunc.ParentID = Convert.ToInt32(ParentID);
             if (Convert.ToInt32(ID) == Convert.ToInt32(ParentID))
             {
                 return(Json(new { status = false, message = "Không thể chọn chức năng cha chính nó" }, JsonRequestBehavior.AllowGet));
             }
         }
         else
         {
             objFunc.ParentID = 0;
         }
         if (objFunctionsDAO.CheckControllerAction(Convert.ToInt32(ID), Controller_Action))
         {
             return(Json(new { status = false, message = "Controller-Action đã tồn tại!" }, JsonRequestBehavior.AllowGet));
         }
         objFunc.ID                = Convert.ToInt32(ID);
         objFunc.Name              = Name;
         objFunc.Description       = Description;
         objFunc.ModuleID          = Convert.ToInt32(ModuleID);
         objFunc.Controller_Action = Controller_Action;
         if (objFunctionsDAO.Update(objFunc))
         {
             SetAlert("Cập nhật chức năng thành công", AlertType.Success);
             return(Json(new { status = true, message = "" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { status = false, message = "Lỗi cập nhật chức năng" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(Json(new { status = false, message = "Lỗi: " + ex }, JsonRequestBehavior.AllowGet));
     }
 }
Пример #5
0
 public ActionResult Edit(int id)
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         CSF_Functions_DAO objFunctionsDAO = new CSF_Functions_DAO();
         var func = objFunctionsDAO.GetFunctionByID(id);
         ModulesDropDownList();
         ParentFunctionDropDownList();
         string        ca  = func.Controller_Action;
         List <string> lca = ca.Split('-').ToList();
         ControllerDropDownList(lca[0]);
         ActionDropDownList(lca[0], lca[1]);
         return(View(func));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
Пример #6
0
        public ActionResult Create(FormCollection fc, CSF_Functions func)
        {
            try
            {
                //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
                if (ModelState.IsValid)
                {
                    CSF_Functions_DAO objFunctionsDAO  = new CSF_Functions_DAO();
                    string            controllerAction = fc["listController"] + "-" + fc["listAction"];
                    //Kiểm tra trùng tên ControllerAction
                    if (objFunctionsDAO.CheckControllerAction(0, controllerAction))
                    {
                        SetAlert("Controller-Action đã tồn tại!", AlertType.Error);
                        return(View());
                    }

                    func.Controller_Action = controllerAction;
                    int ReturnID = objFunctionsDAO.Insert(func);
                    if (ReturnID > 0)
                    {
                        SetAlert("Thêm chức năng thành công", AlertType.Success);
                        return(RedirectToAction("Index", "QT_Functions"));
                    }
                    else
                    {
                        SetAlert("Thêm chức năng không thành công", AlertType.Error);
                    }
                }
                return(View());
            }
            catch (Exception ex)
            {
                SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
                Logs.WriteLog(ex);
                return(View());
            }
        }