protected void Page_Load(object sender, System.EventArgs e) { string s = Request.Params["UserID"]; userID = int.Parse(Request.Params["UserID"]); currentUser = new User(userID); Label1.Text = "用户: " + currentUser.UserName + " 角色分配"; if (!Page.IsPostBack) { DataSet dsRole = AccountsTool.GetRoleList(); CheckBoxList1.DataSource = dsRole.Tables[0].DefaultView; CheckBoxList1.DataTextField = "Description"; CheckBoxList1.DataValueField = "RoleID"; CheckBoxList1.DataBind(); AccountsPrincipal newUser = new AccountsPrincipal(currentUser.UserName); if (newUser.Roles.Count > 0) { ArrayList roles = newUser.Roles; for (int i = 0; i < roles.Count; i++) { // RoleList.Text += "<li>" + roles[i] + "</li>"; foreach (ListItem item in CheckBoxList1.Items) { if (item.Text == roles[i].ToString()) { item.Selected = true; } } } } } }
public void FillCategoryList(int categoryId) { DataView dv = null; //TODO: 如是保留角色, 加载全部权限 string idStr = BLL.SysManage.ConfigSystem.GetValueByCache("ReservedRoleIDs", ApplicationKeyType.System); if (!string.IsNullOrWhiteSpace(idStr)) { string[] ids = idStr.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); int id; foreach (string item in ids) { id = Globals.SafeInt(item, -1); if (id > 0 && UserPrincipal.HasRole(id)) { DataSet dsPerm = AccountsTool.GetPermissionsByCategory(categoryId); dv = dsPerm.Tables[0].DefaultView; break; //如此用户拥有一个保留角色就加载全部权限供菜单分配使用 } } } if (dv == null) { DataSet dsPerm = UserPrincipal.PermissionLists; dv = dsPerm.Tables[0].DefaultView; dv.RowFilter = "CategoryID=" + categoryId; } radbtnlistPermission.DataSource = dv; radbtnlistPermission.DataValueField = "PermissionID"; radbtnlistPermission.DataTextField = "Description"; radbtnlistPermission.DataBind(); }
private void BindRoles() { if (DropUserlist.SelectedItem == null) { return; } string UserName = DropUserlist.SelectedItem.Text; currentUser = new User(UserName); AccountsPrincipal newUser = new AccountsPrincipal(UserName); DataSet dsRole = AccountsTool.GetRoleList(); chkboxRolelist.DataSource = dsRole.Tables[0].DefaultView; chkboxRolelist.DataTextField = "Description"; chkboxRolelist.DataValueField = "RoleID"; chkboxRolelist.DataBind(); if (newUser.Roles.Count > 0) { ArrayList roles = newUser.Roles; for (int i = 0; i < roles.Count; i++) { //RoleList.Text += "<li>" + roles[i] + "</li>"; foreach (ListItem item in chkboxRolelist.Items) { if (item.Text == roles[i].ToString()) { item.Selected = true; } } } } }
} //系统管理_用户角色分配管理_分配角色设置页 public void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //Check string departmentId = this.DepartmentId; string userType = this.UserType; if (string.IsNullOrWhiteSpace(departmentId) || string.IsNullOrWhiteSpace(UserType)) { return; } int enterpriseId = Globals.SafeInt(departmentId, -1); if (enterpriseId < 1) { return; } ////获取企业信息 //BLL.Ms.Enterprise enterpriseBll = new BLL.Ms.Enterprise(); //Model.Ms.Enterprise enterprise = enterpriseBll.GetModel(enterpriseId); //lblName.Text = enterprise.Name; //获取下属用户 User userBll = new User(); ltbUser.DataSource = userBll.GetUserList(userType, departmentId, string.Empty); ltbUser.DataTextField = "UserName"; ltbUser.DataValueField = "UserID"; ltbUser.DataBind(); ltbUser.SelectedIndex = 0; ////识别关联用户 //for (int i = 0; i < ltbUser.Items.Count; i++) //{ // if (ltbUser.Items[i].Text == enterprise.UserName) // { // ltbUser.Items[i].Text += DefaultText; // } //} //获取可分配角色 DataSet dsRole = AccountsTool.GetRoleList(); cblRole.DataSource = dsRole.Tables[0].DefaultView; cblRole.DataTextField = "Description"; cblRole.DataValueField = "RoleID"; cblRole.DataBind(); //移除保留角色 for (int n = 0; n < cblRole.Items.Count; n++) { if (ReservedRoleIDs.Contains(cblRole.Items[n].Value)) { cblRole.Items.Remove(cblRole.Items[n]); } } //设置选择用户角色 SelectionRoles(); } }
private void PermissionsDatabind() { int CategoryId = int.Parse(this.ClassList.SelectedValue); DataSet PermissionsList = AccountsTool.GetPermissionsByCategory(CategoryId); this.DataGrid1.DataSource = PermissionsList; this.DataGrid1.DataBind(); }
private void CategoriesDatabind() { DataSet CategoriesList = AccountsTool.GetAllCategories(); this.ClassList.DataSource = CategoriesList; this.ClassList.DataTextField = "Description"; this.ClassList.DataValueField = "CategoryID"; this.ClassList.DataBind(); }
private void BindCategorylist() { DataSet allCategories = AccountsTool.GetAllCategories(); droplistPermCategories.DataSource = allCategories.Tables[0]; droplistPermCategories.DataTextField = "Description"; droplistPermCategories.DataValueField = "CategoryID"; droplistPermCategories.DataBind(); }
private void dataBind() { roles = AccountsTool.GetRoleList(); DataView dv = roles.Tables["Roles"].DefaultView; //保留角色 if (!UserPrincipal.HasPermissionID(GetPermidByActID(Act_ShowReservedRole))) { dv.RowFilter = "RoleID not in (" + ReservedRoleIDs + ")"; } RoleList.DataSource = dv; //roles.Tables["Roles"]; RoleList.DataBind(); }
//绑定类别列表 private void DoInitialDataBind() { currentRole = new Role(Convert.ToInt32(Request["RoleID"])); RoleLabel.Text = "当前角色: " + currentRole.Description; this.TxtNewname.Text = currentRole.Description; DataSet allCategories = AccountsTool.GetAllCategories(); CategoryDownList.DataSource = allCategories.Tables[0]; CategoryDownList.DataTextField = "Description"; CategoryDownList.DataValueField = "CategoryID"; CategoryDownList.DataBind(); }
public void BindData() { //是否有编辑权限数据的权限 if (!UserPrincipal.HasPermissionID(GetPermidByActID(Act_UpdateData)) && GetPermidByActID(Act_UpdateData) != -1) { gridView.Columns[2].Visible = false; } if (ClassList.SelectedItem != null && ClassList.SelectedValue.Length > 0) { int CategoryId = int.Parse(ClassList.SelectedValue); DataSet ds = AccountsTool.GetPermissionsByCategory(CategoryId); gridView.DataSetSource = ds; } }
public void CategoriesDatabind() { DataSet CategoriesList = AccountsTool.GetAllCategories(); ClassList.DataSource = CategoriesList; ClassList.DataTextField = "Description"; ClassList.DataValueField = "CategoryID"; ClassList.DataBind(); droplistCategories.DataSource = CategoriesList; droplistCategories.DataTextField = "Description"; droplistCategories.DataValueField = "CategoryID"; droplistCategories.DataBind(); droplistCategories.Items.Insert(0, new ListItem("移动到...", "")); }
//绑定类别列表 private void DoInitialDataBind() { currentRole = new Role(Convert.ToInt32(lblRoleID.Text)); RoleLabel.Text = currentRole.Description; this.TxtNewname.Text = currentRole.Description; DataSet allCategories = AccountsTool.GetAllCategories(); if (!DataSetTools.DataSetIsNull(allCategories)) { CategoryDownList.DataSource = allCategories.Tables[0]; CategoryDownList.DataTextField = "Description"; CategoryDownList.DataValueField = "CategoryID"; CategoryDownList.DataBind(); } }
} //系统管理_用户管理_角色分配页面 public void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if ((Request.Params["UserID"] != null) && (Request.Params["UserID"] != "")) { string userID = Request.Params["UserID"]; lblUserID.Text = userID; User currentUser = new User(Convert.ToInt32(userID)); DataSet dsRole = AccountsTool.GetRoleList(); CheckBoxList1.DataSource = dsRole.Tables[0].DefaultView; CheckBoxList1.DataTextField = "Description"; CheckBoxList1.DataValueField = "RoleID"; CheckBoxList1.DataBind(); AccountsPrincipal newUser = new AccountsPrincipal(currentUser.UserName); if (newUser.Roles.Count > 0) { ArrayList roles = newUser.Roles; for (int i = 0; i < roles.Count; i++) { foreach (ListItem item in CheckBoxList1.Items) { if (item.Text == roles[i].ToString()) { item.Selected = true; } } } } //移除保留角色 if (!UserPrincipal.HasPermissionID(GetPermidByActID(Act_ShowReservedRole))) { for (int n = 0; n < CheckBoxList1.Items.Count; n++) { if (ReservedRoleIDs.Contains(CheckBoxList1.Items[n].Value)) { CheckBoxList1.Items.Remove(CheckBoxList1.Items[n]); } } } } } }
protected void Page_Load(object sender, System.EventArgs e) { userID = int.Parse(Request.Params["UserID"]); currentUser = new User(userID); Label1.Text = "为用户: " + currentUser.UserName + " 分配角色"; if (!Page.IsPostBack) { //获取并显示所有角色 DataSet dsRole = AccountsTool.GetRoleList(); CheckBoxList1.DataSource = dsRole.Tables[0].DefaultView; CheckBoxList1.DataTextField = "Description"; CheckBoxList1.DataValueField = "RoleID"; CheckBoxList1.DataBind(); //获取用户已经拥有的角色,遍历CheckBoxList控件设置选中状态 AccountsPrincipal newUser = new AccountsPrincipal(currentUser.UserName); if (newUser.Roles.Count > 0) { ArrayList roles = newUser.Roles; for (int i = 0; i < roles.Count; i++) { foreach (ListItem item in CheckBoxList1.Items) { if (item.Text == roles[i].ToString()) { item.Selected = true; } } } } if (newUser.Permissions.Count > 0) { RoleList.Visible = true; ArrayList Permissions = newUser.Permissions; RoleList.Text = "用户拥有的权限列表:<ul>"; for (int i = 0; i < Permissions.Count; i++) { RoleList.Text += "<li>" + Permissions[i] + "</li>"; } RoleList.Text += "</ul>"; } } }
protected void Page_Load(object sender, EventArgs e) { GetUserInfo(); DataSet ds = AccountsTool.GetAllCategories(); ArrayList list = new ArrayList(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow row = ds.Tables[0].Rows[i]; Hashtable ht = new Hashtable(); ht.Add("CategoryID", row["CategoryID"]); ht.Add("Description", row["Description"]); list.Add(ht); } menuList.DataSource = list; menuList.DataBind(); }
//填充非权限列表 public void FillCategoryList(int categoryId) { currentRole = new Role(Convert.ToInt32(lblRoleID.Text)); GetRolePermissionlist(); DataSet ds = AccountsTool.GetPermissionsByCategory(categoryId); if (!DataSetTools.DataSetIsNull(ds)) { DataView dv = ds.Tables[0].DefaultView; if (!UserPrincipal.HasPermissionID(GetPermidByActID(Act_ShowReservedPerm))) { dv.RowFilter = "PermissionID not in (" + ReservedPermIDs + ")"; } chkPermissions.DataSource = dv; chkPermissions.DataValueField = "PermissionID"; chkPermissions.DataTextField = "Description"; chkPermissions.DataBind(); } }
private void dataBind() { roles = AccountsTool.GetRoleList(); RoleList.DataSource = roles.Tables["Roles"]; RoleList.DataBind(); }