Ejemplo n.º 1
0
        /// <summary>
        /// Look for all the free rooms during a period of a hotel to know the number of free room, free space and the occupation rate
        /// </summary>
        public static HotelAvailability GetAvailability(int idHotel, DateTime arrival, DateTime departure)
        {
            HotelAvailability hotelAvailability = new HotelAvailability();
            int     availablePlace = 0;
            decimal minPrice       = decimal.MaxValue;

            List <Room> rooms = RoomDB.GetRoomsWithNoReservationByHotel(idHotel, arrival, departure);

            foreach (Room room in rooms)
            {
                availablePlace += room.Type;

                if (room.Price < minPrice)
                {
                    minPrice = room.Price;
                }
            }

            double totalRoom = GetCapacity(idHotel).TotalNumberRoom;

            double occupancyRate = 1.0 - (rooms.Count() / totalRoom);

            hotelAvailability.NumberOfAvailableRoom         = rooms.Count();
            hotelAvailability.NumberOfAvailablePerson       = availablePlace;
            hotelAvailability.OcucupancyRate                = occupancyRate;
            hotelAvailability.HasAvailableRoomWithTv        = rooms.Any(room => room.HasTV == true);
            hotelAvailability.HasAvailableRoomWithHairDryer = rooms.Any(room => room.HasHairDryer == true);
            hotelAvailability.MinPrice = minPrice;

            return(hotelAvailability);
        }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            checkHotel(); //to check with the hotel information details
        }
        //to show the hotel information details
        if (Session["emailH"] != null)
        {
            Hotel a = (Hotel)Session["emailH"];
            tbxHotel.Text     = a.Name;
            tbxEmail.Text     = a.OrgEmail;
            tbxRegID.Text     = a.RegID;
            tbxAddress.Text   = a.Address;
            tbxPcode.Text     = a.PostalCode;
            tbxCity.Text      = a.City;
            tbxCountry.Text   = a.Country;
            tbxPassword.Text  = a.Password;
            tbxContact.Text   = a.ContactNo;
            tbxDesc.Text      = a.Description;
            tbxLicense.Text   = a.License;
            imgHotel.ImageUrl = "../images/" + a.Photo;
            tbxSrating.Text   = Convert.ToString(a.StarRating);
        }
        //to show the hotel rooms into the gridview
        List <Room> rooms = RoomDB.getHotelRoomByCountry(Session["countryName"].ToString(), Session["hotel"].ToString());

        gvRoom.DataSource = rooms;
        gvRoom.DataBind();
    }
Ejemplo n.º 3
0
        /// <summary>
        /// Return a object with the total of room and total of person of a hotel
        /// </summary>
        public static HotelCapacity GetCapacity(int idHotel)
        {
            HotelCapacity hotelCapacity = new HotelCapacity();
            int           place         = 0;

            List <Room> rooms = RoomDB.GetRoomsByHotel(idHotel);

            foreach (Room room in rooms)
            {
                place += room.Type;
            }

            hotelCapacity.TotalNumberRoom   = rooms.Count();
            hotelCapacity.TotalNumberPerson = place;


            return(hotelCapacity);
        }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string imagefile = "notavailable.jpg";

        if (FileUpload1.HasFile) //checking whether the file upload has the file
        {
            imagefile = FileUpload1.FileName;
            FileUpload1.SaveAs(Server.MapPath("~/images/" + imagefile));//store the file in the images folder
        }

        Hotel  h   = (Hotel)Session["userHotel"]; //retrieve the hotel session
        Random rnd = new Random();                //declara random number generator
        int    rId = rnd.Next(0, 100);            //initialize the random number generator

        Room r = new Room()
        {
            RoomID   = "RM" + rId,
            RoomName = tbxName.Text,
            Type     = tbxType.Text,
            Capacity = Convert.ToInt32(tbxCap.Text),
            RoomSize = tbxSize.Text,
            Desc     = tbxDesc.Text,
            Remarks  = tbxRemarks.Text,
            Services = tbxServices.Text,
            Pictures = imagefile,
            Price    = Convert.ToDouble(tbxPrice.Text),
            Hotel    = h
        };
        int id = RoomDB.insertRoom(r);            //to insert room into database

        lblOutput.Text   = "Successfully added!"; //to show the message, where hotel owner successfully added room into database
        tbxName.Text     = "";
        tbxType.Text     = "";
        tbxCap.Text      = "";
        tbxSize.Text     = "";
        tbxDesc.Text     = "";
        tbxRemarks.Text  = "";
        tbxServices.Text = "";
        imagefile        = "notavailable";
        tbxPrice.Text    = "";
        gvBind();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            List <Room> rooms = RoomDB.getRoomByOwner(Convert.ToInt32(Session["HotelID"])); //get the data from database
            if (rooms.Count != 0)                                                           //check the room data is not null
            {
                Session["room"] = rooms;                                                    //create a room session

                lblNoRoom.Visible = false;
                lvRoom.DataSource = rooms;
                lvRoom.DataBind();
            }
            else
            {
                lblNoRoom.Visible = true;
            }
            //to disable past dates
            tbxCheckIn.Attributes["min"]  = DateTime.Now.ToString("yyyy-MM-dd");
            tbxCheckOut.Attributes["min"] = DateTime.Now.ToString("yyyy-MM-dd");
        }
    }
Ejemplo n.º 6
0
 public RoomBUS()
 {
     rDB  = new RoomDB();
     bDB  = new BookingDB();
     rtDB = new RoomTypeDB();
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Return a Room object
        /// </summary>
        public static Room GetRoom(int idRoom)
        {
            Room room = RoomDB.GetRoom(idRoom);

            return(room);
        }
 public static Room GetRoomFromId(int IdRoom)
 {
     return(RoomDB.GetRoomFromId(IdRoom));
 }
 public static List <Room> GetAllEmptyRoomsAtDateRange(DateTime firstNight, DateTime lastNight)
 {
     return(RoomDB.GetAllEmptyRoomsAtDateRange(firstNight, lastNight));
 }
Ejemplo n.º 10
0
 //Permet un hotel d'ajouter une télévision a une chambre
 public static void ModifiyHasTV(Boolean HasTv, int IdRoomDesired)
 {
     RoomDB.ModifiyHasTV(HasTv, IdRoomDesired);
 }
Ejemplo n.º 11
0
 //Récupère une chambre avec son id
 public static int countRoomByIdHotel(int IdHotel, DateTime checkInDesired, DateTime checkOutDesired, String location, int nbCustomer)
 {
     return(RoomDB.countRoomByIdHotel(IdHotel, checkInDesired, checkOutDesired, location, nbCustomer));
 }
Ejemplo n.º 12
0
 //Recupre les chambres en fonction des date désirées, de l'emplacement de l'hotel et le nombre de client
 public static List <Room> GetRoomByDate(DateTime checkInDerired, DateTime checkOutDesired, String location, int nbCustomer)
 {
     return(RoomDB.GetRoomByDate(checkInDerired, checkOutDesired, location, nbCustomer));
 }
Ejemplo n.º 13
0
 // Appelle la requête qui récupère la liste de toutes les chambres qui sont occupées à une certaine période
 public static List <Room> GetOccupiedRooms(int idHotel, DateTime dateStart, DateTime dateEnd)
 {
     return(RoomDB.GetOccupiedRooms(idHotel, dateStart, dateEnd));
 }
Ejemplo n.º 14
0
 // Appelle la requête qui récupère une chambre en fonction de son identifiant (en paramètre)
 public static Room GetRoom(int idRoom)
 {
     return(RoomDB.GetRoom(idRoom));
 }
Ejemplo n.º 15
0
 // Appelle la requête qui récupère la liste de toutes les chambres qui correspondent à la recherche avancée
 public static List <Room> GetSearchedRoomsAdvanced(int idHotel, DateTime dateStart, DateTime dateEnd, Boolean hasTV, Boolean hasHairDryer)
 {
     return(RoomDB.GetSearchedRoomsAdvanced(idHotel, dateStart, dateEnd, hasTV, hasHairDryer));
 }
Ejemplo n.º 16
0
 // Appelle la requête qui récupère la liste de toutes les chambres qui correspondent à la recherche simple
 public static List <Room> GetSearchedRoomsSimple(int idHotel, DateTime dateStart, DateTime dateEnd)
 {
     return(RoomDB.GetSearchedRoomsSimple(idHotel, dateStart, dateEnd));
 }
Ejemplo n.º 17
0
 // Appelle la requête qui récupère la liste de toutes les chambres d'un hôtel (en fonction de son identifiant en paramètre)
 public static List <Room> GetAllRooms(int idHotel)
 {
     return(RoomDB.GetAllRooms(idHotel));
 }
Ejemplo n.º 18
0
 //récupère toutes les chambres
 public static List <Room> GetAllRoom()
 {
     return(RoomDB.GetAllRoom());
 }
    protected void lvRoom_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        //to check the date cannot be past date
        if (Convert.ToDateTime(tbxCheckIn.Text) <= Convert.ToDateTime(tbxCheckOut.Text) && Convert.ToDateTime(tbxCheckIn.Text) >= DateTime.Now)
        {
            if (e.CommandName == "RoomBook") //user selects on the particular room to book
            {
                bool exist = false;
                Room r     = RoomDB.getRoom(e.CommandArgument.ToString()); //get the room id from user selection
                //initialize the checkin and checkout -- datetime
                DateTime chkin  = Convert.ToDateTime(tbxCheckIn.Text);
                DateTime chkout = Convert.ToDateTime(tbxCheckOut.Text);

                double amount;        //declare amount
                if (chkin == chkout)  //if the checkin and checkout same day
                {
                    amount = r.Price; //amount will be same
                }
                else
                {
                    int duration = Convert.ToInt32((chkout - chkin).TotalDays); //initialize the duration, to calculate how many days
                    amount = r.Price * duration;                                //calculate the price, based on how many days
                }
                //add the cartitem details for room
                CartItem     c  = new CartItem(r, chkin.ToShortDateString(), chkout.ToShortDateString(), Convert.ToDouble(amount), r.Type, (Convert.ToInt32(tbxNoRoom.Text)));
                ShoppingCart sc = (ShoppingCart)Session["cart"]; //create s shopping cart session
                if (sc == null)                                  //if shopping cart is null
                {
                    //user can add into cart item classes
                    sc = new ShoppingCart();
                    sc.RoomAdd(c);
                    lblOutput.Text = "Room added to the Shopping Cart"; //show the messages, when user already add the room
                }
                else
                {
                    List <CartItem> ci = sc.RoomCI;
                    foreach (CartItem citm in ci) //use foreach to check whether cartitem already added or not
                    {
                        if (citm.SCRoom.RoomID == r.RoomID)
                        {
                            exist = true;
                        }
                    }
                    if (exist == false)
                    {
                        sc.RoomAdd(c);
                        lblOutput.Text = "Room added to the shopping cart"; //show the message when user already add the room into cart item
                    }
                    else
                    {
                        lblOutput.Text = "You have already added this room to the shopping cart"; //to show the message, user already added this room into shopping cart
                    }
                }
                Session["cart"] = sc; //create a session for shopping cart
            }
        }
        else
        {
            lblOutput.Text = "Check-Out date cannot be earlier than Check-In date or check in date cannot be past date!"; //to show the error message when the user select the past date
        }
    }
Ejemplo n.º 20
0
 //Recupre les chambres en fonction des date désirées, de l'emplacement de l'hotel et le nombre de client et ajoute la recherche avancée
 public static List <Room> GetRoomByDateRequestAdd(DateTime checkInDerired, DateTime checkOutDesired, String location, int nbCustomer, String requestAdd)
 {
     return(RoomDB.GetRoomByDateRequestAdd(checkInDerired, checkOutDesired, location, nbCustomer, requestAdd));
 }
Ejemplo n.º 21
0
 public static List <Room> GetRoomsByDateAndLocation(DateTime beginDate, DateTime endDate, string location)
 {
     return(RoomDB.GetRoomAvalaibleLocation(beginDate, endDate, location));
 }
Ejemplo n.º 22
0
 //Récupère les chambres en fonction de l'id de la reservation
 public static List <Room> GetRoomByIdReservation(int IdReservation)
 {
     return(RoomDB.GetRoomByIdReservation(IdReservation));
 }
Ejemplo n.º 23
0
 public static List <Room> GetRoomsByIdHotel(int IdHotel)
 {
     return(RoomDB.GetRoomForHotel(IdHotel));
 }
Ejemplo n.º 24
0
 //Modifie la requete pour la recherche avancé
 public static String RequestEdit(int hasHairDryer, int hasTv, int hasWifi, int hasParking)
 {
     return(RoomDB.RequestEdit(hasHairDryer, hasTv, hasWifi, hasParking));
 }
Ejemplo n.º 25
0
 public static List <Room> GetRoomsByDateHotelAndNbPerson(DateTime beginDate, DateTime endDate, int IdHotel, int NbPerson)
 {
     return(RoomDB.GetRoomsByDateHotelAndNbPerson(beginDate, endDate, IdHotel, NbPerson));
 }
 public static List <Room> GetRoomsFromHotel(int IdHotel)
 {
     return(RoomDB.GetRoomsFromHotel(IdHotel));
 }
Ejemplo n.º 27
0
 public static List <Room> GetRoomsByIdBooking(int IdBooking)
 {
     return(RoomDB.GetRoomsByIdBooking(IdBooking));
 }
 public static decimal[] GetMinMaxPriceFromRooms()
 {
     return(RoomDB.GetMinMaxPriceFromRooms());
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Return a list of Room who has no reservation during a defined period and in relation with a hotel
        /// </summary>
        public static List <Room> GetRoomsWithNoReservationByHotel(int idHotel, DateTime arrival, DateTime departure)
        {
            List <Room> rooms = RoomDB.GetRoomsWithNoReservationByHotel(idHotel, arrival, departure);

            return(rooms);
        }