Beispiel #1
0
        public ActionResult Edit(FormCollection form)
        {
            string writeMsg = string.Empty;
            Hotel  item     = new Hotel();

            item.ID         = int.Parse(Request.Form["ID"]);
            item.Title      = Request.Form["Title"];
            item.Keywords   = Request.Form["Keywords"];
            item.Content    = form["Content"];
            item.CategoryID = int.Parse(Request.Form["CategoryID"]);
            item.ModifyID   = WebCookieHelper.GetEmployeeId();
            item.ModifyTime = DateTime.Now;
            item.ImagePath  = HtmlContentHelper.GetFirstImgUrl(item.Content);
            item.Summary    = HtmlContentHelper.GetSummary(item.Content);

            EnterRepository.GetRepositoryEnter().HotelRepository.Get(m => m.ID == item.ID);
            bool result = EnterRepository.GetRepositoryEnter().HotelRepository.EditEntity(item, new string[] { "Title", "Keywords", "CategoryID", "Content", "ModifyID", "ModifyTime", "ImagePath", "Summary" });

            if (EnterRepository.GetRepositoryEnter().SaveChange() > 0)
            {
                writeMsg = "修改成功!";
            }
            else
            {
                writeMsg = "修改失败!";
            }
            return(Content(writeMsg));
        }
Beispiel #2
0
 /// <summary>
 /// 导入订房报名
 /// </summary>
 public ActionResult ImportOrder()
 {
     try
     {
         string   writeMsg = "";
         string   selectID = Request.Form["cbx_select"] != "" ? Request.Form["cbx_select"] : "";
         string[] ids      = selectID.Split(',');
         if (ids.Count() > 0)
         {
             int employeeid = WebCookieHelper.GetEmployeeId();
             foreach (var item in ids)
             {
                 int id     = Convert.ToInt32(item);
                 var result = EnterRepository.GetRepositoryEnter().UsersRepository.LoadEntities(m => m.ID == id).FirstOrDefault();
                 result.EmployeeID = employeeid;
                 EnterRepository.GetRepositoryEnter().UsersRepository.EditEntity(result, new string[] { "EmployeeID" });
             }
             if (EnterRepository.GetRepositoryEnter().SaveChange() > 0)
             {
                 writeMsg = string.Format("导入成功");
             }
             else
             {
                 writeMsg = "导入失败";
             }
         }
         return(Content(writeMsg));
     }
     catch (Exception ex)
     {
         log.Error(ex);
         return(Content("导入失败!"));
     }
 }
Beispiel #3
0
        public ActionResult Add(FormCollection form)
        {
            string writeMsg = string.Empty;
            Hotel  item     = new Hotel();

            item.Title      = Request.Form["Title"];
            item.Keywords   = Request.Form["Keywords"];
            item.CategoryID = int.Parse(Request.Form["CategoryID"]);
            item.Content    = form["Content"];
            item.CreateID   = WebCookieHelper.GetEmployeeId();
            item.CreateTime = DateTime.Now;
            item.ModifyID   = WebCookieHelper.GetEmployeeId();
            item.ModifyTime = DateTime.Now;
            item.ImagePath  = HtmlContentHelper.GetFirstImgUrl(item.Content);
            item.Summary    = HtmlContentHelper.GetSummary(item.Content);

            EnterRepository.GetRepositoryEnter().HotelRepository.AddEntity(item);
            if (EnterRepository.GetRepositoryEnter().SaveChange() > 0)
            {
                writeMsg = "{msg:\"保存成功!\",id:" + item.ID.ToString() + "}";
            }
            else
            {
                writeMsg = "{msg:\"保存失败!\",id:0}";
            }
            return(Content(writeMsg));
        }
Beispiel #4
0
        public ActionResult ChangePwd()
        {
            string szPwdOld     = Request.Form["pwdold"] != "" ? Request.Form["pwdold"] : "";
            string szPwdNew     = Request.Form["pwdnew"] != "" ? Request.Form["pwdnew"] : "";
            string szPwdConfirm = Request.Form["pwdconfirm"] != "" ? Request.Form["pwdconfirm"] : "";
            int    id           = WebCookieHelper.GetEmployeeId();
            var    curUser      = EnterRepository.GetRepositoryEnter().EmployeeRepository.LoadEntities(m => m.ID == id).FirstOrDefault();

            if (curUser == null)
            {
                return(RedirectToAction("Login"));
            }
            string writeMsg = "更改失败!";

            if (curUser.Pwd != szPwdOld)
            {
                writeMsg = "原始密码错误,无法更改密码!";
            }
            else
            {
                curUser.Pwd = szPwdNew;
                EnterRepository.GetRepositoryEnter().EmployeeRepository.EditEntity(curUser, new string[] { "Pwd" });
                if (EnterRepository.GetRepositoryEnter().SaveChange() > 0)
                {
                    writeMsg = "更改成功!";
                }
                else
                {
                    writeMsg = "更改失败!";
                }
            }
            return(Content(writeMsg));
        }
Beispiel #5
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));
        }
Beispiel #6
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;
            }
        }
Beispiel #7
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());
        }
Beispiel #8
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;
            }
        }
Beispiel #9
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));
        }
Beispiel #10
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;
            }
        }
Beispiel #11
0
        public ActionResult ArticleBack()
        {
            int    employeeID = WebCookieHelper.GetEmployeeId();
            string writeMsg   = "同步成功!";

            try
            {
                string selectID = Request.Form["cbx_select"] != "" ? Request.Form["cbx_select"] : "";
                if (selectID != string.Empty && selectID != "0")
                {
                    string[] ids = selectID.Split(',');
                    foreach (var item in ids)
                    {
                        int id   = int.Parse(item);
                        var blog = EnterRepository.GetRepositoryEnter().BlogRepository.LoadEntities(m => m.ID == id).FirstOrDefault();
                        if (blog.ArticleID == 0)
                        {
                            var article = new Article();
                            article.CategoryID = blog.CategoryID;
                            article.Content    = blog.Content;
                            article.Title      = blog.Title;
                            article.ViewCount  = blog.ViewCount;
                            article.Summary    = blog.Summary;
                            article.ModifyTime = blog.ModifyTime;
                            article.ModifyID   = employeeID;
                            article.Keywords   = blog.Keywords;
                            article.ImagePath  = blog.ImagePath;
                            article.CreateID   = employeeID;
                            article.CreateTime = blog.CreateTime;
                            EnterRepository.GetRepositoryEnter().ArticleRepository.AddEntity(article);
                            if (EnterRepository.GetRepositoryEnter().SaveChange() <= 0)
                            {
                                writeMsg = string.Format("同步失败");
                                break;
                            }
                            blog.ArticleID = article.ID;
                            EnterRepository.GetRepositoryEnter().BlogRepository.Get(m => m.ID == id);
                            EnterRepository.GetRepositoryEnter().BlogRepository.EditEntity(blog, new string[] { "ArticleID" });
                            if (EnterRepository.GetRepositoryEnter().SaveChange() <= 0)
                            {
                                writeMsg = string.Format("同步失败");
                                break;
                            }
                        }
                        else
                        {
                            var article = EnterRepository.GetRepositoryEnter().ArticleRepository.LoadEntities(m => m.ID == blog.ArticleID).FirstOrDefault();
                            if (article != null)
                            {
                                article.CategoryID = blog.CategoryID;
                                article.Content    = blog.Content;
                                article.Title      = blog.Title;
                                article.ViewCount  = blog.ViewCount;
                                article.Summary    = blog.Summary;
                                article.Keywords   = blog.Keywords;
                                article.ModifyTime = blog.ModifyTime;
                                article.ModifyID   = employeeID;
                                article.ImagePath  = blog.ImagePath;
                                article.CreateID   = employeeID;
                                article.CreateTime = blog.CreateTime;
                                EnterRepository.GetRepositoryEnter().ArticleRepository.Get(m => m.ID == article.ID);
                                EnterRepository.GetRepositoryEnter().ArticleRepository.EditEntity(article, new string[] {
                                    "CategoryID"
                                    , "Content"
                                    , "Title"
                                    , "ViewCount"
                                    , "Summary"
                                    , "Keywords"
                                    , "ModifyTime"
                                    , "ModifyID"
                                    , "CreateID"
                                    , "CreateTime"
                                    , "ImagePath"
                                });
                                if (EnterRepository.GetRepositoryEnter().SaveChange() <= 0)
                                {
                                    writeMsg = string.Format("同步失败");
                                    break;
                                }
                            }
                            else
                            {
                                article            = new Article();
                                article.CategoryID = blog.CategoryID;
                                article.Content    = blog.Content;
                                article.Title      = blog.Title;
                                article.ViewCount  = blog.ViewCount;
                                article.Summary    = blog.Summary;
                                article.Keywords   = blog.Keywords;
                                article.ModifyTime = blog.ModifyTime;
                                article.ModifyID   = employeeID;
                                article.ImagePath  = blog.ImagePath;
                                article.CreateID   = employeeID;
                                article.CreateTime = blog.CreateTime;
                                EnterRepository.GetRepositoryEnter().ArticleRepository.AddEntity(article);
                                if (EnterRepository.GetRepositoryEnter().SaveChange() <= 0)
                                {
                                    writeMsg = string.Format("同步失败");
                                    break;
                                }
                                blog.ArticleID = article.ID;
                                EnterRepository.GetRepositoryEnter().BlogRepository.Get(m => m.ID == id);
                                EnterRepository.GetRepositoryEnter().BlogRepository.EditEntity(blog, new string[] { "ArticleID" });
                                if (EnterRepository.GetRepositoryEnter().SaveChange() <= 0)
                                {
                                    writeMsg = string.Format("同步失败");
                                    break;
                                }
                            }
                        }
                    }
                }
                return(Content(writeMsg));
            }
            catch (Exception ex)
            {
                GlobalMethod.log.Error(ex);
                writeMsg = "同步失败";
                return(Content(writeMsg));
            }
        }