Exemple #1
0
        /** 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);
        }
Exemple #2
0
        /** Method is responsibke for handling onclick event on schedule table */
        private void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (timetable.CurrentCell.ColumnIndex < 2)
            {
                return;
            }
            string   timeRange   = timetable.CurrentCell.OwningRow.Cells[1].Value as string;
            TimeSpan slotTime    = TimeSpan.Parse(timetable.CurrentCell.OwningRow.Cells[0].Value as string);
            int      staffId     = Int32.Parse(timetable.CurrentCell.OwningColumn.Name);
            string   doctorsName = timetable.CurrentCell.OwningColumn.HeaderText as string;

            ScheduleController.slotStatus slotStatus = controller.getSlotStatus(slotTime, staffId);
            int staffScheduleId = controller.getStaffScheduleId(slotTime, staffId);

            if (slotStatus == ScheduleController.slotStatus.Available)
            {
                BookingWindow booking = new BookingWindow(this, this.date, timeRange, doctorsName, staffScheduleId);
                booking.Show();
            }
        }