Ejemplo n.º 1
0
        internal List <IBooking> GetActiveBookings(string reservationID)
        {
            List <IBooking> bookings = new List <IBooking>();

            foreach (IBooking book in dbCon.GetBookings(reservationID))
            {
                if (book.BStatus != BookStatus.Canceled)
                {
                    bookings.Add(book);
                }
            }
            return(bookings);
        }
Ejemplo n.º 2
0
        internal List <IBooking> GetActiveBookings(string customerID)
        {
            List <IBooking> bookings = new List <IBooking>();

            foreach (IBooking book in dbCon.GetBookings(customerID))
            {
                if (book.BStatus == BookStatus.Confirmed)
                {
                    bookings.Add(book);
                }
            }
            return(bookings);
        }
Ejemplo n.º 3
0
        //Return a list of available room types
        internal List <IAvaliableRoom> GetAvailableRooms(RoomType?roomtype, DateTime?startdate, DateTime?enddate)
        {
            List <IBooking> bookings = dbCon.GetBookings();
            List <IRoom>    rooms    = GetRooms();

            List <IAvaliableRoom> avaliablerooms = new List <IAvaliableRoom>(), temp;

            foreach (IRoom room in rooms)
            {
                bool foundroom = false;
                foreach (AvaliableRoom avaliroom in avaliablerooms)
                {
                    if (avaliroom.RType == room.RType)
                    {
                        foundroom = true;
                        avaliroom.Add();
                    }
                }
                if (foundroom == false)
                {
                    IRoomPrice rmp = dbCon.GetRoomPrice(room.RType);
                    if (rmp == null)
                    {
                        MessageBox.Show("房间价格未初始化!", "查询价格错误");
                        return(avaliablerooms);
                    }
                    avaliablerooms.Add(new AvaliableRoom(room.RType, rmp.Price));
                }
            }

            if (roomtype != null)
            {
                temp = new List <IAvaliableRoom>();
                foreach (IAvaliableRoom avaliroom in avaliablerooms)
                {
                    if (avaliroom.RType == roomtype)
                    {
                        temp.Add(avaliroom);
                    }
                }
                avaliablerooms = temp;
            }

            if (startdate != null && enddate != null)
            {
                foreach (AvaliableRoom avaliroom in avaliablerooms)
                {
                    foreach (IBooking booking in bookings)
                    {
                        if (booking.Roomtype == avaliroom.RType)
                        {
                            bool overlap = startdate <booking.EndDate && enddate> booking.StartDate;
                            if (overlap)
                            {
                                avaliroom.Reduce();
                            }
                        }
                    }
                }
            }

            return(avaliablerooms);
        }