Exemplo n.º 1
0
 public ActionResult Create(FormCollection fc, CSF_Modules obj)
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         if (ModelState.IsValid)
         {
             CSF_Modules_DAO objDAO   = new CSF_Modules_DAO();
             int             ReturnID = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 SetAlert("Thêm mới module thành công", AlertType.Success);
                 return(RedirectToAction("Index", "QT_Modules"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm mới module không thành công");
             }
             return(View("Index"));
         }
         return(View());
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
Exemplo n.º 2
0
 public JsonResult Delete(int id)
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         CSF_Modules_DAO objDAO = new CSF_Modules_DAO();
         if (objDAO.CheckDelete(id))
         {
             if (objDAO.Delete(id))
             {
                 SetAlert("Xóa module 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 bản ghi" }, JsonRequestBehavior.AllowGet));
             }
         }
         else
         {
             return(Json(new { status = false, message = "Module đang sử dụng không được phép xóa." }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(Json(new { status = false, message = "Lỗi: " + ex }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 3
0
 public ActionResult Edit(FormCollection fc, CSF_Modules obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CSF_Modules_DAO objDAO     = new CSF_Modules_DAO();
             CSF_Users_DAO   objUserDao = new CSF_Users_DAO();
             if (objDAO.EditModules(obj))
             {
                 SetAlert("Cập nhật module thành công", AlertType.Success);
                 return(RedirectToAction("Index", "QT_Modules"));
             }
             else
             {
                 SetAlert("Cập nhật module không thành công", AlertType.Error);
             }
         }
         return(View(obj));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
Exemplo n.º 4
0
        protected void ModulesDropDownList()
        {
            CSF_Modules_DAO objModulesDAO = new CSF_Modules_DAO();
            var             listModules   = objModulesDAO.GetAll();

            TempData["ddlModules"] = new SelectList(listModules, "ID", "Name");
            TempData.Keep("ddlModules");
        }
Exemplo n.º 5
0
        public ActionResult Create()
        {
            try
            {
                //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
                TempData["listController"] = GetControllerNames();
                TempData.Keep("listController");
                DT_WebGISEntities   MyContext = new DT_WebGISEntities();
                List <SubSelectBox> listTree  = new List <SubSelectBox>();
                SubSelectBox        sc;
                var listData = MyContext.CSF_Functions
                               .Join(MyContext.CSF_Modules,
                                     fc => fc.ModuleID,
                                     md => md.ID,
                                     (fc, md) => new { CSF_Functions = fc, CSF_Modules = md })
                               .Where(md => md.CSF_Modules.IsActive == true)
                               .Select(mdp => mdp.CSF_Functions).ToList();
                var    listData0 = listData.Where(x => x.ParentID == 0).OrderBy(x => x.Name).ToList();
                string tag       = "";
                foreach (var item in listData0)
                {
                    sc      = new SubSelectBox();
                    sc.id   = item.ID;
                    sc.name = item.Name;
                    listTree.Add(sc);
                    BuildSubTree(listTree, item.ID, listData, tag);
                }
                TempData["functions"] = listTree.ToList();
                TempData.Keep("functions");

                CSF_Modules_DAO objModulesDAO = new CSF_Modules_DAO();
                var             modules       = objModulesDAO.GetAll();
                TempData["modules"] = modules.ToList();
                TempData.Keep("modules");

                //ParentFunctionDropDownList();
                ModulesDropDownList();

                return(View());
            }
            catch (Exception ex)
            {
                SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
                Logs.WriteLog(ex);
                return(View());
            }
        }
Exemplo n.º 6
0
 public ActionResult Index(string keyword, int?page)
 {
     try
     {
         keyword = keyword != null ? keyword : "";
         CSF_Modules_DAO objDAO = new CSF_Modules_DAO();
         var             data   = objDAO.Search1(keyword);
         ViewBag.SearchString = keyword;
         int pageSize   = 10;
         int pageNumber = (page ?? 1);
         return(View(data.ToPagedList(pageNumber, pageSize)));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), "error");
         Logs.WriteLog(ex);
         return(View());
     }
 }