/// <summary>
        /// Verifies that all the user input data is valid.
        /// </summary>
        /// <returns>A boolean indicating whether the
        /// input data is valid or not.</returns>
        private bool ValidateForm()
        {
            bool isValid = true;
            //Lamda expression comparing the input to "" (null data).
            //Returns true if they are equal.
            Func <string, bool> compareString = s => s == "";

            CheckIDIsValid();
            //If the error message is null (i.e. there is no error message),
            //isValid remains the same.
            isValid = compareString(ErrorProvider.GetError(TextBoxStudentIDValue)) ? isValid : false;
            ClassLibrary.CheckNameIsValid(TextBoxFirstNameValue, ErrorProvider);
            isValid = compareString(ErrorProvider.GetError(TextBoxFirstNameValue)) ? isValid : false;
            ClassLibrary.CheckNameIsValid(TextBoxLastNameValue, ErrorProvider);
            isValid = compareString(ErrorProvider.GetError(TextBoxLastNameValue)) ? isValid : false;

            return(isValid);
        }
        /// <summary>
        /// Verifys that the user input data is valid.
        /// </summary>
        /// <returns>A boolean indicating whether the components
        /// have validated correctly or not.</returns>
        private bool ValidateForm()
        {
            bool isValid = true;
            //Lamda expression that compares an input to null data.
            //Returns true if the supplied input is null.
            Func <string, bool> compareString = s => s == "";

            ClassLibrary.CheckNameIsValid(TextBoxFirstNameValue, ErrorProvider);
            //Alternative to writing IF statements to improve readability.
            //isValid remains the same (in this case, TRUE) if the ErrorProvider
            //has no error set, otherwise it is set to false
            isValid = compareString(ErrorProvider.GetError(TextBoxFirstNameValue)) ? isValid : false;
            ClassLibrary.CheckNameIsValid(TextBoxLastNameValue, ErrorProvider);
            isValid = compareString(ErrorProvider.GetError(TextBoxLastNameValue)) ? isValid : false;
            ClassLibrary.CheckEmailIsValid(TextBoxStaffEmailValue, ErrorProvider);
            isValid = compareString(ErrorProvider.GetError(TextBoxStaffEmailValue)) ? isValid : false;

            //Returns true if all components validate successfully
            return(isValid);
        }
 private void TextBoxLastNameValue_Validating(object sender, CancelEventArgs e)
 {
     ClassLibrary.CheckNameIsValid(TextBoxLastNameValue, ErrorProvider);
 }