private void BindList()
 {
     IList<RoleInfo> list = new Role().GetList();
     RoleInfo aInfo = new RoleInfo();
     list.Add(aInfo);
     gvRoleList.DataSource = list;
     gvRoleList.DataBind();
 }
        protected void rbSel_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                string id = lbID.Value;
                if (string.IsNullOrEmpty(id) == true)
                {
                    return;
                }
                divUser.Visible = true;
                UserInfo uInfo = new User().GetByID(id);
                tbName.Text = uInfo.Name;
                ddlDepartment.SelectedValue = uInfo.DepartmentID;

                BindRoles();
                IList<RoleInfo> rList = new Role().GetListByUserID(id);
                foreach (RoleInfo rInfo in rList)
                {
                    string roleID = rInfo.ID;
                    cblRoles.Items.FindByValue(roleID).Selected = true;
                }
            }
            catch (ArgumentNullException aex)
            {
                ShowMsg(aex.Message);
            }
            catch (Exception ex)
            {
                ShowMsg(ex.Message);
                Log(ex);
            }
        }
Beispiel #3
0
 protected void btnRoleBind_Click(object sender, EventArgs e)
 {
     try
     {
         if (rblPower.SelectedIndex == -1)
         {
             ShowMsg("请选择权限组绑定。");
             return;
         }
         if (string.IsNullOrEmpty(this.NodeID))
         {
             ShowMsg("请选择栏目。");
             return;
         }
         PermissionGroupInfo pgInfo = new PermissionGroup().GetByMenuID(this.NodeID);
         if (pgInfo == null || string.IsNullOrEmpty(pgInfo.ID))
         {
             ShowMsg("请先为栏目绑定权限组再添加角色。");
             return;
         }
         // 绑定选中的角色
         IList<RoleInfo> rList = new Role().GetListByMenuID(this.NodeID);
         new BLL.Menu().AddRolesToMenu(this.NodeID, pgInfo.ID, rList);
         // 显示角色的权限配置列表
         gvRoleList.DataSource = rList;
         gvRoleList.DataBind();
     }
     catch (ArgumentNullException aex)
     {
         ShowMsg(aex.Message);
     }
     catch (Exception exc)
     {
         ShowMsg(exc.Message);
         Log(exc);
     }
 }
Beispiel #4
0
        protected void gvRoleList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                string ID = e.CommandArgument.ToString();
                int index = Convert.ToInt32(ID);
                if (e.CommandName == "btnDel")
                {
                    //new Role().Delete(ID);
                }
                else
                {
                    #region 控件
                    GridViewRow gvr = (GridViewRow)gvRoleList.Rows[index];
                    TextBox tbName = (TextBox)gvr.FindControl("tbName");
                    TextBox tbRemark = (TextBox)gvr.FindControl("tbRemark");
                    Label lblID = (Label)gvr.FindControl("lblID");
                    #endregion

                    if (e.CommandName == "btnEdit")
                    {
                        //new Role().Update(lblID.Text, tbName.Text, tbRemark.Text);
                    }
                }
                ShowMsg("绑定成功!");
                // 绑定选中的角色
                IList<RoleInfo> rList = new Role().GetListByMenuID(this.NodeID);
                gvRoleList.DataSource = rList;
                gvRoleList.DataBind();
            }
            catch (Exception exc)
            {
                ShowMsg(exc.Message);
                Log(exc);
            }
        }
Beispiel #5
0
 /// <summary>
 /// 选择编辑栏目
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void tMenus_SelectedNodeChanged(object sender, EventArgs e)
 {
     try
     {
         //选中节点值
         string value = tMenus.SelectedNode.Value;
         this.NodeID = value;
         MenuInfo mInfo = new BLL.Menu().GetByID(this.NodeID);
         this.ParentID = mInfo.ParentID;
         tbName.Text = mInfo.Name;
         tbRemark.Text = mInfo.Remark;
         tbSortNum.Text = mInfo.MenuCode;
         tbURL.Text = mInfo.URL;
         //rblIsShow.SelectedIndex = (mInfo.IsShow == true) ? 0 : 1;
         if (string.IsNullOrEmpty(mInfo.Target) == false)
         {
             rblExtend.SelectedValue = mInfo.Target;
         }
         btnSubmit.Visible = true;
         btnAdd.Visible = true;
         btnDel.Visible = true;
         btnSub.Visible = true;
         // 加载权限组
         rblPower.DataSource = new PermissionGroup().GetList();
         rblPower.DataBind();
         PermissionGroupInfo pgInfo = new PermissionGroup().GetByMenuID(mInfo.ID);
         if (pgInfo != null && string.IsNullOrEmpty(pgInfo.ID) == false)
         {
             rblPower.SelectedValue = pgInfo.ID;
             btnRoleBind.Visible = true;
         }
         // 加载角色
         IList<RoleInfo> rList = new Role().GetList();
         cblRole.DataSource = rList;
         cblRole.DataBind();
         IList<RoleInfo> mRoleList = new Role().GetListByMenuID(mInfo.ID);
         foreach (RoleInfo rInfo in mRoleList)
         {
             cblRole.Items.FindByValue(rInfo.ID).Selected = true;
         }
         // 为选中的角色绑定权限
         gvRoleList.DataSource = mRoleList;
         gvRoleList.DataBind();
     }
     catch (Exception exc)
     {
         ShowMsg(exc.Message);
         Log(exc);
     }
 }