private void button2_Click(object sender, EventArgs e) { //capture the booking details from the textboxes if (comboBox1.SelectedIndex == -1)//Nothing selected { MessageBox.Show("Please select number of guests from the drop down list", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboBox1.Focus(); return; } else if (dateTimePicker2.Value < dateTimePicker1.Value) { MessageBox.Show("Check out date should be a later date than the check in date", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); dateTimePicker1.Focus(); return; } else { //check the availability Collection <Room> Avail; Avail = bookingController.CheckAvailability(dateTimePicker1.Value.Date, dateTimePicker2.Value.Date, roomController.AllRooms); DialogResult result; Booking aBooking; //if there are bookings available if (Avail.Count() > 0) { result = MessageBox.Show("Booking for " + dateTimePicker1.Value.ToShortDateString() + " - " + dateTimePicker2.Value.ToShortDateString() + " is available\nClick yes to confirm", "Confirm Reservation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (result == DialogResult.Yes) { this.Hide(); //make the booking with all the fields we currently have aBooking = new Booking(); aBooking.BookingID = bookingController.GenerateBookingID(); aBooking.ReservationDate = DateTime.Today.ToShortDateString(); aBooking.StartDate = dateTimePicker1.Value.ToShortDateString(); aBooking.EndDate = dateTimePicker2.Value.ToShortDateString(); aBooking.RoomNumber = Avail[0].RoomNumber; //assigned to the first available room aBooking.NoOfGuests = comboBox1.SelectedItem.ToString(); aBooking.Price = bookingController.CalculateBookingPrice(dateTimePicker1.Value, dateTimePicker2.Value, roomRateController.AllRoomRates); aBooking.DepositAmount = (aBooking.Price / 10); aBooking.DepositPaid = "false"; ReservationDetailsDisplayForm obj = new ReservationDetailsDisplayForm(bookingController, roomController, guestController, aBooking, paymentController); //this must change to the capture guest details obj.Show(); } if (result == DialogResult.No) //if they want to stay on this page { } } //if there are no bookings available else { result = MessageBox.Show("Reservation unavailable\nPlease select new dates", "Reservation Unvailable", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); //to select new dates if (result == DialogResult.OK) { } } } }