Beispiel #1
0
 public Booking(Customer Customer, Hotel Hotel, String At, int Duration, int RoomNr, int NumAdults, int NumChilds)
 {
     this.Customer = Customer;
     this.Hotel = Hotel;
     this.At = At;
     this.Duration = Duration;
     this.RoomNr = RoomNr;
     this.NumAdults = NumAdults;
     this.NumChilds = NumChilds;
 }
Beispiel #2
0
        public List<Booking> ListBookingsByHid(int hid)
        {
            List<Booking> list = new List<Booking>();
            SqlCommand command = new SqlCommand("SELECT customer.email, customer.name, customer.adr, customer.tel,"
                           + " booking.at, booking.duration, booking.roomNr, booking.numAdults, booking.numChilds,"
                           + " hotel.hid, hotel.name, hotel.adr"
                           + " FROM booking JOIN hotel on(hotel.hid = booking.in_hotel_hid) JOIN customer on(customer.email = booking.by_customer_email)"
                           + " WHERE hotel.hid = @hid", con);
            command.Parameters.AddWithValue("@hid", hid);
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {

                Customer c = new Customer(
                            (String)reader["email"],
                            (String)reader["name"],
                            (String)reader["adr"],
                            (Decimal)reader["tel"]
                        );
                c.ToolTip = "Email: " + (String)reader["email"] + " | Count: " + GetCustomerBookingsCount((String)reader["email"], hid);
                Booking b = new Booking(
                       c,
                        new Hotel(
                            (int)reader[9],
                            (String)reader[10],
                            (String)reader[11]
                        ),
                        (String)reader[4],
                        (int)reader[5],
                        (int)reader[6],
                        (int)reader[7],
                        (int)reader[8]
                    );

                list.Add(b);
            }

            reader.Close();
            return list;
        }