示例#1
0
        public void DeleteStockEntryTest()
        {
            SQLStockRepository stockRepo = new SQLStockRepository();

            string actual = stockRepo.DeleteStock(102674);

            Assert.AreEqual(1, actual);
        }
示例#2
0
        /// <summary>Deletes a stock entry</summary>
        public string DeleteStock(uint id)
        {
            string             serverResponse;
            SQLStockRepository stockRepo = new SQLStockRepository();

            serverResponse = stockRepo.DeleteStock(id);

            return(serverResponse);
        }
示例#3
0
        /// <summary>Occurs when an item is added or removed from the StockEntriesBound collection</summary>
        private void StockEntriesBound_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            try
            {
                LoggingService.Log("Collection changed", "Log.txt");

                StockEntry         stockChanged   = new StockEntry();
                SQLStockRepository stockRepo      = new SQLStockRepository();
                string             serverResponse = "";

                if (e.OldItems != null)
                {
                    stockChanged   = e.OldItems[0] as StockEntry;
                    serverResponse = stockRepo.DeleteStock(stockChanged.ID);
                }

                if (e.NewItems != null)
                {
                    stockChanged = e.NewItems[0] as StockEntry;

                    serverResponse = stockRepo.AddStockEntry(stockChanged);
                    uint stockID;

                    if (uint.TryParse(serverResponse, out stockID))
                    {
                        stockChanged.ID = stockID;
                        serverResponse  = "Stock entry inserted with ID of " + stockID;
                    }
                }

                if (serverResponse != "")
                {
                    Messages.Items.Insert(0, serverResponse);
                }
            }
            catch (Exception ex)
            {
                Messages.Items.Insert(0, ex.Message);
                LoggingService.Log(ex, "Log.txt");
            }
        }