private void btnSubmit_Click(object sender, EventArgs e) { if (isValidData()) { if (txtSymptoms.TextLength < 20) { MessageBox.Show("Symptoms description should be more than 20 characters"); return; } newAppt = new Appointment(); newVisit = new Visit(); this.PutVisitData(newVisit); this.PutApptData(newAppt); try { //Inserts the Visit into the table and stores VisitID newVisit.VisitID = visitsController.AddVisit(newVisit); AppointmentController.appointmentCheckedIn(newAppt); MessageBox.Show("The visit was successfully added."); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } }