home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / HIWBenefitsDefault.asp < prev    next >
Text File  |  1997-11-01  |  14KB  |  307 lines

  1. <%
  2.  
  3.   ' Save URL of calling page as needed
  4.   SetURLCallHIW
  5.  
  6. %>
  7.  
  8. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  9. <HTML>
  10. <HEAD>
  11. <!--META TAGS ARE RECOMMENDED FOR THE SEARCH ENGINE-->
  12. <META NAME="DESCRIPTION" CONTENT="How It Works Page">
  13. <META NAME="KEYWORDS" CONTENT="help, code, source code, questions, explanation">
  14. <META NAME="GENERATOR" CONTENT="Microsoft Visual InterDev 1.0">
  15. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso8859-1">
  16. <!--END META TAGS-->
  17.  
  18. <TITLE>How The Benefits Home Page Works</TITLE>
  19. </HEAD>
  20.  
  21. <BODY  BGCOLOR=#FFFFFF TOPMARGIN=0 LEFTMARGIN=0 ALINK=#23238E VLINK=#808080 LINK=#FFCC00>
  22. <BASEFONT FACE="VERDANA, ARIAL, HELVETICA" SIZE=2>
  23.  
  24. <!--Change link color on mouseover
  25.     Only if running Internet Explorer 4.0 or later -->
  26. <!--#include file=../libHighlight.inc-->
  27.  
  28. <!--BEGIN TOP TABLE HOLDING GRAPHIC, NAVIGATIONAL LINK, AND MAIN CONTENT-->
  29. <TABLE WIDTH="100%" HEIGHT="100%" CELLPADDING=0 CELLSPACING=0  BGCOLOR="#000000" BORDER=0>
  30.   <TR>
  31.     <TD BGCOLOR="#000000" ALIGN=CENTER VALIGN=TOP WIDTH=170>
  32.       <BR>
  33.       <IMG SRC="../images/btslarge.jpg" HEIGHT=119 WIDTH=171  
  34.         ALT="Behind the Scenes at Exploration Air" BORDER=0 >
  35.       <BR>
  36.       <BR>
  37.       <BR>
  38.       <!--BACK BUTTON AND VARIABLE TO RETURN TO ORIGINATING PAGE-->
  39.       <A HREF="<%=Session("URLCallHIW")%>">
  40.         <IMG SRC="../images/barrowy.gif" HEIGHT=8 WIDTH=8 ALT="Return to Exploration Air Benefits"  
  41.           HSPACE=2 BORDER=0>
  42.       </A>
  43.       <FONT SIZE=2 FACE="VERDANA, ARIAL, HELVETICA"><STRONG>
  44.         <A HREF="<%=Session("URLCallHIW")%>" TITLE="Return to Exploration Air Benefits">
  45.           B  A  C  K 
  46.         </A>
  47.       </STRONG></FONT>
  48.       <BR> 
  49.       <BR>
  50.       <!--JAVASCRIPT TO VIEW PAGE'S SOURCE CODE-->
  51.       <FONT SIZE=2 FACE="VERDANA, ARIAL, HELVETICA">
  52.         <A HREF="JavaScript:openWindow('../Benefits/default.asp')" 
  53.           TITLE="View the Source for the Default page">
  54.           V I E W   S O U R C E
  55.         </A>
  56.         <BR>
  57.       </FONT>
  58.     </TD>
  59.     <TD BGCOLOR="#FFFFFF" BACKGROUND="../images/btsbg.gif" VALIGN=top>
  60.       <BR CLEAR=ALL>
  61.       <TABLE CELLPADDING=10 CELLSPACING=0 BORDER=0>   
  62.         <TR>
  63.           <TD VALIGN=top>
  64.             <FONT FACE="VERDANA, ARIAL, HELVETICA" COLOR="#0000FF" SIZE=5>
  65.               How The Employee Benefits Home Page Works
  66.             </FONT>
  67.             <P>
  68.             <HR>
  69.             <FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE="3">
  70.                         
  71.             <H2>The Big Picture</H2>
  72.  
  73.             This page retrieves the user's  Windows NT user name and determines whether the user has
  74.             used the Benefits
  75.             application before. If the user has used Benefits before, his information is retrieved. The
  76.             first time into Benefits, the user's records are initialized.
  77.  
  78.             <H2>Design Goals</H2>
  79.  
  80.             The goal of the Benefits application is to demonstrate Best Practices for creating sophisticated
  81.             Web applications. It uses a combination of Active Server Pages (ASP) scripts and ActiveX
  82.             <STRONG><A HREF="HIWBenefitsComponent.asp">components</A> </STRONG>
  83.             running under Microsoft® Transaction Server to interface with a Microsoft® SQL Server 
  84.             <STRONG><A HREF="HIWBenefitsSchema.asp">database</A></STRONG>. 
  85.             The Benefits application generally uses Microsoft® Visual Basic® Scripting 
  86.             Edition (VBScript) on the server,
  87.             and JScript on the client. It is designed to work best with Microsoft® Internet 
  88.             Explorer 4.0
  89.             and later, but will also degrade gracefully to work with lower level browsers.
  90.  
  91.             <P>The Benefits application is a multi-tier client/server application.
  92.             The ASP pages present data to the user and accept changes, requesting as needed the 
  93.             services of the 
  94.             ActiveX components. The ActiveX components implement business logic and interface with 
  95.             the database. A Microsoft® SQL Server database provides data services. Microsoft®
  96.             Transaction Server works at all three levels to ensure data integrity and efficient resource usage.
  97.  
  98.             <H2>Functional Overview</H2>
  99.  
  100.             <P>This page is generated under two conditions. The first is by request to the page, as 
  101.             when the link to "Benefits"
  102.             from the Exploration Air Home Page is clicked, or a bookmark is clicked or the URL entered
  103.             in the browser's Address field. The second is when a user attempts to access
  104.             another page in the Benefits application without having first visited the Default page 
  105.             during the current session. 
  106.  
  107.             <P>Each page in the Benefits application includes a file called <STRONG>libAuthenticate.inc</STRONG>. This file
  108.             checks whether the user has a Session variable containing the EmployeeId. If not, 
  109.             then the request is redirected to this page to ensure that the application is properly 
  110.             initialized for the user.
  111.  
  112.             <P>This page first checks to see if this is the first time the user has been at this page during the
  113.             current session. It determines if this is the first time by checking whether the 
  114.             session variable "EmployeeId" has been set. Session variables are created by assigning a 
  115.             value to them. Session variables 
  116.             apply only to an individual user's session, and persist until the session is ended. A 
  117.             session is defined as the period between when a browser is opened and
  118.             when it is closed. If more than one browser window is open, the session will 
  119.             continue until all browser windows are closed.
  120.  
  121.             <P>If the session variable "EmployeeId" has not been set, the page will 
  122.             request the <STRONG>LOGON_USER</STRONG> from the browser. The value of <STRONG>LOGON_USER</STRONG>
  123.             is the user's Windows NT 
  124.             account name, including domain name, in the format <STRONG>MYDOMAIN\myusername</STRONG>.
  125.  
  126.             <P>This means that, in production, the Benefits application is only accessed from a 
  127.             valid WindowsáNT account, using a browser that is capable of passing WindowsáNT account information
  128.             (currently possible only with Microsoft Internet Explorer 2.0 or later).
  129.             The Directory Security on the server must be set 
  130.             to require "Windows NT Challenge/Response" for the Benefits directory. If the Directory 
  131.             Security is not set correctly, the server will not request the LOGON_USER, and the Benefits
  132.             application will not be able to access the database, so it will not let the user move beyond this
  133.             Default.asp page. In order to make the demonstration site more forgiving, an 
  134.             existing user name is defaulted into the logon user field if it is not received from the 
  135.             browser. This feature would not be used in a production system.
  136.  
  137.             <P>The user name is used to retrieve the EmployeeId from the database, using an
  138.             ActiveX component called by the subroutine <STRONG>LookupEmployee</STRONG>. If there is a problem 
  139.  
  140.             <TABLE CELLPADDING=10 BORDER=0 WIDTH=40% ALIGN=RIGHT>
  141.                 <TR>
  142.                     <TD>
  143.                         <TABLE BORDER=1 BGCOLOR="#E0E0E0">
  144.                           <TR>
  145.                             <TD>
  146.                               <!--#include file=HIWBenefitsMTS.inc -->
  147.                             </TD>
  148.                           </TR>
  149.                         </TABLE>
  150.                     </TD>
  151.                 </TR>
  152.             </TABLE>
  153.  
  154.             with initializing the component or accessing the database, the page will display an error
  155.             message in the top middle. The component that is called by LookupEmployee was created
  156.             using Visual Basic 5.0, and runs under Microsoft® Transaction Server 2.0 (MTS). The 
  157.             method called to look up the employee is <STRONG><A HREF=HIWBenefitsComponent.asp#LookupEmployee>
  158.             Employee.LookupEmployee</A></STRONG>.
  159.  
  160.             <P>If there were no errors in looking up the employee record from the database, then the code 
  161.             checks to see if there is now an <STRONG>EmployeeId</STRONG> set for the session. 
  162.             The <STRONG>EmployeeId</STRONG> will
  163.             be present if there was a record in the database for the user.
  164.  
  165.             <P>If there is still not a session EmployeeId, then the user must be a new employee, 
  166.             so the code    sets up a new employee in the database. This process is done by the 
  167.             subprocedure <STRONG>SetupEmployee</STRONG>. <STRONG>SetupEmployee</STRONG> calls 
  168.             the <STRONG><A HREF=HIWBenefitsComponent.asp#AddNew>
  169.             Employee.AddNew</A></STRONG> method of the 
  170.             <STRONG><A HREF=HIWBenefitsComponent.asp#Employee>
  171.             Employee</A></STRONG> class of the ActiveX component <STRONG><A HREF=HIWBenefitsComponent.asp>
  172.             Benefit</A></STRONG>. The 
  173.             <STRONG><A HREF=HIWBenefitsComponent.asp#AddNew>Employee.AddNew</A></STRONG>
  174.             method inserts a record in the Employee table for the employee. <STRONG>
  175.             <A HREF=HIWBenefitsComponent.asp#AddNew>Employee.AddNew</A></STRONG> then 
  176.             calls the <STRONG><A HREF=HIWBenefitsComponent.asp#AddEmployeeDependent>
  177.             Employee.AddEmployeeDependent</A></STRONG> method
  178.             to create records in the tables Dependent and EmployeeDependent. Each employee has 
  179.             a record in the Dependent table with <STRONG>DependentType</STRONG> of <STRONG>Employee</STRONG>.
  180.             The dependent record is used to hold personal information, and also used to track benefit
  181.             coverage.
  182.                                     
  183.             <P>
  184.             <STRONG><A HREF=HIWBenefitsComponent.asp#AddNew>
  185.             Employee.AddNew</A></STRONG> next calls <STRONG><A HREF=HIWBenefitsComponent.asp#NewBenefits>
  186.             Employee.NewBenefits</A></STRONG>to create the benefit records for the employee. 
  187.             Every benefit that is active and applies to the current year will be added to the employee's 
  188.             records.
  189.             If a minimum Plan is defined, the employee's benefit record will include that Plan. Last, 
  190.             <STRONG><A HREF=HIWBenefitsComponent.asp#AddNew>
  191.             Employee.AddNew</A></STRONG> calls <STRONG><A HREF=HIWBenefitsComponent.asp#AddQualifier>
  192.             Employee.AddQualifier</A></STRONG> to add a qualifier record to the EmployeeQualifier table, so that the
  193.             Benefits application will allow the employee to change his benefit choices for a period
  194.             of time defined in the BenefitQualifier table.
  195.  
  196.             <P>
  197.             <H2>Data Model</H2>
  198.             You can view a diagram of the <STRONG><A HREF="HIWBenefitsSchema.asp">database</A>.
  199.             </STRONG>The data used to set the Session's EmployeeId is from the 
  200.             <STRONG><A HREF="HIWBenefitsDatabase.asp#Employee">Employee</A>
  201.             </STRONG> table. If a new 
  202.             employee record is created, records are added to tables 
  203.             <STRONG><A HREF="HIWBenefitsDatabase.asp#Employee">Employee</A>
  204.             </STRONG>,
  205.             <STRONG><A HREF="HIWBenefitsDatabase.asp#Dependent">Dependent</A>
  206.             </STRONG>, 
  207.             <STRONG><A HREF="HIWBenefitsDatabase.asp#EmployeeDependent">EmployeeDependent</A>
  208.             </STRONG>, and
  209.             <STRONG><A HREF="HIWBenefitsDatabase.asp#EmployeeQualifier">EmployeeQualifier</A>
  210.             </STRONG>.
  211.  
  212.             <P>
  213.             <H2>Components Used</H2>
  214.             This pages uses methods in the Employee class of the Benefit component.
  215.             The <STRONG><A HREF="HIWBenefitsComponent.asp#LookupEmployee">Employee.LookupEmployee
  216.             </A></STRONG> method is used to return the EmployeeId. If the user does not already have a
  217.             record in the Benefits application, 
  218.             the <STRONG><A HREF="HIWBenefitsComponent.asp#AddNEW">Employee.AddNEW</A></STRONG>
  219.             method is used to create the database records for the employee.
  220.  
  221.             <P>
  222.             </FONT>
  223.           </TD>
  224.         </TR>
  225.       </TABLE>
  226.       <!--END TOP TABLE HOLDING GRAPHIC, NAVIGATIONAL LINK, AND MAIN CONTENT-->
  227.  
  228.       <BR>
  229.       <BR>
  230.  
  231.       <CENTER>
  232.       <!--BEGIN LEGAL INFORMATION-->
  233.       <TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
  234.         <TR>
  235.           <TD>
  236.             <FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE="1">
  237.               <A HREF="../legal.htm">
  238.                 ©1997 Microsoft Corporation. All rights reserved. Terms of Use.
  239.               </A>
  240.             </FONT>
  241.             <P>
  242.           </TD>
  243.         </TR>
  244.       </TABLE>
  245.       </CENTER>
  246.       <!--END LEGAL INFORMATION-->
  247.     </TD>
  248.   </TR>
  249. </TABLE>
  250.  
  251. </BODY>
  252. </HTML>
  253. <!--END HTML-->
  254.  
  255. <SCRIPT LANGUAGE="JavaScript">
  256. function openWindow(SourceURL)
  257. {
  258.     // Set some defaults
  259.     width=450;
  260.     height=450;
  261.  
  262.     url = "code.asp?Source=" + SourceURL;
  263.     window.open(url,"Sample","resizable=yes,scrollbars=yes,width=" + width + ",height=" + height);
  264. }
  265. </SCRIPT>
  266.  
  267. <%
  268.  
  269.   '
  270.   ' SetURLCallHIW saves the name of the page in the application that called HIW page
  271.   '
  272.   Sub SetURLCallHIW
  273.     ' Extract the last directory from path
  274.     Dim strPathInfo, strLastChar, intLocation, ShortString, strLastDir
  275.     strPathInfo = Request.ServerVariables("HTTP_REFERER")
  276.     ' now str has a value like: "http://servername/exair/benefits/Default.asp"
  277.     ' we need to extract "benefits"
  278.     strLastChar = ""
  279.     ShortString = strPathInfo
  280.     intLocation = 0
  281.     
  282.     If Len(ShortString) > 0 Then
  283.         ' Get position of beginning of file name
  284.         Do Until strLastChar = "/"
  285.           strLastChar = right(ShortString, 1)
  286.           ShortString = left(ShortString, len(ShortString)-1)
  287.           intLocation = intLocation + 1
  288.         Loop
  289.     
  290.         ' Now get position of beginning of last directory name
  291.         strLastChar = ""
  292.         Do Until strLastChar = "/"
  293.           strLastChar = right(ShortString, 1)
  294.           ShortString = left(ShortString, len(ShortString)-1)
  295.           intLocation = intLocation + 1
  296.         Loop
  297.         strLastDir = mid(strPathInfo, len(strPathInfo) - (intLocation - 2), 10)
  298.     
  299.         ' If last directory not 'HowItWorks', then save the calling URL
  300.         If strLastDir <> "HowItWorks" Then
  301.           Session("URLCallHIW") = strPathInfo
  302.         End If
  303.     End If
  304.   End Sub
  305.  
  306. %>
  307.