Пример #1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void BTN_SAVE_Click(object sender, EventArgs e)
    {
        RoleMoudleInfo        _RoleMoudleInfo = null;
        List <RoleMoudleInfo> list            = new List <RoleMoudleInfo>();
        double RightValue = 0;

        foreach (GridViewRow row in this.GridView1.Rows)
        {
            _RoleMoudleInfo          = new RoleMoudleInfo();
            _RoleMoudleInfo.MoudleId = int.Parse(this.GridView1.DataKeys[row.RowIndex].Value.ToString());
            _RoleMoudleInfo.RoleId   = int.Parse(ViewState["ROLEID"].ToString());
            CheckBoxList CheckList = (CheckBoxList)row.Cells[1].Controls[1];
            if (CheckList.Items.Count > 0)
            {
                foreach (ListItem item in CheckList.Items)
                {
                    if (item.Selected)
                    {
                        RightValue = RightValue + Math.Pow(2, double.Parse(item.Value));
                    }
                }
            }
            _RoleMoudleInfo.PowerValue = (int)RightValue;
            list.Add(_RoleMoudleInfo);
            RightValue = 0;
        }
        if (_RoleMoudle.GrantRolePower(list))
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('角色权限授予成功!');</script>");
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('角色权限授予失败!');</script>");
        }
    }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="tnc"></param>
 protected void ChoiceTreeNode(TreeNodeCollection tnc, List <RoleMoudleInfo> info)
 {
     foreach (TreeNode node in tnc)
     {
         RoleMoudleInfo Info = info.Find(delegate(RoleMoudleInfo info1)
         {
             return(info1.MoudleId == int.Parse(node.Value));
         });
         if (node.ChildNodes.Count != 0)
         {
             if (Info != null)
             {
                 node.Checked = true;
             }
             ChoiceTreeNode(node.ChildNodes, info);
         }
         else
         {
             if (Info != null)
             {
                 node.Checked = true;
             }
         }
     }
 }
Пример #3
0
    private void CheckRights()
    {
        List <RoleMoudleInfo> list = this._RoleMoudle.GetRoleMoudle(ViewState["ROLEID"].ToString());
        RoleMoudleInfo        info = null;
        string id = "";

        foreach (GridViewRow row in this.GridView1.Rows)
        {
            id   = this.GridView1.DataKeys[row.RowIndex].Value.ToString();
            info = list.Find(delegate(RoleMoudleInfo infos)
            {
                return(infos.MoudleId.ToString() == id);
            });
            CheckBoxList CheckList = (CheckBoxList)row.Cells[1].Controls[1];
            if (info != null)
            {
                Check(CheckList, info.PowerValue.ToString());
            }
        }
    }