Example #1
0
        public IActionResult SaveItem(string Id = null)
        {
            USUsersModel data           = new USUsersModel();
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int          IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchUSUsers()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            data.ListItemsGroups = USGroupsService.GetListSelectItems();
            data.ListItemsStatus = USUsersService.GetStatusSelectItems();
            data.ListDMCoQuan    = DMCoQuanService.GetListByLoaiCoQuan(0, 1);
            data.ListDMChucVu    = DMChucVuService.GetListSelectItems();
            if (IdDC == 0)
            {
                data.Item = new USUsers();
            }
            else
            {
                data.Item = USUsersService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
Example #2
0
        public ActionResult SaveItem(Banners model)
        {
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int          IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            BannersModel data           = new BannersModel()
            {
                Item = model
            };

            if (ModelState.IsValid)
            {
                if (model.Id == IdDC)
                {
                    model.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    BannersService.SaveItem(model);
                    if (model.Id > 0)
                    {
                        TempData["MessageSuccess"] = "Cập nhật thành công";
                    }
                    else
                    {
                        TempData["MessageSuccess"] = "Thêm mới thành công";
                    }
                    return(RedirectToAction("Index", new { CatId = model.CatId, IdCoQuan = model.IdCoQuan }));
                }
            }
            else
            {
                data.ListItemsCategories = BannersCategoriesService.GetListSelectItems();
                data.ListDMCoQuan        = DMCoQuanService.GetListByLoaiCoQuan(0, 1);
            }
            return(View(data));
        }
Example #3
0
        public IActionResult SaveItem(string Id = null, int CatId = 0, int IdCoQuan = 1)
        {
            BannersModel data           = new BannersModel();
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int          IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchBanners()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = "", CatId = CatId, IdCoQuan = IdCoQuan
            };
            data.ListItemsCategories = BannersCategoriesService.GetListSelectItems();
            data.ListDMCoQuan        = DMCoQuanService.GetListByLoaiCoQuan(0, 1);
            if (IdDC == 0)
            {
                data.Item = new Banners()
                {
                    CatId = CatId, Status = true
                };
            }
            else
            {
                data.Item = BannersService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
Example #4
0
        public IActionResult Index([FromQuery] SearchBanners dto)
        {
            int TotalItems = 0;

            if (dto.IdCoQuan == 0)
            {
                dto.IdCoQuan = 1;
            }
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            BannersModel data           = new BannersModel()
            {
                SearchData = dto
            };

            data.ListItems = BannersService.GetListPagination(data.SearchData, API.Models.Settings.SecretId + ControllerName);
            if (data.ListItems != null && data.ListItems.Count() > 0)
            {
                TotalItems = data.ListItems[0].TotalRows;
            }
            data.ListDMCoQuan = DMCoQuanService.GetListByLoaiCoQuan(0, 1);
            data.Pagination   = new Models.Partial.PartialPagination()
            {
                CurrentPage = data.SearchData.CurrentPage, ItemsPerPage = data.SearchData.ItemsPerPage, TotalItems = TotalItems, QueryString = Request.QueryString.ToString()
            };
            data.ListItemsCategories = BannersCategoriesService.GetListSelectItems();
            return(View(data));
        }
Example #5
0
        public IActionResult SaveItem(string Id = null, int CategoryId = 0, int ParentId = 0)
        {
            DMCoQuanModel data = new DMCoQuanModel();

            data.ListItemsCoQuan     = DMCoQuanService.GetListByLoaiCoQuan(CategoryId);
            data.ListItemsLayout     = DMCoQuanService.GetListLayout();
            data.ListItemsLoaiCoQuan = DMLoaiCoQuanService.GetListSelectItems();
            int    IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + "DMCoQuan").ToString());
            string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();

            data.SearchData = new SearchDMCoQuan()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            if (IdDC == 0)
            {
                data.Item            = new DMCoQuan();
                data.Item.CategoryId = CategoryId;
                data.Item.ParentId   = ParentId;
            }
            else
            {
                data.Item = DMCoQuanService.GetItem(IdDC, API.Models.Settings.SecretId + "DMCoQuan".ToString());
            }


            return(View(data));
        }
Example #6
0
        public ActionResult SaveItem(USUsers model)
        {
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int          IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            USUsersModel data           = new USUsersModel()
            {
                Item = model
            };

            if (ModelState.IsValid)
            {
                if (model.Id == IdDC)
                {
                    if (model.Id == 0)
                    {
                        if (model.Password == null || model.Password == null)
                        {
                            model.Password = "******";
                        }
                        model.Password = USUsersService.GetMD5(model.Password);
                    }
                    dynamic DataSave = USUsersService.SaveItem(model);
                    if (model.Id > 0)
                    {
                        TempData["MessageSuccess"] = "Cập nhật thành công";
                    }
                    else
                    {
                        TempData["MessageSuccess"] = "Thêm mới thành công";
                    }
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                data.ListItemsGroups = USGroupsService.GetListSelectItems();
                data.ListItemsStatus = USUsersService.GetStatusSelectItems();
                data.ListDMCoQuan    = DMCoQuanService.GetListByLoaiCoQuan(0, 1);
                data.ListDMChucVu    = DMChucVuService.GetListSelectItems();
            }
            return(View(data));
        }
Example #7
0
        public ActionResult SaveItem(DMCoQuan model)
        {
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int           IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            DMCoQuanModel data           = new DMCoQuanModel();

            data.ListItemsLayout     = DMCoQuanService.GetListLayout();
            data.ListItemsLoaiCoQuan = DMLoaiCoQuanService.GetListSelectItems();
            data.Item = model;
            if (ModelState.IsValid)
            {
                if (model.Id == IdDC)
                {
                    model.CreatedBy = model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    var Obj = DMCoQuanService.SaveItem(model);
                    if (Obj.N == -1)
                    {
                        TempData["MessageError"] = "Mã cơ quan trùng";
                        data.ListItemsCoQuan     = DMCoQuanService.GetListByLoaiCoQuan(model.CategoryId);

                        return(View(data));
                    }
                    else if (Obj.N == -2)
                    {
                        TempData["MessageError"] = "Chọn Cơ quan cha không hợp lệ";
                        data.ListItemsCoQuan     = DMCoQuanService.GetListByLoaiCoQuan(model.CategoryId);

                        return(View(data));
                    }
                    else
                    {
                        TempData["MessageSuccess"] = "Cập nhật thành công";
                        return(RedirectToAction("Index", new { CategoryId = model.CategoryId }));
                    }
                }
            }
            else
            {
                data.ListItemsCoQuan = DMCoQuanService.GetListByLoaiCoQuan(model.CategoryId);
            }
            return(View(data));
        }