You are on page 1of 17

WAP Applications

Airline Implementation:
<%
dim conn,rs
set conn=server.createobject("ADODB.Connection")
set rs=server.createobject("ADODB.RecordSet")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\students\batch2\wml\database.mdb;Persist Security Info=False"
%>

Above code is used to declare ADODB.Connection, ADODB.Recordset


objects and open database. This information is used to retrieve records from
the database.

1. Reservation:

Select Source:
<select name="source">
<%
rs.open "select distinct source,destination from flight_info",conn
while not rs.EOF
%>
<option value="<%=rs.fields("source")%>" ><%=rs.fields("source")%></option>
<%
rs.movenext
wend
%>
</select>

Select Destination:
<select name="destination">

Dept. of CSE Narayana Engg. College, Nellore 48


WAP Applications

<%
while not rs.EOF
%>
<option value="<%=rs.fields("Destination")%>" >
<%=rs.fields("Destination")%></option>
<%
rs.movenext
wend
%>
</select>

Above code is used to retrieve Source, Destination from the


database and display it in database. Database changes will be reflected
automatically.
After selecting Source and Destination we need to send the data to
next page. For this we used anchor tag as follows. It sends source and
destination to airreservationok.asp page

<anchor>
Ok
<go href="http://www.neccse.com:8080/wapbatch/wml/airreservationok.asp"
method="post">
<postfield name="source" value="$(source)"/>
<postfield name="destination" value="$(destination)"/>
</go>
</anchor>

In the airreservationok.asp we retrieve the values sent by the clients with the
help of the following code:

Dept. of CSE Narayana Engg. College, Nellore 49


WAP Applications

Here, Request object is used to retrieve values:


Variable names should match at the sender and receiver side.
source=request.form.item("source")
destination=request.form.item("destination")

After getting source and destination retrieve corresponding dates and flight
numbers from the database. For this we open the database as follows:

rs. open "select * from flight_info where source='" &source & _


"' and destination ='" & destination & "' ",conn

If the recordset object is set to end of file(eof) then display that there are no
flights. Otherwise display flight dates and numbers similar to the above code.
Request the Credit Card Number, No. of kids, children, adult from the user and
send it to checkdatabase.asp page.

For this, the code will look like this:

<p align="left"><br/>No. of kids(1&nbsp;-&nbsp;5)<br/></p>


<p align="center"><input name="kid" format="N*N"/></p>
<p align="left">No. of Children(6&nbsp;-&nbsp;12)</p>
<p align="center"><input name="child" format="N*N"/></p>
<p align="left">No. of Adult(13&nbsp;- &nbsp;above)</p>
<p align="center"><input name="adult" format="N*N"/><br/><br/></p>
<p align="center">
<anchor>Send
<go href="http://www.neccse.com:8080/wapbatch/wml/checkdatabase.asp"
method="post">
<postfield name="source" value="$(source)"/>
<postfield name="destination" value="$(destination)"/>
<postfield name="flightnumber" value="$(flightnumber)"/>

Dept. of CSE Narayana Engg. College, Nellore 50


WAP Applications

<postfield name="flight_date" value="$(flight_date)"/>


<postfield name="kid" value="$(kid)"/>
<postfield name="child" value="$(child)"/>
<postfield name="adult" value="$(adult)"/>
<postfield name="creditcardnumber" value="$(creditcardnumber)"/>
</go>
</anchor>

In checkdatabase.asp we initially check whether flights are available for


user selection. If flights are there then we check whether sufficient number of
seats are available or not. For this code is as follows:

if datediff("d",fli_date,flight_date)=0 and flight_number=fli_number then


total_seats=cint(rs.fields("total_seats"))
journeyamount=ccur(rs.fields("amount"))
flightfound="true"
end if

For reservation, code is as follows:

if flightfound="true" then
if sumnumber<=total_seats then
rs.open "select amount from fare_amount where category='kid'"
kidamount=cint(rs.fields("amount"))
rs.close
rs.open "select amount from fare_amount where category='child'"
childamount=cint(rs.fields("amount"))
rs.close

rs.open "select amount from fare_amount where category='adult'"


adultamount=cint(rs.fields("amount"))
rs.close

Dept. of CSE Narayana Engg. College, Nellore 51


WAP Applications

sumamount=cint(kidnumber)*cint(kidamount)+
cint(childnumber)*cint(childamount)+
cint(adultnumber)*cint(adultamount)
sumamount=sumamount+journeyamount

rs.open "select * from credit_info",conn,adOpenDynamic


if rs.eof then
response.write "Bank Database is Empty"
else
found="false"
while not rs.eof
creditcard=rs.fields("creditcardnumber")
if creditcard=creditcardnumber then
found="true"
finalcreditamount=ccur(rs.fields("balance"))

end if
rs.movenext
wend
rs.movefirst
end if

if found="true" then
response.write "Kid Number = "&kidnumber&" <br/>"
response.write "Child Number = "&childnumber&" <br/>"
response.write "Adult Number = "&adultnumber&" <br/>"
response.write "Kid Amount = Rs."&kidamount&" <br/>"
response.write "Child Amount =Rs."&childamount&" <br/>"
response.write "Adult Amount =Rs. "&adultamount&" <br/>"
if ccur(finalcreditamount-sumamount)<500 then
response.write "Sufficient amount is not available in your account"

Dept. of CSE Narayana Engg. College, Nellore 52


WAP Applications

else
commandob.activeconnection=conn
commandob.commandtext="update credit_info set “ & _
“balance='"&ccur(finalcreditamount-sumamount)& _
"' where creditcardnumber='"&creditcardnumber&"'"
commandob.commandtype=adCmdText
commandob.execute numofrec
commandob.commandtext="select * from credit_info"
commandob.commandtype=adCmdText
response.write "<br/>Amount Rs."&sumamount& _
" is debited from your account"

dim randnumber
while valuesetted="false"

randomize
randnumber=cstr(Rnd*999999*10)
commandob.commandtext="select userid from bank “ & _
“where userid='"&randnumber&"'"
commandob.commandtype=adCmdText
set objrs=commandob.execute

if objrs.eof then
commandob.commandtext="insert into bank
(userid,credit_number)”&_
“ values
"&cstr(left(randnumber,5))&"','"&cstr(creditcardnumber)&"')"
commandob.commandtype=adCmdText
commandob.execute
valuesetted="true"
end if

Dept. of CSE Narayana Engg. College, Nellore 53


WAP Applications

wend

commandob.commandtext="insert into fare “ & _


“(userid,cat_kids,cat_child,cat_adult) values”
“(‘"&cstr(left(randnumber,5))&"','"&cint(kidnumber)&_
"','"&cint(childnumber)&"','"&cint(adultnumber)&"')"

commandob.commandtype=adCmdText
commandob.execute
commandob.commandtext="insert into reserved_info”&_
“(flight_number,userid,source,destination) values”&_
“('"&cstr(flight_number)&"','"&cstr(left(randnumber,5))&_
"','"&cstr(source)&"','"&cstr(destination)&"')"
commandob.commandtype=adCmdText
commandob.execute
commandob.commandtext="update flight_info set “&_
“total_seats='"&cint(total_seats-sumnumber)& _
"' where flight_number='"&flight_number&"'"

commandob.commandtype=adCmdText
commandob.execute

response.write "<br/>Your ID number is "


response.write cstr(left(randnumber,5))
response.write ". Preserve this number"
end if

else
response.write "Credit card number is invalid"
end if
else
response.write "Sufficient number of seats are not available"

Dept. of CSE Narayana Engg. College, Nellore 54


WAP Applications

response.write "<br/><br/> Sorry!. Available Number of Seats are”&_


"&total_seats
response.write "<br/><br/> If you want to reserve Press Options-
Reserve”&_
“Button Below. Thanking You."
end if
else
response.write "No flight is available for your date"

end if

Cancellation:

In Cancellation the user must give the user id given as part of Reservation. This
will be sent to to rnovalid.asp page.

Full code for this page is as follows( aircancellation.asp)

<% response.contenttype="text/vnd.wap.wml"%>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="aircancellation" title="Cancellation">
<p>Enter Reservation number<br/></p>

<p align="center"><br/><br/><input type="text" name="rno"/><br/>


<anchor>
Ok

Dept. of CSE Narayana Engg. College, Nellore 55


WAP Applications

<go href="http://www.neccse.com:8080/wapbatch/wml/rnovalid.asp"
method="post">
<postfield name="rno" value="$(rno)"/>
</go>
</anchor>&nbsp;&nbsp;&nbsp;&nbsp;
<a
href="http://www.neccse.com:8080/wapbatch/wml/services.asp#airinfo">Cancel
</a>
</p>
</card>
</wml>

In rnovalid.asp page the required rno(userid) will be received and operations


are performed quite opposite to Reservation process.

We initially check whether user exists in the database or not. If the user
enters invalid User id then we will display a page stating that the user is not a
valid user.
Otherwise we contact the database to give creditcardnumber, number of kids,
children, adult and ticket cost for their journey. Amount is calculated from these
and will be debited from his/her account. This is informed to him/her. Then
information is updated and deleted from the database.

Code for this is as follows:

<% response.contenttype="text/vnd.wap.wml"%>

Dept. of CSE Narayana Engg. College, Nellore 56


WAP Applications

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<!--#include file="datasourcecode.asp"-->
<!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common
Files\System\ado\msado15.dll"-->
<card id="validation_cancellation" title="Cancellation">
<p>
<%
dim rno,kidnumber,childnumber,adultnumber,kidamount,
dim childamount,adultamount,sumamount,sumnumber
dim commandob,objrs,flight_number
dim creditcardnumber,userid,balance,source,
dim destination,total_seats,journeyamount

set commandob=server.createobject("ADODB.Command")
set objrs=server.createobject("ADODB.RecordSet")
rno=cstr(request.form.item("rno"))
userid=cstr(rno)
commandob.activeconnection=conn
commandob.commandtype=adCmdText
commandob.commandtext="select amount from fare_amount where
category='kid'"
set objrs=commandob.execute
kidamount=ccur(objrs.fields("amount"))
commandob.commandtext="select amount from fare_amount where
category='child'"
set objrs=commandob.execute
childamount=ccur(objrs.fields("amount"))

Dept. of CSE Narayana Engg. College, Nellore 57


WAP Applications

commandob.commandtext="select amount from fare_amount where


category='adult'"
set objrs=commandob.execute
adultamount=ccur(objrs.fields("amount"))

commandob.commandtext="select * from reserved_info where


userid='"&cstr(rno)&"'"
set objrs=commandob.execute
if objrs.eof then
response.write "You have entered Invalid Id. Sorry!"
else
objrs.close
commandob.commandtext="select credit_number from”
“bank”&_
“where userid='"&cstr(userid)&"'"
commandob.commandtype=adCmdText
set objrs=commandob.execute
creditcardnumber=cstr(objrs.fields("credit_number"))
commandob.commandtext="select balance from”
“credit_info where”&_
“creditcardnumber='"&cstr(creditcardnumber)&"'"
set objrs=commandob.execute
balance=ccur(objrs.fields("balance"))
objrs.close
commandob.commandtext="select * from reserved_info”& _
“whereuserid='"&cstr(userid)&"'"
set objrs=commandob.execute
flight_number=cstr(objrs.fields("flight_number"))
source=cstr(objrs.fields("source"))
destination=cstr(objrs.fields("destination"))
objrs.close

Dept. of CSE Narayana Engg. College, Nellore 58


WAP Applications

commandob.commandtext="select * from fare where”&_


“userid='"&cstr(userid)&"'"
set objrs=commandob.execute
kidnumber=cint(objrs.fields("cat_kids"))
childnumber=cint(objrs.fields("cat_child"))
adultnumber=cint(objrs.fields("cat_adult"))
sumnumber= cint(kidnumber)+cint(childnumber) +
cint(adultnumber)
sumamount=cint(kidnumber)*ccur(kidamount) +
cint(childnumber)*ccur(childamount)+
cint(adultnumber)*ccur(adultamount)
commandob.commandtext="select total_seats,amount”
“from flight_info where”&_
“flight_number='"&cstr(flight_number)&"'"
set objrs=commandob.execute
total_seats=cint(objrs.fields("total_seats"))
journeyamount=ccur(objrs.fields("amount"))
commandob.commandtext="update flight_info set “&_
“total_seats='"&cint(cint(total_seats)+cint(sumnumber))&_
"'"&"where flight_number='"&cstr(flight_number)&"'"
commandob.execute
commandob.commandtext="select credit_number from”
“bank where userid='"&cstr(userid)&"'"
set objrs=commandob.execute
creditcardnumber=objrs.fields("credit_number")
commandob.commandtext="update credit_info set “&_
“balance='"&ccur(balance+sumamount+journeyamount)&"'
“where creditcardnumber='"&creditcardnumber&"'"
commandob.execute
commandob.commandtext="delete from bank where”&_
“ userid='"&cstr(userid)&"'"

Dept. of CSE Narayana Engg. College, Nellore 59


WAP Applications

commandob.execute
commandob.commandtext="delete from fare where “&_
“userid='"&cstr(userid)&"'"
commandob.execute
commandob.commandtext="delete from reserved_info where”&_
“userid='"&cstr(userid)&"'"
commandob.execute

response.write "Your Source is "&source&"<br/>"


response.write "Your Destination is "&destination&"<br/>"
response.write "No. of Kids ="&kidnumber&"<br/>"
response.write "No. of Children="&childnumber&"<br/>"
response.write "Adult Number ="&adultnumber&"<br/>"
response.write "Credit Card Number="&creditcardnumber&"<br/>"
response.write "Flight Number="&flight_number&"<br/>"
response.write "Your ticket is successfully cancelled."
end if
objrs.close
conn.close
set objrs=nothing
set conn=nothing %>
<do type="prev" label="Home">
<go href="http://www.neccse.com:8080/wapbatch/wml/main.asp"/>
</do>
</p>
</card>
</wml>

Seaports Implementation:
Connection variables and database is as follows:
<%
dim conn1,rs1

Dept. of CSE Narayana Engg. College, Nellore 60


WAP Applications

set conn1=server.createobject("ADODB.Connection")
set rs1=server.createobject("ADODB.RecordSet")
conn1.open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\students\batch2\wml\shipdatabase.mdb;Persist Security Info=False"
%>

Seaport Reservation:

User selects source and destination similar to Airline Reservation we will


display corresponding ship number, ship date. Along with these user needs to
enter his/her creditcardnumber, amount of space, amount of weight and type of
goods.
Then we generate user id and container id for his goods to transport.

Seaport Cancellation:

Here, the user needs to enter his user id and container id for cancellation.
Once he/she enter correct numbers values are retrieved from the database and
additions/subtractions are performed. Here, we cost charges based on space
and weight collectively.

Code for cancellation as follows:

rno=cstr(request.form.item("rno"))
cno=cstr(request.form.item("cno"))

commandob.activeconnection=conn1
commandob.commandtype=adCmdText
commandob.commandtext="select * from reserved_info where
userid='"&cstr(rno)&"' and containernumber='"&cstr(cno)&"'"
set objrs=commandob.execute

Dept. of CSE Narayana Engg. College, Nellore 61


WAP Applications

if objrs.eof then
response.write "Invalid User Id"
else
valuesetted="true"
space2=(objrs.fields("space1"))
weight2=(objrs.fields("weight"))
shipnumber=cstr(objrs.fields("shipnumber"))
creditcardnumber=cstr(objrs.Fields("creditcardnumber"))
cargo_type=cstr(objrs.fields("cargo_type"))
end if

commandob.CommandText ="select * from credit_info where


creditcardnumber='"&cstr(creditcardnumber)&"'"
set objrs=commandob.Execute
balance=ccur(objrs.Fields("balance"))
commandob.commandtext="select * from ship_info where
ship_number='"&cstr(shipnumber)&"'"
set objrs=commandob.execute
value1=cint(objrs.fields("space1"))
value2=cint(objrs.fields("weight"))

commandob.commandtext="update ship_info set


space1='"&cint(space2+value1)&"',weight='"&cint(weight2+value2)&"' where
ship_number='"&cstr(shipnumber)&"'"
commandob.execute

if(cint(space2)<=50 and cint(space2)>0 ) then


sumamount=ccur(5000)
elseif( cint(space2)>=51 and cint(space2)<=100 ) then
sumamount=ccur(7500)
elseif(cint(space2)>=101 and cint(space2)<=250 )then

Dept. of CSE Narayana Engg. College, Nellore 62


WAP Applications

sumamount=ccur(15000)
elseif(cint(space2)>=251 and cint(space2)<=500 )then
sumamount=ccur(50000)
else
sumamount=ccur(250000)
end if

if( cint(weight2)<=50 and cint(weight2)>=0) then


sumamount=sumamount+ccur(5000)
elseif( cint(weight2)>=51 and cint(weight2)<=100) then
sumamount=sumamount+ccur(7500)
elseif( cint(weight2)>=101 and cint(weight2)<=200)then
sumamount=sumamount+ccur(15000)
elseif( cint(weight2)>=201 and cint(weight2)<=500)then
sumamount=sumamount+ccur(50000)
else
sumamount=sumamount+ccur(250000)
end if

commandob.commandtext="select cost from typecost where”&_


“cargo_type='"&cstr(cargo_type)&"'"
set objrs=commandob.execute
sumamount=sumamount+ccur(objrs.fields("cost"))
commandob.CommandText ="update credit_info set”&_
“balance='"&cstr(balance+sumamount)&"' where
creditcardnumber='"&cstr(creditcardnumber)&"'"
commandob.Execute
commandob.commandtext="delete from reserved_info where
shipnumber='"&cstr(shipnumber)&"'"
commandob.execute
response.write "User id="&rno&"<br/>"

Dept. of CSE Narayana Engg. College, Nellore 63


WAP Applications

response.write "Container Id="&cno&"<br/>"


response.write "Your Space="&space2&" Cubic Meters"&"<br/>"
response.write "Your Weight="&weight2&"Kgs"&"<br/>"
response.write "<br/><br/> Your Reservation is successfully cancelled"

Dept. of CSE Narayana Engg. College, Nellore 64

You might also like