示例#1
0
 protected void Button为用户添加新角色_Click(object sender, EventArgs e)
 {
     Roles.AddUserToRole(DropDownList用户.Text, ListBox所有角色.Text);
     ListBox用户所属角色.DataSource = Roles.GetRolesForUser(DropDownList用户.Text);
     ListBox用户所属角色.DataBind();
     ListBox所有角色.DataSource = Roles.GetAllRoles();
     ListBox所有角色.DataBind();
 }
示例#2
0
 protected void Button删除选中的角色_Click(object sender, EventArgs e)
 {
     if (Roles.GetUsersInRole(ListBox所有角色.Text).Count <string>() == 0)
     {
         Roles.DeleteRole(ListBox所有角色.Text);
         ListBox所有角色.DataSource = Roles.GetAllRoles();
         ListBox所有角色.DataBind();
     }
     else
     {
         Response.Write("该角色有用户,无法删除");
     }
 }
示例#3
0
 protected void Button创建新角色_Click(object sender, EventArgs e)
 {
     Roles.CreateRole(TextBox新角色.Text);
     ListBox所有角色.DataSource = Roles.GetAllRoles();
     ListBox所有角色.DataBind();
 }