public void changeQuantityInCart(object sender, EventArgs e) { Button button = (Button)sender; int id = Convert.ToInt32(button.Tag.ToString()); String operation = button.Text.ToString(); int i = 0; Boolean found = false; while (!found) { SaleItem item = cart[i]; if (item.getId() == id) { if (operation == "+") { item.incrementQuantity(); } else { item.decrementQuantity(); } found = true; } i++; } generateCart(); }
private Boolean cartHasItem(SaleItem cartItem) { int i = 0; while (i < cart.Count) { SaleItem item = cart[i]; if (item.getId() == cartItem.getId()) { item.incrementQuantity(); return(true); } i++; } return(false); }