home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 September / CHIPCD_9_99.iso / software / uaktualnienia / OptionPackPL / iis4_07.cab / DependentAdd.asp < prev    next >
Text File  |  1998-04-27  |  12KB  |  412 lines

  1. <%@ LANGUAGE="VBSCRIPT" TRANSACTION=REQUIRED %>
  2. <% Option Explicit %>
  3. <!--#include file=libAuthenticate.inc-->
  4.  
  5. <%
  6.  
  7.   Dim m_intRelationship, m_strFirstName, m_strLastName, m_strMiddleName, m_strSSN, _
  8.     m_intGender, m_datBirthdate, m_intReason, m_strMainPrompt, m_Reason, m_ChangeDate
  9.  
  10.   '
  11.   ' This block determines whether to display the page, or attempt to update the
  12.   ' database and then redirect.
  13.   '
  14.  
  15.   If Request.Form("SubmitDependent") <> "" Then
  16.     GetValuesFromForm
  17.     If UpdateDatabase = 0 Then ' database update occurred successfully
  18.       Response.Redirect("EmpProfile.asp?DepAddSuccess=1")
  19.       Response.End
  20.     Else  ' database update did not occur successfully so let the user know
  21.  
  22.     End If
  23.   End If
  24.  
  25. m_strMainPrompt = "Enter the dependent's information, then click Save.<BR> " & _
  26.   "The items listed in <STRONG>bold</STRONG> and marked by a blue bullet are required."
  27.  
  28. %>
  29.  
  30. <!--BEGIN HTML-->
  31. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  32. <HTML>
  33. <HEAD>
  34. <META NAME="DESCRIPTION" Content="Exploration Air's Add Dependent Page">
  35. <META NAME="KEYWORDS" CONTENT="dependent, add, new, spouse, child">
  36. <META NAME="GENERATOR" CONTENT="Microsoft Visual InterDev 1.0">
  37. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso8859-1">
  38. <TITLE>Add Dependent</TITLE>
  39. </HEAD>
  40.  
  41. <BODY BGCOLOR=#FFFFFF TOPMARGIN=0 LEFTMARGIN=0 ALINK=#23238E VLINK=#228B22 LINK=#23238E>
  42. <BASEFONT FACE="VERDANA, ARIAL, HELVETICA" SIZE=2>
  43.  
  44. <!--Change link color on mouseover
  45.     Only if running Internet Explorer 4.0 or later -->
  46. <!--#include file=../libHighlight.inc-->
  47.  
  48. <!--COLOR BANNER_START-->
  49. <CENTER>
  50. <TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0 BORDER=0>
  51.   <TR>
  52.     <TD BGCOLOR="#C71585" WIDTH=100% HEIGHT=20>
  53.     </TD>
  54.   </TR>
  55. </TABLE>
  56. <!--COLOR BANNER_END-->
  57.  
  58. <!--BEGIN TOP TABLE CONTAINING LOGO AND NAVIGATIONAL LINK-->
  59. <TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0 BORDER=0>
  60.   <TR>
  61.     <TD VALIGN=TOP WIDTH=325>
  62.       <A HREF="../default.asp">
  63.         <IMG SRC="../images/logo_sm.gif" WIDTH=200 HEIGHT=100 
  64.           ALT="Return to Exploration Air Home Page" BORDER=0>
  65.       </A>
  66. <BR>
  67.       <A HREF="default.asp">
  68.         <IMG SRC="../images/barrowy.gif" HEIGHT=8 WIDTH=8 HSPACE=5
  69.              ALT="Return to Employee Benefit Home Page" BORDER=0>
  70.       </A>
  71.       <FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE="2" ><STRONG>
  72.         <A HREF="default.asp" TITLE="Click to return to Employee Benefit Home Page">
  73.           EMPLOYEE BENEFITS HOME PAGE
  74.         </A>
  75.       </STRONG></FONT>
  76. <BR>
  77.       <A HREF="EmpProfile.asp">
  78.         <IMG SRC="../images/barrowy.gif" HEIGHT=8 WIDTH=8 HSPACE=5
  79.              ALT="Return to Employee Profile Page" BORDER=0>
  80.       </A>
  81.       <FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE="2" ><STRONG>
  82.         <A HREF="EmpProfile.asp" TITLE="Click to return to Employee Profile Page">        
  83.           EMPLOYEE PROFILE PAGE
  84.         </A>
  85.       </STRONG></FONT>
  86.     </TD>
  87.     <TD VALIGN=MIDDLE WIDTH=200>
  88.     </TD>
  89.     <TD WIDTH=200>
  90.       <FONT FACE="VERDANA, ARIAL, HELVETICA" COLOR="#0000FF" SIZE=5>
  91.         Add Dependent
  92.       </FONT>
  93.     </TD>
  94.     <TD VALIGN=TOP ALIGN=RIGHT>
  95.       <A HREF="../HowItWorks/HIWBenefitsDependentAdd.asp">
  96.         <IMG SRC="../images/btssmall.gif" WIDTH="115" HEIGHT="52" 
  97.           ALT="Click here to learn how this page works" BORDER=0>
  98.       </A>
  99.     </TD>
  100.   </TR>
  101. </TABLE>
  102. <!--END TABLE CONTAINING LOGO AND NAVIGATIONAL LINK -->
  103. <BR>
  104.  
  105. <P>
  106. <CENTER>
  107. <%= m_strMainPrompt %>
  108. </CENTER>
  109.  
  110. <P>
  111.  
  112. <!--BEGIN FORM-->
  113. <FORM NAME="DependentForm" METHOD=POST ACTION="DependentAdd.asp" Language="JavaScript"
  114.   onSubmit="if (!validateForm(document.DependentForm))
  115.             {
  116.               alert ('Please provide all of the required information (listed in bold), then click Save.');
  117.               return false;
  118.              }">
  119.  
  120. <TABLE BORDER=1> 
  121.   <TR>
  122.     <TD BGCOLOR="#C71585" COLSPAN=2>
  123.       <STRONG><FONT COLOR="#FFFFFF"> Dependent Information</FONT></STRONG>
  124.     </TD>
  125.   </TR>
  126.   <TR>
  127.     <TD>
  128.       <IMG SRC="images/bulletb.gif"><STRONG>Relationship</STRONG>
  129.     </TD>
  130.     <TD>
  131.       <% BuildDependentTypeList %>
  132.     </TD>
  133.   </TR>
  134.   <TR>
  135.     <TD WIDTH=110>
  136.       <IMG SRC="images/bulletb.gif"><STRONG>First Name</STRONG>
  137.     </TD>
  138.     <TD COLSPAN=3 WIDTH=190>
  139.       <INPUT SIZE=25 MAXLENGTH=20 NAME="FirstName" VALUE="<%= m_strFirstName %>">
  140.     </TD>
  141.   </TR>      
  142.   <TR>
  143.     <TD>
  144.       <IMG SRC="images/bulletb.gif"><STRONG>Last Name</STRONG>
  145.     </TD>
  146.     <TD COLSPAN=3>
  147.       <INPUT SIZE=25 MAXLENGTH=20 NAME="LastName" VALUE="<%= m_strLastName %>">
  148.     </TD>
  149.   </TR>
  150.   <TR>
  151.     <TD>
  152.        Middle Name
  153.     </TD>
  154.     <TD COLSPAN=3>
  155.       <INPUT SIZE=25 MAXLENGTH=20 NAME="MiddleName" VALUE="<%= m_strMiddleName %>">
  156.     </TD>
  157.   </TR>
  158.   <TR>
  159.     <TD>
  160.       <IMG SRC="images/bulletb.gif"><STRONG>SSN</STRONG>
  161.     </TD>
  162.     <TD COLSPAN=3>
  163.       <INPUT SIZE=25 MAXLENGTH=11 NAME="SSN" VALUE="<%= m_strSSN %>">
  164.     </TD>
  165.   </TR>
  166.   <TR>
  167.     <TD>
  168.       <IMG SRC="images/bulletb.gif"><STRONG>Gender</STRONG>
  169.     </TD>
  170.     <TD COLSPAN=3>
  171.       <% BuildGenderList %>
  172.     </TD>
  173.   </TR>
  174.   <TR>
  175.     <TD>
  176.       <IMG SRC="images/bulletb.gif"><STRONG>Birthdate</STRONG>
  177.     </TD>
  178.     <TD COLSPAN=3>
  179.       <INPUT SIZE=25 MAXLENGTH=20 NAME="Birthdate" VALUE="<%= m_datBirthdate %>">
  180.     </TD>
  181.   </TR>        
  182.   <TR>
  183.     <TD>
  184.       <IMG SRC="images/bulletb.gif"><STRONG>Reason for Change</STRONG>
  185.     </TD>
  186.     <TD>
  187.       <% BuildChangeQualifierList %>
  188.     </TD>
  189.   </TR>
  190.   <TR>
  191.     <TD>
  192.       <IMG SRC="images/bulletb.gif"><STRONG>Date Event Occured</STRONG>
  193.     </TD>
  194.     <TD COLSPAN=3>
  195.       <INPUT SIZE=25 MAXLENGTH=20 NAME="ChangeDate" VALUE="<%= m_ChangeDate %>">
  196.     </TD>
  197.   </TR> 
  198. </TABLE>
  199.  
  200. <P>
  201. </CENTER>
  202. <P>
  203. <CENTER>
  204. <INPUT TYPE="Submit" NAME="SubmitDependent" VALUE="Save">
  205. </FORM>
  206.  
  207. </CENTER>
  208. <!--END FORM-->
  209.  
  210.  
  211. <P> 
  212. <HR=400>
  213. <P>
  214.  
  215. <!--BEGIN LEGAL INFORMATION-->
  216. <CENTER>
  217. <FONT FACE="VERDANA, ARIAL, HELVETICA" SIZE="1">
  218. <A HREF="../legal.htm" TITLE="Click to view Copyright and Legal Information">
  219.   ©1997 Microsoft Corporation. All rights reserved. Terms of Use.
  220. </A>
  221. </FONT>
  222. </CENTER>
  223. <!--END LEGAL INFORMATION-->
  224.  
  225. <P>
  226.  
  227.  
  228. <!--COLOR BANNER_START-->
  229. <TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0 BORDER=0>
  230.   <TR>
  231.     <TD BGCOLOR="#C71585" WIDTH=100% HEIGHT=20>
  232.     </TD>
  233.   </TR>
  234. </TABLE>
  235. <!--COLOR BANNER_END-->
  236.  
  237. </BODY>
  238. </HTML>
  239. <!--END HTML-->
  240.  
  241. <SCRIPT LANGUAGE="JavaScript">
  242. // Begin client side helper functions
  243.   function validateForm(form)
  244.   {
  245.     if (isEmpty(form.Relationship)) return false;
  246.     if (isEmpty(form.FirstName)) return false;
  247.     if (isEmpty(form.LastName)) return false;
  248.     if (isEmpty(form.SSN)) return false;
  249.     if (isEmpty(form.Gender)) return false;
  250.     if (NotDate(form.Birthdate)) return false;
  251.     if (isEmpty(form.AddReason)) return false;
  252.     if (NotDate(form.ChangeDate)) return false;
  253.     
  254.     return true;
  255.   }
  256.  
  257.   function isEmpty(textcontrol)
  258.   {
  259.     str = textcontrol.value
  260.     for (i = 0; i < str.length; i++)
  261.     {
  262.       chr = str.substring(i, i + 1);
  263.       if (chr != ' ')
  264.       {
  265.         return false;
  266.       }
  267.     }
  268.     return true;
  269.   }
  270.  
  271.   function NotDate(textcontrol)
  272.   {
  273.     myDate = Date.parse(textcontrol.value)
  274.     if (isNaN(myDate))
  275.     {
  276.       return true;
  277.     }
  278.     return false;
  279.   }
  280.  
  281. </SCRIPT>
  282.  
  283. <%
  284.   '
  285.   ' Begin server side helper functions
  286.   '
  287.  
  288.   '
  289.   ' Create Select list of Dependent Types
  290.   '
  291.   Sub BuildDependentTypeList
  292.     Dim BenefitList, rstDependentTypeList
  293.     Set BenefitList = Server.CreateObject("Benefit.BenefitList")
  294.     Set rstDependentTypeList = BenefitList.DependentTypeList(Application("DSNBenefits"))
  295.     Response.Write "<SELECT NAME=Relationship >" & Chr(13)
  296.     Do Until rstDependentTypeList.EOF
  297.       ' Don't do for DependentType = "Employee"
  298.       If rstDependentTypeList("DependentTypeRank") <> 1 Then
  299.         Response.Write "<OPTION VALUE="
  300.           ' Don't do for DependentType = "Select Dependent Type"
  301.           If rstDependentTypeList("DependentTypeRank") <> 0 Then
  302.             Response.Write rstDependentTypeList("DependentTypeId")
  303.           End If
  304.         Response.Write ">" & rstDependentTypeList("DependentTypeLabel") & Chr(13)
  305.       End If
  306.       rstDependentTypeList.MoveNext
  307.     Loop
  308.     Response.Write "</SELECT>" & Chr(13)
  309.   End Sub
  310.  
  311.   '
  312.   ' Create Select list of Genders
  313.   '
  314.   Sub BuildGenderList
  315.     Dim BenefitList, rstGenderList
  316.     Set BenefitList = Server.CreateObject("Benefit.BenefitList")
  317.     Set rstGenderList = BenefitList.GenderList(Application("DSNBenefits"))
  318.     Response.Write "<SELECT NAME=Gender >" & Chr(13)
  319.     Do Until rstGenderList.EOF
  320.       Response.Write "<OPTION VALUE=" 
  321.       ' Don't do for GenderRank 0
  322.       If rstGenderList("GenderRank") <> 0 Then
  323.         Response.Write rstGenderList("GenderId")
  324.       End If
  325.       Response.Write ">" & rstGenderList("GenderLabel") & Chr(13)
  326.       rstGenderList.MoveNext
  327.     Loop
  328.     Response.Write "</SELECT>" & Chr(13)
  329.   End Sub
  330.  
  331.   '
  332.   ' Create Select list of available Change Qualifiers
  333.   '
  334.   Sub BuildChangeQualifierList
  335.     Dim Benefit, rstReasonList, intQualifierClass, intBenefitId
  336.     ' Get the Dependent Add codes
  337.     intQualifierClass = 4
  338.     ' Tell method to disregard BenefitId
  339.     intBenefitId = 0
  340.     Set Benefit = Server.CreateObject("Benefit.BenefitList")
  341.     Set rstReasonList = Benefit.ChangeQualifierList(Application("DSNBenefits"), intBenefitId, _
  342.       intQualifierClass)
  343.     Response.Write "<SELECT NAME=AddReason >" & Chr(13)
  344.     Do Until rstReasonList.EOF
  345.       Response.Write "<OPTION VALUE="
  346.       If rstReasonList("QualifierRank") > 0 Then
  347.         Response.Write rstReasonList("QualifierId") & ">"
  348.       Else
  349.         Response.Write " >"
  350.       End If
  351.       Response.Write rstReasonList("QualifierLabel")
  352.       Response.Write Chr(13)
  353.       rstReasonList.MoveNext
  354.     Loop
  355.     Response.Write "</SELECT>" & Chr(13)
  356.   End Sub
  357.  
  358.   ' 
  359.   ' Take values from the submitted form and assign to page level variables.
  360.   '
  361.   Sub GetValuesFromForm
  362.     m_intRelationship = CInt(Request.Form("Relationship"))
  363.     m_strFirstName = Trim(Request.Form("FirstName"))
  364.     m_strLastName = Trim(Request.Form("LastName"))
  365.     m_strMiddleName = Trim(Request.Form("MiddleName"))
  366.     m_strSSN = Trim(Request.Form("SSN"))
  367.     m_intGender = CInt(Request.Form("Gender"))
  368.     m_datBirthdate = Trim(Request.Form("Birthdate"))
  369.     If Not IsDate(m_datBirthdate) Then
  370.       m_datBirthdate = Now()
  371.     End If
  372.     m_Reason = Trim(Request.Form("AddReason"))
  373.     m_ChangeDate = Trim(Request.Form("ChangeDate"))
  374.     If Not IsDate(m_ChangeDate) Then
  375.       m_ChangeDate = Now()
  376.     End If
  377.   End Sub
  378.  
  379.   ' 
  380.   ' Update the database. Return 0 if successful or 1 if an error is encountered.
  381.   '
  382.   Function UpdateDatabase
  383.     On Error Resume Next
  384.     Dim Employee
  385.     Set Employee = Server.CreateObject("Benefit.Employee")
  386.     Employee.AddDependent Application("DSNBenefits"), Session("EmployeeId"), _
  387.       m_intRelationship, m_strFirstName, m_strLastName, _ 
  388.       m_strMiddleName, m_strSSN, m_intGender, m_datBirthdate
  389.     
  390.     Dim Benefit
  391.     Set Benefit = Server.CreateObject("Benefit.BenefitList")
  392.     Benefit.AddQualifier Application("DSNBenefits"), Session("EmployeeId"), m_Reason, _
  393.       m_ChangeDate
  394.     
  395.     If Err.Number = 0 Then
  396.       UpdateDatabase = 0
  397.     Else
  398.       ContextObject.SetAbort
  399.       UpdateDatabase = 1
  400.     End If
  401.     
  402.   End Function
  403.  
  404.   Sub OnTransactionCommit
  405.   
  406.   End Sub
  407.  
  408.   Sub OnTransactionAbort    
  409.         m_strMainPrompt = "A problem occurred while trying to update the database. Please try again later. "
  410.     End Sub
  411. %>
  412.