-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCart.aspx.cs
75 lines (68 loc) · 2.58 KB
/
Cart.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//AUTHOR: Kush Shah and Jeff Chien
//COURSE: ISYS 415-501
//FORM: Cart.aspx
//PURPOSE: The purpose of this form is to have the listbox load the quantity of product and its respective price
//INITIALIZE: When initialized, this form will retrieve information from the Order.aspx page that includes the product and quantity and concatenate it onto the listbox.
//INPUT: the information retrieved from the quantity textbox in the order page and the product that was queried.
//PROCESS: The process will be inputting this information into the database so that the customer may search for themselves and see the order inputted.
//OUTPUT: The order is outputted into the databse
//TERMINATE: There is no cleaning that needs to be done
//HONOR CODE: “On my honor, as an Aggie, I have neither given
// nor received unauthorized aid on this academic
// work.”
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WompomPizza
{
public partial class Cart1 : System.Web.UI.Page
{
private CartItemList cart;
protected void Page_Load(object sender, EventArgs e)
{
cart = CartItemList.GetCart();
if (!IsPostBack)
this.DisplayCart();
}
private void DisplayCart() //Displays the cart and lists the items in the cart
{
lstCart.Items.Clear();
CartItem item;
for (int i = 0; i < cart.Count; i++)
{
item = cart[i];
lstCart.Items.Add(item.Display());
}
}
protected void btnRemove_Click1(object sender, EventArgs e)
{
if (cart.Count > 0)
{
if (lstCart.SelectedIndex > -1)
{
cart.RemoveAt(lstCart.SelectedIndex);
this.DisplayCart();
}
else
{
lblMessage.Text = "Please select the item you want to remove.";
}
}
} //Removes the selection in the listbox
protected void btnEmpty_Click1(object sender, EventArgs e)
{
if (cart.Count > 0)
{
cart.Clear();
lstCart.Items.Clear();
}
} // Empty the listbox
protected void btnCheckOut_Click1(object sender, EventArgs e)
{
Response.Redirect("~/CheckOut.aspx");
} //Check out to purchase the pizza
}
}