Exemplo n.º 1
0
        public ActionResult Create(FormCollection fc, CMS_News obj)
        {
            try
            {
                TempData.Keep("categories");
                if (ModelState.IsValid)
                {
                    CMS_News_DAO  objDAO     = new CMS_News_DAO();
                    CSF_Users_DAO objUserDao = new CSF_Users_DAO();
                    int           userID     = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
                    obj.ID_USERCREATE = userID;

                    int ReturnID = objDAO.Insert(obj);
                    if (ReturnID > 0)
                    {
                        SetAlert("Thêm tin tức thành công", AlertType.Success);
                        return(RedirectToAction("Index", "CMS_News"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Thêm tin tức 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 ActionResult Create(FormCollection fc, CMS_Videos obj)
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         TempData.Keep("TypeOfVideoID");
         if (ModelState.IsValid)
         {
             CMS_Videos_DAO objDAO     = new CMS_Videos_DAO();
             CSF_Users_DAO  objUserDao = new CSF_Users_DAO();
             int            intUserID  = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
             obj.UserCreate = intUserID;
             int ReturnID = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 SetAlert("Thêm video thành công", AlertType.Success);
                 return(RedirectToAction("index", "CMS_Videos"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm mới 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.º 3
0
 public ActionResult Create(FormCollection fc, CMS_Services obj, HttpPostedFileBase file)
 {
     try
     {
         TempData.Keep("TypeOfMap");
         if (ModelState.IsValid)
         {
             CMS_Services_DAO objDAO     = new CMS_Services_DAO();
             CSF_Users_DAO    objUserDao = new CSF_Users_DAO();
             int intUserID = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
             obj.UserCreate = intUserID;
             int ReturnID = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 SetAlert("Thêm services thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_Services"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm services 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.º 4
0
 public ActionResult Edit(FormCollection fc, CMS_News obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_News_DAO  objDAO     = new CMS_News_DAO();
             CSF_Users_DAO objUserDao = new CSF_Users_DAO();
             int           userID     = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
             obj.ID_USERMODIFY = userID;
             bool update = false;
             update = objDAO.Update(obj);
             if (update)
             {
                 SetAlert("Cập nhật tin tức thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_News"));
             }
             else
             {
                 SetAlert("Cập nhật 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());
     }
 }
 public ActionResult Create(FormCollection fc, CMS_Notifications obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_Notifications_DAO objDAO     = new CMS_Notifications_DAO();
             CSF_Users_DAO         objUserDao = new CSF_Users_DAO();
             int userID = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
             obj.UserCreate = userID;
             int ReturnID = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 //cache lai thong bao
                 WebApp.Controllers.HomeController hController = new WebApp.Controllers.HomeController();
                 hController.Cache_ThongBao();
                 SetAlert("Thêm thông báo nội bộ thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_Notifications"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm thông báo nội bộ 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.º 6
0
 public ActionResult Edit(FormCollection fc, CMS_Questions obj)
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         TempData.Keep("TypeOfQuestionID");
         if (ModelState.IsValid)
         {
             CMS_Questions_DAO objDAO     = new CMS_Questions_DAO();
             CSF_Users_DAO     objUserDao = new CSF_Users_DAO();
             int userID = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
             obj.UserCreate = userID;
             if (objDAO.Update(obj))
             {
                 SetAlert("Cập nhật thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_Questions"));
             }
             else
             {
                 SetAlert("Cập nhật 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.º 7
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            try
            {
                var descriptor               = filterContext.ActionDescriptor;
                var actionName               = descriptor.ActionName;
                var controllerName           = descriptor.ControllerDescriptor.ControllerName;
                DT_WebGISEntities MyContext  = new DT_WebGISEntities();
                CSF_Users_DAO     objUserDao = new CSF_Users_DAO();
                string            username   = filterContext.HttpContext.User.Identity.Name;

                if (!string.IsNullOrEmpty(username))
                {
                    int        intGuestGroup    = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["IDGuestGroup"]);
                    List <int> listUserRole     = objUserDao.GetRoleIDByUserName(username, intGuestGroup);
                    string     ControllerAction = controllerName + "-" + actionName;
                    var        ListPermission   = (from a in MyContext.CSF_RoleFunction
                                                   join b in MyContext.CSF_Functions on a.FunctionID equals b.ID
                                                   where listUserRole.Contains(a.RoleID)
                                                   select new { ca = b.Controller_Action.ToLower() }).ToList();
                    //write log
                    int intUserID = objUserDao.GetUserIDByUserName(username);
                    if (intUserID > 0)
                    {
                        CSF_Logs objLog = new CSF_Logs();
                        objLog.Controller_Action = controllerName + "-" + actionName;
                        objLog.CreateDate        = System.DateTime.Now;
                        objLog.UserCreate        = intUserID;
                        //objLog.Content = descriptor.ToString();
                        MyContext.CSF_Logs.Add(objLog);
                        MyContext.SaveChanges();
                    }
                    var permission = ListPermission.Where(x => x.ca.Contains(ControllerAction.ToLower())).FirstOrDefault();
                    if (permission == null && username.ToLower().Trim() != "host")
                    {
                        base.OnActionExecuting(filterContext);
                        filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary {
                            { "controller", "home" }, { "action", "index" }, { "area", "" }
                        });
                    }
                }
                else
                {
                    //filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "home" }, { "action", "login" }, { "area", "" } });

                    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary {
                        { "Area", "" },
                        { "Controller", "home" },
                        { "Action", "login" },
                        { "RedirectUrl", filterContext.HttpContext.Request.Url }
                    }
                                                                     );
                }
            }
            catch (Exception ex)
            {
                Logs.WriteLog(ex);
            }
        }
Exemplo n.º 8
0
 public JsonResult SetNgungCongBo(string[] arrChecked, string abc)
 {
     try
     {
         int              ikq            = 0;
         string[]         arrIDTinTuc    = arrChecked;
         CMS_News_DAO     objNewsDao     = new CMS_News_DAO();
         CMS_Approves_DAO objApproverDao = new CMS_Approves_DAO();
         CMS_Approves     objApp         = new CMS_Approves();
         int              iIDNews        = 0;
         if (arrIDTinTuc != null && arrIDTinTuc.Length > 0)
         {
             for (int i = 0; i < arrIDTinTuc.Length; i++)
             {
                 iIDNews = Convert.ToInt32(arrIDTinTuc[i].ToString());
                 objNewsDao.UpdateTrangThai(iIDNews, 6, 0);
                 objApp.ID_News        = iIDNews;
                 objApp.ID_News_Status = 6;
                 CSF_Users_DAO objUserDao = new CSF_Users_DAO();
                 int           intUserID  = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
                 objApp.ID_User = intUserID;
                 objApp.Comment = abc;
                 ikq            = objApproverDao.Insert(objApp);
             }
         }
         if (ikq > 0)
         {
             //cache lai tin bai
             WebApp.Controllers.HomeController hController = new WebApp.Controllers.HomeController();
             hController.Cache_TinBai();
             return(Json(new { status = true, message = "Ngừng công bố tin tức thành công" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { status = false, message = "Lỗi ngừng công bố tin tức" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(Json(new { status = false, message = "Lỗi: " + ex }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 9
0
 public JsonResult SetDuyet(string[] arrChecked, string abc)
 {
     try
     {
         int              ikq            = 0;
         string[]         arrIDTinTuc    = arrChecked;
         CMS_News_DAO     objNewsDao     = new CMS_News_DAO();
         CMS_Approves_DAO objApproverDao = new CMS_Approves_DAO();
         CMS_Approves     objApp         = new CMS_Approves();
         int              iIDNews        = 0;
         //int intRoleID = Convert.ToInt32(RoleID);
         //int intUserID = 0;
         //CSF_UserRole_DAO objUserRoleDAO = new CSF_UserRole_DAO();
         if (arrIDTinTuc != null && arrIDTinTuc.Length > 0)
         {
             for (int i = 0; i < arrIDTinTuc.Length; i++)
             {
                 iIDNews = Convert.ToInt32(arrIDTinTuc[i].ToString());
                 objNewsDao.UpdateTrangThai(iIDNews, 4, 0);
                 objApp.ID_News        = iIDNews;
                 objApp.ID_News_Status = 4;
                 CSF_Users_DAO objUserDao = new CSF_Users_DAO();
                 int           intUserID  = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
                 objApp.ID_User = intUserID;
                 objApp.Comment = abc;
                 ikq            = objApproverDao.Insert(objApp);
             }
         }
         if (ikq > 0)
         {
             return(Json(new { status = true, message = "Duyệt tin tức thành công" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { status = false, message = "Lỗi duyệt tin tức" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(Json(new { status = false, message = "Lỗi: " + ex }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 10
0
 public ActionResult Create(FormCollection fc, CMS_Documents obj)
 {
     try
     {
         TempData.Keep("TypeOfDocumentID");
         TempData.Keep("AreaOfDocument");
         TempData.Keep("OrganizationID");
         if (ModelState.IsValid)
         {
             CMS_Documents_DAO objDAO = new CMS_Documents_DAO();
             if (objDAO.CheckExist_DocumentNumber(obj))
             {
                 SetAlert("Số hiệu đã tồn tại!", AlertType.Error);
                 return(View());
             }
             CSF_Users_DAO objUserDao = new CSF_Users_DAO();
             int           intUserID  = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
             obj.UserCreate = intUserID;
             int ReturnID = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 //cache lai van ban
                 WebApp.Controllers.HomeController hController = new WebApp.Controllers.HomeController();
                 hController.Cache_VanBan();
                 SetAlert("Thêm văn bản thành công", AlertType.Success);
                 return(RedirectToAction("index", "cms_documents"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm văn bản 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.º 11
0
 public JsonResult SaveSetupPage(CSF_PagePartial obj)
 {
     try
     {
         CSF_Users_DAO objUserDao = new CSF_Users_DAO();
         int           intUserID  = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
         obj.UserCreate = intUserID;
         CSF_Pages_DAO dao = new CSF_Pages_DAO();
         int           id  = dao.PagePartialSave(obj);
         if (id > 0)
         {
             return(Json(new { state = true, message = "Thêm mới thành công" }, JsonRequestBehavior.AllowGet));
         }
         return(Json(new { state = false, message = "Lỗi thêm mới" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { state = false, message = ex }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 12
0
 public ActionResult Create(FormCollection fc, CSF_Pages obj)
 {
     try
     {
         TempData.Keep("module");
         TempData.Keep("page");
         if (ModelState.IsValid)
         {
             CSF_Pages_DAO objDAO = new CSF_Pages_DAO();
             if (objDAO.CheckExist_PageKey(obj))
             {
                 SetAlert("Key đã tồn tại!", AlertType.Error);
                 return(View());
             }
             CSF_Users_DAO objUserDao = new CSF_Users_DAO();
             int           intUserID  = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);
             obj.UserCreate = intUserID;
             int ReturnID = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 SetAlert("Thêm page thành công", AlertType.Success);
                 return(RedirectToAction("Index", "QT_Pages"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm page 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.º 13
0
        public ActionResult CreateBanDo(FormCollection fc, CMS_Maps obj)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string strThumbnailDir = System.Configuration.ConfigurationManager.AppSettings["ThumbnailFileUrl"].ToString();
                    var    item            = Request.Files.AllKeys.Where(m => m.StartsWith("Thumbnail")).FirstOrDefault();
                    var    imgThumbnail    = Request.Files[item];
                    if (imgThumbnail != null && imgThumbnail.ContentLength > 0)
                    {
                        //var fileName = "thumbnail_" + DateTime.Now.ToString("yyyyMMddhhmmsstt") + Guid.NewGuid().ToString() + Path.GetExtension(imgThumbnail.FileName);
                        //obj.Thumbnail = fileName;

                        // Save file
                        //var path = Path.Combine(Server.MapPath(strThumbnailDir), fileName);
                        //imgThumbnail.SaveAs(path);
                    }
                    else
                    {
                        //obj.Thumbnail = "thumbnail_DEFAULT.jpg";
                    }

                    CMS_MapService     objMapService    = new CMS_MapService();
                    CMS_Maps_DAO       objDAO           = new CMS_Maps_DAO();
                    CMS_MapService_DAO objDAOMapService = new CMS_MapService_DAO();
                    string             strIDService     = "0";
                    if (fc["ddlServices"] != null)
                    {
                        strIDService = fc["ddlServices"].ToString();
                    }
                    if (strIDService == "0")
                    {
                        SetAlert("Chọn Services", AlertType.Error);
                        return(View());
                    }
                    CSF_Users_DAO objUserDao = new CSF_Users_DAO();
                    int           intUserID  = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name);

                    obj.UserCreate = intUserID;
                    int ReturnID = objDAO.Insert(obj);
                    if (ReturnID > 0)
                    {
                        objMapService.MapID     = ReturnID;
                        objMapService.Orders    = 0;
                        objMapService.ServiceID = Convert.ToInt32(strIDService);
                        objDAOMapService.Insert(objMapService);
                        SetAlert("Thêm bản đồ thành công", AlertType.Success);
                        return(RedirectToAction("Index", "CMS_Maps"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Thêm bản đồ 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());
            }
        }