Пример #1
0
        public ActionResult GetEmpMenu()
        {
            string strJson = string.Empty;

            try
            {
                if (!WebCookieHelper.EmployeeCheckLogin())
                {
                    return(RedirectToAction("Admin/Account/Login"));
                }

                int nEmpID = WebCookieHelper.GetEmployeeId();

                var menus = MenuServices.GetMenuByEmpID(nEmpID);


                if (menus.ToList().Count > 0)
                {
                    strJson = JsonHelper.GetMenuJson(menus, 0);
                    strJson = "{" + strJson + "}";
                }
                else
                {
                    strJson = "\"menus\":[]";
                }
                //string strJson = "[{\"id\":\"1\",\"text\":\"hello1\",\"checked\":\"true\",\"state\":\"open\",\"children\":[{\"id\":\"2\",\"text\":\"hello2\",\"state\":\"open\"}]},{\"id\":\"1\",\"text\":\"hello1\",\"state\":\"open\",\"children\":[{\"id\":\"2\",\"text\":\"hello2\",\"state\":\"open\"}]}]";
            }
            catch (Exception ex)
            {
                throw;
            }
            return(Content(strJson));
        }
Пример #2
0
        /// <summary>
        /// 添加或修改数据
        /// </summary>
        public ActionResult UpdateData()
        {
            try
            {
                bool  blResult = false;
                int   id       = Request.Form["id"] != "" ? Convert.ToInt32(Request.Form["id"]) : 0;
                Users model    = GetData(id);

                string writeMsg = "操作失败!";
                if (model != null)
                {
                    if (id < 1)
                    {
                        if (WebCookieHelper.EmployeeCheckLogin())
                        {
                            int empid = WebCookieHelper.GetEmployeeId();

                            model.EmployeeID = empid;
                            //判断是否已经有相同号码的考生
                            if (EnterRepository.GetRepositoryEnter().UsersRepository.LoadEntities(m => m.Tel == model.Tel).Count() > 0)
                            {
                                writeMsg = "存在相同的电话号码无法新增,请查看考生是否在预报名列表";
                            }
                            else
                            {
                                EnterRepository.GetRepositoryEnter().UsersRepository.AddEntity(model);
                                if (EnterRepository.GetRepositoryEnter().SaveChange() > 0)
                                {
                                    writeMsg = "增加成功!";
                                }
                            }
                        }
                        else
                        {
                            writeMsg = "请重新登录!";
                        }
                    }
                    else
                    {
                        //EnterRepository.GetRepositoryEnter().UsersRepository.Get(m => m.ID == id);
                        EnterRepository.GetRepositoryEnter().UsersRepository.EditEntity(model, new string[] { "Name", "School", "ExamSchool", "Sequences", "Tel", "Baks", "PayMoney", "ExamPlace", "Room", "Hotel", "HotelExpense", "MoneyBack", "Gender", "Template", "PayPlace", "ExceptRoomie", "Status" });
                        if (EnterRepository.GetRepositoryEnter().SaveChange() > 0)
                        {
                            writeMsg = "更新成功!";
                        }
                        else
                        {
                            writeMsg = "更新失败!";
                        }
                    }
                }
                return(Content(writeMsg));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #3
0
        public ActionResult Index()
        {
            if (!WebCookieHelper.EmployeeCheckLogin())
            {
                return(Redirect("/Admin/Account/Login"));
            }

            ViewBag.Name = WebCookieHelper.GetEmployeeInfo((int)WebCookieHelper.EmployeeInfo.Name);
            return(View());
        }
Пример #4
0
        //
        // GET: /Employee/

        public ActionResult Index(int?id)
        {
            if (!WebCookieHelper.EmployeeCheckLogin())
            {
                string userAgent = Request.UserAgent;
                if (userAgent.ToLower().Contains("micromessenger"))
                {
                    Utility.CookieHelper.SetCookie("returnurl", Request.Url.ToString(), "", 1);
                    return(Redirect("/weixin/account"));
                }
                else
                {
                    return(Redirect("/member/login?returnurl=" + Request.Url));
                }
            }
            string tel  = string.Empty;
            string name = string.Empty;

            string keyword = Request.QueryString["keyword"];

            name = keyword;
            Pagination pagination = new Pagination();
            int        page       = 1;

            if (id != null)
            {
                page = int.Parse(id.ToString());
            }

            int totalCount = 0;

            pagination.Size      = 30;
            pagination.ActionUrl = "employee/index";

            pagination.CurrentPageIndex = page;
            DateTime startTime     = DateTime.Now;
            int      szEmployeeIDs = 0;
            int      empid         = WebCookieHelper.GetEmployeeId();

            if (!RightServices.CheckAuthority(SystemContext.RightPoint.ViewAllUsers, empid))
            {
                szEmployeeIDs = empid;
            }
            var    lstUsers = EnterRepository.GetRepositoryEnter().UsersRepository.LoadPageList(szEmployeeIDs, empid, tel, name, (page - 1) * pagination.Size, pagination.Size, out totalCount).ToList();
            string time     = (DateTime.Now - startTime).TotalSeconds.ToString();

            pagination.TotalCount = totalCount;
            pagination.Order      = "Name";
            pagination.Keyword    = keyword;
            ViewBag.time          = time;
            ViewBag.keyword       = keyword;
            ViewBag.users         = lstUsers;
            ViewBag.Pagination    = pagination;
            return(View());
        }
Пример #5
0
        public ActionResult Order()
        {
            if (!WebCookieHelper.EmployeeCheckLogin())
            {
                string userAgent = Request.UserAgent;
                if (userAgent.ToLower().Contains("micromessenger"))
                {
                    Utility.CookieHelper.SetCookie("returnurl", Request.Url.ToString(), "", 1);
                    return(Redirect("/weixin/account"));
                }
                else
                {
                    return(Redirect("/member/login?returnurl=" + Request.Url));
                }
            }
            var users = EnterRepository.GetRepositoryEnter().UsersRepository.LoadEntities(m => m.EmployeeID == 0).OrderByDescending(m => m.ID).ToList();

            ViewBag.users = users;
            return(View());
        }
Пример #6
0
        public ActionResult QueryEmployeeIDs()
        {
            try
            {
                if (!WebCookieHelper.EmployeeCheckLogin())
                {
                    return(RedirectToAction("Admin/Account/Login"));
                }
                JsonHelper json    = new JsonHelper();
                string     strJson = string.Empty;
                json.AddItem("id", "");
                json.AddItem("text", "所有");
                json.ItemOk();

                int    empid = WebCookieHelper.GetEmployeeId();
                string Name  = WebCookieHelper.GetEmployeeInfo((int)WebCookieHelper.EmployeeInfo.Name);
                if (!RightServices.CheckAuthority(SystemContext.RightPoint.ViewAllUsers, empid))
                {
                    json.AddItem("id", empid.ToString());
                    json.AddItem("text", Name);
                    json.ItemOk();
                }
                else
                {
                    var result = UsersServices.GetStaffEmployee(empid);
                    foreach (Employee item in result)
                    {
                        json.AddItem("id", item.ID.ToString());
                        json.AddItem("text", item.Name);
                        json.ItemOk();
                    }
                }
                strJson = json.ToEasyuiListJsonString();
                return(Content(strJson));
            }
            catch (Exception ex)
            {
                GlobalMethod.log.Error(ex);
                throw;
            }
        }
Пример #7
0
        public ActionResult Export()
        {
            string     jsons        = "";
            JsonHelper jsonHelper   = new JsonHelper();
            var        Template     = Request.Form["Template"];
            var        Name         = Request.Form["Name"];
            var        szEmployeeID = Request.Form["EmployeeID"];

            string filePath = string.Format("{0}{1}"
                                            , Server.MapPath(SystemContext.FilePath.Excel)
                                            , "test.xls");

            if (!WebCookieHelper.EmployeeCheckLogin())
            {
                return(Content(""));
            }
            int empid = WebCookieHelper.GetEmployeeId();

            if (string.IsNullOrEmpty(szEmployeeID) || szEmployeeID == "所有")
            {
                szEmployeeID = "0";
            }

            if (!RightServices.CheckAuthority(SystemContext.RightPoint.ViewAllUsers, empid))
            {
                szEmployeeID = empid.ToString();
            }
            try
            {
                var lstUser = EnterRepository.GetRepositoryEnter().UsersRepository.GetUsersList(int.Parse(szEmployeeID), empid, null, null);

                string           templateValue = SystemContext.Template.GetTemplate(Template);
                ExcelHelper      excelOpr      = new ExcelHelper();
                string[]         columnName    = templateValue.Split(',');
                List <ArrayList> values        = new List <ArrayList>();
                foreach (var user in lstUser)
                {
                    ArrayList value = new ArrayList();
                    for (int j = 0; j < columnName.Length; j++)
                    {
                        value.Add(GetColumnValue(user, columnName[j]));
                    }
                    value.Add("");
                    values.Add(value);
                }

                excelOpr.ToExcel(filePath, columnName, values);
                jsons = "[{\"success\":true,msg:\"导出成功\",filePath:\""
                        + string.Format("{0}/{1}"
                                        , SystemContext.FilePath.Excel
                                        , "test.xls")
                        + "\"}]";
            }
            catch (Exception ex)
            {
                GlobalMethod.log.Error(ex);

                jsons = "[{\"success\":true,msg:\"导出失败\"}]";
            }
            return(Content(jsons));
        }
Пример #8
0
        /// <summary>
        /// 查询数据
        /// </summary>
        public ActionResult QueryData()
        {
            try
            {
                int    page          = Request.Form["page"] != "" ? Convert.ToInt32(Request.Form["page"]) : 0;
                int    size          = Request.Form["rows"] != "" ? Convert.ToInt32(Request.Form["rows"]) : 0;
                string sort          = Request.Form["sort"] != "" ? Request.Form["sort"] : "";
                string order         = Request.Form["order"] != "" ? Request.Form["order"] : "";
                string Template      = Request.Form["Template"] != "" ? Request.Form["Template"] : "";
                string szEmployeeIDs = !string.IsNullOrEmpty(Request.Form["EmployeeID"]) ? Request.Form["EmployeeID"] : "0";
                string Name          = Request.Form["Name"] != "" ? Request.Form["Name"] : "";
                string Tel           = Request.Form["Tel"] != "" ? Request.Form["Tel"] : "";
                if (page < 1)
                {
                    return(Content(""));
                }
                if (Name == "所有")
                {
                    Name = string.Empty;
                }
                if (szEmployeeIDs == "所有")
                {
                    szEmployeeIDs = "0";
                }

                if (!WebCookieHelper.EmployeeCheckLogin())
                {
                    return(Content(""));
                }
                int empid = WebCookieHelper.GetEmployeeId();
                if (!RightServices.CheckAuthority(SystemContext.RightPoint.ViewAllUsers, empid))
                {
                    szEmployeeIDs = empid.ToString();
                }
                int        rowCount = 0;
                var        lstUsers = EnterRepository.GetRepositoryEnter().UsersRepository.LoadPageList(int.Parse(szEmployeeIDs), empid, Tel, Name, (page - 1) * size, size, out rowCount).ToList();
                JsonHelper json     = new JsonHelper();
                string     strJson  = string.Empty;
                try
                {
                    foreach (Users item in lstUsers)
                    {
                        item.Hotel = item.Hotel == null?"":item.Hotel.Replace("\t", "");
                        item.Tel   = item.Tel == null ? "" : item.Tel.Replace("\n", "");
                        item.Baks  = item.Baks == null ? "" : item.Baks.Replace("\n", "");
                        json.AddItem("ID", item.ID.ToString());
                        json.AddItem("Name", item.Name);
                        json.AddItem("School", item.School);
                        json.AddItem("ExamSchool", item.ExamSchool);
                        json.AddItem("Sequences", item.Sequences.ToString());
                        json.AddItem("Tel", item.Tel);
                        json.AddItem("Baks", item.Baks);
                        json.AddItem("Pwd", item.Pwd);
                        json.AddItem("PayMoney", item.PayMoney);
                        json.AddItem("ExamPlace", item.ExamPlace);
                        json.AddItem("Hotel", item.Hotel);
                        json.AddItem("PassWord", item.Pwd);
                        json.AddItem("PayMoney", item.PayMoney);
                        json.AddItem("ExamPlace", item.ExamPlace);
                        json.AddItem("Room", item.Room);
                        json.AddItem("Hotel", item.Hotel);
                        json.AddItem("HotelExpense", item.HotelExpense);
                        json.AddItem("MoneyBack", item.MoneyBack);
                        json.AddItem("EmployeeID", item.EmployeeID.ToString());
                        json.AddItem("EmployeeName", item.EmployeeName);
                        json.AddItem("Gender", item.Gender);
                        json.AddItem("Template", item.Template);
                        json.AddItem("PayPlace", item.PayPlace);
                        json.AddItem("CreateTime", item.CreateTime == null?DateTime.Now.ToString():item.CreateTime.ToString());
                        json.AddItem("ExceptRoomie", item.ExceptRoomie);
                        json.AddItem("Status", item.Status);
                        json.AddItem("Prize", item.Prize);
                        json.ItemOk();
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }
                json.totlalCount = rowCount;
                if (json.totlalCount > 0)
                {
                    strJson = json.ToEasyuiGridJsonString();
                }
                else
                {
                    strJson = @"[]";
                }
                // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateUser\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyUser\":\"ceshi\"} ],\"total\":3}";
                return(Content(strJson));
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
        }