Exemplo n.º 1
0
        //calls uspRetrieveExistingBooking
        public static List <BookingElement> RetrieveExistingBooking(string email, int bookingID)
        {
            if (String.IsNullOrEmpty(email) || bookingID == 0)
            {
                List <BookingElement> empty = new List <BookingElement>();
                return(empty);
            }
            else
            {
                SqlConnection dbConnection = new SqlConnection(connectionString);
                SqlCommand    cmdRetrieveExistingBooking = new SqlCommand("uspRetrieveExistingBooking", dbConnection);
                cmdRetrieveExistingBooking.CommandType = CommandType.StoredProcedure;
                SqlParameter pCustomerEmail = new SqlParameter("@CustomerEmail", SqlDbType.VarChar, 50);
                SqlParameter pBookingID     = new SqlParameter("@BookingID", SqlDbType.Int);
                cmdRetrieveExistingBooking.Parameters.Add(pBookingID);
                cmdRetrieveExistingBooking.Parameters.Add(pCustomerEmail);


                List <BookingElement> existingBooking = new List <BookingElement>();
                try
                {
                    dbConnection.Open();
                    pBookingID.Value     = bookingID;
                    pCustomerEmail.Value = email;
                    SqlDataReader reader = cmdRetrieveExistingBooking.ExecuteReader();
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            BookingElement b = new BookingElement();
                            b.ReservationDate    = reader.GetDateTime(0);
                            b.BookingID          = reader.GetInt32(1);
                            b.DateBookingCreated = reader.GetDateTime(2);
                            b.Paid            = reader.GetString(3);
                            b.RoomID          = reader.GetInt32(4);
                            b.NumberOfGuests  = reader.GetInt32(5);
                            b.RoomRate        = reader.GetDecimal(6);
                            b.BookingNotes    = reader.GetString(7);
                            b.RoomName        = reader.GetString(8);
                            b.CustomerName    = reader.GetString(9);
                            b.CustomerCountry = reader.GetString(10);
                            b.CustomerEmail   = reader.GetString(11);
                            b.CustomerPhone   = reader.GetString(12);
                            existingBooking.Add(b);
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    dbConnection.Close();
                }
                return(existingBooking);
            }
        }
Exemplo n.º 2
0
        public static List <BookingElement> CreateBookingElementsForUserSelectedDates(List <DateTime> dates, List <Room> currentRoomData)
        {
            List <Room>           roomData       = currentRoomData;
            List <BookingElement> bookingElement = new List <BookingElement>();

            foreach (Room r in roomData)
            {
                foreach (DateTime date in dates)
                {
                    BookingElement b = new BookingElement();
                    b.UserDate    = date.Date;
                    b.RoomID      = r.RoomID;
                    b.MaxCapacity = r.MaxCapacity;                     //added for gridview drop down
                    bookingElement.Add(b);
                }
            }
            return(bookingElement);
        }