XML/XSL Portal

Multiple Stylesheet Aware
HideXML Documenting CodeHide
     
  
 
 

shipping.asp

None.
No Comments Found.
Include Files
  • /advworks/Cart.inc (1)
  • /advworks/Disclaim.inc (1)
  • /advworks/srcform.inc (1)
Session Variables Set
  • ItemCount (2)
Session Variables Used
  • ConnectionString (2)
  • CustomerID (2)
  • ItemCount (4)
  • MyShoppingCart (2)
Redirections
  • RESPONSE-REDIRECT > /advworks/Equipment/GetCustomer.asp (1)
  • RESPONSE-REDIRECT > /advworks/default.asp (1)
  • RESPONSE-REDIRECT > /advworks/equipment/congratulations.asp (1)
Images Used
Tlc 319
319
Source
<% CustomerID = Session("CustomerID") if CustomerID =0 then ' new customer Response.Redirect "/advworks/Equipment/GetCustomer.asp" End If %> <!--#include virtual="/advworks/Cart.inc"--> <script LANGUAGE="VBScript" RUNAT="Server"> FUNCTION CheckString (s, endchar) pos = InStr(s, "'") While pos > 0 s = Mid(s, 1, pos) & "'" & Mid(s, pos + 1) pos = InStr(pos + 2, s, "'") Wend CheckString="'" & s & "'" & endchar END FUNCTION </script> <% ' Get session variables ARYshoppingcart = Session("MyShoppingCart") iCount = Session("ItemCount") Set Conn = Server.CreateObject("ADODB.Connection") msg="" DateErrorMsg = "<TT><B><I>An valid Expiration Date (MM/YY greater than today's date) is required</I></B></TT><BR>" Action = Left(UCase(Request("Action")),5) If Action = "ORDER" Then ' First do some validation on the entries If Len(Request("CreditCardNumber")) < 8 Then msg="<TT><B><I>Credit Card number must have at least 8 digits</I></B></TT><BR>" elseif NOT IsDate(Request("ExpDate")) then msg = DateErrorMsg elseif CDate(Request("ExpDate")) < now then msg = DateErrorMsg End If If Request("ShipName") = "" OR _ Request("ShipContactFirstName") = "" OR _ Request("ShipContactLastName") = "" OR _ Request("ShipAddress") = "" OR _ Request("ShipCity") = "" OR _ Request("ShipState") = "" OR _ Request("ShipPostalCode") = "" OR _ Request("ShipCountry") = "" OR _ Request("ShipPhoneNumber") = "" Then msg = msg & "<TT><B><I>All fields must have a valid non-empty response.</I></B></TT><BR>" End If If msg = "" Then 'No errors -- insert into database sql = "INSERT INTO Orders(CustomerID, EmployeeID, OrderDate, ShipName, " sql = sql & "ShipContactFirstName, ShipContactLastName, ShipAddress, ShipCity, " sql = sql & "ShipStateOrProvince, ShipPostalCode, ShipCountry, ShipPhoneNumber, " sql = sql & "ShipDate, ShippingMethodID, FreightCharge, SalesTaxRate) " sql = sql & "VALUES( " sql = sql & Request("CustomerID") sql = sql & ", 6, " sql = sql & "{fn now()}," sql = sql & CheckString(Request("ShipName"),",") sql = sql & CheckString(Request("ShipContactFirstName"),",") sql = sql & CheckString(Request("ShipContactLastName"),",") sql = sql & CheckString(Request("ShipAddress"), ",") sql = sql & CheckString(Request("ShipCity"), ",") sql = sql & CheckString(Request("ShipState"), ",") sql = sql & CheckString(Request("ShipPostalCode"), ",") sql = sql & CheckString(Request("ShipCountry"), ",") sql = sql & CheckString(Request("ShipPhoneNumber"), ",") sql = sql & "{fn now()}, " sql = sql & Request("ShippingMethod") & ", " sql = sql & Request("FreightCharge") & ", " sql = sql & Request("SalesTaxRate") & ")" Conn.Open Session("ConnectionString") Conn.Execute(sql) sql = "select @@identity" sql = "select max(OrderID) from Orders" set rs = Conn.Execute(sql) OrderID = rs(0) rs.Close ' Generate Order Detail record for each item in shopping cart For i = 1 to iCount sql = "INSERT INTO Order_Details(OrderID, ProductID, Quantity, UnitPrice, Discount) " sql = sql & "VALUES( " sql = sql & OrderID & "," sql = sql & ARYshoppingcart(cartProductID,i) & "," sql = sql & ARYshoppingcart(cartItemQuantity,i) & "," sql = sql & ARYshoppingcart(cartUnitPrice,i) & "," sql = sql & "0)" Conn.Execute(sql) Next ' Generate Payment record sql = "INSERT INTO Payments(OrderID, PaymentAmount, PaymentDate, CreditCardNumber, CreditCardExpDate, PaymentMethodID) " sql = sql & "VALUES( " sql = sql & OrderID & "," sql = sql & Request("PaymentAmount") & "," sql = sql & "{fn now()}," sql = sql & "'" & Request("CreditCardNumber") & "'," sql = sql & "'" & CDate(Request("ExpDate")) & "'," sql = sql & "2)" Conn.Execute(sql) Session("ItemCount") = 0 Conn.Close Response.Redirect "/advworks/equipment/congratulations.asp" End If 'msg = "" Elseif Action = "CANCE" Then Session("ItemCount") = 0 Response.Redirect "/advworks/default.asp" End If %> <html> <head> <title>Shipping and Payment</title></head> <body BACKGROUND="images/back_sub.gif" LINK="#800000" VLINK="#008040"> <font FACE="Verdana, Arial, Helvetica" SIZE="2"> <bgsound SRC="sounds/windfin4.wav"> <table WIDTH="600" BORDER="0"> <tr> <td> <img SRC="images/spacer.gif" ALIGN="RIGHT" WIDTH="100" ALT></td> <td COLSPAN="5"> <img SRC="images/hd_payment_and_shipping.gif" WIDTH="364" HEIGHT="42" ALT="Payment and Shipping"> <br> <hr SIZE="4"></td></tr> <!-- BEGIN sidebar navigation --> <tr> <td ROWSPAN="4" ALIGN="RIGHT" VALIGN="TOP"> <img SRC="images/spacer.gif" WIDTH="120" HEIGHT="350" ALIGN="RIGHT" ALT></td> <td> <!-- BEGIN table inserted into table data cell --> <!-- BEGIN form with first row of data --> <form ACTION="/advworks/equipment/shipping.asp?" METHOD="POST"> <!-- BEGIN column header row --> <% = msg %> <table CELLPADDING="5" COLSPAN="2"> <tr> <td WIDTH="310" BGCOLOR="#800000"><font COLOR="#FFFFFF" STYLE="Verdana, Arial, Helvetica" SIZE="2">Shipping</font></td> <td WIDTH="310" BGCOLOR="#800000"><font COLOR="#FFFFFF" STYLE="Verdana, Arial, Helvetica" SIZE="2">Payment</font></td> </tr> <td BGCOLOR="f7efde" VALIGN="TOP"> <font SIZE="2"> <% Conn.Open Session("ConnectionString") set rs = Conn.Execute("select * from Customers where CustomerID = " & CustomerID) %> First Name: <input TYPE="Text" NAME="ShipContactFirstName" VALUE="<%=rs("ContactFirstName")%>" SIZE="31" MAXLENGTH="35"><p> Last Name: <input TYPE="Text" NAME="ShipContactLastName" VALUE="<%=rs("ContactLastName")%>" SIZE="31" MAXLENGTH="35"><p> Company: <input TYPE="Text" NAME="ShipName" VALUE="<%=rs("CompanyName")%>" SIZE="31" MAXLENGTH="35"><p> Address: <input TYPE="Text" NAME="ShipAddress" VALUE="<%=rs("BillingAddress")%>" SIZE="36" MAXLENGTH="36"><p> City:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;nbspState:&nbsp;&nbsp;&amp;nbspPostal&amp;nbspCode:<br> <input TYPE="Text" NAME="ShipCity" VALUE="<%=rs("City")%>" Size="8"> <input TYPE="Text" NAME="ShipState" VALUE="<%=rs("StateOrProvince")%>" Size="2"> <input TYPE="Text" NAME="ShipPostalCode" VALUE="<%=rs("PostalCode")%>" Size="5"><p> Country: <input TYPE="Text" NAME="ShipCountry" VALUE="<%=rs("Country")%>" Size="21"> Phone: <input TYPE="Text" NAME="ShipPhoneNumber" VALUE="<%=rs("PhoneNumber")%>" Size="21"> <input TYPE="HIDDEN" NAME="CustomerID" VALUE="<%=rs("CustomerID")%>"> <% rs.Close %> </font> </td> <td BGCOLOR="f7efde" VALIGN="TOP"> <font SIZE="2"> Credit Card: <br> <select NAME="Credit Card"> <option value="--------">VISA <option value="--------">Master Card <option value="--------">American Express <option value="--------">Discover </select><p> Credit Card #: <input TYPE="Text" NAME="CreditCardNumber" VALUE="<%=Request("CreditCardNumber")%>" Size="35"><p> Expiration Date:<br> <input TYPE="Text" NAME="ExpDate" VALUE="<%=Request("ExpDate")%>" Size="8"> <p> Shipping Method:<br> <% Set rs = Conn.Execute("select * from Shipping_Methods") Checked = " checked>" do while not rs.eof Response.Write "<input type=radio name=ShippingMethod value=" & rs("ShippingMethodID") & Checked & rs("ShippingMethod") & "<BR>" Checked = ">" rs.MoveNext loop rs.Close Conn.Close %> <hr> </font> </td> </tr> </table> <!-- BEGIN new table with summary of order --> <p> <table COLSPAN="7" CELLPADDING="5" BORDER="0"> <!-- BEGIN column header row --> <tr> <td ALIGN="CENTER" BGCOLOR="#800000"> <font COLOR="#ffffff" SIZE="2">Product Code</font> </td> <td ALIGN="CENTER" BGCOLOR="#800000"> <font COLOR="#ffffff" SIZE="2">Product Name</font> </td> <td ALIGN="CENTER" WIDTH="150" BGCOLOR="#800000"> <font COLOR="#ffffff" SIZE="2">Description</font> </td> <td ALIGN="CENTER" BGCOLOR="#800000" WIDTH="75"> <font COLOR="#ffffff" SIZE="2">Quantity</font> </td> <td ALIGN="CENTER" BGCOLOR="#800000" WIDTH="75"> <font COLOR="#ffffff" SIZE="2">Price</font> </td> </tr> <!-- BEGIN row of inserted product data --> <% iSubtotal = 0 For i = 1 to iCount %> <tr> <td BGCOLOR="f7efde" ALIGN="CENTER"> <font SIZE="2"><%=ARYshoppingcart(cartProductID,i)%></font> </td> <td BGCOLOR="f7efde" ALIGN="CENTER"> <font SIZE="2"><%=ARYshoppingcart(cartProductName,i)%></font> </td> <td BGCOLOR="f7efde" ALIGN="LEFT" WIDTH="150"> <font SIZE="2"><%=ARYshoppingcart(cartProductDescription,i)%></font> </td> <td BGCOLOR="f7efde" ALIGN="CENTER"> <font SIZE="2"><%=ARYshoppingcart(cartItemQuantity,i)%></font> </td> <td BGCOLOR="f7efde" ALIGN="RIGHT"> <font SIZE="2"><% = FormatCurrency(ARYshoppingcart(cartUnitPrice,i)) %></font> </td> </tr> <% If (ARYshoppingcart(cartUnitPrice,i)) <> "" Then iSubTotal = iSubtotal + (ARYshoppingcart(cartUnitPrice,i) * ARYshoppingcart(cartItemQuantity,i)) End If Next %> <!-- BEGIN subtotal --> <tr> <td COLSPAN="3"></td> <td COLSPAN="1" BGCOLOR="f7efde" ALIGN="RIGHT"><font COLOR="#800000" SIZE="2">Subtotal:</font></td> <td BGCOLOR="f7efde" ALIGN="RIGHT"><font SIZE="2"><%=FormatCurrency(iSubTotal)%></font></td> </tr> <!-- BEGIN tax --> <%iTaxRate = 0.08 %> <%iTax = iSubTotal * iTaxRate%> <tr> <td COLSPAN="3"></td> <td COLSPAN="1" BGCOLOR="f7efde" ALIGN="RIGHT"><font COLOR="#800000" SIZE="2">Tax (8%):</font></td> <td BGCOLOR="f7efde" ALIGN="RIGHT"><font SIZE="2"><%=FormatCurrency(iTax)%></font></td> </tr> <!-- BEGIN shipping and handling --> <%iShipping = iSubTotal * 0.1%> <tr> <td COLSPAN="3"></td> <td COLSPAN="1" BGCOLOR="f7efde" ALIGN="RIGHT"><font COLOR="#800000" SIZE="2">Shipping and Handling:</font></td> <td BGCOLOR="f7efde" ALIGN="RIGHT"><font SIZE="2"><%=FormatCurrency(iShipping)%></font></td></tr> <!-- BEGIN grand total --> <% iGrandTotal = iSubTotal + iTax + iShipping%> <tr> <td COLSPAN="3"></td> <td COLSPAN="1" BGCOLOR="f7efde" ALIGN="RIGHT"><font COLOR="#800000" SIZE="2">Grand Total:</font></td> <td BGCOLOR="f7efde" ALIGN="RIGHT"><font SIZE="2"><%=FormatCurrency(iSubTotal + iTax + iShipping)%></font></td> </tr> <!-- BEGIN Order Now! and Cancel buttons --> <tr> <td ALIGN="LEFT" COLSPAN="3"></td> <td COLSPAN="2" BGCOLOR="#ffffff" ALIGN="RIGHT"> <input TYPE="HIDDEN" NAME="FreightCharge" VALUE="<%=iShipping%>"> <input TYPE="HIDDEN" NAME="SalesTaxRate" VALUE="<%=iTaxRate%>"> <input TYPE="HIDDEN" NAME="PaymentAmount" VALUE="<%=iGrandTotal%>"> <input TYPE="SUBMIT" NAME="Action" VALUE="Order Now!"> <input TYPE="SUBMIT" NAME="Action" VALUE="Cancel"> </td> </tr> </table> <!-- END table inserted into table data cell --> </form> </td> <% REM Column Span Value %> <% HTML_CS = 5 %> <% HTML_INDENT = FALSE %> <!--#include virtual="/advworks/Disclaim.inc"--> <!--#include virtual="/advworks/srcform.inc"--> </table> </body> </html>
 
 
  
     
Open

Delete

View XML
View XSL