home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1999 September
/
CHIPCD_9_99.iso
/
software
/
uaktualnienia
/
OptionPackPL
/
iis4_07.cab
/
HIWBenefitsDefault.asp
< prev
next >
Wrap
Text File
|
1998-04-27
|
14KB
|
307 lines
<%
' Save URL of calling page as needed
SetURLCallHIW
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<!--META TAGS ARE RECOMMENDED FOR THE SEARCH ENGINE-->
<META NAME="DESCRIPTION" CONTENT="How It Works Page">
<META NAME="KEYWORDS" CONTENT="help, code, source code, questions, explanation">
<META NAME="GENERATOR" CONTENT="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso8859-1">
<!--END META TAGS-->
<TITLE>How The Benefits Home Page Works</TITLE>
</HEAD>
<BODY BGCOLOR=#FFFFFF TOPMARGIN=0 LEFTMARGIN=0 ALINK=#23238E VLINK=#808080 LINK=#FFCC00>
<BASEFONT FACE="VERDANA, ARIAL, HELVETICA" SIZE=2>
<!--Change link color on mouseover
Only if running Internet Explorer 4.0 or later -->
<!--#include file=../libHighlight.inc-->
<!--BEGIN TOP TABLE HOLDING GRAPHIC, NAVIGATIONAL LINK, AND MAIN CONTENT-->
<TABLE WIDTH="100%" HEIGHT="100%" CELLPADDING=0 CELLSPACING=0 BGCOLOR="#000000" BORDER=0>
<TR>
<TD BGCOLOR="#000000" ALIGN=CENTER VALIGN=TOP WIDTH=170>
<BR>
<IMG SRC="../images/btslarge.jpg" HEIGHT=119 WIDTH=171
ALT="Behind the Scenes at Exploration Air" BORDER=0 >
<BR>
<BR>
<BR>
<!--BACK BUTTON AND VARIABLE TO RETURN TO ORIGINATING PAGE-->
<A HREF="<%=Session("URLCallHIW")%>">
<IMG SRC="../images/barrowy.gif" HEIGHT=8 WIDTH=8 ALT="Return to Exploration Air Benefits"
HSPACE=2 BORDER=0>
</A>
<FONT SIZE=2 FACE="VERDANA, ARIAL, HELVETICA"><STRONG>
<A HREF="<%=Session("URLCallHIW")%>" TITLE="Return to Exploration Air Benefits">
B A C K
</A>
</STRONG></FONT>
<BR>
<BR>
<!--JAVASCRIPT TO VIEW PAGE'S SOURCE CODE-->
<FONT SIZE=2 FACE="VERDANA, ARIAL, HELVETICA">
<A HREF="JavaScript:openWindow('../Benefits/default.asp')"
TITLE="View the Source for the Default page">
V I E W S O U R C E
</A>
<BR>
</FONT>
</TD>
<TD BGCOLOR="#FFFFFF" BACKGROUND="../images/btsbg.gif" VALIGN=top>
<BR CLEAR=ALL>
<TABLE CELLPADDING=10 CELLSPACING=0 BORDER=0>
<TR>
<TD VALIGN=top>
<FONT FACE="VERDANA, ARIAL, HELVETICA" COLOR="#0000FF" SIZE=5>
How The Employee Benefits Home Page Works
</FONT>
<P>
<HR>
<FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE="3">
<H2>The Big Picture</H2>
This page retrieves the user's Windows NT user name and determines whether the user has
used the Benefits
application before. If the user has used Benefits before, his information is retrieved. The
first time into Benefits, the user's records are initialized.
<H2>Design Goals</H2>
The goal of the Benefits application is to demonstrate Best Practices for creating sophisticated
Web applications. It uses a combination of Active Server Pages (ASP) scripts and ActiveX
<STRONG><A HREF="HIWBenefitsComponent.asp">components</A> </STRONG>
running under Microsoft® Transaction Server to interface with a Microsoft® SQL Server
<STRONG><A HREF="HIWBenefitsSchema.asp">database</A></STRONG>.
The Benefits application generally uses Microsoft® Visual Basic® Scripting
Edition (VBScript) on the server,
and JScript on the client. It is designed to work best with Microsoft® Internet
Explorer 4.0
and later, but will also degrade gracefully to work with lower level browsers.
<P>The Benefits application is a multi-tier client/server application.
The ASP pages present data to the user and accept changes, requesting as needed the
services of the
ActiveX components. The ActiveX components implement business logic and interface with
the database. A Microsoft® SQL Server database provides data services. Microsoft®
Transaction Server works at all three levels to ensure data integrity and efficient resource usage.
<H2>Functional Overview</H2>
<P>This page is generated under two conditions. The first is by request to the page, as
when the link to "Benefits"
from the Exploration Air Home Page is clicked, or a bookmark is clicked or the URL entered
in the browser's Address field. The second is when a user attempts to access
another page in the Benefits application without having first visited the Default page
during the current session.
<P>Each page in the Benefits application includes a file called <STRONG>libAuthenticate.inc</STRONG>. This file
checks whether the user has a Session variable containing the EmployeeId. If not,
then the request is redirected to this page to ensure that the application is properly
initialized for the user.
<P>This page first checks to see if this is the first time the user has been at this page during the
current session. It determines if this is the first time by checking whether the
session variable "EmployeeId" has been set. Session variables are created by assigning a
value to them. Session variables
apply only to an individual user's session, and persist until the session is ended. A
session is defined as the period between when a browser is opened and
when it is closed. If more than one browser window is open, the session will
continue until all browser windows are closed.
<P>If the session variable "EmployeeId" has not been set, the page will
request the <STRONG>LOGON_USER</STRONG> from the browser. The value of <STRONG>LOGON_USER</STRONG>
is the user's Windows NT
account name, including domain name, in the format <STRONG>MYDOMAIN\myusername</STRONG>.
<P>This means that, in production, the Benefits application is only accessed from a
valid WindowsáNT account, using a browser that is capable of passing WindowsáNT account information
(currently possible only with Microsoft Internet Explorer 2.0 or later).
The Directory Security on the server must be set
to require "Windows NT Challenge/Response" for the Benefits directory. If the Directory
Security is not set correctly, the server will not request the LOGON_USER, and the Benefits
application will not be able to access the database, so it will not let the user move beyond this
Default.asp page. In order to make the demonstration site more forgiving, an
existing user name is defaulted into the logon user field if it is not received from the
browser. This feature would not be used in a production system.
<P>The user name is used to retrieve the EmployeeId from the database, using an
ActiveX component called by the subroutine <STRONG>LookupEmployee</STRONG>. If there is a problem
<TABLE CELLPADDING=10 BORDER=0 WIDTH=40% ALIGN=RIGHT>
<TR>
<TD>
<TABLE BORDER=1 BGCOLOR="#E0E0E0">
<TR>
<TD>
<!--#include file=HIWBenefitsMTS.inc -->
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
with initializing the component or accessing the database, the page will display an error
message in the top middle. The component that is called by LookupEmployee was created
using Visual Basic 5.0, and runs under Microsoft® Transaction Server 2.0 (MTS). The
method called to look up the employee is <STRONG><A HREF=HIWBenefitsComponent.asp#LookupEmployee>
Employee.LookupEmployee</A></STRONG>.
<P>If there were no errors in looking up the employee record from the database, then the code
checks to see if there is now an <STRONG>EmployeeId</STRONG> set for the session.
The <STRONG>EmployeeId</STRONG> will
be present if there was a record in the database for the user.
<P>If there is still not a session EmployeeId, then the user must be a new employee,
so the code sets up a new employee in the database. This process is done by the
subprocedure <STRONG>SetupEmployee</STRONG>. <STRONG>SetupEmployee</STRONG> calls
the <STRONG><A HREF=HIWBenefitsComponent.asp#AddNew>
Employee.AddNew</A></STRONG> method of the
<STRONG><A HREF=HIWBenefitsComponent.asp#Employee>
Employee</A></STRONG> class of the ActiveX component <STRONG><A HREF=HIWBenefitsComponent.asp>
Benefit</A></STRONG>. The
<STRONG><A HREF=HIWBenefitsComponent.asp#AddNew>Employee.AddNew</A></STRONG>
method inserts a record in the Employee table for the employee. <STRONG>
<A HREF=HIWBenefitsComponent.asp#AddNew>Employee.AddNew</A></STRONG> then
calls the <STRONG><A HREF=HIWBenefitsComponent.asp#AddEmployeeDependent>
Employee.AddEmployeeDependent</A></STRONG> method
to create records in the tables Dependent and EmployeeDependent. Each employee has
a record in the Dependent table with <STRONG>DependentType</STRONG> of <STRONG>Employee</STRONG>.
The dependent record is used to hold personal information, and also used to track benefit
coverage.
<P>
<STRONG><A HREF=HIWBenefitsComponent.asp#AddNew>
Employee.AddNew</A></STRONG> next calls <STRONG><A HREF=HIWBenefitsComponent.asp#NewBenefits>
Employee.NewBenefits</A></STRONG>to create the benefit records for the employee.
Every benefit that is active and applies to the current year will be added to the employee's
records.
If a minimum Plan is defined, the employee's benefit record will include that Plan. Last,
<STRONG><A HREF=HIWBenefitsComponent.asp#AddNew>
Employee.AddNew</A></STRONG> calls <STRONG><A HREF=HIWBenefitsComponent.asp#AddQualifier>
Employee.AddQualifier</A></STRONG> to add a qualifier record to the EmployeeQualifier table, so that the
Benefits application will allow the employee to change his benefit choices for a period
of time defined in the BenefitQualifier table.
<P>
<H2>Data Model</H2>
You can view a diagram of the <STRONG><A HREF="HIWBenefitsSchema.asp">database</A>.
</STRONG>The data used to set the Session's EmployeeId is from the
<STRONG><A HREF="HIWBenefitsDatabase.asp#Employee">Employee</A>
</STRONG> table. If a new
employee record is created, records are added to tables
<STRONG><A HREF="HIWBenefitsDatabase.asp#Employee">Employee</A>
</STRONG>,
<STRONG><A HREF="HIWBenefitsDatabase.asp#Dependent">Dependent</A>
</STRONG>,
<STRONG><A HREF="HIWBenefitsDatabase.asp#EmployeeDependent">EmployeeDependent</A>
</STRONG>, and
<STRONG><A HREF="HIWBenefitsDatabase.asp#EmployeeQualifier">EmployeeQualifier</A>
</STRONG>.
<P>
<H2>Components Used</H2>
This pages uses methods in the Employee class of the Benefit component.
The <STRONG><A HREF="HIWBenefitsComponent.asp#LookupEmployee">Employee.LookupEmployee
</A></STRONG> method is used to return the EmployeeId. If the user does not already have a
record in the Benefits application,
the <STRONG><A HREF="HIWBenefitsComponent.asp#AddNEW">Employee.AddNEW</A></STRONG>
method is used to create the database records for the employee.
<P>
</FONT>
</TD>
</TR>
</TABLE>
<!--END TOP TABLE HOLDING GRAPHIC, NAVIGATIONAL LINK, AND MAIN CONTENT-->
<BR>
<BR>
<CENTER>
<!--BEGIN LEGAL INFORMATION-->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
<TR>
<TD>
<FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE="1">
<A HREF="../legal.htm">
©1997 Microsoft Corporation. All rights reserved. Terms of Use.
</A>
</FONT>
<P>
</TD>
</TR>
</TABLE>
</CENTER>
<!--END LEGAL INFORMATION-->
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
<!--END HTML-->
<SCRIPT LANGUAGE="JavaScript">
function openWindow(SourceURL)
{
// Set some defaults
width=450;
height=450;
url = "code.asp?Source=" + SourceURL;
window.open(url,"Sample","resizable=yes,scrollbars=yes,width=" + width + ",height=" + height);
}
</SCRIPT>
<%
'
' SetURLCallHIW saves the name of the page in the application that called HIW page
'
Sub SetURLCallHIW
' Extract the last directory from path
Dim strPathInfo, strLastChar, intLocation, ShortString, strLastDir
strPathInfo = Request.ServerVariables("HTTP_REFERER")
' now str has a value like: "http://servername/exair/benefits/Default.asp"
' we need to extract "benefits"
strLastChar = ""
ShortString = strPathInfo
intLocation = 0
If Len(ShortString) > 0 Then
' Get position of beginning of file name
Do Until strLastChar = "/"
strLastChar = right(ShortString, 1)
ShortString = left(ShortString, len(ShortString)-1)
intLocation = intLocation + 1
Loop
' Now get position of beginning of last directory name
strLastChar = ""
Do Until strLastChar = "/"
strLastChar = right(ShortString, 1)
ShortString = left(ShortString, len(ShortString)-1)
intLocation = intLocation + 1
Loop
strLastDir = mid(strPathInfo, len(strPathInfo) - (intLocation - 2), 10)
' If last directory not 'HowItWorks', then save the calling URL
If strLastDir <> "HowItWorks" Then
Session("URLCallHIW") = strPathInfo
End If
End If
End Sub
%>