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); //} }
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); } } }
public BEUsers SelectByIDWithUserGroups(int UserID) { DAUsers da = new DAUsers(); DAUserGroups daUserGroups = new DAUserGroups(); DAGroups daGroups = new DAGroups(); BEUsers ds = new BEUsers(); da.SelectByID(UserID.ToString(),ds.tbl_Users); daGroups.SelectGroupsByUserID(UserID, ds.tbl_Groups); daUserGroups.SelectByID(UserID.ToString(), ds.tbl_UserGroups); return ds; }