コード例 #1
0
        private void PrintBill_Click(object sender, RoutedEventArgs e)
        {
            if (Project.Instance.Bill.FullPrice == 0)
            {
                MessageBox.Show("Bill cannot be empty", "Congratulations", MessageBoxButton.OK, MessageBoxImage.Information);
                this.Close();
            }

            if (IsValid() == false)
            {
                return;
            }
            Project.Instance.Bill.DateOfSale = DateTime.Now;
            Project.Instance.Bill.BillNo     = DateTime.Now.Millisecond;
            BillDAO.Create(Project.Instance.Bill);
            foreach (var b in Project.Instance.Bill.FurnitureForSaleList)
            {
                foreach (var f in Project.Instance.FurnitureList)
                {
                    if (f.ID == b.ID)
                    {
                        BillDAO.AddFurnitureOnBill(Project.Instance.Bill, f);
                        f.Quantity -= b.Quantity;
                        FurnitureDAO.Update(f);
                    }
                }
            }
            foreach (var b in Project.Instance.Bill.AdditionalServiceList)
            {
                foreach (var a in Project.Instance.AdditionalServicesList)
                {
                    BillDAO.AddAdditionalServiceOnBill(Project.Instance.Bill, a);
                }
            }
            MessageBox.Show("Success!", "Congratulations", MessageBoxButton.OK, MessageBoxImage.Information);
            Project.Instance.Bill = new Bill();

            MainWindow.DeleteSoldFurniture();
            this.Close();
        }