コード例 #1
0
        //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();
        }
コード例 #2
0
 private void Status(int flags)
 {
     if (flags == 1)
     {
         db.SaveChanges();
     }
 }
コード例 #3
0
        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();
                }
            }
        }
コード例 #4
0
        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;
        }
コード例 #5
0
        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();
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        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();
        }