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(); } }
public BEGroups SelectByIDWithUserGroups(int GroupID) { DAGroups da = new DAGroups(); BEGroups ds = new BEGroups(); da.SelectByID(GroupID.ToString(), ds.tbl_Groups); return ds; }
public BEGroups SelectAllAdminGroups() { DAGroups da = new DAGroups(); BEGroups ds = new BEGroups(); da.SelectAllAdminGroups( ds.tbl_Groups); return ds; }
protected void BindGroupsList() { BPGroups groups = new BPGroups(); dsGroups = groups.SelectAllAdminGroups(); dgGroups.DataBind(); }
public BEGroups SelectGroupsByUserID(int UserID) { DAGroups da = new DAGroups(); BEGroups ds = new BEGroups(); ds.EnforceConstraints = false; da.SelectGroupsByUserID(UserID, ds.tbl_Groups); return ds; }
public BEGroups SelectGroupPermissionsByGroupID(int GroupID) { DAGroups daGroups = new DAGroups(); DAGroupPermissions daGroupPerms = new DAGroupPermissions(); DAPermissions daPerms = new DAPermissions(); DAPermissionValues daPermValues = new DAPermissionValues(); BEGroups ds = new BEGroups(); //ds.EnforceConstraints = false; daGroups.SelectByID(GroupID.ToString(), ds.tbl_Groups); daPerms.SelectAll(ds.tbl_Permissions); daGroupPerms.SelectByID(GroupID.ToString(), ds.tbl_GroupPermissions); daPermValues.SelectAll(ds.tbl_PermissionValues); return ds; }
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_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 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 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"); } }
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); } } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.btnChangePass.Click += new System.EventHandler(this.btnChangePass_Click); this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click); this.DSGroups = new BEGroups(); this.DSUsers = new BEUsers(); this.DSGroups.DataSetName = "DSGroups"; this.DSGroups.Locale = new System.Globalization.CultureInfo("en-US"); this.DSUsers.DataSetName = "DSUsers"; this.DSUsers.Locale = new System.Globalization.CultureInfo("en-US"); this.Load += new System.EventHandler(this.Page_Load); }
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 Update(BEGroups dsGroups) { DAGroups da = new DAGroups(); DAUserGroups daUserGroups = new DAUserGroups(); DAGroupPermissions daGroupPerms = new DAGroupPermissions(); //delete has be be called before if a usergroup is being deleted DataTable deletedUserGroups = dsGroups.tbl_UserGroups.GetChanges(DataRowState.Deleted); DataTable modifiedUserGroups = dsGroups.tbl_UserGroups.GetChanges(DataRowState.Modified); DataTable addUserGroups = dsGroups.tbl_UserGroups.GetChanges(DataRowState.Added); if (deletedUserGroups!= null) { daUserGroups.Update(deletedUserGroups); } daGroupPerms.Update( dsGroups.tbl_GroupPermissions); da.Update( dsGroups.tbl_Groups); if (modifiedUserGroups!= null) { daUserGroups.Update(modifiedUserGroups); } if (addUserGroups!= null) { daUserGroups.Update(addUserGroups); } //if (dsGroups.tbl_Groups.Count > 0) //{ //cache the first user record incase update groups is called. // _UpdateUserInfo(dsGroups); //} }
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 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"); }
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(); }
protected void BindUserGroups() { if (UserID > 0) { BPGroups bp = new BPGroups(); DSGroups = bp.SelectGroupsByUserID(UserID); dgUserGroups.DataBind(); } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.DSGroups = new BEGroups(); this.DSUsers = new BEUsers(); //this.DSOwners = new BE_Oryx.BEOwners(); this.DSGroups.BeginInit(); this.DSUsers.BeginInit(); //((System.ComponentModel.ISupportInitialize)(this.DSOwners)).BeginInit(); this.btnCancel.Click += new EventHandler(this.btnCancel_Click); this.btnDelete.Click += new EventHandler(this.btnDelete_Click); this.btnSubmit.Click += new EventHandler(this.btnSubmit_Click); //this.lnkAssignOwners.Click += new System.EventHandler(this.lnkAssignOwners_Click); //this.lnkOwners.Click += new System.EventHandler(this.lnkOwners_Click); //this.imgOwnersAllRight.Click += new System.Web.UI.ImageClickEventHandler(this.imgOwnersAllRight_Click); //this.imgOwnersRight.Click += new System.Web.UI.ImageClickEventHandler(this.imgOwnersRight_Click); //this.imgOwnersLeft.Click += new System.Web.UI.ImageClickEventHandler(this.imgOwnersLeft_Click); //this.imgOwnersAllLeft.Click += new System.Web.UI.ImageClickEventHandler(this.imgOwnersAllLeft_Click); //this.btnUpdateOwners.Click += new System.EventHandler(this.btnUpdateOwners_Click); this.lnkAssign.Click += new EventHandler(this.lnkAssign_Click); this.lnkPermissions.Click += new EventHandler(this.lnkPermissions_Click); this.dgPermissions.ItemCommand += new DataGridCommandEventHandler(this.dgPermissions_ItemCommand); this.dgPermissions.CancelCommand += new DataGridCommandEventHandler(this.dgPermissions_CancelCommand); this.dgPermissions.UpdateCommand += new DataGridCommandEventHandler(this.dgPermissions_UpdateCommand); this.dgPermissions.ItemDataBound += new DataGridItemEventHandler(this.dgPermissions_ItemDataBound); this.btnMoveAllRight.Click += new ImageClickEventHandler(this.btnMoveAllRight_Click); this.btnMoveRight.Click += new ImageClickEventHandler(this.btnMoveRight_Click); this.btnMoveLeft.Click += new ImageClickEventHandler(this.btnMoveLeft_Click); this.btnMoveAllLeft.Click += new ImageClickEventHandler(this.btnMoveAllLeft_Click); this.btnDone.Click += new EventHandler(this.btnDone_Click); this.lnkAddUsers.Click += new EventHandler(this.lnkAddUsers_Click); this.lnkViewUsers.Click += new EventHandler(this.lnkViewUsers_Click); this.btnSearch.Click += new EventHandler(this.btnSearch_Click); this.btnMoveAllRight2.Click += new ImageClickEventHandler(this.btnMoveAllRight2_Click); this.btnMoveRight2.Click += new ImageClickEventHandler(this.btnMoveRight2_Click); this.btnMoveLeft2.Click += new ImageClickEventHandler(this.btnMoveLeft2_Click); this.btnMoveAllLeft2.Click += new ImageClickEventHandler(this.btnMoveAllLeft2_Click); this.btnUpdateUsers.Click += new EventHandler(this.btnUpdateUsers_Click); // // DSGroups // this.DSGroups.DataSetName = "DSGroups"; this.DSGroups.Locale = new CultureInfo("en-US"); // // DSUsers // this.DSUsers.DataSetName = "DSUsers"; this.DSUsers.Locale = new CultureInfo("en-US"); // // DSOwners // //this.DSOwners.DataSetName = "BEOwners"; //this.DSOwners.Locale = new System.Globalization.CultureInfo("en-US"); this.Load += new EventHandler(this.Page_Load); this.DSGroups.EndInit(); this.DSUsers.EndInit(); //((System.ComponentModel.ISupportInitialize)(this.DSOwners)).EndInit(); }
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(); }
public void UpdateGroupPermissions(BEGroups dsGroups) { DAGroupPermissions daGroupPerm = new DAGroupPermissions(); daGroupPerm.Update( dsGroups.tbl_GroupPermissions); }