Shopping car

xiaoxiao2021-03-06  64

<% '-------------------------- - 'ASP Shopping Car' ------------- Constant Definition ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ 'Define the cargo table. Keywords iDProductionTable = "Production"

'Define an order table, order illite table, order number field name ORDERTABLE = "Ordertable" ORDERID = "ORDERID" ORDERDETAILTABLE = "ORDERDETAIL" ------------- Constant definition end ----- -------------------------

'------------- Class definition ---------------------------------- - 'Shopping Cars' quoted LDB class LDCART

'---------------------------------' Private Function Part '--------- -------------------------------------------------------------------------------------------------------------------------------------------------- Code, the second means that the purchase quantity private cpcount 'Current merchandise of the product is private myQuery' query class private mydb 'data operation class private curruserid' current user code

Private function getinfobyid (id) 'Get cargo information according to the cargo number Return type to record set set getinfobyid = mydb.doselect ("SELECT *" & productionTable & "WHERE ID =" & id) End Function

Private function getUserInfobyid (userid) 'Get user information return type to record set myQuery.cols = "id" myQuery.types = "1" myQuery.values ​​= "= ##" & userid set mydb.ldQuery = myQuery mydb.tablename = " User "mydb.cols =" "mydb.neednumber = 1 set getInfobyid = mydb.getRecordset

End function '----------------------------------' Public function part '------- ----------------------------

Public Function Initial 'Initial Cart cpcount = 0 Curruserid = Session ("UserID") set myQuery = new ldquery set mydb = new ldb set mydb.ldquery = myQuery end function

Public Function AddItem (ID) 'According to the cargo ID, the number of goods is 1' return value = 0: Success 'return value = -1: The goods have been in the shopping cart' Return value = -2: Shopping cart is full if cpcount = 50 Then additem = -2 exit function end ifdim i, res for i = 0 to cpcount-1 if id = cplist (i, 0) Then addIn = -1 EXIT FUNCTION END IF NEXT

CPList (cpcount, 0) = ID CPLIST (cpcount, 1) = 1 cpcount = cpcount 1 additem = 0 end function public function removeItem (ID) 'According to the goods ID, the cargo' return value = 0: Success' return value = - 1: Cargo is not in the shopping cart J = -1 for i = 0 to cpcount-1 if cplist (i, 0) = ID THEN J = I end if next if j = -1 Then RemoveItem = -1 exit function endiff

For i = j to cpcount-1 cplist (i, 0) = CPLIST (i 1) = CPLIST (i 1, 1) Next CPLIST (cpcount, 0) = "" CPLIST ( Cpcount, 1) = 0

Cpcount = cpcount-1 removeItem = 0 End Function

Public Function DisplayCart 'Show Cart Response.write "
---------------------------------- -------------------
"Response.Write" Current User: "& Curruserid &" ---------------- ----------------------------------------
"if cpcount = 0 THEN Response .write "Shopping is empty!" Else for i = 1 To cpcount set currinfo = getInfobyid (CPLIST (i-1, 0)) Response.write "The goods code is:" & CPLIST (i-1, 0) & "name is : "& Currinfo (" MC ") &" Price is: "JG") & "Quantity is:" & CPLIST (I-1, 1) Response.write "
" Next Response.write "--- -------------------------------------------------- ---
"response.write" The total number of current goods is: "& cpcount &" || "" The current price of the current goods is: "& counttotalpay end if End function

Public Function UpdateCount (ID, Count) 'Change the number of items' return value = 0: Success 'return value = -1: Cargo is not in the shopping cart' Return value = -2: The number of changes is less than or equal to 0 if count <1 The updatecount = -2 exit function end if 'judgment, is it greater than or equal to 0 if not, return an error message - integer-2J = -1 for i = 0 to cpcount-1 if CPList (i, 0) = ID THEN J = I end if next if j = -1 the updatecount = -1 exit function end if 'Determined whether the goods you want to delete are already in the shopping cart, if not, return an error message-integer-1

CPList (j, 1) = count updatecount = 0 End function

Public Function CountTotalPay 'calculation total price' Return value: Total price Temptotal = 0 for i = 0 to cpcount-1 Temptotal = Temptotal GetInfobyid (CPList (i, 0)) ("JG") * CPLIST (i, 1) Next COUNTTOTALPAY = Temptotal End Function

Public Function ApplyOrder 'Submit Order' Return Value = 0: Success ZK = 1 'Discount ORDERID = Replace (LDFormator (NOW) & Curruserid, "-", "") ORDERID = Replace (ORDERID, "", "") OrderId = Replace (ORDERID, ":", "") mydb.tablename = Ordertable mydb.cols = "UserID | HJ | SJ | IP | YB | DZ | SJR | TEL | ORDERID" MyDb.Types = "1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 "MYDB.VALUES = CURRUSERID &" & COUNTTOALPAY & "& ldformatdatetime (now) &" & getuserip () & "& yb &" | & dz & "| & sjr &" | & Tel & "|" & Orderid mydb.add

MYDB.TABLENAME = OrderDetailTable mydb.cols = "ORDERID | CPID | count | zk" mydb.types = "0 | 0 | 1 | 1"

For i = 0 to cpcount-1 mydb.values ​​= ORDERID & "|" & CPList (i, 0) & "|" & cplist (i, 1) & "|" & zk mydb.add next ApplyOrder = 0 END FUNCTION

Public Function Clear 'Empty Shop Cart' Return Value = 0: Success for i = 1 To Cpcount CPlist (i-1, 0) = "" CPLIST (I-1, 1) = 0 Next Cpcount = 0 End FunctionPublic Function DeleteOrder OrderID) 'return value = 0: success MyQuery.Cols = "OrderID" MyQuery.Types = "0" MyQuery.Values ​​= "<##" & OrderID MyDB.TableName = OrderTable MyDB.Delete MyDB.TableName = OrderDetailTable MyDB.Delete DeleteOrder = 0 End functionend class' ------------- Class definition end -------------------------------------------------------------------------------------- ----

%>

转载请注明原文地址:https://www.9cbs.com/read-90107.html

New Post(0)