示例#1
0
        //Loads a booking based on booking reference entered enabling the user to edit it
        private void btnLoadBooking_Click(object sender, RoutedEventArgs e)
        {
            //Pull booking and customer details from database
            Singleton db = Singleton.Instance;

            data.DBConnect();
            Booking  booking  = data.SetBooking(Int32.Parse(txtBookingReference.Text));
            Customer customer = data.SetCustomer(booking.CustomerRef);
            Extras   extras   = data.SetExtras(Int32.Parse(txtBookingReference.Text));

            if (booking.BookingRef == 0)
            {
                MessageBox.Show("Failed to find that booking. Please retry");
            }
            else
            {
                //Create new 'edit booking' window and pass in classes
                EditBooking eb = new EditBooking(booking, c, guest);

                //Displays and sets the on the booking window to the values taken from the database
                eb.lblBookingRef.Content         = booking.BookingRef;
                eb.dtpArrivalEdit.SelectedDate   = booking.Arrival_date;
                eb.dtpDepartureEdit.SelectedDate = booking.Departure_date;
                eb.lblCustomerName.Content       = customer.Name;
                eb.lblCustomerRef.Content        = customer.CustomerRef;
                eb.txtDinnerDesc.Text            = extras.DDesc;
                eb.txtBreakfastDesc.Text         = extras.BDesc;
                eb.txtCarHireName.Text           = extras.HireName;
                eb.dtpHireStart.SelectedDate     = extras.HireStart;
                eb.dtpHireEnd.SelectedDate       = extras.HireEnd;

                //Inserts list of guests taken from database into the combobox on the edit booking window
                data.DBConnect();
                eb.cbbGuests.ItemsSource = data.SetGuest(Int32.Parse(txtBookingReference.Text));

                //Show 'edit booking' window, close current window
                eb.Show();
                this.Close();
            }
        }