private void buttonChangePassword_Click(object sender, EventArgs e)
        {
            // check if new password was not left blank
            if (string.IsNullOrWhiteSpace(textBoxNewPassword.Text))
            {
                errorProvider.SetError(textBoxNewPasswordConfirmed, "New password must not be left blank!");
            }
            // check if new password and new password confirmed match
            else if (textBoxNewPassword.Text == textBoxNewPasswordConfirmed.Text)
            {
                string errorMessage = LoginValidation.CheckPasswordStrength(textBoxNewPassword.Text);

                // check if password meets characteristics
                if (string.IsNullOrWhiteSpace(errorMessage))
                {
                    // check if current password is correct
                    if (LoginValidation.ValidateCredentials(Main.mainApplication.employeeEmail, textBoxCurrentPassword.Text).passwordValid)
                    {
                        // change password
                        DatabaseManagement.GetInstanceOfDatabaseConnection().UpdateRecord(DatabaseQueries.UpdateRecord(DatabaseQueries.UPDATE_EMPLOYEE_PASSWORD, LoginValidation.HashPassword(textBoxNewPassword.Text), DatabaseQueries.EMPLOYEE_WHERE_EMAIL, Main.mainApplication.employeeEmail));
                        // display message box to notify user
                        MessageBox.Show("Password changed successfully.", "Password Change Confirmation");
                        // and go back to previous page
                        Main.mainApplication.GoBackPage();
                    }
                    else
                    {
                        errorProvider.SetError(textBoxCurrentPassword, "Password incorrect!");
                    }
                }
                else
                {
                    errorProvider.SetError(textBoxNewPassword, errorMessage);
                }
            }
            else
            {
                errorProvider.SetError(textBoxNewPasswordConfirmed, "Passwords do not match!");
            }
        }
        private void buttonLogIn_Click(object sender, EventArgs e)
        {
            // store employees email for later use
            string employeeEmail = comboBoxEmail.Text;
            // validate email and store any error messages received
            string errorMessage = LoginValidation.ValidateEmail(comboBoxEmail.Text);

            // if error message returned, turn the flag on
            if (!string.IsNullOrWhiteSpace(errorMessage))
            {
                errorProvider.SetError(comboBoxEmail, errorMessage);
                return;
            }

            // check if password was not left blank before continuing
            if (string.IsNullOrWhiteSpace(textBoxPassword.Text))
            {
                errorProvider.SetError(textBoxPassword, "Password must not be left blank!");
                return;
            }

            // store results of validation as boolean values (bool emailValid, bool passwordValid)
            var(emailValid, passwordValid) = LoginValidation.ValidateCredentials(employeeEmail, textBoxPassword.Text);

            // if both email and password are valid, continue to main application
            if (emailValid && passwordValid)
            {
                // add logon entry to log file
                FileWriter.WriteLog("login");

                // if email address already occurs in the log file, delete it
                FileWriter.DeleteLine(MAIL_LOG_FILE, FileWriter.ContainsLine(MAIL_LOG_FILE, employeeEmail));
                // insert email address at the beginning of the file
                FileWriter.InsertAtBeginning(MAIL_LOG_FILE, employeeEmail);

                // hide current form
                this.Hide();

                // create main form and open it
                using (Main MainApplication = new Main(employeeEmail))
                    MainApplication.ShowDialog();

                // once main application closes, add logoff entry to event file
                FileWriter.WriteLog("logout");

                // open login page again
                this.Show();
                // load default settings of the login page
                LoadDefaultSettings();
            }
            // else if email incorrect
            else if (!emailValid)
            {
                errorProvider.SetError(comboBoxEmail, "Email address incorrect!");
            }
            // else if password incorrect
            else if (!passwordValid)
            {
                errorProvider.SetError(textBoxPassword, "Password incorrect!");
            }
            // in case of any inexpected errors
            else
            {
                FileWriter.WriteLog("login validation error");
                MessageBox.Show("Please report this error to your manager.", "Unexpected Error");
            }
        }