private void AddBookings() { //If the BookingDate is not in the past... if (Convert.ToDateTime(txtBookingDate.Text) >= DateTime.Today) { //Try to... try { //Call the Add Booking Method from the Bookings table and pass across the data. int rowsAffected = Bookings.AddBooking(txtMemberID.Text, dateTimePickerClass.Value.ToString("yyyy-MM-dd"), txtBookingDate.Text, cbClassID.Text); if (rowsAffected > 0) { //If the Booking has been added successfully, display the message below. MessageBox.Show("Class has been booked successfully."); //Call the GetID method. GetID(); //Call the Reset method. Reset(); } } //Catch any possible exceptions and display an error message. catch (Exception ex) { MessageBox.Show(ex.Message); } } //Otherwise, display the message below. else { MessageBox.Show("The booking date cannot be in the past."); } }