<%@ LANGUAGE="VBSCRIPT" %> <% Dim FileName ' ********************************** ' Function to check file Existance ' ********************************** Function IsFileExists(byVal FileName) If FileName = "" Then IsFileExists = False Exit Function End If Dim objFSO Set objFSO = Server.CreateObject("Scripting.FileSystemObject") If (objFSO.FileExists( FileName ) = True) Then IsFileExists = True Else IsFileExists = False End If Set objFSO = Nothing End Function %> <% '/////////////////////////////////////////////////////////////////////////////// ' displayp.asp - Display Products page' ' This active server page displays the information for products. 'It has several different ways of displaying product information depending on the 'op and CategoryID variables that are sent into it via the querystring. ' 'When CategoryID has no value, the information for all products is displayed 'in HTML format. Otherwise, the information only for products that belong 'to the category referenced by CategoryID is displayed in HTML format. ' 'When the op variable is "Update", an additional column will be added to the 'product information table that contains "Update" buttons. The buttons allow 'the user to update the products' information. ' 'When the op variable is "Remove", 'an additional column is added to the HTML output table that contains checkboxes 'and a "Remove Product(s)" button is added to the bottom of the page. 'The checkboxes allow the user to select as many products as they wish from the 'table to be removed when the "Remove Product(s)" button is pressed. ' 'If the op variable has no value, then no extra columns are added and just the 'product information is displayed. '////////////////////////////////////////////////////////////////////////////// 'Set the page to expire so that the page is refresed everytime the 'user requests it. Response.Expires = 0 %> Lifeline Packaging Products Details <% 'Get the CategoryID number from the calling page if any. groupID = Trim(Request.QueryString("groupID")) Image=Trim(Request.QueryString("Image")) 'Get the display operation from the calling page if any. op = Request.QueryString("op") 'Reference the Session connection variable cn = Session("cnn") Set ProductInfo = Server.CreateObject("ADODB.Recordset") Set CategoryInfo = Server.CreateObject("ADODB.Recordset") querystr = "SELECT ProductID,MFG_No, A,A2,B, C, D,E, F, G, H," _ & "Cavities_per_Unit,comments,groupID,CategoryID,Image FROM Products WHERE groupID = '" & groupID & "' ORDER BY ProductID" set cn = server.createobject("ADODB.Connection") cndata = "driver={Microsoft Access Driver (*.mdb)};" & _ "dbq=" & Server.MapPath("../www/images/lifeline.mdb") cn.Open cndata,"","" ProductInfo.Open querystr, cn %>
<% 'Output the table headers For i = 1 To 13 Response.Write "" NEXT %> <% 'Loop through the recordset to output the table values Do While Not ProductInfo.EOF Response.Write "" Response.Write "" For i = 1 to 13 'Output the field values for the product Response.Write "" NEXT Response.Write "" ProductInfo.MoveNext LOOP 'Close the Recordset ProductInfo.Close %>
<% IF Image = " " THEN Response.Write "
" Response.Write "No Image Available" Response.Write "
" ELSE FileName = Trim(Image) FileName = Server.MapPath("../www/pics/" & FileName) If IsFileExists(FileName) = True Then Response.Write " border=1> <% Else Response.Write "No Image Available " End If END IF %>
" & ProductInfo.Fields(i).Name & "
" Response.Write ProductInfo.Fields(i).Value Response.Write "