home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / BookFlight.asp < prev    next >
Text File  |  1997-11-01  |  9KB  |  317 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, strMonth
  211.     iDate = strFlyDateDay
  212.     strMonth = strFlyDateMonth
  213.  
  214.     If iDate="" Then iDate=0
  215.  
  216.     Select Case strMonth
  217.         Case "January", "March", "May", "July", "August", "October", "December"
  218.             If iDate > 31 Or iDate < 1 Then 
  219.                 fFormErr = True
  220.                 strFormErr = "You must enter an appropriate day (1-31) for the month of " & strMonth
  221.             End If
  222.  
  223.         Case "February"
  224.             ' HACK! Does not handle leap years yet
  225.             If iDate > 28 Or iDate < 1 Then 
  226.                 fFormErr = True
  227.                 strFormErr = "You must enter an appropriate day (1-28) for the month of " & strMonth
  228.             End If
  229.  
  230.         Case Else
  231.             If iDate > 30 Or iDate < 1 Then 
  232.                 fFormErr = True
  233.                 strFormErr = "You must enter an appropriate day (1-30) for the month of " & strMonth
  234.             End If
  235.     End Select 
  236.  
  237.     Dim Flights, FlightMiles, FlightNumber
  238.     Set Flights = Server.CreateObject("Flight.Schedule")
  239.     FlightMiles = Flights.CostOfFlightInMiles(Application("DSN"), strFrom,strTo,strClass)
  240.     FlightNumber = Flights.FlightNumber(Application("DSN"), strFrom, strTo)
  241.  
  242.     If IsNull(m_lngMileage) Then m_lngMileage = 0
  243.  
  244.     If FlightMiles > m_lngMileage Then
  245.         fFormErr = True
  246.         strFormErr = "You have insufficient frequent flier miles to fly from " & strFrom & " to " & strTo & ". <BR>" & _
  247.                      "You need " & FormatNumber(FlightMiles,0) & " but only have " & FormatNumber(m_lngMileage,0) & "."
  248.     End If
  249.                              
  250.     If fFormErr Then
  251.         Response.Redirect "BookFlightError.asp?ErrorString=" & Server.URLEncode(strFormErr)
  252.     Else
  253.         Dim CheckDate, FlightDate
  254.         CheckDate = CDate(strMonth & " " & iDate & ", " & Year(Now))
  255.         If CheckDate > Date Then
  256.             FlightDate = CheckDate
  257.         Else
  258.             FlightDate = CDate(strMonth & " " & iDate & ", " & Year(Now)+1)
  259.         End If
  260.         
  261.         Dim strQueryString
  262.         strQueryString = "From=" & Server.URLEncode(strFrom) & "&" & _
  263.                          "To=" & Server.URLEncode(strTo) & "&" & _ 
  264.                          "AccountID=" & Session("AccountID") & "&" & _
  265.                          "FlightNumber=" & FlightNumber & "&" & _
  266.                          "FlightDate=" & FlightDate & "&" & _
  267.                          "FlightMiles=" & FlightMiles & "&" & _
  268.                          "MilesLeft=" & m_lngMileage - FlightMiles & "&" & _
  269.                          "Class=" & Server.URLEncode(strClass)
  270.         
  271.         Response.Redirect "DoBookFlight.asp?" & strQueryString
  272.     End If
  273.   
  274.   End If
  275.  
  276.  
  277. %> 
  278. <!-- END TABLE CONTAINING MAIN CONTENT-->
  279.  
  280. <P> 
  281. <HR=400>
  282. <P>
  283.  
  284. <CENTER>
  285. <FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE="1"><A HREF="../legal.htm">©1997 Microsoft Corporation. All rights reserved. Terms of Use.</A></FONT>
  286. </CENTER>
  287.  
  288. <P>
  289.  
  290. <!--BEGIN COLOR BANNER-->
  291. <TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0 BORDER=0>
  292.     <TR>
  293.       <TD BGCOLOR="#C71585" WIDTH=100% HEIGHT=20>
  294.       </TD>
  295.     </TR>
  296. </TABLE>
  297. <!--END COLOR BANNER-->
  298.  
  299. <% Response.Flush %>
  300.  
  301. </BODY>
  302. </HTML>
  303.  
  304. <% 
  305.     Sub GetCities
  306.         Dim strDest, Flights, DSN, Dest
  307.         DSN = Application("DSN")
  308.         Set Flights=Server.CreateObject("Flight.Schedule")
  309.         Set Dest = Flights.Destinations(DSN)
  310.         Do While Not Dest.EOF
  311.             strDest = Dest("CityName")
  312.             Response.Write("<OPTION> " & strDest)
  313.             Dest.MoveNext
  314.         Loop
  315.     End Sub
  316. %>
  317.