Example #1
0
        private void CheckBox_IsChecked(object sender, RoutedEventArgs e)
        {
            CheckBox      box  = (CheckBox)sender;
            BasketProduct item = (BasketProduct)box.Tag;

            if (box.IsChecked == true)
            {
                item.IsChecked = true;
            }
            else
            {
                item.IsChecked = false;
            }
        }
Example #2
0
        public void SendToBasket(string name, int amount, int price)
        {
            BasketProduct basketItem = new BasketProduct()
            {
                Name      = name,
                Amount    = amount,
                Price     = price,
                IsChecked = false
            };

            if (basketItemsList.Exists(a => a.Name == name))
            {
                BasketProduct existProduct = basketItemsList.Where(a => a.Name == name).Select(a => a).FirstOrDefault();
                existProduct.Amount += amount;
                existProduct.Price  += price;
            }
            else
            {
                basketItemsList.Add(basketItem);
            }

            ShowBasketItems();
        }
Example #3
0
        public void ReadSavedBasket()
        {
            if (File.Exists(savedBasketPath))
            {
                readBasketArray = File.ReadAllLines(savedBasketPath);

                if (readBasketArray.Length > 0)
                {
                    foreach (var item in readBasketArray)
                    {
                        string[] temp = item.Split(',');

                        BasketProduct basketItem = new BasketProduct();

                        basketItem.Name      = temp[0];
                        basketItem.Amount    = int.Parse(temp[1]);
                        basketItem.Price     = int.Parse(temp[2]);
                        basketItem.IsChecked = false;
                        basketItemsList.Add(basketItem);
                    }
                    ShowBasketItems();
                }
            }
        }