protected void btnSave_Click(object sender, EventArgs e)
    {
        PRolePermissionsData rolePermissionsData = new PRolePermissionsData();
        SCommBB commBB = new SCommBB();
        PRolePermissionsBB rolePermissionsBB = new PRolePermissionsBB();
        try
        {
            //删除当前角色所有权限
            rolePermissionsBB.DeleteRecordByRole(this.RoleId, 2);

            //保存权限
            string strPermissions = "";
            CheckBox checkBox = new CheckBox();
            foreach (DataListItem item in this.DataList1.Items)
            {
                //获取ItemoNo
                Label label = (Label)item.FindControl("itemNo");
                string itemNo = label.Text;
                if (itemNo.IndexOf('-') >= 0)
                {
                    itemNo = itemNo.Substring(itemNo.LastIndexOf('-') + 1);
                }

                foreach (System.Web.UI.Control control in item.Controls)
                {
                    if (control.GetType() == checkBox.GetType())
                    {
                        if (((CheckBox)control).Checked == true)
                        {
                            strPermissions += itemNo + "," + ((CheckBox)control).ToolTip + ",0|";
                        }
                    }
                }
            }
            //保存权限
            commBB.ExecuteSql("exec sys_BatchSavePermissions " + this.RoleId.ToString() + ",'" + strPermissions.Remove(strPermissions.Length - 1) + "'");
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            commBB.Dispose();
            rolePermissionsBB.Dispose();
        }

        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('保存成功!');", true);
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string idValue = Request.Params["id"];
            if (idValue != null)
            {
                int id = int.Parse(idValue);
                //删除节点的同时,删除TreeFunction、角色权限、人员权限
                STreeData treeData = new STreeData();
                STreeBB treeBB = new STreeBB();
                STreeFunctionBB treeFunctionBB = new STreeFunctionBB();
                PRolePermissionsBB rolePermissionsBB = new PRolePermissionsBB();
                PEmpPermissionsBB empPermissionsBB = new PEmpPermissionsBB();
                try
                {
                    treeData = treeBB.GetModel(id);
                    treeBB.DeleteRecord(id);
                    treeFunctionBB.DeleteRecordByNode(id);
                    rolePermissionsBB.DeleteRecordByItem(treeData.itemNo);
                    empPermissionsBB.DeleteRecordByItem(treeData.itemNo);

                    this.RefreshApplicationPageUrlTable();
                    this.RefreshApplicationTreeTable();

                    ClientScript.RegisterStartupScript(this.GetType(), "CloseSubmit", "CloseSubmit()", true);
                }
                catch (Exception ex)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
                    return;
                }
                finally
                {
                    treeBB.Dispose();
                    treeFunctionBB.Dispose();
                    rolePermissionsBB.Dispose();
                    empPermissionsBB.Dispose();
                }
            }
        }
    }
 /// <summary>
 /// 初始化默认权限数据
 /// </summary>
 private void InitPermissionData()
 {
     PRolePermissionsBB rolePermissionsBB = new PRolePermissionsBB();
     STreeFunctionBB treeFunctionBB = new STreeFunctionBB();
     SCommBB commBB = new SCommBB();
     try
     {
         //除了超级管理员,其他用户只能在自己的权限列表范围之内进行分配
         if (this.IsHaveRole(1))
         {
             this.treeFunctionDs = treeFunctionBB.GetList("");
         }
         else
         {
             this.treeFunctionDs = commBB.Query("select distinct nodeId,permissionsTypeId,permissionsTypeNo as functionNo,permissionsTypeNm as functionNm from vSTree where empId="
                 + this.currentUser.empId.ToString() + " order by permissionsTypeId");
         }
         //获取岗位具体权限
         this.rolePermissionsDs = rolePermissionsBB.GetList("roleId=" + this.RoleId.ToString());
     }
     finally
     {
         rolePermissionsBB.Dispose();
         treeFunctionBB.Dispose();
         commBB.Dispose();
     }
 }
示例#4
0
 /// <summary>
 /// ɾ��
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnDel_Click(object sender, EventArgs e)
 {
     PRoleBB roleBB = new PRoleBB();
     PUserRoleBB userRoleBB = new PUserRoleBB();
     PRolePermissionsBB rolePermissionsBB = new PRolePermissionsBB();
     //��ȡѡ�е�����Id
     try
     {
         foreach (GridViewRow gvrow in this.grid.Rows)
         {
             CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
             int id = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["id"]);
             if (chkId.Checked == true)
             {
                 PRoleData roleData = new PRoleData();
                 roleData = roleBB.GetModel(id);
                 if (roleData.isSys)
                 {
                     this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"����λΪϵͳ��λ�����޷�ɾ����\");", true);
                     return;
                 }
                 else
                 {
                     //ɾ����ɫ��ͬʱ��ɾ����Ա��ɫ����ɫȨ��
                     roleBB.DeleteRecord(id);
                     userRoleBB.DeleteRecordByRole(id);
                     rolePermissionsBB.DeleteRecordByRole(id, 2);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
         return;
     }
     finally
     {
         roleBB.Dispose();
         userRoleBB.Dispose();
         rolePermissionsBB.Dispose();
     }
     this.BindGrid();
 }