home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2000 March / VPR0003B.ISO / nec98 / bookflight.asp < prev    next >
Text File  |  1999-10-14  |  9KB  |  347 lines

  1. <%@ LANGUAGE="VBSCRIPT" %>
  2. <% Option Explicit %>
  3. <% Response.Buffer = True %>
  4.  
  5. <!--#include file=libAuthenticate.asp-->
  6.  
  7. <%
  8.   Dim m_Member, m_lngMileage
  9.  
  10.   ' create a reference to the Member class of the ExAir dll component
  11.   Set m_Member = Server.CreateObject("ExAir.Member")
  12.  
  13.   ' retrieve the mileage for the current user
  14.   m_lngMileage = m_Member.GetMileage(Application("DSN"), Session("AccountID"))
  15. %>
  16.  
  17. <!--BEGIN HTML-->
  18. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  19. <HTML>
  20. <HEAD>
  21. <!--META TAGS ARE RECOMMENDED FOR THE SEARCH ENGINE-->
  22. <META NAME="DESCRIPTION" CONTENT="Exploration Air's Book Flights page for members">
  23. <META NAME="KEYWORDS" CONTENT="book, flight, miles, mileage, bonus">
  24. <META NAME="GENERATOR" CONTENT="Microsoft Visual InterDev 1.0">
  25. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso8859-1">
  26. <!--END META TAGS-->
  27.  
  28. <TITLE>Book a Flight using Miles</TITLE>
  29. </HEAD>
  30.  
  31. <BODY BGCOLOR=#FFFFFF TOPMARGIN=0 LEFTMARGIN=0 ALINK=#23238E VLINK=#228B22 LINK=#23238E>
  32. <BASEFONT FACE="VERDANA, ARIAL, HELVETICA" SIZE=2>
  33.  
  34. <!--Change link color on mouseover
  35.     Only if running Internet Explorer 4.0 or later -->
  36. <!--#include file=../libHighlight.inc-->
  37. <!--#include file=../libGlobalFuncs.inc-->
  38.  
  39. <!--COLOR BANNER_START-->
  40. <TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0 BORDER=0>
  41.     <TR>
  42.       <TD BGCOLOR="#C71585" WIDTH=100% HEIGHT=20>
  43.       </TD>
  44.     </TR>
  45. </TABLE>
  46. <!--COLOR BANNER_END-->
  47.  
  48.  
  49. <!--BEGIN TABLE CONTAINING LOGO, TITLE, AND NAVIGATIONAL LINK-->
  50. <TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0 BORDER=0>
  51.     <TR>
  52.       <TD VALIGN=TOP WIDTH=415 HEIGHT=76>
  53.             <IMG SRC="images/freqflyer.jpg" WIDTH=420 HEIGHT=240 ALT="Exploration Air Frequent Flyer logo">
  54.             <BR>
  55.             <A HREF="<%=HomePage("..")%>"><IMG SRC="../images/barrowy.gif" HEIGHT=8 WIDTH=8 HSPACE=5 ALT="Return to Exploration Air Home Page" BORDER=0></A> 
  56.             <FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE=2><STRONG><A HREF="<%=HomePage("..")%>">EXPLORATION AIR HOME PAGE</A></STRONG></FONT>
  57.       </TD>
  58.       <TD VALIGN=MIDDLE WIDTH=200><FONT FACE="VERDANA, ARIAL, HELVETICA" COLOR="#0000FF" SIZE=5>Book a Flight using Miles</FONT>
  59.       </TD>
  60.     </TR>
  61.     <TR>
  62.       <TD VALIGN=TOP WIDTH=415 HEIGHT=15>
  63.             <A HREF="default.asp"><IMG SRC="../images/barrowy.gif" HEIGHT=8 WIDTH=8 HSPACE=5 ALT="Return to Frequent Flyer Home Page" BORDER=0></A> 
  64.             <FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE=2> <STRONG><A HREF="default.asp">FREQUENT FLYER HOME PAGE</A></STRONG></FONT>
  65.       </TD>
  66.     </TR>
  67. </TABLE>
  68. <!--END TABLE CONTAINING LOGO, TITLE, AND NAVIGATIONAL LINK -->
  69.  
  70. <BR>
  71. <BR>
  72.  
  73. <% If Request.Form("FlyFrom") = "" Then %>
  74. <!-- BEGIN TABLE CONTAINING MAIN CONTENT-->
  75. <FORM ACTION="BookFlight.asp" METHOD="POST">
  76. <CENTER>
  77.  
  78. <FONT SIZE=3>Flights may be booked no more than one year in advance</FONT>
  79. <P>
  80.  
  81. <TABLE BORDER=1 BORDERCOLOR="#000000" CELLPADDING=0 CELLSPACING=0 HEIGHT=168 WIDTH=455>
  82.     <TR>
  83.         <TD WIDTH=555 VALIGN=TOP HEIGHT=16 COLSPAN=7 BGCOLOR="#000084">
  84.             <FONT SIZE="1" COLOR="#FFFFFF" FACE="MS Sans Serif, Arial, Helv">
  85.             <B> 
  86.             Exploration Air Flight Wizard
  87.             </B></FONT>
  88.         </TD>
  89.     </TR>
  90.  
  91.     <TR>
  92.         <TD WIDTH="450" COLSPAN="7"> 
  93.             <CENTER>
  94.             <TABLE BORDER=0>
  95.                 <TR>
  96.                     <FONT FACE="MS Sans Serif, Arial, Helv" SIZE="2">
  97.                     <STRONG>I wish to:</STRONG>
  98.                     </FONT>
  99.                 </TR>
  100.  
  101.                 <TR>
  102.                     <TD WIDTH=100>
  103.                         <FONT FACE="MS Sans Serif, Arial, Helv" SIZE="1">
  104.                         <STRONG>Fly from:</STRONG>
  105.                         </FONT>
  106.                     </TD>
  107.                     <TD>
  108.                         <SELECT NAME="FlyFrom">
  109.                             <% GetCities %>
  110.                         </SELECT>
  111.                     </TD>
  112.                 </TR>
  113.  
  114.                 <TR>
  115.                     <TD WIDTH=100>
  116.                         <FONT FACE="MS Sans Serif, Arial, Helv" SIZE="1">
  117.                         <STRONG>Fly to:</STRONG>
  118.                         </FONT>
  119.                     </TD>
  120.                     <TD>
  121.                         <SELECT NAME="FlyTo">
  122.                             <% GetCities %>
  123.                         </SELECT>
  124.                     </TD>
  125.                 </TR>
  126.  
  127.                 <TR>
  128.                     <TD WIDTH=100>
  129.                         <FONT FACE="MS Sans Serif, Arial, Helv" SIZE="1">
  130.                         <STRONG>Fly on this date:</STRONG>
  131.                         </FONT>
  132.                     </TD>
  133.                     <TD>
  134.                         <SELECT NAME="FlyDateMonth">
  135.                             <OPTION>January
  136.                             <OPTION>February
  137.                             <OPTION>March
  138.                             <OPTION>April
  139.                             <OPTION>May
  140.                             <OPTION>June
  141.                             <OPTION>July
  142.                             <OPTION>August
  143.                             <OPTION>September
  144.                             <OPTION>October
  145.                             <OPTION>November
  146.                             <OPTION>December
  147.                         </SELECT>
  148.                         <INPUT TYPE=TEXT NAME="FlyDateDay" SIZE=2>
  149.                     </TD>
  150.                 </TR>
  151.  
  152.                 <TR>
  153.                     <TD WIDTH=100>
  154.                         <FONT FACE="MS Sans Serif, Arial, Helv" SIZE="1">
  155.                         <STRONG>Fly this class:</STRONG>
  156.                         </FONT>
  157.                     </TD>
  158.                     <TD>
  159.                         <SELECT NAME="FlyClass">
  160.                             <OPTION>Coach
  161.                             <OPTION>Business
  162.                             <OPTION>First
  163.                         </SELECT>
  164.                     </TD>
  165.                 </TR>
  166.             </TABLE>
  167.             </CENTER>
  168.         </TD>
  169.     </TR>
  170.  
  171.     <TR>
  172.         <TD WIDTH="450" HEIGHT=40 ALIGN=RIGHT COLSPAN="2">
  173.             <FONT FACE="MS Sans Serif, Arial, Helv" SIZE="1">
  174.             <INPUT TYPE="SUBMIT" NAME="Finish" VALUE="Book Flight!">
  175.              
  176.             <br>
  177.             </FONT>
  178.         </TD>
  179.     </TR>
  180.  
  181.     <TR>
  182.         <TD WIDTH="555" VALIGN=TOP HEIGHT=16 COLSPAN=7 BGCOLOR="#000084">
  183.             <BR>
  184.         </TD>
  185.     </TR>
  186. </TABLE>
  187. </CENTER>
  188. <% 
  189.   Else
  190.     Dim fFormErr, strFormErr
  191.     fFormErr = False
  192.  
  193.     Dim strFrom, strTo, strClass, strFlyDateDay, strFlyDateMonth
  194.     strFrom = Request.Form("FlyFrom")
  195.     strTo = Request.Form("FlyTo")
  196.     strClass = Request.Form("FlyClass")
  197.     strFlyDateDay = Request.Form("FlyDateDay")
  198.     strFlyDateMonth = Request.Form("FlyDateMonth")
  199.  
  200.     If strFrom="" Or strTo="" Or strClass="" Or strFlyDateMonth="" Or strFlyDateDay="" Then
  201.         fFormErr = True
  202.         strFormErr = "You must enter all the form data."
  203.     End If
  204.  
  205.     If strFrom = strTo Then
  206.         fFormErr = True
  207.         strFormErr = "Origin and destination of flight must be different."
  208.     End If
  209.  
  210.     Dim iDate, iMonth, strMonth
  211.     iDate = strFlyDateDay
  212.     strMonth = strFlyDateMonth
  213.  
  214.     If iDate="" Then iDate=0
  215.  
  216.     Select Case strMonth
  217.         Case "January"
  218.             iMonth = 1
  219.         Case "February"
  220.             iMonth = 2
  221.         Case "March"
  222.             iMonth = 3
  223.         Case "April"
  224.             iMonth = 4
  225.         Case "May"
  226.             iMonth = 5
  227.         Case "June"
  228.             iMonth = 6
  229.         Case "July"
  230.             iMonth = 7
  231.         Case "August"
  232.             iMonth = 8
  233.         Case "September"
  234.             iMonth = 9
  235.         Case "October"
  236.             iMonth = 10
  237.         Case "November"
  238.             iMonth = 11
  239.         Case "December"
  240.             iMonth = 12
  241.         Case Else
  242.             fFormErr = True
  243.             strFormErr = "You have entered an in appropriate month.  Please re-enter."
  244.     End Select
  245.  
  246.     Select Case strMonth
  247.         Case "January", "March", "May", "July", "August", "October", "December"
  248.             If iDate > 31 Or iDate < 1 Then 
  249.                 fFormErr = True
  250.                 strFormErr = "You must enter an appropriate day (1-31) for the month of " & strMonth
  251.             End If
  252.  
  253.         Case "February"
  254.             ' HACK! Does not handle leap years yet
  255.             If iDate > 28 Or iDate < 1 Then 
  256.                 fFormErr = True
  257.                 strFormErr = "You must enter an appropriate day (1-28) for the month of " & strMonth
  258.             End If
  259.  
  260.         Case Else
  261.             If iDate > 30 Or iDate < 1 Then 
  262.                 fFormErr = True
  263.                 strFormErr = "You must enter an appropriate day (1-30) for the month of " & strMonth
  264.             End If
  265.     End Select 
  266.  
  267.     Dim Flights, FlightMiles, FlightNumber
  268.     Set Flights = Server.CreateObject("Flight.Schedule")
  269.     FlightMiles = Flights.CostOfFlightInMiles(Application("DSN"), strFrom,strTo,strClass)
  270.     FlightNumber = Flights.FlightNumber(Application("DSN"), strFrom, strTo)
  271.  
  272.     If IsNull(m_lngMileage) Then m_lngMileage = 0
  273.  
  274.     If FlightMiles > m_lngMileage Then
  275.         fFormErr = True
  276.         strFormErr = "You have insufficient frequent flier miles to fly from " & strFrom & " to " & strTo & ". <BR>" & _
  277.                      "You need " & FormatNumber(FlightMiles,0) & " but only have " & FormatNumber(m_lngMileage,0) & "."
  278.     End If
  279.                              
  280.     If fFormErr Then
  281.         Response.Redirect "BookFlightError.asp?ErrorString=" & Server.URLEncode(strFormErr)
  282.     Else
  283.         Dim CheckDate, FlightDate
  284.         CheckDate = CDate(Year(Now) & "/" & iMonth & "/" & iDate)
  285.         If CheckDate > Date Then
  286.             FlightDate = CheckDate
  287.         Else
  288.             FlightDate = CDate(Year(Now)+1 & "/" & iMonth & "/" & iDate)
  289.         End If
  290.         
  291.         Dim strQueryString
  292.         strQueryString = "From=" & Server.URLEncode(strFrom) & "&" & _
  293.                          "To=" & Server.URLEncode(strTo) & "&" & _ 
  294.                          "AccountID=" & Session("AccountID") & "&" & _
  295.                          "FlightNumber=" & FlightNumber & "&" & _
  296.                          "FlightDate=" & FlightDate & "&" & _
  297.                          "FlightMiles=" & FlightMiles & "&" & _
  298.                          "MilesLeft=" & m_lngMileage - FlightMiles & "&" & _
  299.                          "Class=" & Server.URLEncode(strClass)
  300.         
  301.         Response.Redirect "DoBookFlight.asp?" & strQueryString
  302.     End If
  303.   
  304.   End If
  305.  
  306.  
  307. %> 
  308. <!-- END TABLE CONTAINING MAIN CONTENT-->
  309.  
  310. <P> 
  311. <HR=400>
  312. <P>
  313.  
  314. <CENTER>
  315. <FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE="1"><A HREF="../legal.htm">©1997 Microsoft Corporation. All rights reserved. Terms of Use.</A></FONT>
  316. </CENTER>
  317.  
  318. <P>
  319.  
  320. <!--BEGIN COLOR BANNER-->
  321. <TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0 BORDER=0>
  322.     <TR>
  323.       <TD BGCOLOR="#C71585" WIDTH=100% HEIGHT=20>
  324.       </TD>
  325.     </TR>
  326. </TABLE>
  327. <!--END COLOR BANNER-->
  328.  
  329. <% Response.Flush %>
  330.  
  331. </BODY>
  332. </HTML>
  333.  
  334. <% 
  335.     Sub GetCities
  336.         Dim strDest, Flights, DSN, Dest
  337.         DSN = Application("DSN")
  338.         Set Flights=Server.CreateObject("Flight.Schedule")
  339.         Set Dest = Flights.Destinations(DSN)
  340.         Do While Not Dest.EOF
  341.             strDest = Dest("CityName")
  342.             Response.Write("<OPTION> " & strDest)
  343.             Dest.MoveNext
  344.         Loop
  345.     End Sub
  346. %>
  347.