//�Ƴ�Ȩ�� protected void RemovePermissionButton_Click(object sender, System.EventArgs e) { if(this.PermissionList.SelectedIndex>-1) { int currentRole = Convert.ToInt32(Request["RoleID"]); Role bizRole = new Role(currentRole); bizRole.RemovePermission( Convert.ToInt32(this.PermissionList.SelectedValue) ); CategoryDownList_SelectedIndexChanged(sender,e); } }
private void BtnAdd_Click(object sender, System.Web.UI.ImageClickEventArgs e) { Role role = new Role(); role.Description = TextBox1.Text; try { role.Create(); } catch { } TextBox1.Text = ""; 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(); }
//增加权限 protected void AddPermissionButton_Click(object sender, System.EventArgs e) { int[] items = CategoryList.GetSelectedIndices(); if (items.Length > 0) { int currentRole = Convert.ToInt32(Request["RoleID"]); Role bizRole = new Role(currentRole); foreach (int i in items) { int permid = Convert.ToInt32(this.CategoryList.Items[i].Value); bizRole.AddPermission(permid); } } CategoryDownList_SelectedIndexChanged(sender, e); }
//填充已有权限listbox private void SelectCategory(int categoryId, bool forceSelection) { currentRole = new Role(Convert.ToInt32(Request["RoleID"])); DataTable categories = currentRole.Permissions.Tables["Categories"]; DataRow currentCategory = categories.Rows.Find(categoryId); if (currentCategory != null) { DataRow[] permissions = currentCategory.GetChildRows("PermissionCategories"); PermissionList.Items.Clear(); foreach (DataRow currentRow in permissions) { PermissionList.Items.Add( new ListItem((string)currentRow["Description"], Convert.ToString(currentRow["PermissionID"]))); } } }
private void BtnUpName_Click(object sender, System.Web.UI.ImageClickEventArgs e) { string newname = this.TxtNewname.Text.Trim(); currentRole = new Role(Convert.ToInt32(Request["RoleID"])); currentRole.Description = newname; currentRole.Update(); DoInitialDataBind(); }
protected void RemoveRoleButton_Click(object sender, System.EventArgs e) { int currentRole = Convert.ToInt32(Request["RoleID"]); Role bizRole = new Role(currentRole); bizRole.Delete(); Server.Transfer("RoleAdmin.aspx"); }
protected void dataBind() { currentRole = new Role(Convert.ToInt32(Request["RoleID"])); DataSet ds = new DataSet(); ds = currentRole.Users; int pageIndex = this.DataGrid1.CurrentPageIndex; DataGrid1.DataSource = ds.Tables[0].DefaultView; int record_Count = ds.Tables[0].Rows.Count; int page_Size = DataGrid1.PageSize; int totalPages = int.Parse(Math.Ceiling((double)record_Count / page_Size).ToString()); if (totalPages > 0) { if (pageIndex > totalPages - 1) pageIndex = totalPages - 1; } else { pageIndex = 0; } DataGrid1.CurrentPageIndex = pageIndex; DataGrid1.DataBind(); //显示数量 if (this.DataGrid1.CurrentPageIndex == 0) { btnFirst.Enabled = false; btnPrev.Enabled = false; if (this.DataGrid1.PageCount == 1) { btnLast.Enabled = false; btnNext.Enabled = false; } } else if (this.DataGrid1.CurrentPageIndex == this.DataGrid1.PageCount - 1) { btnLast.Enabled = false; btnNext.Enabled = false; } this.lblpagesum.Text = totalPages.ToString(); this.lblpage.Text = (pageIndex + 1).ToString(); this.lblrowscount.Text = record_Count.ToString(); }