コード例 #1
0
        //displays current bookings for current restaurant
        private void btnDisplay_Click(object sender, EventArgs e)
        {
            int userID = 0;

            //set temp booking
            ControlBooking tempBook = new ControlBooking(0, DateTime.Today, 0, 0);

            //check role for display filter
            if (theCurrentUser.GetRole() == "Customer")
            {
                userID = theCurrentUser.GetUserID();
            }

            //get existing bookings
            List <string> bookings = tempBook.GetBookings(theRestaurants[activeRestaurant].GetRestaurantID(), userID);

            string[] splitBook;

            foreach (string book in bookings)
            {
                splitBook = book.Split(',');

                string[] row          = { splitBook[0], splitBook[1], splitBook[2], splitBook[3], splitBook[4] };
                var      listViewItem = new ListViewItem(row);
                lstBookings.Items.Add(listViewItem);
            }
        }
コード例 #2
0
        private void GetAvailableTimes(string aDate)
        {
            List <int> availableTimes = new List <int>();

            //set temp booking
            ControlBooking tempBook = new ControlBooking(0, DateTime.Today, 0, 0);

            //get existing bookings
            List <int> bookedTimes = tempBook.GetTimes(theRestaurants[activeRestaurant].GetRestaurantID(), aDate, theRestaurants[activeRestaurant].GetRestaurantTables());


            //get openingTimes
            string openingTimes = theRestaurants[activeRestaurant].GetRestaurantHours();

            string[] splitOpenTimes = openingTimes.Split(',');

            //build availableTimes
            if (splitOpenTimes[0] == "True")
            {
                availableTimes.Add(10);
                availableTimes.Add(11);
                availableTimes.Add(12);
            }

            if (splitOpenTimes[1] == "True")
            {
                availableTimes.Add(18);
                availableTimes.Add(19);
                availableTimes.Add(20);
            }



            //check and remove bookedTimes from availableTimes
            if (bookedTimes.Count > 0)
            {
                foreach (int time in bookedTimes)
                {
                    availableTimes.Remove(time);
                }
            }

            //output availableTimes
            lstBookTimes.DataSource = availableTimes;
        }
コード例 #3
0
        //register/update a booking
        private void btnSaveBooking_Click(object sender, EventArgs e)
        {
            //set temp Restaurant
            ControlBooking tempBook = new ControlBooking(0, DateTime.Today, 0, 0);

            int  id;
            bool isIDValid = Int32.TryParse(lblBookingID.Text, out id);

            if (isIDValid)
            {
                //update booking
            }
            else
            {
                //register new booking
                tempBook.BookTable(theRestaurants[activeRestaurant].GetRestaurantID(), dteBookDate.Text, theCurrentUser.GetUserID(), (int)lstBookTimes.SelectedItem);
                MessageBox.Show("Table successfully booked!");
            }

            grpBookings.Visible       = false;
            grpManageBookings.Visible = true;
            LoadRestaurantDisplay(activeRestaurant);
        }