//private PaymentForm paymentForm = new PaymentForm(); private void SoupQtyTextBox_TextChanged(object sender, EventArgs e) { int numOutput; SoupQtyUp.Enabled = !(Inventory.Items["Soup"].NumberInStock == 0); if (int.TryParse(SoupQtyTextBox.Text, out numOutput)) { if (Inventory.Items["Soup"].NumberInStock == 0) { SoupQtyTextBox.Text = SoupQtyTextBox.Text; } } else { SoupQtyTextBox.Text = "0"; } SubtotalTextBox.Text = CheckoutCart.CalculateSubtotal().ToString("#,###.00"); }
private void QtyDown_Click(object sender, EventArgs e) { int i; if (sender is Control) { Control controlRef = sender as Control; if (int.TryParse(SoupQtyTextBox.Text.Trim(), out i) && i > 0) { SoupQtyTextBox.Text = (--i).ToString(); } if (Inventory.Items[controlRef.Tag.ToString()].NumberInStock == 1) { controlRef.Enabled = true; } Inventory.ReturnItems(controlRef.Tag.ToString()); for (int j = 0; j < listBox1.Items.Count; j++) { if (listBox1.Items[j] is Product && (listBox1.Items[j] as Product).Name == controlRef.Tag.ToString()) { (listBox1.Items[j] as Product).NumberInStock--; //listBox1.Invalidate(listBox1.GetItemRectangle(j)); listBox1.Items[j] = listBox1.Items[j]; if ((listBox1.Items[j] as Product).NumberInStock == 0) { listBox1.Items.RemoveAt(j); } UpdateListboxItems(); SubtotalTextBox.Text = CheckoutCart.CalculateSubtotal().ToString("C"); TaxTextBox.Text = PointOfSaleRepository.SalesTaxAmount.ToString("C"); break; } } } UpdateTotals(); UpdateListboxItems(); }
private void UpdateTotals() { SubtotalTextBox.Text = CheckoutCart.CalculateSubtotal().ToString("C"); TaxTextBox.Text = PointOfSaleRepository.SalesTaxAmount.ToString("C"); TotalTextBox.Text = PointOfSaleRepository.Total.ToString("C"); }