(
<Serializable()> _
Public Class WroxShoppingCart
Private _dateCreated As DateTime
Private _lastUpdate As DateTime
Private _items As List(Of CartItem)
Public Sub New()
_items = New List(Of CartItem)
_dateCreated = DateTime
End Sub
Public Property Items() As List(Of CartItem)
Get
Return _items
End Get
Set(ByVal value As List(Of CartItem))
_items = value
End Set
End Property
Public Sub Insert(ByVal ProductID As Integer
Dim ItemIndex As Integer = ItemIndexOfID(ProductID)
If ItemIndex =
Dim NewItem As New CartItem()
NewItem
NewItem
NewItem
NewItem
NewItem
_items
Else
_items(ItemIndex)
End If
_lastUpdate = DateTime
End Sub
Public Sub Update(ByVal RowID As Integer
Dim Item As CartItem = _items(RowID)
Item
Item
Item
_lastUpdate = DateTime
End Sub
Private Function ItemIndexOfID(ByVal ProductID As Integer) As Integer
Dim index As Integer
For Each item As CartItem In _items
If item
Return index
End If
index +=
Next
Return
End Function
Public Sub DeleteItem(ByVal rowID As Integer)
_items
_lastUpdate = DateTime
End Sub
Public ReadOnly Property Total() As Double
Get
Dim t As Double
If _items Is Nothing Then
Return
End If
For Each Item As CartItem In _items
t += Item
Next
Return t
End Get
End Property
End Class
(
[
From:http://tw.wingwit.com/Article/program/net/201311/15596.html