home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / MS_DEV / VID / SERVER / ASF / DATA.Z / check_out.asp < prev    next >
Text File  |  1996-10-28  |  9KB  |  284 lines

  1. <!--#include virtual="/AdvWorks/Num2Dolr.inc"-->
  2.  
  3. <%
  4.     iCount = Session("ItemCount")
  5.     ARYshoppingcart = Session("MyShoppingCart")
  6.  
  7.      
  8.   If Request.QueryString("ProductCode") <> "" Then
  9.        iCount = iCount + 1
  10.      Session("ItemCount") = iCount
  11.      SQLcatalog_item = "SELECT ProductID, ProductCode, ProductName, ProductDescription, UnitPrice, OnSale FROM Products WHERE {fn UCASE(ProductCode)} = '" & Ucase(Request.QueryString("ProductCode")) & "'"
  12.      Set RScatalog_item = Conn.Execute(SQLcatalog_item)
  13.       
  14.      If Not IsEmpty(RScatalog_item) Then
  15.         ARYshoppingcart(1,iCount) = "CHECKED"
  16.         ARYshoppingcart(2,iCount) = RScatalog_item("ProductCode")
  17.         ARYshoppingcart(3,iCount) = RScatalog_item("ProductName")
  18.         ARYshoppingcart(4,iCount) = RScatalog_item("ProductDescription")
  19.         ARYshoppingcart(5,iCount) = " "
  20.         ARYshoppingcart(6,iCount) = " "
  21.         ARYshoppingcart(7,iCount) = 1
  22.         If RScatalog_item("OnSale") Then
  23.            ARYshoppingcart(8,iCount) = RScatalog_item("UnitPrice") - (RScatalog_item("UnitPrice") * 0.1)
  24.         Else
  25.            ARYshoppingcart(8,iCount) = RScatalog_item("UnitPrice")
  26.         End If
  27.         ARYshoppingcart(9,iCount) = RScatalog_item("ProductID")
  28.         Session("MyShoppingCart") = ARYshoppingcart
  29.      End If
  30.   End If
  31.   
  32.   SELECT CASE Request("Action")
  33.    
  34.    CASE "Shop for More"
  35.     For i = 1 to iCount       
  36.       ARYshoppingcart(5,i) = Request("Color" & CStr(i))
  37.       ARYshoppingcart(6,i) = Request("Size" & CStr(i))
  38.       If IsNumeric(Request("Quantity" & CStr(i))) Then
  39.         ARYshoppingcart(7,i) = Request("Quantity" & CStr(i))
  40.       Else
  41.         ARYshoppingcart(7,i) = 1
  42.       End If
  43.     Next
  44.     Session("MyShoppingCart") = ARYshoppingcart
  45.     Response.Redirect "/AdvWorks/equipment/default.asp"
  46.  
  47.    CASE "Recalculate"
  48.     For i = 1 to iCount       
  49.       ARYshoppingcart(5,i) = Request("Color" & CStr(i))
  50.       ARYshoppingcart(6,i) = Request("Size" & CStr(i))
  51.       ARYshoppingcart(7,i) = Request("Quantity" & CStr(i))
  52.     Next
  53.     For i = 1 to iCount
  54.       If Request("Confirm" & CStr(i)) = "" Then
  55.         iCount = iCount - 1
  56.         For x = 1 to UBound(ARYshoppingcart,1)
  57.           ARYshoppingcart(x,i) = ""
  58.         Next
  59.         n = i
  60.         while n < UBound(ARYshoppingcart,2)
  61.           For x = 1 to UBound(ARYshoppingcart,1)
  62.             ARYshoppingcart(x,n) = ARYshoppingcart(x,n + 1)
  63.             ARYshoppingcart(x,n + 1) = ""
  64.           Next
  65.           n = n + 1
  66.         wend
  67.       End If
  68.     Next
  69.     Session("MyShoppingCart") = ARYshoppingcart
  70.     Session("ItemCount") = iCount
  71.  
  72.    CASE "Cancel Order"
  73.     iCount = 0
  74.     Session("ItemCount") = iCount
  75.     Response.Redirect "/AdvWorks/equipment/default.asp"
  76.  
  77.    CASE "Click to Pay"
  78.     ARYshoppingcart(5,iCount) = Request("Color" & CStr(iCount))
  79.     ARYshoppingcart(6,iCount) = Request("Size" & CStr(iCount))
  80.     If IsNumeric(Request("Quantity" & CStr(iCount))) Then
  81.       ARYshoppingcart(7,iCount) = Request("Quantity" & CStr(iCount))
  82.     Else
  83.       ARYshoppingcart(7,iCount) = 1
  84.     End If
  85.     Session("MyShoppingCart") = ARYshoppingcart
  86.         ' Check if new customer
  87.     CustomerID = Session("CustomerID")
  88.     if CustomerID = 0 then ' new customer
  89.       Response.Redirect "/AdvWorks/Equipment/GetCustomer.asp"
  90.     else
  91.         ' First check to ensure that the customer was not removed from the database
  92.       Set rs = Conn.Execute( _
  93.       "select CompanyName " & _
  94.       "FROM Customers " &_
  95.       "where CustomerID = " & CustomerID & _
  96.       " and ContactFirstName = '" & Session("CustomerFirstName") & "'")
  97.       if rs.EOF then
  98.         Session("CustomerID") = -1 ' This means the user WAS in the database at one time, but isn't now
  99.         rs.Close
  100.         Response.Redirect "/AdvWorks/Equipment/GetCustomer.asp"
  101.       end if
  102.       Response.Redirect "/AdvWorks/equipment/shipping.asp"
  103.     end if
  104.  
  105.    CASE ELSE
  106. '    Response.Redirect "/AdvWorks/Equipment/default.asp"
  107.    END SELECT
  108. %>
  109.  
  110. <HTML>
  111.  
  112. <HEAD>
  113. <TITLE>Adventure Works - Shopping Cart</TITLE>
  114. </HEAD>
  115.  
  116. <BODY BACKGROUND="/AdvWorks/multimedia/images/back_sub.gif" LINK="#800000" VLINK="#008040"> 
  117. <FONT FACE="MS SANS SERIF" SIZE=2>
  118. <BGSOUND SRC="/AdvWorks/multimedia/sounds/cash_register.wav">
  119.  
  120. <TABLE BORDER=0>
  121.  
  122. <TR>
  123.  
  124. <TD WIDTH=30> 
  125. <IMG SRC="/AdvWorks/multimedia/images/spacer.GIF" ALIGN=RIGHT ALT="Space">
  126. </TD>
  127.  
  128. <TD COLSPAN=5>
  129. <IMG SRC="/AdvWorks/multimedia/images/hd_Check_out.gif" width="250" height="42" ALT="Check Out">
  130. <HR SIZE=4>
  131. </TD>
  132.  
  133. </TR>
  134.  
  135. <!-- BEGIN sidebar navigation -->
  136.  
  137. <TR>
  138.  
  139. <TD ROWSPAN=20 ALIGN=LEFT VALIGN=TOP>
  140.  
  141. <IMG SRC="/AdvWorks/multimedia/images/spacer.gif" WIDTH=120 ALT="Space">
  142.  
  143. </TD>
  144.  
  145.  
  146. <TD>
  147.  
  148. <!-- BEGIN table inserted into table data cell --><!-- BEGIN form with first row of data -->
  149.  
  150. <FORM ACTION="/AdvWorks/equipment/check_out.asp?" METHOD=POST>
  151.  
  152. <Table COLSPAN=8 CELLPADDING=5 BORDER=0>
  153.  
  154. <!-- BEGIN column header row -->
  155.  
  156. <TR>
  157.  
  158. <TD ALIGN=CENTER BGCOLOR="#800000">
  159. <FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Confirm</FONT>
  160. </TD>
  161. <TD ALIGN=CENTER BGCOLOR="#800000">
  162. <FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Product Code</FONT>
  163. </TD>
  164. <TD ALIGN=CENTER BGCOLOR="#800000">
  165. <FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Product Name</FONT>
  166. </TD>
  167. <TD ALIGN=CENTER WIDTH=150 BGCOLOR="#800000">
  168. <FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Description</FONT>
  169. </TD>
  170. <!--
  171. <TD ALIGN=CENTER BGCOLOR="#800000">
  172. <FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Color</FONT>
  173. </TD>
  174. <TD ALIGN=CENTER BGCOLOR="#800000">
  175. <FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Size</FONT>
  176. </TD>
  177. -->
  178. <TD ALIGN=CENTER BGCOLOR="#800000">
  179. <FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Quantity</FONT>
  180. </TD>
  181. <TD ALIGN=CENTER BGCOLOR="#800000">
  182. <FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>Unit Price</FONT>
  183. </TD>
  184.  
  185. </TR>
  186.  
  187. <%
  188. iSubtotal = 0
  189. For i = 1 to iCount
  190. %>
  191.  
  192. <!-- BEGIN first row of inserted product data -->
  193. <TR>
  194.  
  195. <TD ALIGN=CENTER BGCOLOR="f7efde">
  196. <%If ARYshoppingcart(1,i) = "CHECKED" Then%>
  197.    <INPUT TYPE="CHECKBOX" NAME=<%Response.Write "Confirm" & CStr(i)%> VALUE="Confirmed" CHECKED> <%End If%>
  198. </TD>
  199. <TD BGCOLOR="f7efde" ALIGN=CENTER>
  200. <FONT STYLE="ARIAL NARROW" SIZE=1><%=ARYshoppingcart(2,i)%></FONT>
  201. </TD>
  202. <TD BGCOLOR="f7efde" ALIGN=CENTER>
  203. <FONT STYLE="ARIAL NARROW" SIZE=1><%=ARYshoppingcart(3,i)%></FONT>
  204. </TD>
  205. <TD BGCOLOR="f7efde" ALIGN=LEFT WIDTH=150>
  206. <FONT STYLE="ARIAL NARROW" SIZE=1><%=ARYshoppingcart(4,i)%></FONT>
  207. </TD>
  208. <!--
  209. <TD BGCOLOR="f7efde" ALIGN=CENTER>
  210. <%If ARYshoppingcart(1,i) = "CHECKED" Then%>
  211.    <FONT STYLE="ARIAL NARROW" SIZE=1><INPUT TYPE=TEXT NAME=<%Response.Write "Color" & CStr(i)%> VALUE="<%=ARYshoppingcart(5,i)%>" SIZE=10></FONT>
  212. <%End If%>
  213. </TD>
  214. <TD BGCOLOR="f7efde" ALIGN=CENTER>
  215. <%If ARYshoppingcart(1,i) = "CHECKED" Then%>
  216.    <FONT STYLE="ARIAL NARROW" SIZE=1><INPUT TYPE=TEXT NAME=<%Response.Write "Size" & CStr(i)%> VALUE="<%=ARYshoppingcart(6,i)%>" SIZE=2></FONT>
  217. <%End If%>
  218. </TD>
  219. -->
  220. <TD BGCOLOR="f7efde" ALIGN=CENTER>
  221. <%If ARYshoppingcart(1,i) = "CHECKED" Then%>
  222.    <FONT STYLE="ARIAL NARROW" SIZE=1><INPUT TYPE=TEXT NAME=<%Response.Write "Quantity" & CStr(i)%> VALUE="<%=ARYshoppingcart(7,i)%>" SIZE=2></FONT>
  223. <%End If%>
  224. </TD>
  225. <TD BGCOLOR="f7efde" ALIGN=RIGHT>
  226. <FONT STYLE="ARIAL NARROW" SIZE=1><%=Num2Dollars(ARYshoppingcart(8,i))%></FONT>
  227. </TD>
  228.  
  229. </TR>
  230.  
  231. <%
  232. If (ARYshoppingcart(8,i)) <> "" Then
  233.    iSubTotal = iSubtotal + (ARYshoppingcart(8,i) * ARYshoppingcart(7,i))
  234. End If
  235. Next
  236. %>
  237.  
  238. <!-- BEGIN subtotal -->
  239.  
  240. <TR>
  241.  
  242. <TD COLSPAN=4></TD>
  243. <TD BGCOLOR="f7efde" ALIGN=LEFT><FONT STYLE="ARIAL NARROW" COLOR="#800000" SIZE=1>Subtotal:</FONT></TD>
  244. <TD BGCOLOR="f7efde" ALIGN=RIGHT><FONT STYLE="ARIAL NARROW" SIZE=1><%=Num2Dollars(iSubtotal)%></FONT></TD>
  245. </TR>
  246.  
  247. <TR>
  248. <TD ALIGN=RIGHT COLSPAN=3></TD>
  249. <TD COLSPAN=5 ALIGN=RIGHT>
  250.  
  251. <%If iCount < 5 Then%>
  252.    <INPUT TYPE=SUBMIT NAME="Action" VALUE="Shop for More">
  253. <%End If%>
  254. <%If iCount > 0 Then%>
  255.    <INPUT TYPE=SUBMIT NAME="Action" VALUE="Click to Pay">
  256.    <INPUT TYPE=SUBMIT NAME="Action" VALUE="Recalculate">
  257. <%End If%>
  258. <INPUT TYPE=SUBMIT NAME="Action" VALUE="Cancel Order">
  259.  
  260.  
  261. </TD>
  262. </TR>
  263.  
  264. </TABLE>
  265.  
  266. </FORM>
  267.  
  268. <!-- END table inserted into table data cell -->
  269.  
  270. </TD>
  271.  
  272. <% REM Column Span Value %>
  273. <% HTML_CS = 5 %>
  274. <% HTML_INDENT = FALSE %>
  275. <!--#include virtual="/AdvWorks/Disclaim.inc"-->
  276.  
  277. </TABLE>
  278.  
  279. <!--#include virtual="/AdvWorks/srcform.inc"-->
  280.  
  281. </BODY>
  282.  
  283. </HTML>
  284.