Lab 8 Solution -- product.asp

<%@ language=VBScript %>
<% Option Explicit %>
<!-- #include file = "includes/shop.asp" -->
<%
response.buffer=true

Dim sSQL 
Dim rs
Dim i

dim iView	     
dim iPage		  'as integer
dim sSearch      'as string
dim sReturn    'as string
Dim lProductID 	'as long

lProductID = cLng("0" & trim(Request("PRODUCTID")))

if lProductID = 0 then 
	Response.redirect "/csc123/shop/search.asp"
end if

iView=cInt("0" & Trim(request("VW")))
iPage=cInt("0" & Trim(request("PG") ))
sSearch=Trim(request("SEARCH"))
sReturn = MakeReturn(sSearch)

sSQL = "Select * From Product where ProductID = " & lProductID

Set rs = OpenSQL(sSQL)  'OpenSQL function part of Header.asp

%>
<html>

<head>
<title>Shop Product Page</title>
<meta name="description" content="Product detail page for Shop Demonstration site.">
<link rel="stylesheet" type="text/css" href="../csc123.css">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<!-- #INCLUDE FILE="includes/Header.asp" -->
<h3>Product Detail Page</h3>

<%
response.write "<table border='0' cellpadding='2' cellspacing='1'>"
response.write "<tr><td valign='top' align='left' bgcolor='" & hex(cPaleYellow) & "'>"
Call ShowCart()  'ShowCart procedure part of Header.asp
response.write "</td>"
response.write "<td valign='top' align='left'>&nbsp;</td>"
response.write "<td valign='top' align='left'>"

If rs.EOF then 
	response.write "<p>No records match Product ID: " & ProductID & "</p>" 
else
	response.write "<table border='0' cellpadding='2' cellspacing='1'>"
   response.write "<tr><td align='right' bgcolor=" & cLtBLUE & ">Product #</td><td align='left'>" & rs.fields("ProductID").Value & "&nbsp;</td></tr>"
	response.write "<tr><td align='right' bgcolor=" & cLtBLUE & ">Product Name</td><td align='left'>" & rs.fields("ProductName").Value & "&nbsp;</td></tr>"
	response.write "<tr><td align='right' bgcolor=" & cLtBLUE & ">Description</td><td align='left'>" & rs.fields("ProductDescription").Value & "&nbsp;</td></tr>"
	response.write "<tr><td align='right' bgcolor=" & cLtBLUE & ">Stock</td><td align='left'>" & StockLevel(rs.fields("InStock").Value) & "&nbsp;</td></tr>"
	response.write "<tr><td align='right' bgcolor=" & cLtBLUE & ">Price Each</td><td align='left'>$ " & FormatNumber(rs.fields("Price").Value,2) & "&nbsp;</td></tr>"
	response.write "</table>"
end if

response.write "<form method='post' action='engine.asp'>"
response.write "<input type='hidden' name='ACTION' value='ADD'>"
response.write "<input type='hidden' name='PRODUCTID' value='" & lProductID & "'>"
response.write "<button name='submit' type='submit'>Press Button To Order&nbsp;&nbsp;<image src='/csc123/shop/images/cart.gif' alt='Add To Cart'></button>"
response.write "</form>"

if iView > 0 then response.write "<p>Return to <a href='Search.Asp?VW=1&amp;PG=" & cStr(iPage) & sReturn & "'>search results</a>.</p>"

response.write "</td></tr></table>"
rs.close
set rs = nothing
%>

<!-- #INCLUDE FILE="includes/Footer.asp" -->
</body>
</html>