예제 #1
0
        public ActionResult Save(EmployeeInfo info)
        {
            var    result = info.Save(ModelState, UserID, Employee.ID);
            var    isAjaxRequest = Request.IsAjaxRequest();
            string view; object model;

            if (result)
            {
                view  = isAjaxRequest ? Views.ListPartial : Views.List;
                model = EmployeeInfo.Find(UserID, Employee.ID, Employee.BussinessID, "Luu thông tin thành công");
            }
            else
            {
                view  = isAjaxRequest ? Views.SavePartial : Views.Save;
                model = info;
            }
            if (isAjaxRequest)
            {
                return(Json(new
                {
                    result = result,
                    html = RenderPartialViewToString(view, model),
                },
                            JsonRequestBehavior.DenyGet));
            }
            else
            {
                return(View(view, model));
            }
        }
예제 #2
0
        public ActionResult FindEmployee(EmployeeFilter filter)
        {
            var data = EmployeeInfo.Find(UserID, Employee.ID, Employee.BussinessID, "", filter);

            return(Json(new
            {
                html = RenderPartialViewToString("EmployeeList", data)
            }, JsonRequestBehavior.DenyGet));
        }
예제 #3
0
        public ActionResult DataList()
        {
            var list = EmployeeInfo.Find(UserID, Employee.ID, Employee.BussinessID);

            return(Json(new
            {
                id = list.Data.Select(e => e.ID).ToArray(),
                name = list.Data.Select(e => e.Name).ToArray()
            }, JsonRequestBehavior.DenyGet));
        }
예제 #4
0
        public ActionResult EmployeeList()
        {
            var list = EmployeeInfo.Find(UserID, Employee.ID, Employee.BussinessID, "", new EmployeeFilter()
            {
                Month = DateTime.Now.Month
            });

            return(Json(new
            {
                html = RenderPartialViewToString("EmployeeList", list)
            }, JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        public ActionResult List()
        {
            var data = EmployeeInfo.Find(UserID, Employee.ID, Employee.BussinessID);

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString(Views.ListPartial, data)
                }, JsonRequestBehavior.AllowGet));
            }
            return(View(Views.List, data));
        }
예제 #6
0
        public ActionResult Find(string id)
        {
            var data = EmployeeInfo.Find(UserID, Employee.ID, Employee.BussinessID, "", new EmployeeFilter()
            {
                Name = id
            });

            return(Json(new {
                list = data.Data.Select(e => new {
                    ID = e.ID,
                    Name = e.Name
                }).ToArray()
            }, JsonRequestBehavior.AllowGet));
        }
예제 #7
0
        public ActionResult Remove(int id)
        {
            var message = "Xóa thông tin thành công";

            if (EmployeeInfo.IsAdmin(UserID, Employee.ID, id, DbAction.Employee.Remove))
            {
                message = "Không thể xóa nhân viên có quyền admin";
            }
            else
            {
                EmployeeInfo.Remove(UserID, Employee.ID, id);
            }
            var model = EmployeeInfo.Find(UserID, Employee.ID, Employee.BussinessID, message);

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString(Views.ListPartial, model)
                }, JsonRequestBehavior.AllowGet));
            }
            return(View(Views.List, model));
        }
예제 #8
0
        public ActionResult Download(EmployeeFilter filter)
        {
            var result = false;

            try
            {
                var data = EmployeeInfo.Find(UserID, Employee.ID, Employee.BussinessID, "", filter, true);
                if (data != null)
                {
                    var fileName = String.Format("Employees_{0}.xls", DateTime.Now.ToString("ddMMyyyyHHmmss"));
                    var file     = String.Format("{0}/Content/Download/{1}", SiteConfiguration.ApplicationPath, fileName);
                    Functions.CheckDirectory(String.Format("{0}/Content/Download/", SiteConfiguration.ApplicationPath));
                    SaveDownload(file, data.Data);
                    Session[SessionKey.Download] = fileName;
                    result = true;
                }
            }
            catch { }
            return(Json(new
            {
                result = result
            }, JsonRequestBehavior.DenyGet));
        }