public SingleBooking(DateTime dateTime, int roomID, DailySchedule.TimeSlot timeSlot, Booking booking)
 {
     dateTime_ = dateTime;
     roomID_ = roomID;
     timeSlot_ = timeSlot;
     booking_ = booking;
 }
 public WeeklyBooking(Calendar.Semester semester, DayOfWeek dayOfWeek, int roomID, DailySchedule.TimeSlot timeSlot, Booking booking)
 {
     semester_ = semester;
     roomID_ = roomID;
     dayOfWeek_ = dayOfWeek;
     timeSlot_ = timeSlot;
     booking_ = booking;
 }
        private void OnClick()
        {
            //int RoomValue = comboBox1.ValueMember;
            DateTime currentdate = monthCalendar1.SelectionRange.Start; //gives current DateTime
            DateTime FirstOfWeek;
            if (currentdate.DayOfWeek == DayOfWeek.Sunday) //Get Sunday
            {
                FirstOfWeek = currentdate;
            }
            else if (currentdate.DayOfWeek == DayOfWeek.Monday)
            {
                FirstOfWeek = currentdate.AddDays(-1);
            }
            else if (currentdate.DayOfWeek == DayOfWeek.Tuesday)
            {
                FirstOfWeek = currentdate.AddDays(-2);
            }
            else if (currentdate.DayOfWeek == DayOfWeek.Wednesday)
            {
                FirstOfWeek = currentdate.AddDays(-3);
            }
            else if (currentdate.DayOfWeek == DayOfWeek.Thursday)
            {
                FirstOfWeek = currentdate.AddDays(-4);
            }
            else if (currentdate.DayOfWeek == DayOfWeek.Friday)
            {
                FirstOfWeek = currentdate.AddDays(-5);
            }
            else
            {
                FirstOfWeek = currentdate.AddDays(-6);
            }
            List<Day> dayList = Calendar.Instance.DayArray;
            List<Room> roomList;
            
            bool sundayFound = false;
            int i = 0;
            foreach (var dayIter in dayList) //for sunday
            {
                if (dayIter.CurrentDay == FirstOfWeek)
                {
                    sundayFound = true;
                }
                if (sundayFound)
                {
                    roomList = dayIter.GetRoomList;
                    foreach (var roomIter in roomList)
                    {
                        if (roomIter.RoomID == (int)this.comboBox1.SelectedValue)
                        {
                            weekSchedule_[i] = new DailySchedule();
                            weekSchedule_[i] = roomIter.DaySchedule;

                        }
                    }
                    ++i;
                }
                if (i > 6)
                {
                    break;
                }
            }


            // MessageBox.Show(currentdate, "CalendarTest", MessageBoxButtons.OK);
            for (int row = 0; row < 5; row++ )
            {
                for(int col = 0; col < 7; col++)
                {
                    if(weekSchedule_[col].CheckBooking(row))
                    {
                        buttonArray[row, col].BackColor = System.Drawing.Color.Red;
                        buttonArray[row, col].Text = weekSchedule_[col].getBooking(row).Title;
                        buttonArray[row, col].Refresh();
                    }
                    else
                    {
                        buttonArray[row, col].BackColor = System.Drawing.Color.Lime;
                        buttonArray[row, col].Text = "Free";
                        buttonArray[row, col].Refresh();
                    }
                }
            }

            //    btnr1c1.Text = "test"; // changes the text at runtime
            //btnr1c1.Refresh();
        }
Example #4
0
 //===============================================================================
 // Constructor and Destructors
 //===============================================================================
 public Room(string name, int number)
 {
     roomLocation_ = name;
     roomID_ = number;
     daySchedule_ = new DailySchedule();
 }