private void btnAddTeacher_Click(object sender, EventArgs e) { // Add Teacher Button // declaring variables name = txtTName.Text.ToUpper(); phone = txtTPhone.Text; email = txtTEmail.Text; salary = txtTSalary.Text; // check phone number entered correctly checkPhone = NumberCheck(phone); NumberPrint(checkPhone, "Phone"); // check emails entered correctly checkEmails = EmailCheck(email); // if errors detected print out error EmailPrint(checkEmails); // check salary entered correctly checkNumbers = NumberCheck(salary); NumberPrint(checkNumbers, "Salary"); // validation check on combo box try { subject = cboSubjects.SelectedItem.ToString(); } catch (Exception ex) { MessageBox.Show("Please select a Subject Taught."); } // validation check for the rest of the infomation entered checkFields = (InputCheck(name, phone, email, salary, subject)); if (checkFields == 0 && checkEmails == 0 && checkPhone == 0 && checkNumbers == 0) { hl.AddTeacher(name, phone, email, salary, subject); // clear entry point boxes txtTName.Clear(); txtTPhone.Clear(); txtTEmail.Clear(); txtTSalary.Clear(); cboSubjects.SelectedIndex = -1; MessageBox.Show("Teacher Contact was added sucessfully."); } else if (checkFields == 1) { MessageBox.Show("Whoops, you forgot to enter 1 field. Please enter all the infomation for the Teacher Contact."); } else if (checkFields > 1) { MessageBox.Show(string.Format("Whoops, you forgot to enter {0} fields. Please enter all the infomation for the Teacher Contact.", checkFields)); } }