/// <summary>
        /// 添加和编辑关键字信息
        /// </summary>
        /// <returns></returns>
        public ActionResult OperateGuanJianZi(string id)
        {
            WeiXin.BO.GuanJianZiContract pc = new WeiXin.BO.GuanJianZiContract();
            var operateType = Request.QueryString["operateType"];
            var url = Request.QueryString["url"];

            #region 绑定关键字所属企业
            List<employeeInfo> list = new List<employeeInfo>();
            if ((Session["user"] as UsersContract).RoleID == 1)
            {
                #region 系统管理员 获取所有企业
                list = gs.GetAllEmp();
                #endregion
            }
            else
            {
                #region 获取自己的企业
                list.Add(es.GetEmployeeinfoByEId((Session["user"] as UsersContract).EId));
                #endregion
            }

            #endregion

            #region 绑定关键字类型
            List<GuanJianZiHuiFuTypeContract> gjzType = new List<GuanJianZiHuiFuTypeContract>();
            //获取所有的关键字类型
            List<GuanJianZiType> dsGJZType = gs.GetAllGJZType();

            foreach (var item in dsGJZType)
            {
                GuanJianZiHuiFuTypeContract tt = new GuanJianZiHuiFuTypeContract();
                tt.Id = Convert.ToInt32(item.Id);
                tt.name = item.name;
                gjzType.Add(tt);
            }
            ViewData["gjzType"] = new SelectList(gjzType, "Id", "name");
            #endregion

            switch (operateType)
            {
                case "add":
                    ViewBag.pTitle = "添加关键字";

                    ViewData["Emp"] = new SelectList(list, "Eid", "wxName");
                    return View(pc);
                default:
                    ViewBag.pTitle = "编辑关键字";

                    if (id != null)
                    {
                        //根据关键字编号查询关键字的方法
                        pc = gs.GetGuanJianZiByGJZId(int.Parse(id));
                    }

                    ViewData["Emp"] = new SelectList(list, "Eid", "wxName", pc.eId);
                    return View(pc);
            }
        }
        /// <summary>
        /// 添加和编辑回复关键字信息
        /// </summary>
        /// <returns></returns>
        public ActionResult OperateGuanJianZiHuiFu(string id)
        {
            GuanJianZiHuiFuContract pc = new GuanJianZiHuiFuContract();
            var operateType = Request.QueryString["operateType"];
            var url = Request.QueryString["url"];

            #region 绑定关键字回复内容所属的关键字
            List<GuanJianZiHuiFuTypeContract> list = new List<GuanJianZiHuiFuTypeContract>();
            //获取所有的关键字类型
            List<GuanJianZiHuiFuType> dsGJZType = hfs.GetAllGJZType();

            foreach (var item in dsGJZType)
            {
                GuanJianZiHuiFuTypeContract emp = new GuanJianZiHuiFuTypeContract();
                emp.trueId = Convert.ToInt32(item.trueId);
                emp.name = item.name;
                list.Add(emp);
            }

            ViewData["gjz"] = new SelectList(list, "trueId", "name");
            #endregion

            #region 绑定企业
            List<employeeInfo> listEmp = null;
            if ((Session["user"] as UsersContract).RoleID == 1)
            {
                #region 系统管理员 获取所有企业信息
                listEmp = gs.GetAllEmp();
                #endregion
            }
            else
            {
                #region 获取自己的关键字
                listEmp = gs.GetAllEmp((Session["user"] as UsersContract).EId);
                #endregion
            }
            //获取所有的企业

            ViewData["emp"] = new SelectList(listEmp, "Eid", "wxName");
            #endregion

            switch (operateType)
            {
                case "add":
                    ViewBag.pTitle = "添加回复内容";

                    return View(pc);
                default:
                    ViewBag.pTitle = "编辑回复内容";

                    if (id != null && id != "0")
                    {
                        //根据关键字回复编号查询关键字的方法
                        pc = hfs.GetGuanJianZiHuiFuByHFId(int.Parse(id));
                    }

                    ViewData["nowGJZId"] = pc.gjzId;
                    ViewData["nowTypeId"] = pc.typeId;
                    ViewData["content"] = pc.content;
                    ViewData["oldImg"] = pc.img;
                    return View(pc);
            }
        }
        public ActionResult OperateGuanJianZiHuiFu(FormCollection fc, GuanJianZiHuiFuContract pc, string id, string url)
        {
            #region 绑定关键字回复内容所属的关键字
            List<GuanJianZiHuiFuTypeContract> list = new List<GuanJianZiHuiFuTypeContract>();
            //获取所有的关键字类型
            List<GuanJianZiHuiFuType> dsGJZType = hfs.GetAllGJZType();

            foreach (var item in dsGJZType)
            {
                GuanJianZiHuiFuTypeContract emp = new GuanJianZiHuiFuTypeContract();
                emp.trueId = Convert.ToInt32(item.trueId);
                emp.name = item.name;
                list.Add(emp);
            }

            ViewData["gjz"] = new SelectList(list, "trueId", "name");
            #endregion

            #region 绑定企业
            List<employeeInfo> listEmp = null;
            if ((Session["user"] as UsersContract).RoleID == 1)
            {
                #region 系统管理员 获取所有企业信息
                listEmp = gs.GetAllEmp();
                #endregion
            }
            else
            {
                #region 获取自己的关键字
                listEmp = gs.GetAllEmp((Session["user"] as UsersContract).EId);
                #endregion
            }
            //获取所有的企业

            ViewData["emp"] = new SelectList(listEmp, "Eid", "wxName");
            #endregion

            var countent = new MvcHtmlString(pc.content);
            pc.content = countent.ToString();

            //图文图片
            string img = fc["willUploadImg"];

            //判断要添加的关键字是否已经存在
            //if (hfs.IsExists(pc.content, pc.gjzId.ToString(), id))
            //{
            //    //执行失败信息
            //    ViewData["msg"] = "要添加的回复内容已经存在,请先确认!";
            //    //失败视图
            //    return View("Error");
            //}
            //else
            //{
            pc.time = DateTime.Now.ToString();
            pc.img = img;
            switch (ModelState.IsValid)
            {
                case true:

                    //如果要修改的编号为null,则为添加回复信息操作
                    if (id != null && id == "0")
                    {
                        if (hfs.AddGuanJianZiHuiFu(pc) > 0)
                        {
                            //成功后要跳转的路径(如果无须跳转,直接留在当前页面,不写即可)
                            ViewData["url"] = new UrlHelper(Request.RequestContext).Action("GuanJianZiHuiFuMain");

                            //执行成功信息
                            ViewData["msg"] = "添加回复内容成功!";
                            //成功视图
                            return View("Success");
                        }
                        else
                        {
                            //执行成功信息
                            ViewData["msg"] = "添加回复内容失败!";
                            return View("Error");
                        }
                    }
                    else
                    {
                        pc.gjzId = int.Parse(fc["gjzId"]);
                        if (hfs.UpdateGuanJianZiHuiFu(pc) > 0)
                        {
                            //执行成功信息
                            ViewData["msg"] = "修改回复内容成功!";
                            //成功后要跳转的路径(如果无须跳转,直接留在当前页面,不写即可)
                            ViewData["url"] = new UrlHelper(Request.RequestContext).Action("GuanJianZiHuiFuMain");
                            //成功视图
                            return View("Success");
                        }
                        else
                        {
                            ViewData["msg"] = "修改关回复内容失败!";
                            return View("Error");
                        }
                    }
                default:
                    ViewBag.pTitle = "添加回复内容信息";
                    return View(new GuanJianZiHuiFuContract());
                //}
            }
        }
        public ActionResult OperateGuanJianZi(GuanJianZiContract pc, string id, string url)
        {
            pc.time = DateTime.Now.ToString("yyyy-MM-dd");

            #region 绑定关键字所属企业
            List<employeeInfo> list = new List<employeeInfo>();
            if ((Session["user"] as UsersContract).RoleID == 1)
            {
                #region 系统管理员 获取所有企业
                list = gs.GetAllEmp();
                #endregion
            }
            else
            {
                #region 获取自己的企业
                list.Add(es.GetEmployeeinfoByEId((Session["user"] as UsersContract).EId));
                #endregion
            }

            #endregion

            #region 绑定关键字类型
            List<GuanJianZiHuiFuTypeContract> gjzType = new List<GuanJianZiHuiFuTypeContract>();
            //获取所有的关键字类型
            List<GuanJianZiType> dsGJZType = gs.GetAllGJZType();

            foreach (var item in dsGJZType)
            {
                GuanJianZiHuiFuTypeContract tt = new GuanJianZiHuiFuTypeContract();
                tt.Id = Convert.ToInt32(item.Id);
                tt.name = item.name;
                gjzType.Add(tt);
            }
            ViewData["gjzType"] = new SelectList(gjzType, "Id", "name");
            #endregion

            //判断要添加的关键字是否已经存在
            if (gs.IsExists(pc.name, pc.eId.ToString(), id))
            {
                //执行失败信息
                ViewData["msg"] = "【" + pc.name + "】这个关键字已经存在,请先确认!";
                //失败视图
                return View("Error");
            }
            else
            {
                switch (ModelState.IsValid)
                {
                    case true:

                        //如果要修改的编号为null,则为添加关键字信息操作
                        if (id == null)
                        {

                            if (gs.AddGuanJianZi(pc) > 0)
                            {

                                //成功后要跳转的路径(如果无须跳转,直接留在当前页面,不写即可)
                                ViewData["url"] = new UrlHelper(Request.RequestContext).Action("GuanJianZiMain");

                                //执行成功信息
                                ViewData["msg"] = "添加关键字成功!";
                                //成功视图
                                return View("Success");
                            }
                            else
                            {
                                //执行成功信息
                                ViewData["msg"] = "添加关键字失败!";
                                return View("Error");
                            }
                        }
                        else
                        {
                            pc.gjzId = int.Parse(id);
                            if (gs.UpdateGuanJianZi(pc) > 0)
                            {
                                //执行成功信息
                                ViewData["msg"] = "修改关键字成功!";
                                //成功后要跳转的路径(如果无须跳转,直接留在当前页面,不写即可)
                                ViewData["url"] = new UrlHelper(Request.RequestContext).Action("GuanJianZiMain");
                                //成功视图
                                return View("Success");
                            }
                            else
                            {
                                ViewData["msg"] = "修改关键字失败!";
                                return View("Error");
                            }
                        }
                    default:
                        ViewBag.pTitle = "添加关键字信息";
                        return View(new GuanJianZiHuiFuContract());
                }
            }
        }