private void button1_Click(object sender, EventArgs e) { try { objHospitalDB = new HospitalDB(); Patient objPatient = new Patient(objHospitalDB); PatientRow objPatientRow = new PatientRow(); objPatientRow.Patient_Address = ultraTextAddress.Text; objPatientRow.DateOfBirth = Convert.ToDateTime(ultraCalendarComboDOB.Text); objPatientRow.DateOfRegistration = Convert.ToDateTime(ultraCalendarComboDOR.Text); objPatientRow.FullName = ultraTextFullName.Text; objPatientRow.Phone = Convert.ToInt32(ultraTextPhoneNumber.Text); objPatientRow.Emergency_Contact = Convert.ToInt32(ultraTextEmergencyContact.Text); //DataTable dtPatient = new DataTable(); if (strFormMode == "NEW") { if (MessageBox.Show("Are you sure You want to save", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { objPatient.Insert(objPatientRow); this.Hide(); } } else if (strFormMode == "EDIT") { try { objPatientRow.Patient_ID = Convert.ToInt32(this.id); objPatient.Update(objPatientRow); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }