internal RekordClass Add(BaseCoffe coffeToMake, int quant) { var rek = new RekordClass(); rek.orderedCoffe = coffeToMake; rek.quantinity = quant; rek.singlePrice = rek.orderedCoffe.GetPrice(); rek.orderPrice = rek.singlePrice * rek.quantinity; rek.timeToServe = rek.orderedCoffe.GetTimeToReady() * rek.quantinity; rek.rekordNumber = rekordNumber++; rekordList.Add(rek); return(rek); }
private void btnAddToBill_Click(object sender, RoutedEventArgs e) { SelUnselButton(sender as Button); BaseCoffe coffeToMake; var baseCoffe = CheckEnableButtonInStcp(stcpCoffeSize); if (!baseCoffe.status) { return; } Bartender.CreateBill(); var addOnCoffe = CheckEnableButtonInStcp(stcpAddMenu); switch (baseCoffe.controls[0]) { case Button btn when btn.Name == "btnSmallCoffe": coffeToMake = new SmallCofee(); break; case Button btn when btn.Name == "btnMediumCoffe": coffeToMake = new MediumCofee(); break; case Button btn when btn.Name == "btnBigCoffe": coffeToMake = new BigCofee(); break; default: coffeToMake = null; return; } if (addOnCoffe.status) { foreach (var item in addOnCoffe.controls) { switch (item) { case Button btn when btn.Name.Contains("Milk"): coffeToMake = new CoffeWithMilk(coffeToMake); break; case Button btn when btn.Name.Contains("Cardamon"): coffeToMake = new CoffeWithCardamone(coffeToMake); break; case Button btn when btn.Name.Contains("Whisky"): coffeToMake = new CoffeWithWhisky(coffeToMake); break; case Button btn when btn.Name.Contains("IceCream"): coffeToMake = new CoffeWithIceCream(coffeToMake); break; default: coffeToMake = null; return; } } } RekordClass dataToDisplay = Bartender.AddItemToBill(coffeToMake, int.Parse(txbOuantinity.Text)); var line1 = new StackPanel(); line1.Orientation = Orientation.Vertical; line1.HorizontalAlignment = HorizontalAlignment.Stretch; var txblName1 = new TextBlock(); txblName1.HorizontalAlignment = HorizontalAlignment.Stretch; var txblName2 = new TextBlock(); txblName2.HorizontalAlignment = HorizontalAlignment.Stretch; var txblName3 = new TextBlock(); txblName3.HorizontalAlignment = HorizontalAlignment.Stretch; txblName1.Text = $"{dataToDisplay.orderedCoffe.GetName()}"; txblName2.Text = $"{dataToDisplay.quantinity} x {dataToDisplay.singlePrice}"; txblName3.Text = $"summary: {dataToDisplay.orderPrice}$ - time: {dataToDisplay.timeToServe} sek."; line1.Children.Add(txblName1); line1.Children.Add(txblName2); line1.Children.Add(txblName3); lstvOrders.Items.Add(line1); SelUnselButton(sender as Button); txbOuantinity.Text = "1"; DisableButtons(); }