private void checkoutButton_Click(object sender, RoutedEventArgs e) { if (customMiniMenuBlockList.Count != 0) { OrderAccounting orderAccounting = new OrderAccounting(); CardLoyality card = new CardLoyality(); using (SQLiteConnection con = new SQLiteConnection(App.databasePath)) { card = con.Table <CardLoyality>().Where(x => x.CardLoyalityID == App.currentUser.CardLoyality) .FirstOrDefault(); } double costWithDiscount = CostCalculation.GetCostWithDiscount(card.Score); orderAccounting.Cost = costWithDiscount; orderAccounting.TableNumber = 99; // Need to fix orderAccounting.IsActive = true; orderAccounting.Date = DateTime.Now.ToString("dd/MM/yyyy"); string temp = String.Empty; string message = String.Empty; foreach (var dish in customMiniMenuBlockList) { card.Score += dish.Count; string buffer = dish.Dish.Name + "_" + dish.Count; string mbuffer = dish.Dish.Name + " кол-во " + dish.Count; if (temp == String.Empty) { temp = buffer; message = mbuffer; } else { temp += ", " + buffer; message += "\n" + mbuffer; } } orderAccounting.Dish = temp; message += "\n\n Цена cо скидкой: " + costWithDiscount + "руб."; var result = MessageBox.Show(message, "Заказ", MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { using (SQLiteConnection con = new SQLiteConnection(App.databasePath)) { ServiceHelper.Core.DataHandler.AddIncome(costWithDiscount); con.Insert(orderAccounting, typeof(OrderAccounting)); con.Update(card, typeof(CardLoyality)); } } } }
private void IssueDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { var selected = e.AddedItems; if (selected.Count > 0) { _selectedOrder = selected[0] as OrderAccounting; } }