shopping cart

zhaozj2021-02-16  53

Castclass.asp

<% Class Shopbag

'Space for the product Private ProSpace

'Product Information Number Private Itemscout

'==================================================== ============= ========================================================================================================================================================== ===========================

'Method: Putapro' parameter: A array of item information - PRODATA 'Role: Add a product into the shopping cart' Return value: 'Successfully put it in the product, return true' Products, return false public function Putapro ( BYREF PRODATA) 'Size:' Last DIM Size, Result, Flag Itemscout = Ubound (PRODATA) 'Product Information Number GetPro

If createSpace the 'has a product requires that there is a MYPRINT "There is a product that you need to detect whether the item exists" flag = checkproexists (pRODATA (0)) Else flag = false' shopping cart No product MyPrint "Endix

IF not flag dam

Size = ubound (prosphere)

For i = 0 to Itemscout Prospace (size, i) = PRODATA (i) Next MyPrint "Add a product ....
" SavePro Result = true else result = false endiff

Putapro = result end function '-------------------------------------------- -

'Get all goods public function getAllPro (Byref Prolist) ProList = session ("proid") end function' ---------------------------- ------------------

'Update Product Number PUBLIC FUNCTION UpdatePro (Byref Pronumlist)

Dim pronumdata getpro pronumdata = split (pronumlist, ") for i = 0 to Ubound (pronumdata) Prospace (i, 3) = CINT (Trim (pronumdata (i))) Next SavePro myprint" Updated all items " END FUNCTION

'Delete a product public function deleteapro (id) MyPrint "Prepare to delete a product" DIM Count GetPro Count = Ubound (prosphere) if count = 0 Then MyPrint "The product is already the last one, set the session" Session "Session" Session ("ProID ") = NULL ELSE Redim Tempar (count-1, 3) MyPrint" Start Finding Product IDs To Delete ... "for i = 0 To Count if Cint (ProSpace (i, 0)) = CINT (ID) THEN MyPrint "Find ID, delete!" For j = i to count-1 proospace (j, 0) = prospace (j 1) = prospace (j 1) = prospace (j 1, 1) Prospace (j, 2 ) = Prospace (j 1, 2) Prospace (j, 3) = prospace (j 1, 3) Next

EXIT for end if next

For i = 0 to count-1 Tempar (i, 0) = prospace (i, 0) Tempar (i, 1) = prospace (i, 1) Tempar (i, 2) = prospace (i, 2) Tempar (i , 3) = Prospace (i, 3) Next session ("proID") = Tempar end if end function '-------------------------- ------------------- 'Get a list of information from the product, Separate PUBLIC FUNCTION GETPROLIST (N) Dim Result GetPro if Isnull (ProSpace) Then Result = NULL ELSE For i = 0 to Ubound (prospace) if i = 0 Then Result = results (i, n) else result = result & "& proprospace (i, n) end if next end f killme getProlist = result end function

'==================================================== ================================================== ================================== 私 有 ============== ============================================================================================================================================================================================================= == 'Detecting whether the item already exists' presence or returning true' does not exist returning false private function checkproexists (proid) MYPRINT "Detection Products?
" Dim Result RESULT = FALSE

For i = 0 to Ubound (prospace) if cint (ProSpace (i, 0)) = cint (proid) THEN Result = true end if next checkproexists = result end function '------------- -----------------------------------

'Role:' Space for deposit of items 'Return value:' New Size Return False 'Reconstruction Space Size Return true Private Function CreateSpace () Dim Result MyPrint "Start opening space ...
"' Resize: Space size Dim Resize

'Calculation requires space size if isarray (prosphere) THEN' already available MYPRINT "existing space, you need to reconstruct space size!
" Resize = ubound (prosphere) 1 myredim prkece, resize result = true myprint " Constited space size = 1 ...
"else redim procace (0, itemscout) result = false myprint" no space, open! ...
"End if createSpace = Result End function" --- ------------------------------------------ 'Reconstruction of an array private function Myredim (Byref AARRAY, BYVAL SIZE) MyPrint "Start Reconstruction Space Size ...
" Redim TmpArray (Size, Itemscout) 'Backup Information for i = 0 To Ubound (AARRAY) for J = 0 To Itemscout TmpArray (i , J), AARRAY (I, J) Next Next Redim AARRAY (SIZE, ITEMSCOUT) 'Restore Information for J = 0 To Ubound (TmpArray) for K = 0 To Itemscout AARRAY (J, K) = TMPARRAY (J, K) Next Next NEXT

End function '-----------------------------------------------

'Save Products Private Function SavePro Session ("ProID") = procace myprint "Saves shopping cart ....
" Killme MyPrint "released space.
" End function "-------- -------------------------------------- From Session PRIVATE FUNCTION GETPRO PROCE = Session ("ProID") MyPrint "puts the goods in the session into the shopping cart ...
" end function "---------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------

'Release space private function killme prospace = null end function' -------------------------------------- -------- End Class%>

use:

<%

'Display operation process Function MyPrint (STR) Response.write Strend Function

DIM ASHOWBAG, PRODATA, PROLIST

PRODATA = Array (1, "Proname", "ProPrice", "pronum")

SET ASHOWBAG = New ShopbagState = ashowbag.putapro (prodata) 'Put a product prodata = null ashowbag.getallPro ProList

If State Ten Response.write "Add a product
" Else Response.write "" End ifset showbag = Nothing "

If ISARRAY (PROLIST) THEN for i = 0 To Ubound (Prolist) for j = 0 to 3 Response.write Prolist (i, j) & "==" next response.write "
======= =====
"NEXTELSERESPONSE.WRITE" No Product "end if

%>

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

New Post(0)