protected void btnSubmit_Click(object sender, EventArgs e) { if (ListBox1.SelectedItem == null) { lblError.Text = "请选择角色!以对所选择的角色进行权限分配!"; return; } var bll = new PopedomManagerBLL(); // 获取所选定的角色 var selectedRole = bll.GetRole(int.Parse(ListBox1.SelectedValue)); if (selectedRole == null) { lblError.Text = "请选择角色!以对所选择的角色进行权限分配!"; return; } // 获取分配给用户权限的模块ID列表 // 保存至数据库 selectedRole.PopedomIDList = (from TreeNode node in TreeView1.CheckedNodes where node.Checked select int.Parse(node.Value.Trim())).ToArray(); try { bll.ModifyRolePopedom(selectedRole); } catch (Exception ex) { lblError.Text = ex.Message; } }
private void DisplayModuleTree(PopedomManagerBLL bll) { if (ListBox1.SelectedItem == null) { return; } // 获取所选定的角色 var selectedRole = bll.GetRole(int.Parse(ListBox1.SelectedValue.Trim())); var moduleTree = new AccountBLL().GetModulesTree(); // 递归加载字模块显示树结点 TreeView1.Nodes.Clear(); bindMenuTree(selectedRole, TreeView1.Nodes, moduleTree.SubList); lblSelectedUser.Text = ListBox1.SelectedItem.Text; }