home *** CD-ROM | disk | FTP | other *** search
/ Computer Buyer 1999 March / Dpcb0399.iso / INTERNET / IE401 / ieak4.CAB / corplist.asp < prev    next >
Text File  |  1998-02-09  |  17KB  |  457 lines

  1. <%@ LANGUAGE="VBScript" %>
  2.  
  3. <%
  4. '-------------------------------------------------------------------------------
  5. ' Microsoft Visual InterDev - Data Form Wizard
  6. ' List Page
  7. '
  8. ' (c) 1997 Microsoft Corporation.  All Rights Reserved.
  9. '
  10. ' This file is an Active Server Page that contains the list view of a Data Form. 
  11. ' It requires Microsoft Internet Information Server 3.0 and can be displayed
  12. ' using any browser that supports tables. You can edit this file to further 
  13. ' customize the list view.
  14. '
  15. '-------------------------------------------------------------------------------
  16.  
  17. Dim strPagingMove
  18. Dim strDFName
  19. strDFName = "rsCorpAdminIEGroup"
  20. %>
  21.  
  22. <SCRIPT RUNAT=Server LANGUAGE="VBScript">
  23.  
  24. '---- DataTypeEnum Values ----
  25. Const adUnsignedTinyInt = 17
  26. Const adBoolean = 11
  27. Const adLongVarChar = 201
  28. Const adLongVarWChar = 203
  29. Const adBinary = 128
  30. Const adVarBinary = 204
  31. Const adLongVarBinary = 205
  32.  
  33. '-------------------------------------------------------------------------------
  34. ' Purpose:  Substitutes Empty for Null and trims leading/trailing spaces
  35. ' Inputs:   varTemp    - the target value
  36. ' Returns:    The processed value
  37. '-------------------------------------------------------------------------------
  38.  
  39. Function ConvertNull(varTemp)
  40.     If IsNull(varTemp) Then
  41.         ConvertNull = ""
  42.     Else
  43.         ConvertNull = Trim(varTemp)
  44.     End If
  45. End Function
  46.  
  47. '-------------------------------------------------------------------------------
  48. ' Purpose:  Embeds bracketing quotes around the string
  49. ' Inputs:   varTemp    - the target value
  50. ' Returns:    The processed value
  51. '-------------------------------------------------------------------------------
  52.  
  53. Function QuotedString(varTemp)
  54.     If IsNull(varTemp) Then
  55.         QuotedString = Chr(34) & Chr(34)
  56.     Else
  57.         QuotedString = Chr(34) & CStr(varTemp) & Chr(34)
  58.     End If
  59. End Function
  60.  
  61. '-------------------------------------------------------------------------------
  62. ' Purpose:  Tests string to see if it is a URL by looking for protocol
  63. ' Inputs:   varTemp    - the target value
  64. ' Returns:    True - if is URL, False if not
  65. '-------------------------------------------------------------------------------
  66.  
  67. Function IsURL(varTemp)
  68.     IsURL = True
  69.     If UCase(Left(Trim(varTemp), 6)) = "HTTP:/" Then Exit Function
  70.     If UCase(Left(Trim(varTemp), 6)) = "FILE:/" Then Exit Function
  71.     If UCase(Left(Trim(varTemp), 8)) = "MAILTO:/" Then Exit Function
  72.     If UCase(Left(Trim(varTemp), 5)) = "FTP:/" Then Exit Function
  73.     If UCase(Left(Trim(varTemp), 8)) = "GOPHER:/" Then Exit Function
  74.     If UCase(Left(Trim(varTemp), 6)) = "NEWS:/" Then Exit Function
  75.     If UCase(Left(Trim(varTemp), 7)) = "HTTPS:/" Then Exit Function
  76.     If UCase(Left(Trim(varTemp), 8)) = "TELNET:/" Then Exit Function
  77.     If UCase(Left(Trim(varTemp), 6)) = "NNTP:/" Then Exit Function
  78.     IsURL = False
  79. End Function
  80.  
  81. '-------------------------------------------------------------------------------
  82. ' Purpose:  Handles the display of a field from a recordset depending
  83. '            on its data type, attributes, and the current mode.
  84. ' Assumes:     That the recordset containing the field is open
  85. ' Inputs:   strFieldName     - the name of the field in the recordset
  86. '            avarLookup        - array of lookup values
  87. '-------------------------------------------------------------------------------
  88.  
  89. Function ShowField(strFieldName, avarLookup)
  90.     Dim intRow
  91.     Dim strPartial
  92.     Dim strBool
  93.     Dim nPos
  94.     strFieldValue = ""
  95.     nPos=Instr(strFieldName,".")
  96.     Do While nPos > 0 
  97.         strFieldName= Mid (strFieldName, nPos+1)
  98.         nPos=Instr(strFieldName,".")
  99.     Loop 
  100.     If Not IsNull(avarLookup) Then
  101.         Response.Write "<TD BGCOLOR=White NOWRAP><FONT SIZE=-1>" 
  102.         For intRow = 0 to UBound(avarLookup, 2)
  103.             If ConvertNull(avarLookup(0, intRow)) = ConvertNull(rsCorpAdminIEGroup(strFieldName)) Then
  104.                 Response.Write Server.HTMLEncode(ConvertNull(avarLookup(1, intRow)))
  105.                 Exit For
  106.             End If
  107.         Next
  108.         Response.Write "</FONT></TD>"
  109.         Exit Function
  110.     End If
  111.     
  112.     Select Case rsCorpAdminIEGroup(strFieldName).Type
  113.         Case adBoolean, adUnsignedTinyInt                'Boolean
  114.             strBool = ""
  115.             If rsCorpAdminIEGroup(strFieldName) <> 0 Then
  116.                 strBool = "True"
  117.             Else
  118.                 strBool = "False"
  119.             End If
  120.             Response.Write "<TD BGCOLOR=White ><FONT SIZE=-1>" & strBool & "</FONT></TD>"
  121.             
  122.         Case adBinary, adVarBinary, adLongVarBinary        'Binary
  123.             Response.Write "<TD BGCOLOR=White ><FONT SIZE=-1>[Binary]</FONT></TD>"
  124.             
  125.         Case adLongVarChar, adLongVarWChar                'Memo
  126.             Response.Write "<TD BGCOLOR=White NOWRAP><FONT SIZE=-1>"
  127.             strPartial = Left(rsCorpAdminIEGroup(strFieldName), 50)            
  128.             If ConvertNull(strPartial) = "" Then
  129.                 Response.Write " "
  130.             Else
  131.                 Response.Write Server.HTMLEncode(strPartial)
  132.             End If
  133.             If rsCorpAdminIEGroup(strFieldName).ActualSize > 50 Then Response.Write "..."
  134.             Response.Write "</FONT></TD>"
  135.             
  136.         Case Else
  137.             Response.Write "<TD BGCOLOR=White ALIGN=Left NOWRAP><FONT SIZE=-1>"
  138.             If ConvertNull(rsCorpAdminIEGroup(strFieldName)) = "" Then
  139.                 Response.Write " "
  140.             Else
  141.                 ' Check for special field types
  142.                 Select Case UCase(Left(rsCorpAdminIEGroup(strFieldName).Name, 4))
  143.                     Case "URL_"
  144.                         Response.Write "<A HREF=" & QuotedString(rsCorpAdminIEGroup(strFieldName)) & ">"
  145.                         Response.Write Server.HTMLEncode(ConvertNull(rsCorpAdminIEGroup(strFieldName)))
  146.                         Response.Write "</A>"
  147.                     Case Else
  148.                         If IsURL(rsCorpAdminIEGroup(strFieldName)) Then
  149.                             Response.Write "<A HREF=" & QuotedString(rsCorpAdminIEGroup(strFieldName)) & ">"
  150.                             Response.Write Server.HTMLEncode(ConvertNull(rsCorpAdminIEGroup(strFieldName)))
  151.                             Response.Write "</A>"
  152.                         Else
  153.                             Response.Write Server.HTMLEncode(ConvertNull(rsCorpAdminIEGroup(strFieldName)))
  154.                         End If
  155.                 End Select
  156.             End If
  157.             Response.Write "</FONT></TD>"
  158.     End Select
  159. End Function
  160.  
  161. </SCRIPT>
  162.  
  163. <HTML>
  164. <HEAD>
  165.     <META NAME="GENERATOR" CONTENT="Microsoft Visual InterDev">
  166.     <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
  167.     <META NAME="Keywords" CONTENT="Microsoft Data Form, IEAK CorpAdmin List">
  168.     <TITLE>IEAK CorpAdmin List</TITLE>
  169. </HEAD>
  170.  
  171. <!--------------------------- Formatting Section ------------------------------>
  172.  
  173. <BASEFONT FACE="Arial, Helvetica, sans-serif">
  174. <LINK REL=STYLESHEET HREF="./Stylesheets/Grid/Style2.css">
  175. <BODY BACKGROUND="./Images/Grid/Background/Back2.jpg" BGCOLOR=White>
  176.  
  177. <!---------------------------- Lookups Section ------------------------------->
  178.  
  179. <!---------------------------- Heading Section ------------------------------->
  180.  
  181. <% Response.Write "<FORM ACTION=CorpAdminForm.asp METHOD=""POST"">" %>
  182. <TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 BORDER=0>
  183.     <TR>
  184.         <TH NOWRAP BGCOLOR=Silver ALIGN=Left BACKGROUND="./Images/Grid/Navigation/Nav1.jpg" >
  185.             <FONT SIZE=6> IEAK CorpAdmin</FONT>
  186.         </TH>
  187.         <TD BGCOLOR=Silver VALIGN=Middle ALIGN=Right WIDTH=100% BACKGROUND="./Images/Grid/Navigation/Nav1.jpg">
  188.             <INPUT TYPE="Hidden" NAME="FormMode" VALUE="Edit">
  189.              <INPUT TYPE="SUBMIT" NAME="DataAction" VALUE="Form View"> 
  190.         </TD>
  191.     </TR>
  192.     <TR>
  193.         <TD BGCOLOR=#FFFFCC COLSPAN=3>
  194.             <FONT SIZE=-1>  
  195.             <% 
  196.             If IsEmpty(Session("rsCorpAdminIEGroup_Filter")) Or Session("rsCorpAdminIEGroup_Filter")="" Then
  197.                 Response.Write "Current Filter: None<BR>"
  198.             Else
  199.                 Response.Write "Current Filter: " & Session("rsCorpAdminIEGroup_FilterDisplay") & "<BR>"
  200.             End If 
  201.             %>
  202.             </FONT>
  203.         </TD>
  204.     </TR></TABLE>
  205. </FORM>
  206.  
  207. <!----------------------------- List Section --------------------------------->
  208.  
  209. <TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100% >
  210. <TR>
  211. <TD WIDTH=20> </TD>
  212. <TD>
  213. <TABLE CELLSPACING=1 CELLPADDING=1 BORDER=0 WIDTH=100% >
  214.     <TR BGCOLOR=SILVER VALIGN=TOP>
  215.         <TD ALIGN=Center><FONT SIZE=-1> # </FONT></TD>
  216.         <TD ALIGN=Left><FONT SIZE=-1><B>GroupID</B></FONT></TD>
  217.         <TD ALIGN=Left><FONT SIZE=-1><B>GroupName</B></FONT></TD>
  218.         <TD ALIGN=Left><FONT SIZE=-1><B>INSFile</B></FONT></TD>
  219.     </TR>
  220.  
  221. <!--METADATA TYPE="DesignerControl" startspan
  222.     <OBJECT ID="rsCorpAdminIEGroup" WIDTH=151 HEIGHT=24
  223.         CLASSID="CLSID:F602E721-A281-11CF-A5B7-0080C73AAC7E">
  224.         <PARAM NAME="BarAlignment" VALUE="0">
  225.            <PARAM NAME="PageSize" VALUE="10">
  226.         <PARAM Name="RangeType" Value="2">
  227.         <PARAM Name="DataConnection" Value="DataConn">
  228.         <PARAM Name="CommandType" Value="0">
  229.         <PARAM Name="CommandText" Value="SELECT `GroupID`, `GroupName`, `INSFile` FROM `IEGroup`">
  230.         <PARAM Name="CursorType" Value="1">
  231.         <PARAM Name="LockType" Value="3">
  232.         <PARAM Name="CacheRecordset" Value="1">
  233.     </OBJECT>
  234. -->
  235.  
  236. <%
  237. fHideNavBar = False
  238. fHideNumber = False
  239. fHideRequery = False
  240. fHideRule = False
  241. stQueryString = ""
  242. fEmptyRecordset = False
  243. fFirstPass = True
  244. fNeedRecordset = False
  245. fNoRecordset = False
  246. tBarAlignment = "Left"
  247. tHeaderName = "rsCorpAdminIEGroup"
  248. tPageSize = 10
  249. tPagingMove = ""
  250. tRangeType = "Table"
  251. tRecordsProcessed = 0
  252. tPrevAbsolutePage = 0
  253. intCurPos = 0
  254. intNewPos = 0
  255. fSupportsBookmarks = True
  256. fMoveAbsolute = False
  257.  
  258. If Not IsEmpty(Request("rsCorpAdminIEGroup_PagingMove")) Then
  259.     tPagingMove = Trim(Request("rsCorpAdminIEGroup_PagingMove"))
  260. End If
  261.  
  262. If IsEmpty(Session("rsCorpAdminIEGroup_Recordset")) Then
  263.     fNeedRecordset = True
  264. Else
  265.     If Session("rsCorpAdminIEGroup_Recordset") Is Nothing Then
  266.         fNeedRecordset = True
  267.     Else
  268.         Set rsCorpAdminIEGroup = Session("rsCorpAdminIEGroup_Recordset")
  269.     End If
  270. End If
  271.  
  272. If fNeedRecordset Then
  273.     Set DataConn = Server.CreateObject("ADODB.Connection")
  274.     DataConn.ConnectionTimeout = Session("DataConn_ConnectionTimeout")
  275.     DataConn.CommandTimeout = Session("DataConn_CommandTimeout")
  276.     DataConn.Open Session("DataConn_ConnectionString"), Session("DataConn_RuntimeUserName"), Session("DataConn_RuntimePassword")
  277.     Set cmdTemp = Server.CreateObject("ADODB.Command")
  278.     Set rsCorpAdminIEGroup = Server.CreateObject("ADODB.Recordset")
  279.     cmdTemp.CommandText = "SELECT `GroupID`, `GroupName`, `INSFile` FROM `IEGroup`"
  280.     cmdTemp.CommandType = 1
  281.     Set cmdTemp.ActiveConnection = DataConn
  282.     rsCorpAdminIEGroup.Open cmdTemp, , 1, 3
  283. End If
  284. On Error Resume Next
  285. If rsCorpAdminIEGroup.BOF And rsCorpAdminIEGroup.EOF Then fEmptyRecordset = True
  286. On Error Goto 0
  287. If Err Then fEmptyRecordset = True
  288. If fNeedRecordset Then
  289.     Set Session("rsCorpAdminIEGroup_Recordset") = rsCorpAdminIEGroup
  290. End If
  291. rsCorpAdminIEGroup.PageSize = tPageSize
  292. fSupportsBookmarks = rsCorpAdminIEGroup.Supports(8192)
  293.  
  294. If Not IsEmpty(Session("rsCorpAdminIEGroup_Filter")) And Not fEmptyRecordset Then
  295.     rsCorpAdminIEGroup.Filter = Session("rsCorpAdminIEGroup_Filter")
  296.     If rsCorpAdminIEGroup.BOF And rsCorpAdminIEGroup.EOF Then fEmptyRecordset = True
  297. End If
  298.  
  299. If IsEmpty(Session("rsCorpAdminIEGroup_PageSize")) Then Session("rsCorpAdminIEGroup_PageSize") = tPageSize
  300. If IsEmpty(Session("rsCorpAdminIEGroup_AbsolutePage")) Then Session("rsCorpAdminIEGroup_AbsolutePage") = 1
  301.  
  302. If Session("rsCorpAdminIEGroup_PageSize") <> tPageSize Then
  303.     tCurRec = ((Session("rsCorpAdminIEGroup_AbsolutePage") - 1) * Session("rsCorpAdminIEGroup_PageSize")) + 1
  304.     tNewPage = Int(tCurRec / tPageSize)
  305.     If tCurRec Mod tPageSize <> 0 Then
  306.         tNewPage = tNewPage + 1
  307.     End If
  308.     If tNewPage = 0 Then tNewPage = 1
  309.     Session("rsCorpAdminIEGroup_PageSize") = tPageSize
  310.     Session("rsCorpAdminIEGroup_AbsolutePage") = tNewPage
  311. End If
  312.  
  313. If fEmptyRecordset Then
  314.     fHideNavBar = True
  315.     fHideRule = True
  316. Else
  317.     tPrevAbsolutePage = Session("rsCorpAdminIEGroup_AbsolutePage")
  318.     Select Case tPagingMove
  319.         Case ""
  320.             fMoveAbsolute = True
  321.         Case "Requery"
  322.             rsCorpAdminIEGroup.Requery
  323.             fMoveAbsolute = True
  324.         Case "<<"
  325.             Session("rsCorpAdminIEGroup_AbsolutePage") = 1
  326.         Case "<"
  327.             If Session("rsCorpAdminIEGroup_AbsolutePage") > 1 Then
  328.                 Session("rsCorpAdminIEGroup_AbsolutePage") = Session("rsCorpAdminIEGroup_AbsolutePage") - 1
  329.             End If
  330.         Case ">"
  331.             If Not rsCorpAdminIEGroup.EOF Then
  332.                 Session("rsCorpAdminIEGroup_AbsolutePage") = Session("rsCorpAdminIEGroup_AbsolutePage") + 1
  333.             End If
  334.         Case ">>"
  335.             If fSupportsBookmarks Then
  336.                 Session("rsCorpAdminIEGroup_AbsolutePage") = rsCorpAdminIEGroup.PageCount
  337.             End If
  338.     End Select
  339.     Do
  340.         If fSupportsBookmarks Then
  341.             rsCorpAdminIEGroup.AbsolutePage = Session("rsCorpAdminIEGroup_AbsolutePage")
  342.         Else
  343.             If fNeedRecordset Or fMoveAbsolute Or rsCorpAdminIEGroup.EOF Then
  344.                 rsCorpAdminIEGroup.MoveFirst
  345.                 rsCorpAdminIEGroup.Move (Session("rsCorpAdminIEGroup_AbsolutePage") - 1) * tPageSize
  346.             Else
  347.                 intCurPos = ((tPrevAbsolutePage - 1) * tPageSize) + tPageSize
  348.                 intNewPos = ((Session("rsCorpAdminIEGroup_AbsolutePage") - 1) * tPageSize) + 1
  349.                 rsCorpAdminIEGroup.Move intNewPos - intCurPos
  350.             End If
  351.             If rsCorpAdminIEGroup.BOF Then rsCorpAdminIEGroup.MoveNext
  352.         End If
  353.         If Not rsCorpAdminIEGroup.EOF Then Exit Do
  354.         Session("rsCorpAdminIEGroup_AbsolutePage") = Session("rsCorpAdminIEGroup_AbsolutePage") - 1
  355.     Loop
  356. End If
  357.  
  358. Do
  359.     If fEmptyRecordset Then Exit Do
  360.     If tRecordsProcessed = tPageSize Then Exit Do
  361.     If Not fFirstPass Then
  362.         rsCorpAdminIEGroup.MoveNext
  363.     Else
  364.         fFirstPass = False
  365.     End If
  366.     If rsCorpAdminIEGroup.EOF Then Exit Do
  367.     tRecordsProcessed = tRecordsProcessed + 1
  368. %>
  369. <!--METADATA TYPE="DesignerControl" endspan-->
  370.  
  371.     <TR VALIGN=TOP>
  372.         <TD BGCOLOR=White><FONT SIZE=-1>
  373.         <%
  374.         If tPageSize > 0 Then
  375.             tCurRec = ((Session("rsCorpAdminIEGroup_AbsolutePage") - 1) * tPageSize) + tRecordsProcessed
  376.         Else
  377.             tRecordsProcessed = tRecordsProcessed + 1
  378.             tCurRec = tRecordsProcessed
  379.         End If
  380.         Response.Write "<A HREF=" & QuotedString("CorpAdminAction.asp?Bookmark=" & tCurRec & "&DataAction=Find") & ">" & tCurRec & "</A>"
  381.         %>
  382.  
  383.         </FONT></TD>
  384.         <%
  385.         ShowField "GroupID", Null
  386.         ShowField "GroupName", Null
  387.         ShowField "INSFile", Null
  388.         fHideRule = True
  389.         %>
  390.     </TR>
  391.  
  392. <!--METADATA TYPE="DesignerControl" startspan
  393.     <OBJECT ID="DataRangeFtr1" WIDTH=151 HEIGHT=24
  394.         CLASSID="CLSID:F602E722-A281-11CF-A5B7-0080C73AAC7E">
  395.     </OBJECT>
  396. -->
  397. <%
  398. Loop
  399. If tRangeType = "Table" Then Response.Write "</TABLE>"
  400. If tPageSize > 0 Then
  401.     If Not fHideRule Then Response.Write "<HR>"
  402.     If Not fHideNavBar Then
  403.         %>
  404.         <TABLE WIDTH=100% >
  405.         <TR>
  406.             <TD WIDTH=100% >
  407.                 <P ALIGN=<%= tBarAlignment %> >
  408.                 <FORM <%= "ACTION=""" & Request.ServerVariables("PATH_INFO") & stQueryString & """" %> METHOD="POST">
  409.                     <INPUT TYPE="Submit" NAME="<%= tHeaderName & "_PagingMove" %>" VALUE="   <<   ">
  410.                     <INPUT TYPE="Submit" NAME="<%= tHeaderName & "_PagingMove" %>" VALUE="   <    ">
  411.                     <INPUT TYPE="Submit" NAME="<%= tHeaderName & "_PagingMove" %>" VALUE="    >   ">
  412.                     <% If fSupportsBookmarks Then %>
  413.                         <INPUT TYPE="Submit" NAME="<%= tHeaderName & "_PagingMove" %>" VALUE="   >>   ">
  414.                     <% End If %>
  415.                     <% If Not fHideRequery Then %>
  416.                         <INPUT TYPE="Submit" NAME="<% =tHeaderName & "_PagingMove" %>" VALUE=" Requery ">
  417.                     <% End If %>
  418.                 </FORM>
  419.                 </P>
  420.             </TD>
  421.             <TD VALIGN=MIDDLE ALIGN=RIGHT>
  422.                 <FONT SIZE=2>
  423.                 <%
  424.                 If Not fHideNumber Then
  425.                     If tPageSize > 1 Then
  426.                         Response.Write "<NOBR>Page: " & Session(tHeaderName & "_AbsolutePage") & "</NOBR>"
  427.                     Else
  428.                         Response.Write "<NOBR>Record: " & Session(tHeaderName & "_AbsolutePage") & "</NOBR>"
  429.                     End If
  430.                 End If
  431.                 %>
  432.                 </FONT>
  433.             </TD>
  434.         </TR>
  435.         </TABLE>
  436.     <%
  437.     End If
  438. End If
  439. %>
  440. <!--METADATA TYPE="DesignerControl" endspan-->
  441.  
  442. <!---------------------------- Footer Section -------------------------------->
  443.  
  444. <% 
  445. ' TEMP: cache here until CacheRecordset property is implemented in
  446. '         data range
  447. If fNeedRecordset Then
  448.     Set Session("rsCorpAdminIEGroup_Recordset") = rsCorpAdminIEGroup
  449. End If 
  450. %>
  451.  
  452. </TD></TR></TABLE>
  453. </BODY>
  454. </HTML>
  455.  
  456.