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 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 Page_Loaded(object sender, RoutedEventArgs e) { FirstName.Focus(); CapsLockLabel.Visibility = Visibility.Hidden; refreshRoleList(); refreshEntityList(); toggleConfirm(false); if (!Globals.MyPermissions.Allow("ActivateStaff")) { ActiveCheckBox.IsEnabled = false; ActiveCheckBox.ToolTip = ActiveLabel.ToolTip = "Your current permissions do not allow activating or disabling staff members"; } try { pageMode = PageFunctions.pageParameter(this, "Mode"); selectedStaffID = Int32.Parse(PageFunctions.pageParameter(this, "StaffID")); } catch (Exception generalException) { MessageFunctions.Error("Error retrieving query details", generalException); StaffFunctions.ReturnToStaffPage(selectedStaffID); } if (pageMode == PageFunctions.New) { PageHeader.Content = "Create New Staff Member"; HeaderImage2.SetResourceReference(Image.SourceProperty, "AddIcon"); Instructions.Content = "Fill in the details as required and then click 'Save' to create the record."; BackButton.Visibility = Visibility.Hidden; } else if (pageMode == PageFunctions.Amend) { if (selectedStaffID > 0) { try { thisStaffMember = StaffFunctions.GetStaffMember(selectedStaffID); FirstName.Text = thisStaffMember.FirstName; Surname.Text = thisStaffMember.Surname; UserID.Text = thisStaffMember.UserID; if (thisStaffMember.UserID != null && thisStaffMember.UserID != "") { UserID.IsEnabled = false; } displayRole(); if (thisStaffMember.StartDate != null) { StartDate.SelectedDate = thisStaffMember.StartDate; } if (thisStaffMember.LeaveDate != null) { LeaveDate.SelectedDate = thisStaffMember.LeaveDate; } displayDefaultEntity(); ActiveCheckBox.IsChecked = thisStaffMember.Active; SSOCheckBox.IsChecked = thisStaffMember.SingleSignon; DomainUser.Text = thisStaffMember.OSUser; } catch (Exception generalException) { MessageFunctions.Error("Error populating staff member data", generalException); StaffFunctions.ReturnToStaffPage(selectedStaffID); } } else { MessageFunctions.Error("Load error: no staff member loaded.", null); StaffFunctions.ReturnToStaffPage(selectedStaffID); } } }
private void BackButton_Click(object sender, RoutedEventArgs e) { StaffFunctions.ReturnToStaffPage(selectedStaffID); }