Beispiel #1
0
        /// <summary>
        /// 角色管理页面
        /// </summary>
        /// <returns></returns>
        public ActionResult RoleManage()
        {
            //删除角色

            //接收角色id
            if (Request["num"] != null)
            {
                int id = Convert.ToInt32(Request["num"]);
                //根据角色id查询“员工角色表”此角色有无员工担当
                Employee_RoleInfo er = dal.GetEmployee_RoleInfoByRoleID(id);
                if (er != null)
                {
                    return(Content("0"));
                }
                else
                {
                    //根据角色id删除角色
                    bool isDel = dal.DelRoleByRoleID(id);
                    if (isDel)
                    {
                        return(Content("1"));
                    }
                }
            }


            //查询所有员工
            EmployeeDal         emdal  = new EmployeeDal();
            List <EmployeeInfo> emlist = emdal.GetAllEmployeer();
            //查询所有权限(查询菜单栏)
            PermissionDal         pd       = new PermissionDal();
            List <PermissionInfo> perslist = pd.GetAll();
            //查询所有角色
            List <RoleInfo> roles = dal.GetRoles();

            ViewBag.emlist = emlist;
            ViewBag.roles  = roles;


            int?   RoleID   = Convert.ToInt32(Request["RoleID"]);
            string RoleName = Request["RoleName"];

            if (RoleName != null)
            {
                Session["RoleName"] = RoleName;
            }
            if (RoleID != 0)
            {
                Session["RoleID"] = RoleID;
                List <RoleInfo_PermissionInfo> persByRoID   = dal.GetPerByRoleID(RoleID);
                List <PermissionInfo>          NotPerByRoId = dal.GetNotPerByRoId(RoleID);
                ViewBag.persByRoID   = persByRoID;
                ViewBag.NotPerByRoId = NotPerByRoId;
                ViewBag.perslist     = perslist;
            }


            return(View());
        }