SlideShare une entreprise Scribd logo
1  sur  1
Partial Class Cart 
Inherits System.Web.UI.Page 
Private cart As CartItemList 
Protected Sub Page_Load(ByVal sender As Object, 
ByVal e As System.EventArgs) Handles Me.Load 
cart = CartItemList.GetCart 
If Not IsPostBack Then 
Me.DisplayCart() 
End If 
End Sub 
Private Sub DisplayCart() 
lstCart.Items.Clear() 
Dim cartItem As CartItem 
For i = 0 To cart.Count - 1 
cartItem = cart(i) 
lstCart.Items.Add(cartItem.Display) 
Next 
End Sub 
Protected Sub btnRemove_Click(ByVal sender As Object, 
ByVal e As System.EventArgs) Handles btnRemove.Click 
If cart.Count > 0 Then 
If lstCart.SelectedIndex > -1 Then 
cart.RemoveAt(lstCart.SelectedIndex) 
Me.DisplayCart() 
lblMessage.Text = "" 
Else 
lblMessage.Text = "Please select the item you want to remove." 
End If 
Else 
lblMessage.Text = "" 
End If 
End Sub 
Protected Sub btnEmpty_Click(ByVal sender As Object, 
ByVal e As System.EventArgs) Handles btnEmpty.Click 
If cart.Count > 0 Then 
cart.Clear() 
lstCart.Items.Clear() 
End If 
lblMessage.Text = "" 
End Sub 
Protected Sub btnCheckOut_Click(ByVal sender As Object, 
ByVal e As System.EventArgs) Handles btnCheckOut.Click 
lblMessage.Text = "Sorry, that function hasn't been implemented yet." 
End Sub 
End Class

Contenu connexe

Tendances

Introduction to Backbone.js for Rails developers
Introduction to Backbone.js for Rails developersIntroduction to Backbone.js for Rails developers
Introduction to Backbone.js for Rails developers
AoteaStudios
 
Technical_Detail
Technical_DetailTechnical_Detail
Technical_Detail
rlondono
 

Tendances (10)

Data Binding - Android by Harin Trivedi
Data Binding - Android by Harin TrivediData Binding - Android by Harin Trivedi
Data Binding - Android by Harin Trivedi
 
Introduction to Backbone.js for Rails developers
Introduction to Backbone.js for Rails developersIntroduction to Backbone.js for Rails developers
Introduction to Backbone.js for Rails developers
 
Technical_Detail
Technical_DetailTechnical_Detail
Technical_Detail
 
Web storage
Web storageWeb storage
Web storage
 
ReRxSwift
ReRxSwiftReRxSwift
ReRxSwift
 
09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP
 
jQuery Behaviours
jQuery BehavioursjQuery Behaviours
jQuery Behaviours
 
Agile Data concept introduction
Agile Data   concept introductionAgile Data   concept introduction
Agile Data concept introduction
 
Grails Views
Grails ViewsGrails Views
Grails Views
 
Web technology javascript
Web technology   javascriptWeb technology   javascript
Web technology javascript
 

Cart Page Code

  • 1. Partial Class Cart Inherits System.Web.UI.Page Private cart As CartItemList Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load cart = CartItemList.GetCart If Not IsPostBack Then Me.DisplayCart() End If End Sub Private Sub DisplayCart() lstCart.Items.Clear() Dim cartItem As CartItem For i = 0 To cart.Count - 1 cartItem = cart(i) lstCart.Items.Add(cartItem.Display) Next End Sub Protected Sub btnRemove_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRemove.Click If cart.Count > 0 Then If lstCart.SelectedIndex > -1 Then cart.RemoveAt(lstCart.SelectedIndex) Me.DisplayCart() lblMessage.Text = "" Else lblMessage.Text = "Please select the item you want to remove." End If Else lblMessage.Text = "" End If End Sub Protected Sub btnEmpty_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEmpty.Click If cart.Count > 0 Then cart.Clear() lstCart.Items.Clear() End If lblMessage.Text = "" End Sub Protected Sub btnCheckOut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCheckOut.Click lblMessage.Text = "Sorry, that function hasn't been implemented yet." End Sub End Class