public booking_class Select_booking(int booking_ref, int cust_ref)
        //Method to select the booking, since each booking has a customer associated with it the customer reference must also be used
        {
            Cur_customer_Singleton cur_cust = Cur_customer_Singleton.Instance();

            sql             = "SELECT * FROM booking WHERE booking_ref=" + booking_ref + " AND cust_ref=" + cust_ref + ";"; //Query to find the correct booking given the correct customer reference
            cmd.CommandText = sql;
            sdr             = cmd.ExecuteReader();
            bool          bookExists = false;
            booking_class book       = new booking_class();

            while (sdr.Read()) //while the data reader is reading through the database
            {
                if (sdr.GetString(0) == booking_ref.ToString())

                /*
                 * This if statement will ensure that the booking reference in the database will be equal to the booking reference in the c#
                 * The booking class will have the data from the database saved to the corresponding variable in the booking_class
                 * Ref = first column of the database (i.e the booking reference) etc.
                 */
                {
                    bookExists         = true;
                    book.Ref           = Int32.Parse(sdr.GetString(0));
                    book.Arrivaldate   = sdr.GetString(1);
                    book.DepDate       = sdr.GetString(2);
                    book.Num_of_guests = sdr.GetString(3);
                }
            }
            sdr.Close(); //data reader is no longer in use, therfore close it

            if (bookExists == false)
            //Error checking ensuring that the booking reference exists.
            {
                MessageBox.Show("Booking does not exist given the selected reference number.");
            }
            else
            {
                Cur_booking_Singleton cur_booking = Cur_booking_Singleton.Instance(book);
                Booking bookingWin = new Booking();                         //creating a new booking window
                bookingWin.Show();                                          //open the booking window

                bookingWin.txtBox_booking_ref.Text   = book.Ref.ToString(); //set the text box value, booking ref, to the booking reference
                bookingWin.datepicker_arrival.Text   = book.Arrivaldate;    //The arrival date is already a string and therefore does not need to be converted into a string
                bookingWin.datepicker_dep.Text       = book.DepDate;
                bookingWin.txtBox_num_of_guests.Text = book.Num_of_guests;
            }
            return(book);
        }
        public void load_guests(int booking_ref)                        //NEED TO FIND A WAY TO CHECK IF THERE ARE ANY GUESTS EXISTING

        /*
         * This view method will be slightly different as it will need to load multiple different text boxes from multiple different rows
         * in the database, within the same method. In order to achieve this a list will be used to iterate through all the four possible guests
         */
        {
            Cur_booking_Singleton curbooking = Cur_booking_Singleton.Instance();            //create a new instance of booking, as only one should be used at one time

            sql             = "SELECT * FROM guest WHERE booking_ref=" + booking_ref + ";"; //SELECT statement tha searches for the guests with the correct booking reference
            cmd.CommandText = sql;
            sdr             = cmd.ExecuteReader();

            List <guest> guestList = new List <guest>();  //creation of the list

            while (sdr.Read())
            {
                if (sdr.GetString(5) == booking_ref.ToString()) //if the value of the 5th column in the database table is equal to the booking ref then

                /*
                 * Same as previous reads however this time the identifier is the foreign key booking_reference as there may be multiple guests that need to be loaded in
                 */
                {
                    guest guest = new guest();
                    guest.Pass_num    = sdr.GetString(0);
                    guest.LastName    = sdr.GetString(1);
                    guest.Firstname   = sdr.GetString(2);
                    guest.DoB         = sdr.GetString(3);
                    guest.Dietreq     = sdr.GetString(4);
                    guest.Booking_ref = booking_ref;
                    guestList.Add(guest); //adding all the values from the previous lines into the list, naming each group of values "guest"
                }
            }
            sdr.Close();

            Guests guestsWin = new Guests();                            //creating a new guest window

            guestsWin.txtBox_booking_ref.Text = booking_ref.ToString(); //inserting the booking reference into the booking refernce text box in the guest window

            for (int i = 0; i < guestList.Count(); i++)

            /*
             * This for loop is used to iterate through the possible data that can be loaded into the guest window
             * It will only be the size of the count of the guest list. Therefore the data wont be loaded in if the data for the guest does not exist.
             */
            {
                if (i == 0)
                //for the first item in the list set the follwoing text boxes to the values in the list
                {
                    guestsWin.txtBox_g1_pass_num.Text = guestList[i].Pass_num; //i.e set the passs number text box to be equal to the passpot number of guest 1
                    guestsWin.txtBox_g1_last.Text     = guestList[i].LastName;
                    guestsWin.txtBox_g1_first.Text    = guestList[i].Firstname;
                    guestsWin.datepicker_g1_DoB.Text  = guestList[i].DoB;
                    guestsWin.txtBox_g1_diet_req.Text = guestList[i].DoB;
                }
                if (i == 1)
                {
                    guestsWin.txtBox_g2_pass_num.Text = guestList[i].Pass_num;
                    guestsWin.txtBox_g2_last.Text     = guestList[i].LastName;
                    guestsWin.txtBox_g2_first.Text    = guestList[i].Firstname;
                    guestsWin.datepicker_g2_DoB.Text  = guestList[i].DoB;
                    guestsWin.txtBox_g2_diet_req.Text = guestList[i].DoB;
                }
                if (i == 2)
                {
                    guestsWin.txtBox_g3_pass_num.Text = guestList[i].Pass_num;
                    guestsWin.txtBox_g3_last.Text     = guestList[i].LastName;
                    guestsWin.txtBox_g3_first.Text    = guestList[i].Firstname;
                    guestsWin.datepicker_g3_DoB.Text  = guestList[i].DoB;
                    guestsWin.txtBox_g3_diet_req.Text = guestList[i].DoB;
                }
                if (i == 3)
                {
                    guestsWin.txtBox_g4_pass_num.Text = guestList[i].Pass_num;
                    guestsWin.txtBox_g4_last.Text     = guestList[i].LastName;
                    guestsWin.txtBox_g4_first.Text    = guestList[i].Firstname;
                    guestsWin.datepicker_g4_DoB.Text  = guestList[i].DoB;
                    guestsWin.txtBox_g4_diet_req.Text = guestList[i].DoB;
                }
            }

            sdr.Close();
        }