Beispiel #1
0
        public void addToStock(int itemCode, string itemName, int quantity, double price, DateTime date)
        {
            if (stockMgr.checkStock(itemCode) == true)
            {
                stockMgr.increaseStock(itemCode, quantity, price);
                List <Stock> stocks = stockMgr.getStocks();

                foreach (Stock stock in stocks)
                {
                    if (stock.itemCode == itemCode)
                    {
                        itemName = stock.name;
                    }
                }
            }
            else
            {
                stockMgr.addStock(new Stock(itemCode, itemName, price, quantity, date));
            }

            stockMgr.addTransaction(new TransactionLogAdd("Add", itemCode, itemName, price, date));
        }
        private static void AddToStock()
        {
            int    itemcode = ValidateInt("Item Code");
            string name     = "";
            int    quantity = 0;
            double price    = 0;

            if (stockMgr.checkStock(itemcode) == true)
            {
                Console.WriteLine("This item code already exists. Please enter the quantity and price to be added:");
                quantity = ValidateInt("Quantity");
                price    = ValidateDouble("Price");
            }
            else
            {
                name     = ValidateString("Name");
                quantity = ValidateInt("Quantity");
                price    = ValidateDouble("Price");
            }

            trnUI.addToStock(itemcode, name, quantity, price, DateTime.Now);
        }