private void CheckOut_Click(object sender, RoutedEventArgs e) { Cash = Cash - SUM; CashDisplay.Text = Cash + " €"; //Receipt decimal VAT = (SUM / 100m) * 20m; Receipt.Text = " Total Sum : " + SUM + " €" + "\n VAT : " + VAT + " €" + " // 20 % " + "\n" + "\n" + "\n" + "\n" + "\n" + "\n ------------------------------" + "\n Thank you for your purchase"; // SUM = 0; ShoppingCart.Clear(); ShoppingCartListBox.Items.Refresh(); TotalSum.Clear(); }
private void BtnClick(object sender, RoutedEventArgs e) { if (Convert.ToString((sender as Button).Content) != "Rensa") { if (!int.TryParse(InputOne.Text, out int i) || !int.TryParse(InputTwo.Text, out int k)) { MessageBox.Show("Använd bara siffror tack."); InputOne.Clear(); InputTwo.Clear(); TotalSum.Clear(); } else { string a, b; int c; a = InputOne.Text; b = InputTwo.Text; c = Convert.ToInt32(a) + Convert.ToInt32(b); TotalSum.Text = Convert.ToString(c); } } else { InputOne.Clear(); InputTwo.Clear(); TotalSum.Clear(); } }
//REMOVE A PRODUCT FROM THE CART private void RemoveFromCart_Click(object sender, RoutedEventArgs e) { SUM = 0; ShoppingCart.Remove((Product)ShoppingCartListBox.SelectedItem); foreach (Product item in ShoppingCart) { var ItemSum = Int32.Parse(item.Price); SUM = SUM + ItemSum; TotalSum.Text = SUM.ToString() + " €"; } if (SUM <= 0) { TotalSum.Clear(); } ShoppingCartListBox.Items.Refresh(); }