public void AddAddon(Item item, AddOns add) { item.ItemAddons.Add(add); SubTotal += add.addonPrice; AddedTax += add.addonPrice * TAX_RATE; TotalPrice = SubTotal + AddedTax; }
public void Mod1_Click(object sender, RoutedEventArgs e) { AddOns newAddon = new AddOns(); newAddon.addonName = ((Button)sender).Content.ToString(); updatePrice(); try { using StreamReader sr = new StreamReader("../../../Prices/Prices.txt"); while (!sr.EndOfStream) { string line = sr.ReadLine(); String[] itemInfo = line.Split('\t'); String itemName = ""; String itemPrice = ""; String itemCategory = ""; if (line.Length > 0) { itemName = itemInfo[0]; itemPrice = itemInfo[1]; itemCategory = itemInfo[2]; if (newAddon.addonName.Equals(((Button)sender).Content.ToString())) { newAddon.addonPrice = Convert.ToDouble(itemPrice); } newAddon.addonCategory = itemCategory; } } } catch (IOException ex) { MessageBox.Show("Error reading employee file\n" + ex.Message); } StackPanel S; foreach (Item i in o.OrderItems) { if (i.B.Child.IsFocused) { S = i.B.Child as StackPanel; TextBox T = createBox(String.Format("{0, -10} {1,5} ", " +" + newAddon.addonName, ("\t$" + newAddon.addonPrice.ToString("0.00")))); o.AddAddon(i, newAddon); S.Children.Add(T); } } Subtotal.Content = "Subtotal: $" + o.GetSubtotal(); Taxes.Content = "Tax: $" + o.GetTax(); Total.Content = "Total: $" + o.GetTotalPrice(); }