/** Method initiaties the process of updating the attendance process */ private void saveButton_Click(object sender, System.EventArgs e) { FeedbackWindow message = new FeedbackWindow(); if (attendanceOptions.SelectedIndex != 0) { BookingController controller = new BookingController(); string selectedOption = (attendanceOptions.SelectedItem as ListItem).text; Dictionary <string, int> options = controller.getAttendanceOptions()[selectedOption]; booking.setAttendance(options["attendance"]); booking.setConfirmation(options["confirmation"]); booking.setLackOfCancellation(options["lackOfCancellation"]); if (controller.updateAttendanceStatus(booking)) { message.setMessageForSuccessfullOperation(); } else { message.setMessageForSavingError(); } parent.getAppointmentBoxes(); this.Hide(); } else { message.setCustomizedMessage(ATTENDANCE_OPTION_NOT_SELECTED); } message.Show(); }
/** * Method calls the controller for cancelling the appointment and reloads appointment boxes in parent window * * @return result of cancelling the appointment */ public bool cancelAppointmentAfterConfirmation() { bool result = controller.cancelAppointment(this.bookingId); if (!result) { // set some message here return(false); } parent.getAppointmentBoxes(); return(true); }
/** Method generates timetable's slots */ private void generateTimeTableSlots() { int lengthOfRegularAppointment = surgeryInfo.regularAppointmentLength; TimeSpan surgeryOpeningTime = surgeryInfo.openingTime; TimeSpan surgeryClosingTIme = surgeryInfo.closingTime; this.refreshTimetable(); //reloads parent (Upcoming/Past Appointments) content after booking appointment if (this.parent != null) { parent.getAppointmentBoxes(); } int numberOfMorningAppointments = 0; int numberOfAfternoonAppointments = 0; TimeSpan appointmentStartTime = surgeryOpeningTime; while (appointmentStartTime < surgeryClosingTIme) { TimeSpan appointmentEndTime = appointmentStartTime.Add(TimeSpan.FromMinutes(lengthOfRegularAppointment)); string formattedAppointmentStartTime = string.Format("{0:00}:{1:00}", appointmentStartTime.Hours, appointmentStartTime.Minutes); string formattedAppointmentEndTime = string.Format("{0:00}:{1:00}", appointmentEndTime.Hours, appointmentEndTime.Minutes); string appointmentRange = formattedAppointmentStartTime + " - " + formattedAppointmentEndTime; timetable.Rows.Add(formattedAppointmentStartTime, appointmentRange); for (int columnIndex = 2; columnIndex < timetable.ColumnCount; columnIndex++) { string staffId = timetable.Columns[columnIndex].Name; ScheduleController.slotStatus slotStatus = controller.getSlotStatus(appointmentStartTime, Int32.Parse(staffId)); string slotStatusName = slotStatus.ToString(); if (slotStatusName.Equals("Available") && appointmentStartTime <= new TimeSpan(12, 0, 0)) { numberOfMorningAppointments++; } if (slotStatusName.Equals("Available") && appointmentStartTime > new TimeSpan(12, 0, 0)) { numberOfAfternoonAppointments++; } timetable.Rows[timetable.RowCount - 1].Cells[staffId].Value = (slotStatus == ScheduleController.slotStatus.NotAvailable ? "" : slotStatusName); } appointmentStartTime = appointmentEndTime; } timetable.Visible = true; parent.setNumberOfAppointmentsPerDay(numberOfMorningAppointments, numberOfAfternoonAppointments); }