private void Page_Load(object sender, System.EventArgs e) { this.AuthenticatePage(new string[] {Globals.PermissionLevels.EditUsers, Globals.PermissionLevels.AddUsers, Globals.PermissionLevels.ViewUsers}); if (this.OryxUser.RolePermission(Globals.PermissionLevels.AddUsers) != 2) { btnAddUser.Visible = false; } // Put user code to initialize the page here if (IsNewSession) { AddToListIfAdmin(); IsNewSession = false; } if (!Page.IsPostBack) { BPGroups bp = new BPGroups(); dsGroups = bp.SelectAllAdminGroups(); lstGroups.DataBind(); lstGroups.Items.Insert(0, new ListItem("(All Permission Groups)", "-1")); dgUsers.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindDSUsers(); } }
protected void BindGroupsList() { BPGroups groups = new BPGroups(); dsGroups = groups.SelectAllAdminGroups(); dgGroups.DataBind(); }
private void btnDelete_Click(object sender, EventArgs e) { BPGroups bp = new BPGroups(); BEGroups.tbl_GroupsRow group; DSGroups = bp.SelectByIDWithUserGroups(GroupID); group = DSGroups.tbl_Groups.FindByGroupID(GroupID); group.Delete(); bp.Update(DSGroups); //delete any relationships between users and this Group BPGroups bpUserGroups = new BPGroups(); bpUserGroups.DeleteByGroupID(GroupID); Response.Redirect("BrowsePermissionGroups.aspx"); }
protected void BindUserGroups() { if (UserID > 0) { BPGroups bp = new BPGroups(); DSGroups = bp.SelectGroupsByUserID(UserID); dgUserGroups.DataBind(); } }
private void dgPermissions_CancelCommand(object source, DataGridCommandEventArgs e) { BPGroups bp = new BPGroups(); DSGroups = bp.SelectGroupPermissionsByGroupID(GroupID); dgPermissions.EditItemIndex = -1; dgPermissions.SelectedIndex = -1; dgPermissions.DataBind(); }
private void dgPermissions_UpdateCommand(object source, DataGridCommandEventArgs e) { //Cell Index is the index of permissionID int permissionID = Convert.ToInt32( e.Item.Cells[0].Text); BPGroups bp = new BPGroups(); DSGroups = bp.SelectGroupPermissionsByGroupID(GroupID); BEGroups.tbl_GroupPermissionsRow groupPermission = DSGroups.tbl_GroupPermissions.FindByGroupIDPermissionID(GroupID, permissionID); DropDownList lstPermValues = (DropDownList) e.Item.FindControl("lstPermValues"); groupPermission.GroupPermissionValue = Convert.ToInt16(lstPermValues.SelectedValue); bp.UpdateGroupPermissions(DSGroups); DSGroups = bp.SelectGroupPermissionsByGroupID(GroupID); dgPermissions.EditItemIndex = -1; dgPermissions.SelectedIndex = -1; dgPermissions.DataBind(); }
private void btnDone_Click(object sender, EventArgs e) { if (_HasChangedUsers ) { BPGroups bpGroups = new BPGroups(); if (_HasChangedUsers ) { DSGroups = bpGroups.SelectGroupPermissionsByGroupID(GroupID); ArrayList perms = new ArrayList(PermList); perms.Sort(); //Remove Duplicates if (perms.Count > 1) { int iLast,iCurrent; iLast = (int) perms[0]; for (int i=1; i<perms.Count; i++) { iCurrent = (int) perms[i]; if (iCurrent == iLast) { perms.RemoveAt(i); } iLast = iCurrent; } } int SearchIndex; foreach (BEGroups.tbl_GroupPermissionsRow groupPerm in DSGroups.tbl_GroupPermissions) { SearchIndex = perms.BinarySearch(groupPerm.PermissionID); if (SearchIndex < 0) //if (Array.BinarySearch(groupPerm.PermissionID)) { //Not Found groupPerm.Delete(); } else { perms.RemoveAt(SearchIndex); } } foreach (int i in perms) { BEGroups.tbl_GroupPermissionsRow groupPerm; groupPerm = DSGroups.tbl_GroupPermissions.FindByGroupIDPermissionID(GroupID, i); if(groupPerm == null) { groupPerm = DSGroups.tbl_GroupPermissions.Newtbl_GroupPermissionsRow(); groupPerm.GroupID = GroupID; groupPerm.PermissionID = i; groupPerm.GroupPermissionValue = 2; DSGroups.tbl_GroupPermissions.Addtbl_GroupPermissionsRow(groupPerm); } //The first value for a permission should always be 1. groupPerm.GroupPermissionValue = 2; } } bpGroups.UpdateGroupPermissions(DSGroups); DSGroups = bpGroups.SelectGroupPermissionsByGroupID(GroupID); dgPermissions.DataBind(); } pnlAssign.Visible = false; pnlPermissions.Visible = true; tab1.Attributes["class"] = ""; tab2.Attributes["class"] = "current"; }
private void dgPermissions_ItemCommand(object source, DataGridCommandEventArgs e) { //if (this.OryxUser.RolePermission(Globals.PermissionLevels.ManageAdministratorGroups) > 1) //{ BPGroups bp = new BPGroups(); DSGroups = bp.SelectGroupPermissionsByGroupID(GroupID); if (e.Item.Cells[0].Text != string.Empty) { int permissionID = Convert.ToInt32( e.Item.Cells[0].Text); if (dgPermissions.EditItemIndex == e.Item.ItemIndex) { dgPermissions.EditItemIndex = -1; } else { dgPermissions.EditItemIndex = e.Item.ItemIndex; DSGroups.tbl_PermissionValues.DefaultView.RowFilter = string.Format("PermissionID = {0}", permissionID); } } dgPermissions.DataBind(); //} }
private void lnkPermissions_Click(object sender, EventArgs e) { pnlAssign.Visible = false; pnlPermissions.Visible = true; tab1.Attributes["class"] = ""; tab2.Attributes["class"] = "current"; BPGroups bp = new BPGroups(); DSGroups = bp.SelectByIDWithUserGroups(GroupID); DSGroups = bp.SelectGroupPermissionsByGroupID(GroupID); dgPermissions.DataBind(); }
private void btnSubmit_Click(object sender, EventArgs e) { BPGroups groups = new BPGroups(); BEGroups.tbl_GroupsRow group; DSGroups = groups.SelectByIDWithUserGroups(GroupID); group = DSGroups.tbl_Groups.FindByGroupID(GroupID); if (GroupID == 0) { group = DSGroups.tbl_Groups.Newtbl_GroupsRow(); group.DateCreated = DateTime.Now; group.ModifiedByAdminID = 1; } group.GroupName_ReadOnly = false; group.GroupName = txtGroupName.Text; group.GroupDescription = txtGroupDescription.Text; group.GroupActive = chkActive.Checked; group.DateModified = DateTime.Now; if(GroupID == 0) { DSGroups.tbl_Groups.Addtbl_GroupsRow(group); } groups.Update(DSGroups); if (_HasChangedUsers ) { groups.UpdateUsers(group.GroupID, UserGroupsList); } //Cache.Remove("dsAdmins"); if (GroupID != group.GroupID) { Response.Redirect("EditPermissionGroups.aspx?GroupID=" + group.GroupID); } else { Response.Redirect("BrowsePermissionGroups.aspx"); } }
private void FillSelectedPerms() { lstSelectedPerms.Items.Clear(); BPGroups bp = new BPGroups(); BEGroups ds = bp.SelectGroupPermissionsByGroupID(GroupID); MyListViewItem listItem; foreach (BEGroups.tbl_GroupPermissionsRow groupPerm in ds.tbl_GroupPermissions) { listItem = lstSelectedPerms.Items.Add(); listItem.CheckBox = true; listItem.ItemValue = groupPerm.PermissionID.ToString(); listItem.Text = groupPerm.PermissionName; } }
private void FillAvailablePerms() { lstAvalPerms.Items.Clear(); BPGroups bp = new BPGroups(); BEGroups ds = bp.SelectGroupPermissionsByGroupID(GroupID); MyListViewItem listItem; foreach (BEGroups.tbl_PermissionsRow groupPerm in ds.tbl_Permissions) { if ( ds.tbl_GroupPermissions.FindByGroupIDPermissionID(GroupID, groupPerm.PermissionID) == null) { listItem = lstAvalPerms.Items.Add(); listItem.CheckBox = true; listItem.ItemValue = groupPerm.PermissionID.ToString(); listItem.Text = groupPerm.PermissionName; } } }
private void ShowGroupUsers() { pnlUsers.Visible = true; if (_HasChangedUsers) { BPGroups groups = new BPGroups(); BEGroups.tbl_GroupsRow group; DSGroups = groups.SelectByIDWithUserGroups(GroupID); group = DSGroups.tbl_Groups.FindByGroupID(GroupID); groups.Update(DSGroups); if (_HasChangedUsers) { groups.UpdateUsers(group.GroupID, UserGroupsList); } } BPUsers bp = new BPUsers(); DSUsers = bp.SelectByGroupID(GroupID); dgUsers.DataBind(); }
private void Page_Load(object sender, EventArgs e) { this.AuthenticatePage(new string[] {PermissionLevels.EditPermissionGroups, PermissionLevels.AddPermissionGroups, PermissionLevels.ViewPermissionGroups}); if (GroupID > 0) { if (this.OryxUser.RolePermission(PermissionLevels.EditPermissionGroups) != 2) { btnSubmit.Visible = false; btnDelete.Visible = false; lnkAssign.Enabled = false; lnkAddUsers.Enabled = false; } } else { if (this.OryxUser.RolePermission(PermissionLevels.AddPermissionGroups) != 2) { btnSubmit.Visible = false; btnDelete.Visible = false; lnkAssign.Enabled = false; lnkAddUsers.Enabled = false; } } if (IsNewSession) { AddToListIfAdmin(); IsNewSession = false; } if (hdnPermissionUsers.Value == "hidden") { pnlPermissionUsers.CssClass = "panel-closed"; cntPermissionUsers.Style.Add("display", "none"); hdnPermissionUsers.Value = "hidden"; } else { pnlPermissionUsers.CssClass = "panel-open"; cntPermissionUsers.Style.Add("display", ""); hdnPermissionUsers.Value = "visible"; } if (hdnUserPermissions.Value == "hidden") { pnlUserPermissions.CssClass = "panel-closed"; cntUserPermissions.Style.Add("display", "none"); hdnUserPermissions.Value = "hidden"; } else { pnlUserPermissions.CssClass = "panel-open"; cntUserPermissions.Style.Add("display", ""); hdnUserPermissions.Value = "visible"; } if (!Page.IsPostBack) { BPGroups bp = new BPGroups(); if (GroupID != 0) { //BEGroups.tbl_GroupsRow group; DSGroups = bp.SelectByIDWithUserGroups(GroupID); //group = DSGroups.tbl_Groups.FindByGroupID(GroupID); txtGroupName.DataBind(); txtGroupDescription.DataBind(); chkActive.DataBind(); DSGroups = bp.SelectGroupPermissionsByGroupID(GroupID); dgPermissions.DataBind(); ShowAssignPerms(); ShowGroupUsers(); } else { lblTitle.Text = "Add Administrator Group"; btnDelete.Visible = false; btnSubmit.Text = "Next >"; pnlUserPermissions.Visible = false; pnlPermissionUsers.Visible = false; pnlAreaTabs.Visible = false; pnlUserTabs.Visible = false; } } }
public void UpdateUsers (int GroupID, int[] InstIDS) { ArrayList userList = new ArrayList(InstIDS); ArrayList currentUserList; BPGroups bp = new BPGroups(); BEGroups DSGroups = new BEGroups(); DSGroups = bp.SelectUsersByGroupID(GroupID); _CurrentUserGroupIDS = new int[DSGroups.Tables["tbl_UserGroups"].Rows.Count]; for (int i=0; i < DSGroups.Tables["tbl_UserGroups"].Rows.Count; i++) { _CurrentUserGroupIDS[i] = Convert.ToInt32(DSGroups.Tables["tbl_UserGroups"].Rows[i]["UserID"]); } currentUserList = new ArrayList(_CurrentUserGroupIDS); //DAGroups da = new DAGroups(); DAUserGroups daUserGroups = new DAUserGroups(); userList.Sort(); currentUserList.Sort(); //Insert the records that are new foreach (int userID in userList) { if (currentUserList.BinarySearch(userID) < 0) { //not found in the current users, add it. daUserGroups.InsertByID(userID, GroupID); } } //delete the old records foreach (int userID in currentUserList) { if (userList.BinarySearch(userID) < 0) { //not found in the current groups, add it. daUserGroups.DeleteByID(userID, GroupID); } } }