public ActionResult RoleAllLoad()
        {
            BLL.Organize.Role Role = new BLL.Organize.Role();

            var result = Role.LoadAllRoleByPage();

            return(Json(result));
        }
        public ActionResult RoleLoadAll()
        {
            BLL.Organize.Role role = new BLL.Organize.Role();

            var result = role.LoadAllRole();

            return(Json(result));
        }
        public ActionResult RoleLoad(int page, int rows, string order, string sort)
        {
            BLL.Organize.Role Role = new BLL.Organize.Role();

            var result = Role.LoadAllRoleByPage(page, rows, order, sort);

            return(Json(result));
        }
        public ActionResult RoleEdit(int?id)
        {
            BLL.Organize.Role role = new BLL.Organize.Role();
            this.ViewData["entity"] = role.Edit(id);

            if (id != null)
            {
                ViewData["action"] = string.Join(",", role.LoadRoleAction((int)id));
            }

            return(View());
        }
        public ActionResult RoleSave(B_ROLE entity)
        {
            BLL.Organize.Role role = new BLL.Organize.Role();

            string action = Request.Form["action"];
            string range  = Request.Form["range"];

            if (ModelState.IsValid)
            {
                bool save;
                try
                {
                    save = role.Save(entity);
                    List <int> listActionId = new List <int>();
                    if (!string.IsNullOrEmpty(action))
                    {
                        foreach (string a in action.Split(',').ToList())
                        {
                            listActionId.Add(int.Parse(a));
                        }
                    }
                    List <string> listRangeId = new List <string>();
                    if (!string.IsNullOrEmpty(range))
                    {
                        foreach (string a in range.Split(',').ToList())
                        {
                            listRangeId.Add(a);
                        }
                    }
                    //role.SaveRoleAction(entity.ID, listActionId);
                    Anchor.FA.BLL.Organize.Role.SaveRoleAction(entity.ID, listActionId, listRangeId);
                }
                catch (Exception ex)
                {
                    Log4Net.LogError("RoleSave", ex.ToString());
                    save = false;
                }
                if (save)
                {
                    return(Json(new { IsSuccess = true, Message = "保存成功" }, "text/html", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { IsSuccess = false, Message = "保存失败" }, "text/html", JsonRequestBehavior.AllowGet));
                }
            }
            return(View());
        }
        public ActionResult RoleEdit2(int?id)
        {
            BLL.Organize.Role role = new BLL.Organize.Role();
            this.ViewData["entity"] = role.Edit(id);

            if (id != null)
            {
                ViewData["type"] = "修改角色";
                //ViewData["action"] = string.Join(",", role.LoadRoleAction((int)id));
                //ViewData["ActionRange"] = string.Join(",", role.LoadRoleActionRange((int)id));
                ViewData["ActionRange"] = string.Join(",", Anchor.FA.BLL.Organize.Role.LoadRoleActionRange((int)id).Select(t => "\"" + t + "\""));
            }
            else
            {
                ViewData["type"] = "新增角色";
            }

            return(View());
        }
        public ActionResult RoleDelete(IList <int> idList)
        {
            BLL.Organize.Role Role = new BLL.Organize.Role();
            bool delete;

            try
            {
                delete = Role.Delete(idList);
            }
            catch (Exception)
            {
                delete = false;
            }

            if (delete)
            {
                return(Json(new { IsSuccess = true, Message = "删除成功" }));
            }
            else
            {
                return(Json(new { IsSuccess = false, Message = "删除失败" }));
            }
        }