Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    problem with room reservation page

    hi, i try to make reservation page. my problem is, i have limited knowledge in asp that i don't know where to start.

    can someone please guide me on how to do this step by step?

    i need to make room reservation page where i need to do these 4 things,

    1. generate random number/text for reservation id, so that the customer can search for it, in case the customer did more than one booking.
    2. the customer need to choose the check-in date and check out date, but i need to compare it first to the database whether it is available or not. if the date is not available, it will alert the customer.
    3.i also need to calculate and display the total payment for rooms.
    4. i need to insert the reservation_date when the user click the submit buttons

    here is details for my reservation tables:
    reservation_id (PK)(text)
    customer_id (FK)
    check-in_date
    check-out_date
    reservation_date
    reservation_status (confirmed/cancel)
    payment_status (will update manually)

    i also need to update my room & room_type table as the customer need to choose the room type.

    here is my current code:

    Code:
    <html>
    <head>
    <title>New Reservation </title>
    
    </head>
    
    <body>
    <h1>New Reservation</h1>
    <table>
    <br/>
    <form name="new_res" action="" method="post">
    <tr>
    	<td>Reservation ID </td>
    	<td><input type="text" name="res_id" /></td>
    </tr>
    <tr>
    	<td>Room Type </td>
    	<td><select name="rtype" id="rtype">
    	<option value=""></option>
    	<option value="1SR">Single Room</option>
    	<option value="2TR">Twin Room</option>
    	<option value="3DR">Double Room</option>
    	<option value="4TR">Triple Room</option>
    	<option value="5DS">Double Ensuite</option>
    	<option value="6DR">Dormitory Room</option>
    	</select></td>
    </tr>
    <tr>	
    	<td>Check-in Date </td>
    	<td><select name="indate" id="indate">
    	<option value=""></option>
    	<option value="1">1</option>
    	<option value="2">2</option>
    	<option value="3">3</option>
    	<option value="4">4</option>
    	<option value="5">5</option>
    	<option value="6">6</option>
    	<option value="7">7</option>
    	<option value="8">8</option>
    	<option value="9">9</option>
    	<option value="10">10</option>
    	<option value="11">11</option>
    	<option value="12">12</option>
    	<option value="13">13</option>
    	<option value="14">14</option>
    	<option value="15">15</option>
    	<option value="16">16</option>
    	<option value="17">17</option>
    	<option value="18">18</option>
    	<option value="19">19</option>
    	<option value="20">20</option>
    	<option value="21">21</option>
    	<option value="22">22</option>
    	<option value="23">23</option>
    	<option value="24">24</option>
    	<option value="25">25</option>
    	<option value="26">26</option>
    	<option value="27">27</option>
    	<option value="28">28</option>
    	<option value="29">29</option>
    	<option value="30">30</option>
    	<option value="31">31</option>
    	</select>
    		<select name="month">
    		<option value=""></option>
    		<option value="1">January</option>
    		<option value="2">February</option>
    		<option value="3">March</option>
    		<option value="4">April</option>
    		<option value="5">May</option>
    		<option value="6">June</option>
    		<option value="7">July</option>
    		<option value="8">August</option>
    		<option value="9">September</option>
    		<option value="10">October</option>
    		<option value="11">November</option>
    		<option value="12">December</option>
    		</select>
    	<select name="year">
    	<option value=""></option>
    	<option value="2011">2011</option>
    	<option value="2012">2012</option>
    	<option value="2013">2013</option>
    	<option value="2014">2014</option>
    	<option value="2015">2015</option>
    	</select></td>
    </tr>
    <tr>
    	<td>Check-out Date </td>
    	<td><select name="outdate" id="outdate">
    	<option value=""></option>
    	<option value="1">1</option>
    	<option value="2">2</option>
    	<option value="3">3</option>
    	<option value="4">4</option>
    	<option value="5">5</option>
    	<option value="6">6</option>
    	<option value="7">7</option>
    	<option value="8">8</option>
    	<option value="9">9</option>
    	<option value="10">10</option>
    	<option value="11">11</option>
    	<option value="12">12</option>
    	<option value="13">13</option>
    	<option value="14">14</option>
    	<option value="15">15</option>
    	<option value="16">16</option>
    	<option value="17">17</option>
    	<option value="18">18</option>
    	<option value="19">19</option>
    	<option value="20">20</option>
    	<option value="21">21</option>
    	<option value="22">22</option>
    	<option value="23">23</option>
    	<option value="24">24</option>
    	<option value="25">25</option>
    	<option value="26">26</option>
    	<option value="27">27</option>
    	<option value="28">28</option>
    	<option value="29">29</option>
    	<option value="30">30</option>
    	<option value="31">31</option>
    	</select>
    		<select name="month">
    		<option value=""></option>
    		<option value="1">January</option>
    		<option value="2">February</option>
    		<option value="3">March</option>
    		<option value="4">April</option>
    		<option value="5">May</option>
    		<option value="6">June</option>
    		<option value="7">July</option>
    		<option value="8">August</option>
    		<option value="9">September</option>
    		<option value="10">October</option>
    		<option value="11">November</option>
    		<option value="12">December</option>
    		</select>
    	<select name="year">
    	<option value=""></option>
    	<option value="2011">2011</option>
    	<option value="2012">2012</option>
    	<option value="2013">2013</option>
    	<option value="2014">2014</option>
    	<option value="2015">2015</option>
    	</select></td>
    </tr>
    </tr>
    <tr>
    	<td>Total Payment </td>
    	<td><input type="text" name="payment" id="payment" onclick="return calculate();"></td>
    </tr>
    <tr>
    	<td><input type="submit" name="submit" value="Submit" /></td>
    </tr>	
    </form>
    </table>
    
    *Note : Dear customer, all payment shall be made during arrival.
    </body>
    
    </html>
    
    <% 
    
    c_id = session("cid")
    
    set book = server.createobject("adodb.recordset")
    
    if request.form("submit") = "Submit" then
    
    dim resdate
    
    rdesc = request.form("rtype")
    checkin = request.form("indate")
    checkout = request.form("outdate")
    
    SQL = "Insert into Reservation([Check-In_Date],[Check-Out_Date])" &_
    "values (#" & checkin & "#,#" & checkout & "#)"
    
    connection.execute(SQL)
    
    SQL = "Insert into Room_Type(Description) values('" & rdesc & "')"
    
    connection.execute(SQL)
    
    end if
    
    %>
    as usual, thanks for helping.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,799
    Thanks
    78
    Thanked 4,410 Times in 4,375 Posts
    Is this homework?

    Because it's not nearly complete enough for any "real world" reservation system.

    It feels like homework for some class.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    actually it's my final year project. i need to develop online reservation system. but i think it's the same thing. sorry.. it's just that i tried to search through google or read through book, i still don't understand it.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,799
    Thanks
    78
    Thanked 4,410 Times in 4,375 Posts
    Well, I'll give you a head start on solving the "is there a room available" SQL query.

    Suppose you have a table of exisiting reservations that maybe looks like this:
    Code:
    CREATE TABLE reservations (
        reservationID INT IDENTITY, 
        reservedBY INT REFERENCES customers(custormerID),
        roomnumber INT REFERENCES rooms(roomnumber),
        numberOfGuests INT,
        checkinDate DATETIME,
        checkoutDate DATETIME );
    IDENTITY assumes your database is SQL Server. It will be COUNTER for Access and AUTO_INCREMENT for MySQL.

    Notice that I have assumed the existence of two other tables: customers and rooms.

    Okay, so now you have a new customer who wants to reserve a room. And what you are looking for is a room of the correct roomtype that is available for the duration of the proposed new reservation.

    There are only 6 possible ways that a proposed reservation can match up against an existing reservation.

    In the chart below, S and E represent the Start and End of an existing reservation.
    F and L represent the First and Last (days) of the proposed reservation.
    Here are the possibilitis:
    Code:
    ------F----L----S----E----    new rez ends before existing one starts
    ----F---S---L---E------       overlap
    ----F---S---E---L------       overlap
    --S---F---E---L-------        overlap
    ----S---F---L----E----        overlap
    ----S----E---F---L----        new rez begins after existing one ends
    So I hope you can see that a room is only available when the following WHERE condition is satisfied:
    Code:
    WHERE [new rez ending date] <= checkinDate
    OR checkoutDate <= [new rez beginning date]
    Figure out how to write the full SQL query, starting from that WHERE, and incorporate that into your ASP code.

    **************

    By the way, this part of your proposed code is nonsense:
    Code:
    SQL = "Insert into Room_Type(Description) values('" & rdesc & "')"
    Are you suggesting that when a customer requests it you will build a new room on the hotel of the type they ask for???

    Nonsense. The room types are 100% FIXED AND UNCHANGEABLE until and unless the hotel undergoes a big remodeling!
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •