//Xoa cac bill chua thanh toan private void Window_Closed(object sender, EventArgs e) { CakeShop_dbEntities db = new CakeShop_dbEntities(); var bd = db.BillDetails.ToList(); foreach (var item in bd) { if (item.Bill.Payed == false) { db.BillDetails.Remove(item); db.SaveChanges(); } } var d = db.Bills.ToList(); foreach (var item in d) { if (item.Payed == false) { db.Bills.Remove(item); db.SaveChanges(); } } Application.Current.Shutdown(); }
private void Status(int flags) { if (flags == 1) { db.SaveChanges(); } }
private void BillDone(int flags) { if (flags == 1) { MessageBoxResult result = MessageBox.Show("Thanh toán thành công. Bạn có muốn tiếp tục mua sắm???", "Confirmation", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { CakeShop_dbEntities db = new CakeShop_dbEntities(); Bill bill = new Bill(); bill.Date = DateTime.Now; bill.Payed = false; InitializeComponent(); db.Bills.Add(bill); db.SaveChanges(); GridMain.Children.Clear(); TitleFunction.Text = "Trang chủ"; var screen = new UserControlTypes(); screen.Handler += Categories; GridMain.Children.Add(screen); } else { this.Close(); } } }
private void TotalCarts_Click(object sender, RoutedEventArgs e) { CakeShop_dbEntities db = new CakeShop_dbEntities(); var bills = db.Bills.ToList(); var currentBill = bills[bills.Count - 1]; currentBill.Payed = true; db.SaveChanges(); Handler?.Invoke(1); this.Visibility = Visibility.Collapsed; }
public MainWindow() { CakeShop_dbEntities db = new CakeShop_dbEntities(); Bill bill = new Bill(); bill.Date = DateTime.Now; bill.Payed = false; InitializeComponent(); db.Bills.Add(bill); db.SaveChanges(); var d = db.Bills.ToList(); }
private void Down_MouseLeftButtonUp(object sender, RoutedEventArgs e) { CakeShop_dbEntities db = new CakeShop_dbEntities(); var dtbill = db.BillDetails.ToList(); var selectedItem = BillDTG.SelectedItem as BillDetail; foreach (var item in dtbill) { if (item.CakeID == selectedItem.CakeID && item.IDBill == selectedItem.IDBill && selectedItem != null && item.Quantity > 0) { item.Quantity -= 1; item.Totality = item.Quantity * item.Cake.Price; } } db.SaveChanges(); Refresh(); }
private void DeleteBill_Click(object sender, RoutedEventArgs e) { //var item = BillDTG.SelectedItem as BillDetail; // //db.SaveChanges(); ////refresh //var Bills = db.BillDetails.ToList(); //BillDTG.ItemsSource = Bills; CakeShop_dbEntities db = new CakeShop_dbEntities(); var dtbill = db.BillDetails.ToList(); var selectedItem = BillDTG.SelectedItem as BillDetail; foreach (var item in dtbill) { if (item.CakeID == selectedItem.CakeID && item.IDBill == selectedItem.IDBill && selectedItem != null) { db.BillDetails.Remove(item); } } db.SaveChanges(); Refresh(); }