示例#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));
        }