private void buttonAddAppointment_Click(object sender, EventArgs e) { //Check if any doctor is selected. if (dataGridViewDoctors.SelectedCells.Count > 0) { //Check if proper date and time is selected. if (!validAppointmentDateTime()) { MessageBox.Show("Please select a proper date and time for the appointment.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //Get Doctor information. BusinessLayer.DoctorInformation doctorInfo = new BusinessLayer.DoctorInformation(); doctorInfo.DoctorID = (int)(dataGridViewDoctors.Rows[dataGridViewDoctors.CurrentCell.RowIndex].Cells[0].Value); doctorInfo.FirstName = (string)(dataGridViewDoctors.Rows[dataGridViewDoctors.CurrentCell.RowIndex].Cells[1].Value); doctorInfo.LastName = (string)(dataGridViewDoctors.Rows[dataGridViewDoctors.CurrentCell.RowIndex].Cells[2].Value); doctorInfo.PWZ = (int)(dataGridViewDoctors.Rows[dataGridViewDoctors.CurrentCell.RowIndex].Cells[3].Value); //Get appointment date. DateTime appointmentDate = getAppointmentDateTime(); //Add appointment newAppointment = new BusinessLayer.ReceptionistFacade.ReceptionistAppointment(); newAppointment.Date = appointmentDate; newAppointment.DoctorFirstName = doctorInfo.FirstName; newAppointment.DoctorLastName = doctorInfo.LastName; BusinessLayer.ReceptionistFacade.AddAppointment(receptionistInformation, patientInformation, doctorInfo, appointmentDate); DialogResult = DialogResult.OK; } else { MessageBox.Show("Please select a doctor to register an appointment.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public FormReceptionistCancelAppointment(BusinessLayer.PatientInformation patient, BusinessLayer.ReceptionistFacade.ReceptionistAppointment appointment) { InitializeComponent(); //Set window title. this.Text = "Cancel Appointment"; canceledAppointment = appointment; //Fill patient textboxes. textBoxFirstName.Text = patient.FirstName; textBoxLastName.Text = patient.LastName; textBoxPESEL.Text = patient.PESEL; //Fill appointment textboxes. textBoxDoctor.Text = appointment.DoctorFirstName + " " + appointment.DoctorLastName; textBoxDateAndTime.Text = appointment.Date.ToString(); }
private void buttonCancelAppointment_Click(object sender, EventArgs e) { //Check if any appointment is selected. if (dataGridViewAppointments.SelectedCells.Count > 0) { //Get patient information. BusinessLayer.PatientInformation patientInfo = new BusinessLayer.PatientInformation(); patientInfo.PatientID = (int)(dataGridViewPatients.Rows[dataGridViewPatients.CurrentCell.RowIndex].Cells[0].Value); patientInfo.FirstName = (string)(dataGridViewPatients.Rows[dataGridViewPatients.CurrentCell.RowIndex].Cells[1].Value); patientInfo.LastName = (string)(dataGridViewPatients.Rows[dataGridViewPatients.CurrentCell.RowIndex].Cells[2].Value); patientInfo.PESEL = (string)(dataGridViewPatients.Rows[dataGridViewPatients.CurrentCell.RowIndex].Cells[3].Value); //Get appointment information. var appointmentInfo = new BusinessLayer.ReceptionistFacade.ReceptionistAppointment(); appointmentInfo.AppointmentID = (int)(dataGridViewAppointments.Rows[dataGridViewAppointments.CurrentCell.RowIndex].Cells[4].Value); appointmentInfo.Date = (DateTime)(dataGridViewAppointments.Rows[dataGridViewAppointments.CurrentCell.RowIndex].Cells[0].Value); appointmentInfo.Status = (string)(dataGridViewAppointments.Rows[dataGridViewAppointments.CurrentCell.RowIndex].Cells[1].Value); appointmentInfo.DoctorFirstName = (string)(dataGridViewAppointments.Rows[dataGridViewAppointments.CurrentCell.RowIndex].Cells[2].Value); appointmentInfo.DoctorLastName = (string)(dataGridViewAppointments.Rows[dataGridViewAppointments.CurrentCell.RowIndex].Cells[3].Value); //Check if appointment has status REG. if (appointmentInfo.Status != "REG") { MessageBox.Show("You can only cancel registered appointments that have not begun yet.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //Create and display cancel appointment form. FormReceptionistCancelAppointment formCancelAppointment = new FormReceptionistCancelAppointment(patientInfo, appointmentInfo); DialogResult res = formCancelAppointment.ShowDialog(this); //Select the canceled appointment if canceled. if (res == DialogResult.OK) { //Refresh appointments. searchForAppointments(); foreach (DataGridViewRow row in dataGridViewAppointments.Rows) { if (row.Cells[4].Value.Equals(formCancelAppointment.canceledAppointment.AppointmentID)) { dataGridViewAppointments.CurrentCell = dataGridViewAppointments[1, row.Index]; break; } } } formCancelAppointment.Dispose(); } else { MessageBox.Show("Please select an appointment to cancel.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }