开发者

EXTRACT session element in sorted list

I have two sortedlists one stores product information and the other one stores services how can I use Session.Contents Collection to extract data in these two sortedlist thank you

code service sortedlist

Dim CartItemService As New CartItem
CartItemService.objService = objTempCartService
Me.AddToCart(CartItemService)

Private Sub AddToCart(ByVal CartItem As CartItem)
    Dim CartService As SortedList = GetCart()
    Dim ServiceID As Integer = objTempCartService.ServiceId

    Dim Servicekey As String = "s" & CType(ServiceID, String)
    If CartService.ContainsKey(Servicekey) Then
        CartItem = CType(CartService(Servicekey), CartItem)

    Else
        CartService.Add(Servicekey, CartItem)

    End If
End Sub

Private Function GetCart() As SortedList

    If Session("CartS") Is Nothing Then
        Session.Add("CartS", New SortedList)
    End If
    Return CType(Session("CartS"), SortedList)

End Function

product sortedlist

Dim CartItem As New CartItem
CartItem.objProduct = objTempCart
Me.AddToCart(CartItem)

Private Sub AddToCart(ByVal CartItem As CartItem)

    Dim Cart As SortedList = GetCart()
    Dim sProductID As Integer = objTempCart.ProductId
    Dim k As String = "P" & CType(sProductID, String)
    If Cart.ContainsKey(k) Then
        CartItem = CType(Cart(k), CartItem)
        CartItem.objProduct.OrderQty = CartItem.objProduct.OrderQty + 1
        CartItem.objProduct.Total = CartItem.objProduct.OrderQty * CartItem.objProduct.ProductPrice
    Else
        Cart.Add(k, CartItem)
        CartItem.objProduct.OrderQty = 1
        CartItem.objProduct.Total = CartItem.objProduct.OrderQty * CartItem.objProduct.ProductPrice

    End If
End Sub

Private Function GetCart() As SortedList

    If Session("Cart") Is Nothing Then
        Session.Add("Cart", New SortedList)
    End If
    Retur开发者_JAVA百科n CType(Session("Cart"), SortedList)
End Function
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜