Exemple #1
0
 private void AddButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (listBox.SelectedItem.GetType() != typeof(CustomOrder))
         {
             KeyValuePair <Product, int> productToAdd = (KeyValuePair <Product, int>)listBox.SelectedItem;
             DB.AddItemToCheckout(productToAdd.Key);
             listBox.ItemsSource = Current.GetCollection();
         }
     } catch { }
 }
Exemple #2
0
 public Checkout_Menu(Database data)
 {
     InitializeComponent();
     DB                  = data;
     Current             = DB.GetCurrentCheckout();
     listBox.ItemsSource = Current.GetCollection();
 }
Exemple #3
0
        private void CONFIRM_Click(object sender, RoutedEventArgs e)
        {
            FinalisingCheckout window = new FinalisingCheckout(DB);

            window.ShowDialog();

            if (window.DialogResult != null)
            {
                if ((bool)window.DialogResult)
                {
                    if (DB.GetCurrentCheckout().GetCustomOrders().Count > 0)
                    {
                        foreach (CustomOrder order in DB.GetCurrentCheckout().GetCustomOrders())
                        {
                            order.setIsPaid(true);
                        }
                    }

                    if (DB.GetCurrentCheckout().GetProducts().Count > 0)
                    {
                        foreach (KeyValuePair <Product, int> KVP in DB.GetCurrentCheckout().GetProducts())
                        {
                            KVP.Key.SubtractQuantity(DB.GetCurrentCheckout().GetProducts()[KVP.Key]);
                        }
                    }
                    DB.ClearCheckout();
                    Current             = DB.GetCurrentCheckout();
                    listBox.ItemsSource = Current.GetCollection();
                }
            }
        }
        public Checkout_Categorised(Database Database, string Category)
        {
            OldDB           = Database;
            DB              = Database;
            CurrentCheckout = DB.GetCurrentCheckout();
            InitializeComponent();
            Label.Content = Category;

            if (Category == "Custom Orders")
            {
                List <CustomOrder> CustomOrders = new List <CustomOrder>();
                foreach (CustomOrder custOrder in DB.GetListOfCustomOrders())
                {
                    if (!custOrder.getIsPaid() && custOrder.getActiveOrder())
                    {
                        CustomOrders.Add(custOrder);
                    }
                }
                listBoxItems.ItemsSource = CustomOrders;
            }
            else
            {
                List <Product> RawProducts = DB.GetListOfProducts();
                List <Product> Products    = new List <Product>();
                foreach (Product Product in RawProducts)
                {
                    if (Product.GetItemType() == Category)
                    {
                        Products.Add(Product);
                    }
                }
                listBoxItems.ItemsSource = Products;
            }

            listBoxCheckout.ItemsSource = CurrentCheckout.GetCollection();
            UpdateTotal();
        }
 private void Add_Click(object sender, RoutedEventArgs e)
 {
     DB.AddItemToCheckout(listBoxItems.SelectedItem);
     listBoxCheckout.ItemsSource = CurrentCheckout.GetCollection();
     UpdateTotal();
 }