private void EmailTextBox_TextChanged(object sender, TextChangedEventArgs e) { // Check it is a valid email if (InputValidationHelper.ValidInput((TextBox)sender, EmailErrorMessage, ErrorHelper.UIError.InvalidEmail)) { // Check it is not in use InputValidationHelper.ValidInput((TextBox)sender, EmailErrorMessage, ErrorHelper.UIError.EmailInUse); } TryEnableRegisterButton(); }
private string CheckStaffRecord() { var errorMessage = new StringBuilder(); // First name if (formEmployeeFirstNameTextbox.Text.Trim().Length == 0) { errorMessage.Append("You have not entered a first name!\n"); } // Last name if (formEmployeeLastNameTextbox.Text.Trim().Length == 0) { errorMessage.Append("You have not entered a last name!\n"); } // Phone number if (formEmployeePhoneNumberTextbox.Text.Trim().Length == 0) { errorMessage.Append("You have not entered a phone number!\n"); } // Email address if (formEmployeeEmailAddressTextbox.Text.Trim().Length == 0) { errorMessage.Append("You have not entered an email!\n"); } else if (!InputValidationHelper.ValidInput(formEmployeeEmailAddressTextbox, ErrorHelper.UIError.InvalidEmail)) { errorMessage.Append("You have not entered a valid email address!\n"); } // if the email entered is in use and isn't the email already set for the selected entity else if (formEmployeeEmailAddressTextbox.Text != ((StaffModel)selectedRow).EmailAddress && !InputValidationHelper.ValidInput(formEmployeeEmailAddressTextbox, ErrorHelper.UIError.EmailInUse)) { errorMessage.Append("The email you have entered is already in use by another user!\n"); } // House Name / Number if (formEmployeeHouseNumberNameTextbox.Text.Trim().Length == 0) { errorMessage.Append("You have not entered a house name or number!\n"); } // PostCode if (formEmployeePostCodeTextbox.Text.Trim().Length == 0) { errorMessage.Append("You have not entered a post code!"); } return(errorMessage.ToString()); }
private void LoginButton_Click(object sender, RoutedEventArgs e) { // check email string email = EmailTextBox.Text; // invalid email if (!InputValidationHelper.ValidInput(EmailTextBox, EmailErrorMessage, ErrorHelper.UIError.InvalidEmail)) { return; } // otherwise valid // check credentials string password = PasswordPBox.Password; IUser userLoggingIn = DBAccessHelper.GetUser(email, password); // credentials are invalid if (userLoggingIn == null) { ErrorHelper.ShowInputError(ErrorHelper.UIError.EmailPasswordComboNotRecognised, EmailErrorMessage); ErrorHelper.ShowInputError(ErrorHelper.UIError.EmailPasswordComboNotRecognised, PasswordErrorMessage); return; } // customer logging in if (!userLoggingIn.IsStaff) { // credentials are valid OrderModel order = new OrderModel() { User = userLoggingIn }; ChangePageTo(new SearchProductsPage(order)); return; } // staff logging in var staffMember = (StaffModel)userLoggingIn; ChangePageTo(new StaffLandingPage(staffMember)); }
private void PasswordConfirmPBox_PasswordChanged(object sender, RoutedEventArgs e) { InputValidationHelper.ValidInput((PasswordBox)sender, PasswordPBox, PasswordConfirmErrorMessage, ErrorHelper.UIError.PasswordMismatch); TryEnableRegisterButton(); }
private void PhoneTextbox_TextChanged(object sender, TextChangedEventArgs e) { InputValidationHelper.ValidInput((TextBox)sender, PhoneErrorMessage, ErrorHelper.UIError.InvalidPhoneNumber); TryEnableRegisterButton(); }
private void LastNameTextbox_TextChanged(object sender, TextChangedEventArgs e) { InputValidationHelper.ValidInput((TextBox)sender, LastNameErrorMessage, ErrorHelper.UIError.RequiredField); TryEnableRegisterButton(); }