1 <%@ LANGUAGE="VBSCRIPT" %> 2 <% Response.Buffer = True %> 3 <% Response.Expires = 0 %> 4 <% 5 '-- Open connection to database 6 DB = "eCoffee.mdb" 7 Dir = Request.ServerVariables("SCRIPT_NAME") 8 Dir = StrReverse(Dir) 9 Dir = Mid(Dir, InStr(1, Dir, "/")) 10 Dir = StrReverse(Dir) 11 Path = Server.MapPath(Dir) & "\" 12 File = "eCoffee.dsn" 13 DSNa = "filedsn=" & Path & file & ";DefaultDir=" & Path & ";DBQ=" & Path & DB & ";" 14 '-- See if customer exists 15 dim sql, ConnOpen, RS, RST 16 sql = "Select LastName,FirstName,DeliveryAddress from Customers where CustomerNumber=" & request(""CustNo") 17 Set ConnOpen = Server.CreateObject("ADODB.Connection") 18 Set RS = Server.CreateObject("ADODB.RecordSet") 19 ConnOpen.Open DSNa 20 RS.Open sql, ConnOpen, 1,1 21 if RS.EOF or RS.BOF then 22 WrongCustomer = true 23 else 24 WrongCustomer = false 25 end if 26 %> 27 <?xml version="1.0"?> 28 <DIALOG> 29 <CLASS NAME="GenericHelp"> 30 <HELP> Please select a valid coffee type <OPTIONS/>. </HELP> 31 <ERROR TYPE="ALL"> Sorry, I did not understand, please select from the following list of options: <OPTIONS/>.</ERROR> 32 </CLASS> 33 <%if WrongCustomer then%> 34 <STEP NAME="init"> 35 <PROMPT> Customer <%response.write request("CustNo")%> does not exist. Please try again.<BREAK SIZE="LARGE"/> </PROMPT> 36 <INPUT TYPE="NONE" NEXT="eCoffee.vml#store"/> 37 </STEP> 38 <%else%> 39 <STEP NAME="init"> 40 <PROMPT> Welcome back <%response.write (RS("FirstName") & " " & RS("LastName"="))%><BREAK SIZE="LARGE"/> </PROMPT> 41 <INPUT TYPE="NONE" NEXT="#SelectCoffeeType"/> 42 </STEP> 43 <%'-- See what types of coffee are available at the time 44 sql = "select CoffeeType, CoffeePrice from CoffeeType where QinStock > 0" 45 Set RST = Server.CreateObject("ADODB.RecordSet") 46 RST.Open sql, ConnOpen, 1,1 47 %> 48 <STEP NAME="SelectCoffeeType" PARENT="GenericHelp"> <PROMPT> Please select from the following list of available coffee types :<BREAK SIZE="LARGE"/> 49 <% 50 RST.MoveFirst 51 do while not RST.EOF 52 response.write RST("CoffeeType")%> at the price of <%response.write RST("CoffeePrice")%> dollars per pound. 53 <% 54 RST.MoveNext 55 loop 56 %> 57 </PROMPT> 58 <INPUT TYPE="OPTIONLIST" NAME="CoffeeType"> 59 <% 60 RST.MoveFirst 61 do while not RST.EOF 62 %> 63 <OPTION NEXT="#CoffeeQuantity" VALUE="<%response.write RST("CoffeeType")%>"><%response.write RST("CoffeeType")%></OPTION> 64 <% 65 RST.MoveNext 66 loop 67 %> 68 <OPTION NEXT="#init"> select again </OPTION> 69 </INPUT> 70 </STEP> 71 <STEP NAME="CoffeeQuantity"> 72 <ERROR TYPE="TOOMUCH"> Sorry you selected way! too much coffee. 73 Please try again</ERROR> 74 <PROMPT> Excellent choice <%response.write (RS("FirstName") & " " & RS("LastName"))%>, please select the quantity in increments of one pound. Keep in mind the maximum allowed quantity is ninety nine pounds.<BREAK SIZE="LARGE"/> </PROMPT> 75 <INPUT TYPE="HIDDEN" NAME="LastName" VALUE="<%response.write RS("LastName")%>"/> 76 <INPUT TYPE="HIDDEN" NAME="FirstName" VALUE="<%response.write RS("FirstName")%>"/> 77 <INPUT TYPE="HIDDEN" NAME="CustomerNo" VALUE="<%response.write request("CustNo")%>"/> 78 <INPUT TYPE="HIDDEN" NAME="DeliveryAddress" VALUE="<%response.write RS("DeliveryAddress")%>"/> 79 <INPUT TYPE="DIGITS" NAME="CoffeeQty" NEXT="VerifyOrder.asp" MIN="1" MAX="2"/> 80 </STEP> 81 <%end if%> 82 </DIALOG> 83 <% 84 ConnOpen.Close 85 set RS = nothing 86 set RST = nothing 87 set ConnOpen = nothing 88 %>