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 IActionResult Info(USUsers model)
        {
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int          IdDC           = int.Parse(HttpContext.Request.Headers["Id"]);
            USUsersModel data           = new USUsersModel()
            {
                Item = model
            };

            data.ListItemsGroups = USGroupsService.GetListSelectItems();
            data.ListItemsStatus = USUsersService.GetStatusSelectItems();
            data.ListDMChucVu    = DMChucVuService.GetListSelectItems();
            if (ModelState.IsValid)
            {
                if (model.Id == IdDC)
                {
                    if (model.Id > 0)
                    {
                        dynamic DataSave = USUsersService.SaveAccountInfo(model);
                        TempData["MessageSuccess"] = "Cập nhật thành công";
                    }
                }
            }
            else
            {
                TempData["MessageError"] = "Cập nhật Không thành công";
            }
            return(View(data));
        }
Example #3
0
        public ActionResult SaveItem(DMChucVu model)
        {
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int           IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            DMChucVuModel data           = new DMChucVuModel()
            {
                Item = model
            };

            if (ModelState.IsValid)
            {
                if (model.Id == IdDC)
                {
                    model.CreatedBy = model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    dynamic DataSave = DMChucVuService.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"));
                }
            }
            return(View(data));
        }
Example #4
0
        public IActionResult SaveItem(string Id = null)
        {
            DMChucVuModel data           = new DMChucVuModel();
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int           IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchDMChucVu()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };

            /*
             * if (HttpContext.Session.GetString(ControllerName + "_Search")!= null)
             * {
             *  data.SearchData = JsonConvert.DeserializeObject<SearchDMChucVu>(HttpContext.Session.GetString(ControllerName + "_Search"));
             * }*/
            if (IdDC == 0)
            {
                data.Item = new DMChucVu();
            }
            else
            {
                data.Item = DMChucVuService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
Example #5
0
        public ActionResult UpdateStatus([FromQuery] string Ids, Boolean Status)
        {
            string   ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            DMChucVu item           = new DMChucVu()
            {
                Id = Int32.Parse(MyModels.Decode(Ids, API.Models.Settings.SecretId + ControllerName).ToString()), Status = Status
            };

            try
            {
                if (item.Id > 0)
                {
                    item.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    dynamic UpdateStatus = DMChucVuService.UpdateStatus(item);
                    TempData["MessageSuccess"] = "Cập nhật Trạng Thái thành công";
                    return(Json(new MsgSuccess()));
                }
                else
                {
                    TempData["MessageError"] = "Cập nhật Trạng Thái Không thành công";
                    return(Json(new MsgError()));
                }
            }
            catch
            {
                TempData["MessageSuccess"] = "Cập nhật Trạng Thái không thành công";
                return(Json(new MsgError()));
            }
        }
Example #6
0
        public ActionResult DeleteItem(string Id)
        {
            string   ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            DMChucVu item           = new DMChucVu()
            {
                Id = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString())
            };

            try
            {
                if (item.Id > 0)
                {
                    item.CreatedBy = item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);

                    dynamic DataDelete = DMChucVuService.DeleteItem(item);
                    TempData["MessageSuccess"] = "Xóa thành công";
                    return(Json(new MsgSuccess()));
                }
                else
                {
                    TempData["MessageError"] = "Xóa Không thành công";
                    return(Json(new MsgError()));
                }
            }
            catch {
                TempData["MessageSuccess"] = "Xóa không thành công";
                return(Json(new MsgError()));
            }
        }
Example #7
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 #8
0
        public IActionResult Index([FromQuery] SearchDMChucVu dto)
        {
            int           TotalItems     = 0;
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            DMChucVuModel data           = new DMChucVuModel()
            {
                SearchData = dto
            };

            //HttpContext.Session.SetString(ControllerName + "_Search", JsonConvert.SerializeObject(data.SearchData));
            data.ListItems = DMChucVuService.GetListPagination(data.SearchData, API.Models.Settings.SecretId + ControllerName);
            if (data.ListItems != null && data.ListItems.Count() > 0)
            {
                TotalItems = data.ListItems[0].TotalRows;
            }
            data.Pagination = new Models.Partial.PartialPagination()
            {
                CurrentPage = data.SearchData.CurrentPage, ItemsPerPage = data.SearchData.ItemsPerPage, TotalItems = TotalItems, QueryString = Request.QueryString.ToString()
            };

            return(View(data));
        }
Example #9
0
        public IActionResult Info()
        {
            USUsersModel data           = new USUsersModel();
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int          IdDC           = int.Parse(HttpContext.Request.Headers["Id"]);

            data.SearchData = new SearchUSUsers()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            data.ListItemsGroups = USGroupsService.GetListSelectItems();
            data.ListItemsStatus = USUsersService.GetStatusSelectItems();
            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));
        }