View Single Post
  #5 (permalink)  
Old July 1st, 2009, 02:18 PM
hdpark hdpark is offline
Authorized User
Points: 115, Level: 2
Points: 115, Level: 2 Points: 115, Level: 2 Points: 115, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2007
Location: , , .
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Shopping Cart Crossing Over

Hi Imar,

I modifed it for my application as follows:
1. Display many items on the screen (Default.aspx).
2. Enter multiple items' Quantity
3. Add to Cart
4. Continue Shopping then Goto 1.

A. To do this, I used array to enter multiple items' quantity. I placed this array under App_Code as Class. Does this make Crossing Over problem?

B. I moved this array from App_Code Class to Default.aspx where I display mutiple items. Is this safe and right then?

I attached codes below:

Public Shared Quantities(500, 4) As Integer '0:index, 1:quantity, 2:prodid, 3:errormask
Public Shared dliRowCount, dliQuantity As Integer

.
.
Protected Sub btnAddAll_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles btnAddAll.Click
Dim i As Integer
Dim j As Integer = dliRowCount - 1
Dim errMessage As String = ""
For i = 0 To j
If Quantities(i, 3) Then 'Is ever set Error mark?
errMessage = errMessage & Titles(i, 0) & ", "
End If
Next
If errMessage <> ""Then
lblResults.Text = " Over-quantities in items " & Left(errMessage, Len(errMessage) - 2) & ". Please correct Quantities!!!"
Else
For i = 0 To dliRowCount - 1
If Quantities(i, 1) > 0 Then 'Add Product when Quantity > 0
Dim myProduct As Product = ShopManager.GetProduct(Quantities(i, 2))
For j = 0 To Quantities(i, 1) - 1 'Add upto Quantity or Available
ShopManager.AddProductToCart(myProduct)
Next j
End If
Next
Response.Redirect("~/Shop/ShoppingCart.aspx")
End If
End Sub


Thanks Imar,
HD

Last edited by hdpark : July 1st, 2009 at 02:21 PM.
Reply With Quote