示例#1
0
        public static void AddToList(string listName, decimal price)
        {
            MainPanelForm MP = new MainPanelForm();

            switch (listName)
            {
            case "Red Apple":
                MP.RedApplesList.Enqueue(price);
                break;

            case "Beans":
                MP.BeansStockList.Enqueue(price);
                break;

            case "Fruit Cocktail":
                MP.FruitCocktailList.Enqueue(price);
                break;

            case "Ravoili":
                MP.RavioliList.Enqueue(price);
                break;

            case "Lettuce":
                MP.LettuceList.Enqueue(price);
                break;

            case "Frozen Pizza":
                MP.FrozenPizzaList.Enqueue(price);
                break;

            case "Chicken Dinner":
                MP.ChickenDinnerList.Enqueue(price);
                break;

            case "Bananas":
                MP.BananaList.Enqueue(price);
                break;

            case "Chicken Breast":
                MP.ChickenBreastList.Enqueue(price);
                break;

            case "Salmon":
                MP.SalmonList.Enqueue(price);
                break;

            case "Chuck Roast Cut":
                MP.ChuckRoastList.Enqueue(price);
                break;

            case "Ice Cream":
                MP.IceCreamList.Enqueue(price);
                break;
            }
        }
示例#2
0
 /// <summary>
 /// Adds an item into the users cart.
 /// </summary>
 /// <param name="inventoryItem">The list where we will get the item to add</param>
 /// <param name="name">Name of the item</param>
 public void AddToCart(ConcurrentQueue <decimal> inventoryItem, String name)
 {
     // If items inventory is empty
     if (inventoryItem.Count == 0)
     {
         MessageBox.Show("Out of stock");
     }
     // Item has more inventory
     else
     {
         MainPanelForm MP = new MainPanelForm();
         inventoryItem.TryPeek(out decimal price);    // Gets the price from the list
         MP.ItemList.Add(new CartClass(name, price)); // Adds into the cart
         ListSort();                                  //Sorting
     }
 }
示例#3
0
        public static void ListSort()
        {
            MainPanelForm MP = new MainPanelForm();

            if (MP.ItemList.Count <= 1)
            {
                return;
            }
            else
            {
                CartClass[] array = new CartClass[MP.ItemList.Count];
                MP.ItemList.CopyTo(array, 0);
                ArraySort(array);
                MP.ItemList.Clear();
                foreach (CartClass cart in array)
                {
                    MP.ItemList.Add(cart);
                }
            }
        }