Пример #1
0
        public ActionResult SaveItem(DMLoaiCoQuan model)
        {
            string            ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int               IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            DMLoaiCoQuanModel data           = new DMLoaiCoQuanModel()
            {
                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"]);
                    DMLoaiCoQuanService.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));
        }
Пример #2
0
        public ActionResult DeleteItem(string Id)
        {
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            DMLoaiCoQuan model          = new DMLoaiCoQuan()
            {
                Id = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString())
            };

            try
            {
                if (model.Id > 0)
                {
                    model.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    DMLoaiCoQuanService.DeleteItem(model);
                    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()));
            }
        }
Пример #3
0
        public ActionResult UpdateStatus([FromQuery] string Ids, Boolean Status)
        {
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            DMLoaiCoQuan item           = new DMLoaiCoQuan()
            {
                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 = DMLoaiCoQuanService.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()));
            }
        }
Пример #4
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));
        }
Пример #5
0
        public IActionResult Index([FromQuery] SearchDMCoQuan dto)
        {
            int           TotalItems     = 0;
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            DMCoQuanModel data           = new DMCoQuanModel();

            data.SearchData          = dto;
            data.ListItemsLoaiCoQuan = DMLoaiCoQuanService.GetListSelectItems();
            data.ListItemsLayout     = DMCoQuanService.GetListLayout();
            if (dto.CategoryId == 0 && data.ListItemsLoaiCoQuan != null && data.ListItemsLoaiCoQuan.Count() > 0)
            {
                data.SearchData.CategoryId = Convert.ToInt32(data.ListItemsLoaiCoQuan[0].Value);
            }

            data.ListItems = DMCoQuanService.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));
        }
Пример #6
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));
        }
Пример #7
0
        public IActionResult SaveItem(string Id = null)
        {
            DMLoaiCoQuanModel data           = new DMLoaiCoQuanModel();
            string            ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchDMLoaiCoQuan()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            if (IdDC == 0)
            {
                data.Item = new DMLoaiCoQuan();
            }
            else
            {
                data.Item = DMLoaiCoQuanService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }