📄 reacsh.asp
字号:
for (iCol=0; iCol<this.numCols; iCol++) {
tmpSC[iCol][iDest] = this.SC[iCol][iRow];
}
iDest++;
}
}
this.SC = tmpSC;
this.persist();
}
function UCGetColNamesSerial(colDelim) {
var serialCols = "";
for (var iCol=0; iCol<this.numCols; iCol++) {
if (iCol != 0) serialCols += colDelim;
serialCols += this.colNames[iCol];
}
return serialCols;
}
function UCGetContentsSerial(colDelim, rowDelim) {
var serialCart = "";
for (var iRow=0; iRow<this.GetItemCount(); iRow++) {
if (iRow != 0) serialCart += rowDelim
for (var iCol=0; iCol<this.numCols; iCol++) {
if (iCol != 0) serialCart += colDelim;
serialCart += this.SC[iCol][iRow];
}
}
return serialCart;
}
function UCSetContentsSerial(serialCart, colDelim, rowDelim) {
var Rows = String(serialCart).split(rowDelim)
for (iRow = 0; iRow < Rows.length; iRow++) {
if (Rows[iRow] != "undefined" && Rows[iRow] != "") {
Cols = Rows[iRow].split(colDelim)
iCol = 0
for (iCol = 0; iCol<Cols.length; iCol++) {
this.SC[iCol][iRow] = Cols[iCol]
}
}
}
this.persist();
}
function SetCookie(){
var cookieName = this.GetCookieName()
var cookieStr = this.GetContentsSerial(this.cookieColDel, this.cookieRowDel)
var cookieExp = GetCookieExp(this.cookieLifetime)
Response.Cookies(cookieName) = cookieStr
Response.Cookies(cookieName).expires = cookieExp
}
function GetCookieName(){
var server = Request.ServerVariables("SERVER_NAME");
return server + this.Name;
}
function UCDestroyCookie(){
cookieName = this.GetCookieName();
Response.Cookies(cookieName) = ""
Response.Cookies(cookieName).expires = "1/1/90"
}
function PopulateFromCookie(cookieStr){
this.SetContentsSerial(cookieStr, this.cookieColDel, this.cookieRowDel)
}
// ***************** debug code ********************
function assert(bool, msg) {
if (!bool) {
Response.Write("<BR><BR>An error occured in the UltraDev shopping cart:<BR>" + msg + "<BR>");
//Response.End();
}
}
function AssertCartValid(colNames, msg) {
// go through all cart data structures and insure consistency.
// For example all column arrays should be the same length.
// this function should be called often, especially just after
// makeing changes to the data structures (adding, deleting, etc.)
// also verify we always have the required columns:
// ProductID, Quantity, Price, Total
// the input arg is some I add as I code this package like
// "Prior to return from AddToCart"
//
var ERR_COOKIE_SETTINGS = "Cookie settings on this page are inconsistent with those stored in the session cart<BR>";
var ERR_BAD_NAME = "Cart name defined on this page is inconsistent with the cart name stored in the session<BR>";
var ERR_COLUMN_COUNT = "The number of cart columns defined on this page is inconsistent with the cart stored in the session<BR>";
var ERR_REQUIRED_COLUMNS = "Too few columns; minimum number of columns is 4<BR>";
var ERR_REQUIRED_COLUMN_NAME = "Required Column is missing or at the wrong offset: ";
var ERR_COLUMN_NAMES = "Cart column names defined on this page are inconsistent with the cart stored in the session";
var ERR_INCONSISTENT_ARRAY_LENGTH = "Length of the arrays passed to cart constructor are inconsistent<BR>"
var errMsg = "";
var sessCart = Session(this.Name);
if (sessCart != null) { // Validate inputs against session cart if it exists
if (sessCart.Name != this.Name) errMsg += ERR_BAD_NAME;
if (this.numCols < 4) errMsg += ERR_REQUIRED_COLUMNS;
if (sessCart.numCols != this.numCols) errMsg += "Column Name Array: " + ERR_COLUMN_COUNT;
if (sessCart.numCols != this.colComputed.length) errMsg += "Computed Column Array: " + ERR_COLUMN_COUNT;
if (sessCart.bStoreCookie != this.bStoreCookie) errMsg += "Using Cookies: " + ERR_COOKIE_SETTINGS;
if (sessCart.cookieLifetime != this.cookieLifetime) errMsg += "Cookie Lifetime: " + ERR_COOKIE_SETTINGS;
// check that required columns are in the same place
var productIndex = this.GetIndexOfColName(this.PRODUCTID);
var quantityIndex = this.GetIndexOfColName(this.QUANTITY);
var priceIndex = this.GetIndexOfColName(this.PRICE);
var totalIndex = this.GetIndexOfColName(this.TOTAL);
if (colNames[productIndex] != "ProductID") errMsg += ERR_REQUIRED_COLUMN_NAME + "ProductID<BR>";
if (colNames[quantityIndex] != "Quantity") errMsg += ERR_REQUIRED_COLUMN_NAME + "Quantity<BR>";
if (colNames[priceIndex] != "Price") errMsg += ERR_REQUIRED_COLUMN_NAME + "Price<BR>";
if (colNames[totalIndex] != "Total") errMsg += ERR_REQUIRED_COLUMN_NAME + "Total<BR>";
}
else { // if cart doesn't exist in session, validate input array lengths and presence of reqiured columns
if (this.numCols != this.colComputed.length) errMsg += ERR_INCONSISTENT_ARRAY_LENGTH;
var bProductID = false, bQuantity = false, bPrice = false, bTotal = false;
for (var j = 0; j < colNames.length; j++) {
if (colNames[j] == "ProductID") bProductID = true;
if (colNames[j] == "Quantity") bQuantity= true;
if (colNames[j] == "Price") bPrice = true;
if (colNames[j] == "Total") bTotal = true;
}
if (!bProductID) errMsg += ERR_REQUIRED_COLUMN_NAME + "ProductID<BR>";
if (!bQuantity) errMsg += ERR_REQUIRED_COLUMN_NAME + "Quantity<BR>";
if (!bPrice) errMsg += ERR_REQUIRED_COLUMN_NAME + "Price<BR>";
if (!bTotal) errMsg += ERR_REQUIRED_COLUMN_NAME + "Total<BR>";
}
if (errMsg != "") {
Response.Write(msg + "<BR>");
Response.Write(errMsg + "<BR>");
Response.End();
}
}
function VBConstuctCart(Name, cookieLifetime, vbArrColNames, vbArrColComputed){
var myObj;
var a = new VBArray(vbArrColNames);
var b = new VBArray(vbArrColComputed);
eval("myObj = new UC_ShoppingCart(Name, cookieLifetime, a.toArray(), b.toArray())");
return myObj;
}
</SCRIPT>
<SCRIPT LANGUAGE=vbscript runat=server NAME="UC_CART">
Function GetCookieExp(expDays)
vDate = DateAdd("d", CInt(expDays), Now())
GetCookieExp = CStr(vDate)
End Function
</SCRIPT>
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT NAME="UC_CART">
function DoNumber(str, nDigitsAfterDecimal, nLeadingDigit, nUseParensForNeg, nGroupDigits)
DoNumber = FormatNumber(str, nDigitsAfterDecimal, nLeadingDigit, nUseParensForNeg, nGroupDigits)
End Function
function DoCurrency(str, nDigitsAfterDecimal, nLeadingDigit, nUseParensForNeg, nGroupDigits)
DoCurrency = FormatCurrency(str, nDigitsAfterDecimal, nLeadingDigit, nUseParensForNeg, nGroupDigits)
End Function
function DoDateTime(str, nNamedFormat, nLCID)
dim strRet
dim nOldLCID
strRet = str
If (nLCID > -1) Then
oldLCID = Session.LCID
End If
On Error Resume Next
If (nLCID > -1) Then
Session.LCID = nLCID
End If
If ((nLCID < 0) Or (Session.LCID = nLCID)) Then
strRet = FormatDateTime(str, nNamedFormat)
End If
If (nLCID > -1) Then
Session.LCID = oldLCID
End If
DoDateTime = strRet
End Function
function DoPercent(str, nDigitsAfterDecimal, nLeadingDigit, nUseParensForNeg, nGroupDigits)
DoPercent = FormatPercent(str, nDigitsAfterDecimal, nLeadingDigit, nUseParensForNeg, nGroupDigits)
End Function
function DoTrim(str, side)
dim strRet
strRet = str
If (side = "left") Then
strRet = LTrim(str)
ElseIf (side = "right") Then
strRet = RTrim(str)
Else
strRet = Trim(str)
End If
DoTrim = strRet
End Function
</SCRIPT>
<%
UC_CartColNames=Array("ProductID","Quantity","productName","Price","totalweight","weight","Total")
UC_ComputedCols=Array("","","","","weight","","Price")
set UCCart1=VBConstuctCart("UCCart",2,UC_CartColNames,UC_ComputedCols)
UCCart1__i=0
%>
<%
Dim product__MMColParam
product__MMColParam = "%"
if (Request.QueryString("title") <> "") then product__MMColParam = Request.QueryString("title")
%>
<%
Dim product__vproductid
product__vproductid = "%"
if (Request.QueryString("productid") <> "") then product__vproductid = Request.QueryString("productid")
%>
<%
Dim product__vdazhe
product__vdazhe = "1"
if (Request.QueryString("dazhe") <> "") then product__vdazhe = Request.QueryString("dazhe")
%>
<%
Dim product__vtuijian
product__vtuijian = "1"
if (Request.QueryString("tuijian") <> "") then product__vtuijian = Request.QueryString("tuijian")
%>
<%
Dim product__vbclassid
product__vbclassid = "%"
if (Request.QueryString("classid") <> "") then product__vbclassid = Request.QueryString("classid")
%>
<%
Dim product__vsclassid
product__vsclassid = "%"
if (Request.QueryString("Nclassid") <> "") then product__vsclassid = Request.QueryString("Nclassid")
%>
<%
Dim product__vchangshang
product__vchangshang = "%"
if (Request.QueryString("changshang") <> "") then product__vchangshang = Request.QueryString("changshang")
%>
<%
Dim product__varxprice
product__varxprice = "1"
if (Request.QueryString("xprice") <> "") then product__varxprice = Request.QueryString("xprice")
%>
<%
set product = Server.CreateObject("ADODB.Recordset")
product.ActiveConnection = MM_conn_STRING
product.Source = "SELECT * FROM product WHERE productname LIKE '%" + Replace(product__MMColParam, "'", "''") + "%' and productid like '%" + Replace(product__vproductid, "'", "''") + "' and " + Replace(product__vdazhe, "'", "''") + " and " + Replace(product__vtuijian, "'", "''") + " and bclassid like '%" + Replace(product__vbclassid, "'", "''") + "' and sclassid like '%" + Replace(product__vsclassid, "'", "''") + "' and changshang like '%" + Replace(product__vchangshang, "'", "''") + "' and " + Replace(product__varxprice, "'", "''") + ""
product.CursorType = 0
product.CursorLocation = 2
product.LockType = 3
product.Open()
product_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = 4
Dim Repeat1__index
Repeat1__index = 0
product_numRows = product_numRows + Repeat1__numRows
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
' set the record count
product_total = product.RecordCount
' set the number of rows displayed on this page
If (product_numRows < 0) Then
product_numRows = product_total
Elseif (product_numRows = 0) Then
product_numRows = 1
End If
' set the first and last displayed record
product_first = 1
product_last = product_first + product_numRows - 1
' if we have the correct record count, check the other stats
If (product_total <> -1) Then
If (product_first > product_total) Then product_first = product_total
If (product_last > product_total) Then product_last = product_total
If (product_numRows > product_total) Then product_numRows = product_total
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them
If (product_total = -1) Then
' count the total records by iterating through the recordset
product_total=0
While (Not product.EOF)
product_total = product_total + 1
product.MoveNext
Wend
' reset the cursor to the beginning
If (product.CursorType > 0) Then
product.MoveFirst
Else
product.Requery
End If
' set the number of rows displayed on this page
If (product_numRows < 0 Or product_numRows > product_total) Then
product_numRows = product_total
End If
' set the first and last displayed record
product_first = 1
product_last = product_first + product_numRows - 1
If (product_first > product_total) Then product_first = product_total
If (product_last > product_total) Then product_last = product_total
End If
%>
<%
' *** Move To Record and Go To Record: declare variables
Set MM_rs = product
MM_rsCount = product_total
MM_size = product_numRows
MM_uniqueCol = ""
MM_paramName = ""
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If
%>
<%
' *** Move To Record: handle 'index' or 'offset' parameter
if (Not MM_paramIsDefined And MM_rsCount <> 0) then
' use index parameter if defined, otherwise use offset parameter
r = Request.QueryString("index")
If r = "" Then r = Request.QueryString("offset")
If r <> "" Then MM_offset = Int(r)
' if we have a record count, check if we are past the end of the recordset
If (MM_rsCount <> -1) Then
If (MM_offset >= MM_rsCount Or MM_offset = -1) Then ' past end or move last
If ((MM_rsCount Mod MM_size) > 0) Then ' last page not a full repeat region
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If
' move the cursor to the selected record
i = 0
While ((Not MM_rs.EOF) And (i < MM_offset Or MM_offset = -1))
MM_rs.MoveNext
i = i + 1
Wend
If (MM_rs.EOF) Then MM_offset = i ' set MM_offset to the last possible record
End If
%>
<%
' *** Add item to UC Shopping cart
set UC_rs=product
UC_uniqueCol="productid"
UC_AddLink=""
If (Request.QueryString = "") Then
UC_AddLink = Request.ServerVariables("URL") & "?UC_AddId="
Else
UC_AddLink = Request.ServerVariables("URL") & "?" & Request.QueryString & "&UC_AddId="
End If
UC_AddId = CStr(Request("UC_AddId"))
If (UC_AddId <> "") Then
UC_redirectPage = ""
If (NOT (UC_rs is Nothing)) Then
' Position recordset to correct location
If (UC_rs.Fields.Item(UC_uniqueCol).Value <> UC_AddId) Then
' reset the cursor to the beginning
If (UC_rs.CursorType > 0) Then
If (Not UC_rs.BOF) Then UC_rs.MoveFirst
Else
UC_rs.Close
UC_rs.Open
End If
Do While (Not UC_rs.EOF)
If (Cstr(UC_rs.Fields.Item(UC_uniqueCol).Value) = UC_AddId) Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -