Example #1
0
        /// <summary>
        /// ds2012
        /// 删除角色信息
        /// </summary>
        /// <returns></returns>
        public static string DelDeptRole(HttpContext context, int roleid)
        {
            DeptRoleModel deptRole = DeptRoleDAL.GetRoleDeptByID(roleid);

            if (deptRole == null)
            {
                return("该角色已经删除!");
            }
            return(DeptRoleDAL.DelDeptRole(roleid));
        }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Permissions.ComRedirect(Page, Permissions.redirUrl);
        Response.Cache.SetExpires(DateTime.Now);
        Permissions.CheckManagePermission(Model.Other.EnumCompanyPermission.SafeRightManageEdit);
        if (!IsPostBack)
        {
            if (Request.QueryString["id"] == null)
            {
                Response.Redirect("DeptRolesManage.aspx");
            }

            int  roleId = 0;
            bool b      = int.TryParse(Request.QueryString["id"], out roleId);
            //验证角色编号的合法性
            if (!b)
            {
                //编号不合法则转到角色管理页面
                Response.Redirect("DeptRolesManage.aspx");
            }

            string number   = Session["Company"].ToString();
            string manageId = BLL.CommonClass.CommonDataBLL.getManageID(1);
            if (number != manageId)
            {
                if (!DeptRoleBLL.CheckAllot(number, roleId))
                {
                    ScriptHelper.SetAlert((Control)sender, GetTran("000975", "不能对该角色进行操作,没有权限!"), "DeptRolesManage.aspx");
                    return;
                }
            }
            else
            {
                ManageModel model = ManagerBLL.GetManage(number);
                if (model.RoleID == roleId)
                {
                    ScriptHelper.SetAlert((Control)sender, GetTran("001180", "不能对该系统管理角色进行任何操作."), "DeptRolesManage.aspx");
                    return;
                }
            }
            DeptRoleModel deptRole = DeptRoleBLL.GetDeptRoleByRoleID(roleId);
            if (deptRole == null)
            {
                Response.Redirect("DeptRolesManage.aspx");
            }
            ViewState["deptId"]   = deptRole.DeptID;
            ViewState["roleid"]   = roleId;
            this.txtRoleName.Text = deptRole.Name;  //将角色的名称加载到文本框里
            ViewState["Name"]     = deptRole.Name;
            InitdllDepts();
        }
        Translations();
    }
Example #3
0
        /// <summary>
        /// ds2012
        /// 添加角色及角色权限
        /// </summary>
        /// <param name="context">用来获取当前登录用户权限</param>
        /// <param name="deptRole">角色信息</param>
        /// <returns></returns>
        public static bool AddDeptRole(DeptRoleModel deptRole)
        {
            string ids = "";
            IDictionaryEnumerator ideor = deptRole.htbPerssion.GetEnumerator();

            while (ideor.MoveNext())
            {
                ids = ids + ideor.Key.ToString() + ",";
            }
            try
            {
                DeptRoleDAL.AddDeptRole(ids, deptRole);
            }
            catch (FormatException)
            {
                return(false);
            }
            return(true);
        }
Example #4
0
    private void InitPermissionTree()
    {
        string mid = HttpContext.Current.Request.QueryString["id"];
        //调用角色树图生成方法生成树图
        string    number = Session["Company"].ToString();
        Hashtable htb    = DeptRoleBLL.GetAllPermission(Session["Company"].ToString());                                          //获取指定管理员的所有权限

        this.DivPermission.InnerHtml = (new DeptRoleBLL()).ResetAllPermission(ManagerBLL.GetManage(number).RoleID, number, htb); //获取权限菜单,并生成权限树

        //如果mid不为空则判断为mid的角色是否可以被当前用户登录用户编辑
        if (mid != null && mid != "")
        {
            int id = 0;
            //检查传入参数的合法性
            try
            {
                id = int.Parse(mid);
            }
            catch (FormatException)
            {
                Response.End();
            }
            DeptRoleModel deptRoleModel = DeptRoleBLL.GetDeptRoleByRoleID(id);
            if (deptRoleModel == null)
            {
                Response.Write("<script>alert('" + BLL.Translation.Translate("004200", "当前角色已经不存在,不允许操作") + ".');window.location='DeptRolesManage.aspx'</script>");
                Response.End();
            }
            ManagerBLL manageBLL = new ManagerBLL();
            this.chkAllot.Checked = (deptRoleModel.Allot == 1);

            //查询指定角色权限信息
            htb = DeptRoleBLL.GetAllPermission(deptRoleModel.Id);
            IDictionaryEnumerator idiction = htb.GetEnumerator();
            string str_html = "";
            while (idiction.MoveNext())
            {
                str_html += "<script>getpermission('" + idiction.Key + "');</script>";
            }
            this.DivSetPer.InnerHtml = str_html;
        }
    }
Example #5
0
    /// <summary>
    /// 修改角色的操作事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnUpt_Click(object sender, EventArgs e)
    {
        Application.Lock();
        if (ViewState["roleid"] == null)
        {
            Response.Redirect("DeptRolesManage.aspx");
        }
        if (txtRoleName.Text.Trim() == "")
        {
            ScriptHelper.SetAlert((Control)sender, GetTran("001183", "请输入角色名称!"));
            return;
        }
        else
        {
            if (this.txtRoleName.Text.Trim().Length < 3)
            {
                ScriptHelper.SetAlert((Control)sender, GetTran("000999", "角色名称必须3个字符以上!"));
                return;
            }
        }
        if (txtRoleName.Text != ViewState["Name"].ToString())
        {
            if (DeptRoleBLL.CheckDeptRoleName(this.txtRoleName.Text.Trim(), (int)ViewState["roleid"]) != null)
            {
                ScriptHelper.SetAlert((Control)sender, GetTran("001001", "角色名称已经存在!"));
                return;
            }
        }
        int    roleId   = (int)ViewState["roleid"];
        string number   = Session["Company"].ToString();
        string manageId = BLL.CommonClass.CommonDataBLL.getManageID(1);

        if (number != manageId)
        {
            if (!DeptRoleBLL.CheckAllot(number, roleId))
            {
                ScriptHelper.SetAlert((Control)sender, GetTran("000975", "不能对该角色进行操作,没有权限!"));
                return;
            }
        }
        DeptRoleModel deptRole = new DeptRoleModel(roleId);

        deptRole.DeptID = int.Parse(this.ddlDepts.SelectedValue);
        string ids = Request.Form["qxCheckBox"]; //获取所有选中的菜单的值(pmID),在生成的页面可以查看(后台拼接而成),qxCheckBox是菜单的name(checkbox的name)

        string[]  id  = ids.Split(',');
        Hashtable htb = (Hashtable)Session["permission"];

        htb = DeptRoleBLL.GetAllPermission(Session["Company"].ToString());
        Hashtable htb2 = new Hashtable();
        int       i    = -1;

        if (number != manageId)
        {
            foreach (string n in id)
            {
                if (htb.Contains(int.Parse(n)))
                {
                    htb2.Add(n, "0");
                }
                else
                {
                    i = 0;
                }
            }
        }
        else
        {
            foreach (string n in id)
            {
                if (htb.Contains(int.Parse(n)))
                {
                    htb2.Add(n, "0");
                }
            }
        }
        if (i == -1)
        {
            BLL.CommonClass.ChangeLogs cl = new BLL.CommonClass.ChangeLogs("deptRole", "id");
            cl.AddRecord(roleId);

            deptRole.htbPerssion = htb2;
            deptRole.Name        = this.txtRoleName.Text.Trim();
            deptRole.Allot       = ((CheckBox)this.UCPermission1.FindControl("chkAllot")).Checked ? 1 : 0;
            if (DeptRoleBLL.UptDeptRole(deptRole)) //修改角色
            {
                cl.AddRecord(roleId);
                cl.ModifiedIntoLogs(BLL.CommonClass.ChangeCategory.company25, "角色:" + deptRole.Name, BLL.CommonClass.ENUM_USERTYPE.objecttype7);
                ScriptHelper.SetAlert((Control)sender, GetTran("000001", "修改成功."), "DeptRolesManage.aspx");
            }
            else
            {
                ScriptHelper.SetAlert((Control)sender, GetTran("000002", "修改失败."), "DeptRolesManage.aspx");
            }
        }
        else
        {
            ScriptHelper.SetAlert((Control)sender, GetTran("001003", "异常数据"), "DeptRolesManage.aspx");
            return;
        }
        Application.UnLock();
    }
Example #6
0
    /// <summary>
    /// 添加角色的事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string number   = Session["Company"].ToString();
        string manageId = BLL.CommonClass.CommonDataBLL.getManageID(1);

        if (number != manageId)
        {
            if (!DeptRoleBLL.CheckAllot(number))
            {
                ScriptHelper.SetAlert((Control)sender, GetTran("000997", "当前登录用户没有给下级分配权限的权限!"));
                return;
            }
        }
        if (txtRoleName.Text.Trim() == "")
        {
            ScriptHelper.SetAlert((Control)sender, GetTran("000998", "请输入角色名称!"));
            return;
        }
        else
        {
            if (this.txtRoleName.Text.Trim().Length < 3)
            {
                ScriptHelper.SetAlert((Control)sender, GetTran("000999", "角色名称必须3个字符以上!"));
                return;
            }
        }
        if (DeptRoleBLL.CheckDeptRoleName(this.txtRoleName.Text, 0) != null)
        {
            ScriptHelper.SetAlert((Control)sender, GetTran("001001", "角色名称已经存在!"));
            return;
        }
        string ids = Request.Form["qxCheckBox"];

        if (ids == null || ids == "")
        {
            ScriptHelper.SetAlert((Control)sender, GetTran("001002", "请选择要分配权限!"));
            return;
        }
        DeptRoleModel deptRole = new DeptRoleModel();

        string[]  id  = ids.Split(',');
        Hashtable htb = (Hashtable)Session["permission"];

        htb = DeptRoleBLL.GetAllPermission(Session["Company"].ToString());
        Hashtable htb2 = new Hashtable();
        int       i    = -1;

        foreach (string n in id)
        {
            if (htb.Contains(int.Parse(n)))
            {
                htb2.Add(n, "0");
            }
            else
            {
                i = 0;
                break;
            }
        }
        manageId = BLL.CommonClass.CommonDataBLL.getManageID(1);
        if (number == manageId)
        {
            i = -1;
        }
        if (i == -1)
        {
            deptRole.htbPerssion = htb2;
            deptRole.Name        = this.txtRoleName.Text.Trim();
            ManageModel ma = ManagerBLL.GetManage(Session["Company"].ToString());
            deptRole.PermissionManID = ma.ID;
            deptRole.DeptID          = int.Parse(this.ddlDepts.SelectedValue);
            deptRole.Adddate         = DateTime.Now;
            deptRole.ParentId        = ma.RoleID;
            deptRole.Allot           = ((CheckBox)this.UCPermission1.FindControl("chkAllot")).Checked?1:0;
            if (DeptRoleBLL.AddDeptRole(deptRole))  //添加角色
            {
                ScriptHelper.SetAlert((Control)sender, GetTran("000006", "添加成功."), "DeptRolesManage.aspx");
            }
            else
            {
                ScriptHelper.SetAlert((Control)sender, GetTran("000007", "添加失败."), "DeptRolesManage.aspx");
            }
        }
        else
        {
            ScriptHelper.SetAlert((Control)sender, GetTran("001003", "异常数据"), "DeptRolesManage.aspx");
            return;
        }
    }