private void ShiftsMonthCalendar_DateSelected(object sender, DateRangeEventArgs e)
        {
            System.DateTime aDate = default(System.DateTime);
            //Calendar control functions to set the Start and End date
            startDate = shiftsMonthCalendar.SelectionRange.Start;
            endDate   = shiftsMonthCalendar.SelectionRange.End;

            //***Add control array, ShiftDates, to show the dates of the shifts
            shiftDates = new BlockArray(this, 50, 100, 200, 1);
            aDate      = startDate;

            int intcnt = 0;

            for (intcnt = 0; intcnt <= 6; intcnt++)
            {
                shiftDates.AddNewBlock();
                shiftDates.Item(intcnt).BackColor = Color.White;
                shiftDates.Item(intcnt).Text      = aDate.ToShortDateString();
                //Show date on Button
                aDate = aDate.AddDays(1);
                //**This function allows you to go to the NEXT day
            }

            //***Add a block for each slot on all the shifts – ShiftBookings control array
            shiftBookings = new BlockArray(this, 50, 100, 300, 6);
            for (intcnt = 0; intcnt <= 41; intcnt++)
            {
                shiftBookings.AddNewBlock();
                if (intcnt % 6 > 2)
                {
                    shiftBookings.Item(intcnt).BackColor = Color.Turquoise;
                }
                //*** ONLY 4 slots on a SUNDAY (2 slots per shift)
                if (intcnt == 2 || intcnt == 5)
                {
                    shiftBookings.Item(intcnt).BackColor = Color.DarkSlateGray;
                    // shiftBookings.Item(intcnt).Enabled = false;
                }
                else
                {
                    //***NB NB Add a click event dynamically to make button respond on the click of the user  NB NB
                    shiftBookings.Item(intcnt).Click += SlotSelected;
                }
            }

            shiftsMonthCalendar.Visible  = false;
            calendarMessageLabel.Visible = false;
            FillCombo();
            //workshop 7 SHIFT CONTROLLER METHOD WILL BE CALLED HERE TO SAVE NEW SHIFT TO MEMORY AND
            shiftController.NewShedule(startDate, endDate);
            //THEN WRITE TO DATABASE--LATER
            ShowControls(true);
        }
Exemplo n.º 2
0
        private void ShiftsMonthCalendar_DateSelected(object sender, DateRangeEventArgs e)
        {
            System.DateTime aDate = default(System.DateTime);  // Find the systems date
            //Calendar control functions to set the Start and End date
            startDate = shiftsMonthCalendar.SelectionRange.Start;
            endDate   = shiftsMonthCalendar.SelectionRange.Start;
            //***Add control array, ShiftDates, to show the dates of the shifts – instantiate with parameters
            shiftDates = new BlockArray(this, 50, 100, 400, 1);  //these blocks will appear in a column
            aDate      = startDate;
            int intcnt = 0;

            for (intcnt = 0; intcnt <= 6; intcnt++)
            {
                shiftDates.AddNewBlock();
                shiftDates.Item(intcnt).BackColor = Color.White;
                shiftDates.Item(intcnt).Text      = aDate.ToShortDateString(); //Display the date on the Button
                aDate = aDate.AddDays(1);                                      //**This function allows you to go to the NEXT day
            }
            //***Add a block for each slot on all the shifts (6 slots) – ShiftBookings control array
            shiftBookings = new BlockArray(this, 50, 100, 500, 6);

            for (intcnt = 0; intcnt <= 41; intcnt++)         // Why 41 blocks?   W7-Q1
            {
                // Add a new block for the shiftBooking
                shiftBookings.AddNewBlock();
                // Afternoon slots should be turquoise (HINT:  6 blocks, use the remainder operator)
                if (intcnt % 6 > 2)
                {
                    shiftBookings.Item(intcnt).BackColor = Color.Turquoise;
                }
                //*** ONLY 4 slots on a SUNDAY (indices 2 or 5)– ie  2 slots per shift,  2 INACTIVE Slots
                // ***the colours of these blocks (identify the indices) will change to Color.DarkSlateGray
                if (intcnt == 2 || intcnt == 5)
                {
                    shiftBookings.Item(intcnt).BackColor = Color.DarkSlateGray;
                }
                else
                {
                    //A click event to be added dynamically to make button respond on user click
                    //  subscribe to the eventhandler event for ALL slots except INACTIVE ones
                    shiftBookings.Item(intcnt).Click += SlotSelected;
                }
            }
            // Hide the calendar & the message below the calendar
            shiftsMonthCalendar.Visible  = false;
            calendarMessageLabel.Visible = false;
            // ***Call the method to fill the Combo box – the list of waiters becomes the datasource
            FillCombo();
            //Call NewSchedule ShiftController method to create a ShiftBookings array in memory
            shiftController.NewShedule(startDate, endDate);
            //Show controls for ComboBox and labels
            ShowControls(true);
        }
Exemplo n.º 3
0
        public void showReservationDates()
        {
            //***Add control array, ShiftDates, to show the dates of the shifts – instantiate with parameters
            roomDates = new BlockArray(this, 30, 100, 50, 7);  //these blocks will appear in a column

            int intcnt = 0;

            // show all 31 days in the month
            for (intcnt = 0; intcnt <= 30; intcnt++)
            {
                roomDates.AddNewBlock();
                roomDates.Item(intcnt).Text = Convert.ToString(intcnt + 1);

                // determine colour using the reservations collection in reservationController
                roomDates.Item(intcnt).FlatStyle = FlatStyle.Flat;

                roomDates.Item(intcnt).Click += SlotSelected; // add action event listener to each button

                int count = 0;

                // determine number of reservations on each day
                for (int i = 0; i < reservationController.AllReservations.Count; i++)
                {
                    // get single reservation
                    Reservation reserved = reservationController.AllReservations[i];

                    // check the start and end date
                    string start = reserved.StartDate;
                    string end   = reserved.EndDate;

                    DateTime startDT  = Convert.ToDateTime(start);
                    DateTime endDT    = Convert.ToDateTime(end);
                    int      startDay = Convert.ToInt32(startDT.Day);
                    int      endDay   = Convert.ToInt32(endDT.Day);

                    if (intcnt + 1 >= startDay && intcnt + 1 <= endDay)
                    {
                        count++;
                    }
                }

                // colour dates depending on availability
                if (count == 0)
                {
                    roomDates.Item(intcnt).BackColor = Color.White;
                }
                if (count > 0 && count < 5)
                {
                    roomDates.Item(intcnt).BackColor = Color.Yellow;
                }
                if (count == 5)
                {
                    roomDates.Item(intcnt).BackColor = Color.Red; roomDates.Item(intcnt).Enabled = false;
                }
            }
        }