private void refreshEntitySummaries(bool fromDatabase) { if (fromDatabase) { StaffFunctions.EntitiesNotForStaff = StaffFunctions.AllowedUnlinkedEntities(selectedStaffID); StaffFunctions.EntitiesForStaff = StaffFunctions.AllowedLinkedEntities(selectedStaffID); } EntitiesFrom.ItemsSource = StaffFunctions.EntitiesNotForStaff; EntitiesFrom.Items.SortDescriptions.Clear(); EntitiesFrom.Items.SortDescriptions.Add(new SortDescription("NameAndUser", ListSortDirection.Ascending)); EntitiesFrom.Items.Refresh(); EntitiesFrom.SelectedItem = null; EntitiesTo.ItemsSource = StaffFunctions.EntitiesForStaff; EntitiesTo.Items.SortDescriptions.Clear(); EntitiesTo.Items.SortDescriptions.Add(new SortDescription("Default", ListSortDirection.Descending)); EntitiesTo.Items.Refresh(); EntitiesTo.SelectedItem = null; disableButtons(); if (selectedStaffName != "") { PageHeader.Content = "Entities for " + selectedStaffName; } }
private void refreshStaffSummaries(bool fromDatabase) { if (fromDatabase) { StaffFunctions.StaffNotForEntity = StaffFunctions.StaffNotInEntity(activeOnly, selectedEntityID); StaffFunctions.StaffForEntity = StaffFunctions.StaffInEntity(activeOnly, selectedEntityID); } StaffFrom.ItemsSource = StaffFunctions.StaffNotForEntity; StaffFrom.Items.SortDescriptions.Clear(); StaffFrom.Items.SortDescriptions.Add(new SortDescription("NameAndUser", ListSortDirection.Ascending)); StaffFrom.Items.Refresh(); StaffFrom.SelectedItem = null; StaffTo.ItemsSource = StaffFunctions.StaffForEntity; StaffTo.Items.SortDescriptions.Clear(); StaffTo.Items.SortDescriptions.Add(new SortDescription("NameAndUser", ListSortDirection.Ascending)); StaffTo.Items.Refresh(); StaffTo.SelectedItem = null; disableButtons(); if (selectedEntity != null) { PageHeader.Content = "Staff Members in Entity '" + selectedEntity.EntityName + "'"; } }
private void removeEntities() { try { if (EntitiesTo.SelectedItems != null) { List <EntityProxy> toList = new List <EntityProxy>(); foreach (var selectedRow in EntitiesTo.SelectedItems) { toList.Add((EntityProxy)selectedRow); } bool success = StaffFunctions.ToggleStaffEntities(toList, false, Globals.SelectedStaffMember); if (success) { refreshEntitySummaries(false); CommitButton.IsEnabled = true; //AddButton.IsEnabled = DefaultButton.IsEnabled = RemoveButton.IsEnabled = false; } } else { MessageFunctions.Error("Error removing Entities from staff: no Entity selected.", null); } } catch (Exception generalException) { MessageFunctions.Error("Error removing Entities from staff", generalException); } }
private void removeStaff() { try { if (StaffTo.SelectedItems != null) { List <StaffProxySmall> toList = new List <StaffProxySmall>(); foreach (var selectedRow in StaffTo.SelectedItems) { toList.Add((StaffProxySmall)selectedRow); } bool success = StaffFunctions.ToggleEntityStaff(toList, false, selectedEntity); if (success) { refreshStaffSummaries(false); CommitButton.IsEnabled = true; //AddButton.IsEnabled = DefaultButton.IsEnabled = RemoveButton.IsEnabled = false; } } else { MessageFunctions.Error("Error removing staff from Entity: no staff selected.", null); } } catch (Exception generalException) { MessageFunctions.Error("Error removing staff from Entity", generalException); } }
private void refreshStaffCombo() { staffComboList = StaffFunctions.GetStaffList(activeOnly: false, nameContains: "", roleCode: "", entityID: Globals.CurrentEntityID); staffComboList.Insert(0, Globals.AllStaff); StaffCombo.ItemsSource = staffComboList; StaffCombo.SelectedItem = Globals.AllStaff; }
private void CancelButton_Click(object sender, RoutedEventArgs e) { if (StaffFunctions.IgnoreAnyChanges()) { StaffFunctions.ClearAnyChanges(); PageFunctions.ShowTilesPage(); } }
public static void CompleteLogIn() { MessageFunctions.CancelInfoAlert(); PageFunctions.MenuSecurity(); Globals.FavouriteProjectID = StaffFunctions.MainProjectID(MyStaffID); PageFunctions.ToggleMainMenus(true); PageFunctions.ShowTilesPage(); }
private void Page_Loaded(object sender, RoutedEventArgs e) { try { pageMode = PageFunctions.pageParameter(this, "Mode"); sourceMode = PageFunctions.pageParameter(this, "SourceMode"); selectedStaffID = Int32.Parse(PageFunctions.pageParameter(this, "StaffID")); refreshEntityCombo(true); } catch (Exception generalException) { MessageFunctions.Error("Error retrieving query details", generalException); PageFunctions.ShowTilesPage(); } CommitButton.Visibility = Visibility.Hidden; StaffFrom.Visibility = StaffTo.Visibility = Visibility.Hidden; StaffLabel.Margin = NameContainsLabel.Margin; StaffCombo.Margin = NameContains.Margin; if (selectedStaffID > 0) // Opened from the Staff Page { fromSource = "StaffPage"; Globals.SelectedStaffMember = StaffFunctions.GetStaffMember(selectedStaffID); StaffCombo.IsEnabled = false; // Cannot easily recreate the same selection list viewEntitiesByStaffMember(); if (pageMode == PageFunctions.View) { Instructions.Content = "Note that only Entities you can access yourself are displayed."; } else { Instructions.Content = "Select the Entities this user should have, then click 'Save'. You can then choose other staff from the list."; } } else { fromSource = Globals.TilesPageName; StaffLabel.Visibility = StaffCombo.Visibility = Visibility.Hidden; BackButton.Visibility = Visibility.Hidden; EntitiesFrom.Visibility = EntitiesTo.Visibility = Visibility.Hidden; AddButton.Visibility = DefaultButton.Visibility = RemoveButton.Visibility = Visibility.Hidden; FromLabel.Visibility = ToLabel.Visibility = Visibility.Hidden; if (pageMode == PageFunctions.View) { StaffButton.Visibility = Visibility.Hidden; //EntitiesButtonText.Text = "View Entities"; Instructions.Content = "Select a staff member and click 'Entities', or select an Entity to see its assigned staff."; } else { Instructions.Content = defaultInstructions; } } }
// ---------------------- // // -- Data Management --- // // ---------------------- // // Data updates // private void refreshRoleCombo() { try { RoleCombo.ItemsSource = StaffFunctions.ListStaffRoles(true); RoleCombo.SelectedItem = Globals.AllStaffRoles; } catch (Exception generalException) { MessageFunctions.Error("Error populating role filter list", generalException); } }
// ---------------------- // // -- Data Management --- // // ---------------------- // // Data updates // private void refreshRoleList() { try { roleList = StaffFunctions.ListStaffRoles(false); RoleCombo.ItemsSource = roleList; } catch (Exception generalException) { MessageFunctions.Error("Error populating roles list", generalException); } }
private void CancelButton_Click(object sender, RoutedEventArgs e) { if (pageMode == PageFunctions.Lookup) { StaffFunctions.CancelTeamStaffSelection(); } else { PageFunctions.ShowTilesPage(); } }
private void pushSelection() { try { if (pageMode != PageFunctions.Lookup) { Globals.SelectedStaffMember = (selectedRecord == null) ? null : StaffFunctions.GetStaffMember(selectedRecord.ID); } } catch (Exception generalException) { MessageFunctions.Error("Error processing selection", generalException); } }
private void AmendButton_Click(object sender, RoutedEventArgs e) { try { StaffFunctions.OpenAmendPage(selectedStaffID); } catch (Exception generalException) { MessageFunctions.Error("Error amending record", generalException); } }
private void StaffCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (StaffFunctions.IgnoreAnyChanges()) { StaffFunctions.ClearAnyChanges(); selectedStaffName = StaffCombo.SelectedItem.ToString(); Globals.SelectedStaffMember = StaffFunctions.GetStaffMemberByName(selectedStaffName); selectedStaffID = Globals.SelectedStaffMember.ID; refreshEntitySummaries(true); } }
// -------------- Data updates -------------- // // --------- Other/shared functions --------- // private void chooseStaffName(int staffID = 0) { try { StaffProxy selectedStaff = (staffID != 0) ? StaffFunctions.GetStaffProxy(staffID) : (StaffProxy)PossibleNames.SelectedItem; NameLike.Text = selectedStaff.StaffName; exactName = true; nameFilter(); } catch (Exception generalException) { MessageFunctions.Error("Error processing staff name selection", generalException); } }
private void DisableButton_Click(object sender, RoutedEventArgs e) { try { bool?blnEnabled = StaffFunctions.EnableOrDisable(selectedStaffID); if (blnEnabled != null) { refreshStaffGrid(); } } catch (Exception generalException) { MessageFunctions.Error("Error changing status", generalException); } }
private void togglActiveOnly(bool isChecked) { activeOnly = isChecked; refreshStaffDataGrid(); if (StaffTo.Visibility == Visibility.Visible) { if (StaffFunctions.IgnoreAnyChanges()) { StaffFunctions.ClearAnyChanges(); refreshStaffSummaries(true); } } }
// ---------------------- // // -- Event Management -- // // ---------------------- // // Generic (shared) control events // // Control-specific events // private void MainManagersCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { string selectedName = MainManagersCombo.SelectedValue.ToString(); if (selectedName != Globals.AllRecords) { Staff accountManager = StaffFunctions.GetStaffMemberByName(selectedName); accountManagerID = accountManager.ID; } else { accountManagerID = 0; } refreshClientGrid(); }
private void CommitButton_Click(object sender, RoutedEventArgs e) { bool confirm = MessageFunctions.ConfirmOKCancel("Are you sure you wish to save your amendments?", "Save changes?"); if (!confirm) { return; } bool success = (editMode == ByStaff) ? StaffFunctions.SaveStaffEntitiesChanges(selectedStaffID) : StaffFunctions.SaveEntityStaffChanges(selectedEntityID); if (success) { MessageFunctions.SuccessAlert("Your changes have been saved successfully. You can make further changes, go back to the previous screen, or close the current page.", "Changes Saved"); CommitButton.IsEnabled = false; } }
private void CommitButton_Click(object sender, RoutedEventArgs e) { try { //string roleDescription = ""; string roleCode = ""; //string defaultEntityName = ""; int defaultEntityID = 0; bool active = (ActiveCheckBox.IsChecked == true); string passwd = NewPassword.Password; if (RoleCombo.SelectedItem != null) { StaffRoles role = (StaffRoles)RoleCombo.SelectedItem; roleCode = role.RoleCode; } if (EntityCombo.SelectedItem != null) { Entities defaultEntity = (Entities)EntityCombo.SelectedItem; defaultEntityID = defaultEntity.ID; } if (passwd != "" && passwd != ConfirmPassword.Password) { MessageFunctions.InvalidMessage("New password does not match confirmation. Please check both fields and try again.", "Password Mismatch"); return; } int returnID = StaffFunctions.SaveStaffDetails(selectedStaffID, FirstName.Text, Surname.Text, roleCode, StartDate.SelectedDate, LeaveDate.SelectedDate, UserID.Text, passwd, active, defaultEntityID, (SSOCheckBox.IsChecked == true), DomainUser.Text); if (returnID > 0) { if (selectedStaffID == 0) { MessageFunctions.SuccessAlert("New staff member created successfully.", "Staff details saved"); selectedStaffID = returnID; } else { MessageFunctions.SuccessAlert("Changes saved successfully.", "Staff member amended"); } StaffFunctions.ReturnToStaffPage(selectedStaffID); } } catch (Exception generalException) { MessageFunctions.Error("Error saving details", generalException); } }
private void EntityCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (EntityCombo.SelectedItem == null) { return; } // Do nothing, won't be for long if (resetEntitySelection) // Avoids immediate re-processing if set back to previous selection { resetEntitySelection = false; return; } if (StaffFunctions.IgnoreAnyChanges()) { StaffFunctions.ClearAnyChanges(); Entities selectedRecord = (Entities)EntityCombo.SelectedItem; if (selectedRecord.EntityName == Globals.AllRecords) { selectedEntityID = 0; selectedEntity = null; StaffButton.IsEnabled = false; } else { try { selectedEntity = selectedRecord; selectedEntityID = selectedEntity.ID; StaffButton.IsEnabled = true; } catch (Exception generalException) { MessageFunctions.Error("Error changing entity selection", generalException); selectedEntityID = 0; selectedEntity = null; StaffButton.IsEnabled = false; } } refreshStaffDataGrid(); refreshStaffSummaries(true); } else { resetEntitySelection = true; // If the user cancels the change, don't re-process EntityCombo.SelectedItem = entityComboList.FirstOrDefault(p => p.ID == selectedEntityID); } }
private void BackButton_Click(object sender, RoutedEventArgs e) { if (StaffFunctions.IgnoreAnyChanges()) { StaffFunctions.ClearAnyChanges(); if (backSource == "StaffPage") { StaffFunctions.ReturnToStaffPage(selectedStaffID, sourceMode); } else { refreshEntityCombo(true); //refreshStaffDataGrid(); toggleSelectionControls(true); PageHeader.Content = defaultPageHeader; } } }
private void viewEntitiesByStaffMember() { editMode = ByStaff; toggleSelectionControls(false); try { var staffComboList = StaffFunctions.GetStaffList(activeOnly, nameContains, "", 0); var staffNames = staffComboList.Select(sg => sg.StaffName); StaffCombo.ItemsSource = staffNames; selectedStaffName = StaffFunctions.GetSelectedName(); StaffCombo.SelectedValue = selectedStaffName; refreshEntitySummaries(true); } catch (Exception generalException) { MessageFunctions.Error("Error populating staff list", generalException); return; } }
private void refreshNamesList() { try { exactName = false; string nameLike = NameLike.Text; if (nameLike == "") { PossibleNames.Visibility = Visibility.Hidden; } else { PossibleNames.Visibility = Visibility.Visible; staffDropList = StaffFunctions.GetStaffList(activeOnly: false, nameContains: nameLike, roleCode: "", entityID: Globals.CurrentEntityID); PossibleNames.ItemsSource = staffDropList; } } catch (Exception generalException) { MessageFunctions.Error("Error processing name change", generalException); } }
public bool IsUnusualRole() { if (RoleCode == DefaultRole() || RoleCode == OtherRoleCode) { return(false); } if (RoleCode == IntegrationConsultCode && StaffFunctions.GetRoleDescription(StaffRoleCode).Contains("Consultant")) { return(false); } if (RoleCode == ApplicationConsultCode && StaffRoleCode == SeniorConsultantCode) { return(false); } if (ProjectRole.RoleDescription.Contains("Technical") && StaffFunctions.GetRoleDescription(StaffRoleCode).Contains("Technical")) { return(false); } return(true); }
private void refreshStaffGrid() { try { int entityFilterID = (pageMode == PageFunctions.Lookup) ? Globals.CurrentEntityID : 0; List <StaffProxy> gridList = StaffFunctions.GetStaffList(activeOnly, nameContains, roleCode, entityFilterID); StaffDataGrid.ItemsSource = gridList.OrderBy(gl => gl.UserID).OrderBy(gl => gl.StaffName); if (selectedStaffID > 0) { try { if (gridList.Exists(s => s.ID == selectedStaffID)) { StaffDataGrid.SelectedItem = gridList.First(s => s.ID == selectedStaffID); StaffDataGrid.ScrollIntoView(StaffDataGrid.SelectedItem); } } catch (Exception generalException) { MessageFunctions.Error("Error selecting record", generalException); } } } catch (Exception generalException) { MessageFunctions.Error("Error filling staff grid", generalException); } }
private void StaffDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (StaffDataGrid.SelectedItem != null) { selectedRecord = (StaffProxy)StaffDataGrid.SelectedItem; selectedStaffID = selectedRecord.ID; Globals.SelectedStaffMember = StaffFunctions.GetStaffMember(selectedStaffID); EntitiesButton.IsEnabled = true; } else // No record selected, e.g. because filter changed { clearSelection(); } } catch (Exception generalException) { MessageFunctions.Error("Error processing selection change", generalException); selectedStaffID = 0; // Avoid accidentally using the previous selection clearSelection(); } }
// Data retrieval // // Other/shared functions // private void refreshStaffDataGrid() { try { var gridList = StaffFunctions.GetStaffList(activeOnly, nameContains, "", selectedEntityID); StaffDataGrid.ItemsSource = gridList; if (selectedStaffID > 0) { try { if (gridList.Exists(s => s.ID == selectedStaffID)) { StaffDataGrid.SelectedItem = gridList.First(s => s.ID == selectedStaffID); StaffDataGrid.ScrollIntoView(StaffDataGrid.SelectedItem); } } catch (Exception generalException) { MessageFunctions.Error("Error selecting record", generalException); } } // refreshStaffSummaries(true); } catch (Exception generalException) { MessageFunctions.Error("Error filling staff grid", generalException); } }
private void setDefault() { if (editMode == ByStaff) { try { if (EntitiesTo.SelectedItems == null) { MessageFunctions.Error("Error setting default Entity: no Entity selected.", null); } else if (EntitiesTo.SelectedItems.Count > 1) { MessageFunctions.InvalidMessage("Cannot set default Entity. Please ensure only one Entity is selected.", "Multiple Entities selected"); } else { EntityProxy thisRecord = (EntityProxy)EntitiesTo.SelectedItem; if (thisRecord.Default == false) { int entityID = thisRecord.ID; bool success = StaffFunctions.ChangeDefault(entityID, selectedStaffID); if (success) { refreshEntitySummaries(false); CommitButton.IsEnabled = true; } } } } catch (Exception generalException) { MessageFunctions.Error("Error setting default Entity", generalException); } } else { try { if (StaffTo.SelectedItems != null) { List <StaffProxySmall> defaultList = new List <StaffProxySmall>(); foreach (var selectedRow in StaffTo.SelectedItems) { defaultList.Add((StaffProxySmall)selectedRow); } bool success = StaffFunctions.MakeDefault(defaultList, selectedEntity); if (success) { refreshStaffSummaries(false); CommitButton.IsEnabled = true; } } else { MessageFunctions.Error("Error setting default Entity: no staff selected.", null); } } catch (Exception generalException) { MessageFunctions.Error("Error setting default Entity", generalException); } } }
private void refreshStaffCombo() { staffComboList = StaffFunctions.GetStaffList(activeOnly: true, nameContains: "", roleCode: "", entityID: Globals.CurrentEntityID); StaffCombo.ItemsSource = staffComboList; }