private void btnSubmit_Click(object sender, EventArgs e) { if (isValidData()) { person = new Person(); patient = new Patient(); this.PutPersonData(person); try { //Inserts the Person into the table and stores PersonID person.PersonID = inController.AddPerson(person); //Passes PersonID from Person to Patient patient.PersonID = person.PersonID; //Inserts Patient by using PersonID inController.AddPatient(patient); MessageBox.Show("The patient was successfully added."); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } }