private void buttonSaveAppointment_Click(object sender, EventArgs e) { if (this.comboBoxAppointmentDoctor.SelectedValue == null) { MessageBox.Show("Please select a doctor"); return; } int patientId = this.patient.PatientID.Value; DateTime appointmentDateTime = this.dateTimeAppointmentDate.Value; string reasons = this.textBoxAppointmentReasons.Text; int doctorId = Int32.Parse(this.comboBoxAppointmentDoctor.SelectedValue.ToString()); bool successful = false; if (this.appointmentUpdateMode) { Appointment oldAppointment = (Appointment)this.listViewAppointments.SelectedItems[0].Tag; if (this.validateAppointmentInfo(appointmentDateTime, patientId, doctorId, reasons, oldAppointment)) { DateTime oldDateTime = oldAppointment.DateTime; successful = AppointmentDAL.UpdateAppointment(this.patient.PatientID.Value, oldDateTime, appointmentDateTime, doctorId, reasons); } else { return; } } else if (this.validateAppointmentInfo(appointmentDateTime, patientId, doctorId, reasons)) { successful = AppointmentDAL.AddAppointment(patientId, appointmentDateTime, doctorId, reasons); } else { return; } if (successful) { this.reloadAppointments(); this.clearAppointmentDetailsFields(); this.groupBoxAppointmentInfo.Enabled = false; this.toggleCurrentlyEditingAppointment(false); } else { MessageBox.Show("An error occured while saving the appointment"); } }
/// <summary> /// Adds a new appointment to the DB /// </summary> /// <param name="appointment">appointment to add</param> public void AddAppointment(Appointment appointment) { appointmentDAL.AddAppointment(appointment); }