📄 purchasefinal.asp
字号:
<!-- #INCLUDE FILE="odbc_connection.inc" -->
<%
session("EmptyCart")=0
CustomerID=Session("CustomerID")
if (len(CustomerID)=0 or CustomerID="") then response.redirect "inventory.asp"
intSessionID=Session.SessionID
'place customer ID in tblShoppingCart
on error resume next
Set RS = Server.CreateObject("ADODB.Recordset")
sSQL="UPDATE tbl_ShoppingCart "
sSQL=sSQL & "SET CustomerID=" & CustomerID & " "
sSQL=sSQL & "WHERE (intSessionID=" & intSessionID & ")"
RS.Open sSQL, conn , 3, 2 'write
Set RS=nothing
'========================
' Mail it!
'========================
'Get customer name, phone, email address
'========================
sSQL="SELECT "
sSQL=sSQL & "s_CompanyName, "
sSQL=sSQL & "s_FirstName, "
sSQL=sSQL & "s_LastName, "
sSQL=sSQL & "s_Email, "
sSQL=sSQL & "s_Phone, "
sSQL=sSQL & "s_State, "
sSQL=sSQL & "y_TaxExempt "
sSQL=sSQL & "FROM tbl_Customer "
sSQL=sSQL & "WHERE CustomerID=" & CustomerID
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open sSQL, conn , 3, 3 'read
if err.number<>0 then
msg=msg & "error 0: " & err.description & "<BR>"
err.number=0
end if
s_CompanyName=RS("s_CompanyName")
s_FirstName=RS("s_FirstName")
s_LastName=RS("s_LastName")
s_Email=RS("s_Email")
s_Phone=RS("s_Phone")
s_State=RS("s_State")
y_TaxExempt=RS("y_TaxExempt")
RS.Close
set RS=nothing
if err.number<>0 then
msg=msg & "error 1: " & err.description & "<BR>"
err.number=0
end if
'====================================
'Get customer preferred shipping Info
'====================================
sSQL="SELECT "
sSQL=sSQL & "tbl_CustomerShipTo.s_ShipToFirstName, "
sSQL=sSQL & "tbl_CustomerShipTo.s_ShipToLastName, "
sSQL=sSQL & "tbl_CustomerShipTo.s_ShipToAddress, "
sSQL=sSQL & "tbl_CustomerShipTo.s_ShipToAddress2, "
sSQL=sSQL & "tbl_CustomerShipTo.s_ShipToCity, "
sSQL=sSQL & "tbl_CustomerShipTo.s_ShipToState, "
sSQL=sSQL & "tbl_CustomerShipTo.s_ShipToZip, "
sSQL=sSQL & "tbl_CustomerShipTo.s_ShipToCountry, "
sSQL=sSQL & "tbl_CustomerShipTo.s_ShipToAttention, "
sSQL=sSQL & "tbl_ShipVia.ShipViaID, "
sSQL=sSQL & "tbl_ShipVia.s_ShipVia "
sSQL=sSQL & "FROM tbl_ShipVia "
sSQL=sSQL & "INNER JOIN tbl_CustomerShipTo ON tbl_ShipVia.ShipViaID = tbl_CustomerShipTo.ShipViaID "
sSQL=sSQL & "WHERE tbl_CustomerShipTo.CustomerID=" & CustomerID
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open sSQL, conn , 3, 3 'read
if err.number<>0 then
msg=msg & "error 0a: " & err.description & "<BR>"
err.number=0
end if
s_ShipToFirstName=RS("s_ShipToFirstName")
s_ShipToLastName=RS("s_ShipToLastName")
s_ShipToAddress=RS("s_ShipToAddress")
s_ShipToAddress2=RS("s_ShipToAddress2")
s_ShipToCity=RS("s_ShipToCity")
s_ShipToState=RS("s_ShipToState")
s_ShipToZip=RS("s_ShipToZip")
s_ShipToCountry=RS("s_ShipToCountry")
s_ShipToAttention=RS("s_ShipToAttention")
s_ShipVia=RS("s_ShipVia")
ShipViaID=RS("ShipViaID")
RS.Close
set RS=nothing
'========================
'Get shopping cart data
'========================
sSQL="SELECT "
sSQL=sSQL & "tbl_ShoppingCart.s_Item_No, "
sSQL=sSQL & "tbl_Inventory.s_Description, "
sSQL=sSQL & "tbl_ShoppingCart.intQuantity, "
sSQL=sSQL & "tbl_ShoppingCart.Price, "
sSQL=sSQL & "tbl_ShoppingCart.d_Date, "
sSQL=sSQL & "tbl_ShoppingCart.s_IPaddress "
sSQL=sSQL & "FROM (tbl_Inventory RIGHT JOIN tbl_ShoppingCart ON tbl_Inventory.s_Item_No = tbl_ShoppingCart.s_Item_No) "
sSQL=sSQL & "WHERE (((tbl_ShoppingCart.intSessionID)=" & intSessionID & ") AND ((tbl_ShoppingCart.CustomerID)=" & CustomerID & "))"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open sSQL, conn , 3, 3 'read
if err.number<>0 then
msg=msg & "error 2: " & err.description & " sql: " & sSQL & "<BR>"
err.number=0
end if
d_Date=RS("d_Date")
s_IPaddress=RS("s_IPaddress")
if err.number<>0 then
msg=msg & "error 2.1: " & err.description & "<BR>"
err.number=0
end if
'-- Create the Mailman Object
Set Mailer = Server.CreateObject("ASPMail.ASPMailCtrl.1")
'-- Set the Mail Properties
Subject = "Your [" & session("purchase") & "] order (#" & intSessionID & ") at the ___ web site"
ReplyTo = "sales@yourdomain.com"
SendTo = s_Email 'customer email address
SendCc = ""
ServerAddr = "mail.yourdomain.com"
'Mailer.ServerAddr = "mail.blue-sea.com"
'ServerPort = 25
if err.number<>0 then
msg=msg & "error 2.3: " & err.description & "<BR>"
err.number=0
end if
'-- Set Message Body
sMessageText = "Purchase Date: " & Cstr(d_Date) & vbCrLf
'sMessageText = sMessageText & "Purchaser IP: " & s_IPaddress & vbCrLf
sMessageText = sMessageText & "Company Name: " & s_CompanyName & vbCrLf
sMessageText = sMessageText & "Name: " & s_FirstName & " " & s_LastName & vbCrLf
sMessageText = sMessageText & "Telephone: " & s_Phone & vbCrLf
sMessageText = sMessageText & "---------------------------------" & vbCrLf
sMessageText = sMessageText & "SHIPPING INFO" & vbCrLf
sMessageText = sMessageText & "First Name: " & s_ShipToFirstName & vbCrLf
sMessageText = sMessageText & "Last Name: " & s_ShipToLastName & vbCrLf
sMessageText = sMessageText & "Address: " & s_ShipToAddress & vbCrLf
sMessageText = sMessageText & "Address Line 2: " & s_ShipToAddress2 & vbCrLf
sMessageText = sMessageText & "City: " & s_ShipToCity & vbCrLf
sMessageText = sMessageText & "State: " & s_ShipToState & vbCrLf
sMessageText = sMessageText & "Zip: " & s_ShipToZip & vbCrLf
sMessageText = sMessageText & "Country: " & s_ShipToCountry & vbCrLf
sMessageText = sMessageText & "Attn: " & s_ShipToAttention & vbCrLf
sMessageText = sMessageText & "Ship Via: " & s_ShipVia & vbCrLf
sMessageText = sMessageText & "---------------------------------" & vbCrLf
sMessageText = sMessageText & "ITEMS ORDERED" & vbCrLf
'-- Loop thru recordset to show each item
if err.number<>0 then
msg=msg & "error 2.4: " & err.description & "<BR>"
err.number=0
end if
'CHECK TO SEE IF ANY s_Item_No have HDW-SYS at beginning
'IF THEY ORDERED A SYSTEM, SALESMAN MUST KNOW THIS
SystemCount=0
SubTotal=0
Do until RS.EOF
sMessageText = sMessageText & "(" & RS("intQuantity") & ") "
sMessageText = sMessageText & trim(RS("s_Item_No"))
sMessageText = sMessageText & " (" & trim(RS("s_Description")) & ") @ "
sMessageText = sMessageText & FormatCurrency(RS("Price")) & " ea = "
LineTotal=RS("Price")*RS("intQuantity")
SubTotal=SubTotal+LineTotal
sMessageText = sMessageText & FormatCurrency(LineTotal)
sMessageText = sMessageText & VbCrLf
'find category id from s_Item_No
sSQL="SELECT"
sSQL=sSQL & " tbl_Categories.ID"
sSQL=sSQL & " FROM tbl_Categories"
sSQL=sSQL & " INNER JOIN tbl_Inventory ON tbl_Categories.s_Category = tbl_Inventory.s_Category"
sSQL=sSQL & " WHERE (tbl_Inventory.s_Item_No='" & RS("s_Item_No") & "')"
Set RS_Nested = Server.CreateObject("ADODB.Recordset")
RS_Nested.Open sSQL, conn, 3, 3 'read
CategoryID=RS_Nested("ID")
RS_Nested.close
set RS_Nested=nothing
if CategoryID=1 then
SystemCount=SystemCount+1
sMessageText = sMessageText & " System Detail:" & VbCrLf
RS_SQL="SELECT"
RS_SQL=RS_SQL & " tbl_Inventory_System_Components_Session.s_Component_Item_No"
RS_SQL=RS_SQL & " ,tbl_Inventory.s_Description"
RS_SQL=RS_SQL & " FROM tbl_Inventory_System_Components_Session"
RS_SQL=RS_SQL & " INNER JOIN tbl_Inventory ON"
RS_SQL=RS_SQL & " tbl_Inventory_System_Components_Session.s_Component_Item_No = tbl_Inventory.s_Item_No"
RS_SQL=RS_SQL & " WHERE (tbl_Inventory_System_Components_Session.s_System_Item_No='" & RS("s_Item_No") & "'"
RS_SQL=RS_SQL & " AND tbl_Inventory_System_Components_Session.intSessionID=" & session.sessionID & ")"
RS_SQL=RS_SQL & " ORDER BY tbl_Inventory_System_Components_Session.intKey"
'on error resume next
Set RS_Nested = server.createObject("ADODB.recordset")
RS_Nested.open RS_SQL, conn, 3, 3 'read
Do While Not(RS_Nested.EOF)
sMessageText = sMessageText & " " & trim(RS_Nested("s_Component_Item_No"))
sMessageText = sMessageText & " (" & trim(RS_Nested("s_Description")) & ")"
'sMessageText = sMessageText & " @ " & FormatCurrency(RS_Nested("Price")) & VbCrLf
RS_Nested.movenext
Loop
RS_Nested.close
set RS_Nested=nothing
end if
sMessageText = sMessageText & VbCrLf
RS.movenext
LOOP
RS.close
set RS=nothing
sMessageText = sMessageText & "---------------------------------" & vbCrLf
if y_TaxExempt=true then
TaxPct=0
else
TaxPct=0
'Whatever STATE your store exists in:
if (s_State="FL" or s_State="Fl" or s_State="Florida") then TaxPct=0.065
end if
if TaxPct>0 then
Tax=SubTotal*TaxPct
else
Tax=0
end if
Total=SubTotal+Tax
SubTotal=FormatCurrency(SubTotal)
Tax=FormatCurrency(Tax)
if err.number<>0 then
msg=msg & "error 4: " & err.description & "<BR>"
err.number=0
end if
sMessageText = sMessageText & "SubTotal: " & SubTotal & vbCrLf
sMessageText = sMessageText & "Tax: " & Tax & vbCrLf
sMessageText = sMessageText & "Total: " & FormatCurrency(Total) & vbCrLf
sMessageText = sMessageText & "Note: this figure does not include shipping charges" & vbCrLf
sMessageText = sMessageText & vbCrLf
if SystemCount>0 then
'They Ordered at least one System.
'Let's print a list of components for each system
end if
if session("purchase")="Purchase" then
sMessageText = sMessageText & "Thank you for your order!" & vbCrLf
else
sMessageText = sMessageText & "Thank you for your interest! This quote is good for 7 days." & vbCrLf
end if
if err.number<>0 then
msg=msg & "error 6: " & err.description & "<BR>"
err.number=0
else
'-- Fire off the email message
result = Mailer.SendMail(ServerAddr, SendTo, ReplyTo, Subject, sMessageText)
if result="" then
msg=msg & "<BR>Mail message was delivered"
else
msg=msg & "<BR>error: " & result & "<BR><BR>"
err.number=0
end if
'-- Destroy the Object
Set Mailer = Nothing
'now for a similar msg to RCR people
if SystemCount>0 then
sMessageText=sMessageText & vbCrLf
sMessageText=sMessageText & "Email Address: " & s_Email
sMessageText=sMessageText & vbCrLf
sMessageText=sMessageText & "NOTE:" & vbCrLf
if session("purchase")="Purchase" then
sMessageText=sMessageText & "Customer has purchased " & SystemCount & " systems." & vbCrLf
else
sMessageText=sMessageText & "Customer has been quoted a price on " & SystemCount & " systems." & vbCrLf
end if
sMessageText=sMessageText & vbCrLf
end if
'-- Create the Mailman Object
Set Mailer = Server.CreateObject("ASPMail.ASPMailCtrl.1")
'-- Set the Mail Properties
Subject = "Web Order [" & session("purchase") & "], Cust:" & CustomerID & ", Session:" & intSessionID
ReplyTo = s_Email
SendTo = "sales@yourdomain.com"
SendCc = ""
'Mailer.ServerAddr = "mail.blue-sea.com"
ServerAddr = "mail.yourdomain.com"
'ServerPort = 25
'-- Fire off the email message
result = Mailer.SendMail(ServerAddr, SendTo, ReplyTo, Subject, sMessageText)
if result="" then
msg=msg & "<BR>Mail message was delivered"
else
msg=msg & "<BR>error: " & result & "<BR><BR>"
err.number=0
end if
'-- Destroy the Object
Set Mailer = Nothing
end if
'========================================
'C L E A N U P
'========================================
'make sure current shopping cart has proper designation (quote or not)
b_Quote=true
if session("purchase")="Purchase" then b_Quote=false
sSQL="UPDATE tbl_ShoppingCart"
sSQL=sSQL & " SET b_Quote=" & b_Quote
sSQL=sSQL & " WHERE intSessionID=" & session.SessionID
set RS=conn.execute(sSQL)
sSQL="UPDATE tbl_Inventory_System_Components_Session"
sSQL=sSQL & " SET b_Quote=" & b_Quote
sSQL=sSQL & " WHERE intSessionID=" & session.SessionID
set RS=conn.execute(sSQL)
'Remove previous days' sessions from tbl_Inventory_System_Components_Session
sSQL="DELETE"
sSQL=sSQL & " FROM tbl_Inventory_System_Components_Session"
sSQL=sSQL & " WHERE dDate < #" & Date-11 & "#"
set RS=conn.execute(sSQL)
set RS=nothing
'ONLY DO THIS IF NOT A QUOTE
'Remove this session from tbl_Inventory_System_Components_Session
sSQL="DELETE"
sSQL=sSQL & " FROM tbl_Inventory_System_Components_Session"
sSQL=sSQL & " WHERE (intSessionID=" & session.sessionID
sSQL=sSQL & " AND b_Quote=false)"
set RS=conn.execute(sSQL)
set RS=nothing
'Delete all tbl_ShoppingCart
'older than 10 days
sSQL="DELETE"
sSQL=sSQL & " FROM tbl_ShoppingCart"
sSQL=sSQL & " WHERE dDate < #" & Date-9 & "#"
set RS=conn.execute(sSQL)
set RS=nothing
'Delete this customer (and this order)'s rows from tbl_ShoppingCart
'but only non-quotes--leave quotes for x days
sSQL="DELETE"
sSQL=sSQL & " FROM tbl_ShoppingCart"
sSQL=sSQL & " WHERE (CustomerID=" & CustomerID
sSQL=sSQL & " AND intSessionID=" & intSessionID
sSQL=sSQL & " AND b_Quote=false)"
set RS=conn.execute(sSQL)
set RS=nothing
b_purchase=false
if session("purchase")="Purchase" then b_purchase=true
'add row to tbl_Past_Orders
sSQL="INSERT INTO tbl_Past_Orders ("
sSQL=sSQL & " intSessionID"
sSQL=sSQL & ",CustomerID"
sSQL=sSQL & ",c_Price_Before_Tax"
sSQL=sSQL & ",c_Price_After_Tax"
sSQL=sSQL & ",d_OrderDate"
sSQL=sSQL & ",ShipViaID"
sSQL=sSQL & ",b_purchase"
sSQL=sSQL & ") Values ("
sSQL=sSQL & intSessionID
sSQL=sSQL & "," & CustomerID
sSQL=sSQL & "," & SubTotal
sSQL=sSQL & "," & Total
sSQL=sSQL & ",#" & Date & "#"
sSQL=sSQL & "," & ShipViaID
sSQL=sSQL & "," & b_purchase
sSQL=sSQL & ")"
set RS=conn.execute(sSQL)
set RS=nothing
%>
<HTML>
<HEAD>
<!-- #INCLUDE FILE="shared_styles.inc" -->
<BASE TARGET="catdisplay">
<TITLE>We Thank you for shopping at ___ Computers, Inc.</TITLE>
</HEAD>
<BODY bgcolor="black" link="gold" vlink="gold">
<BR>
<CENTER><FONT FACE="ARIAL" color="white"><b>
<% if session("purchase")="Purchase" then %>
Thank you for your order!<BR>
An ___ Computers Sales Representative<BR>
will be contacting you shortly.<BR><BR>
We have sent your order information via email.<BR>
If you change your mind about anything<BR>
please inform the salesperson when they call.<BR>
<% else %>
Thank you for your interest!<BR>
Your quote is good for 7 days.<BR>
Feel free to call us at 1-800-RCR-2997.<BR>
<BR>
By default the items in your shopping cart<BR>
will be saved in our system for 7 days.<BR>
If you do not wish for these items to<BR>
re-appear in your cart next time you log<BR>
in, you can delete them...<BR>
<form name='purchase' action='DeleteQuote.asp' method='post'>
<input type="submit" value=" Delete Quote "><BR>
</form>
<% end if %>
</b></FONT></CENTER>
<BR>
<CENTER>
<table width="80%" border="0">
<TR>
<TD width="80%" align="center" bgcolor=black>
<B><font color="white">Help Us Help You</font></B>
<BR>
<B><font size=+1 color='white'>Comments About Your Experience Using ___ Computers Online Shopping</font></B><BR>
<FORM method="post" action="SurveyResponse.asp">
<TEXTAREA NAME="txtComment" ROWS="5" COLS="30">(Please include negative and positive comments, ideas, and suggestions in this box. Your comments are for internal use only.)</TEXTAREA>
<BR>
<input type="submit" value=" Tell Us ">
</FORM>
</TD>
</TR>
</TABLE>
</CENTER>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -