Example #1
0
        private void AdjustStockLevels()
        { // makes a new reserved stock holding just the name and quantity used for the chosen stock item.
          // Saves to the reserved stock list in the Storage Class. Adjusts the quantity value in the
          // corresponding stock object in the stock list in the Storage Class
            ReservedStock reservedStock = new ReservedStock();

            reservedStock.Name     = chosenCat3Item.Name;                //copies the name from the chosen item to the reserved stock object
            reservedStock.Quantity = 1;                                  //for now this is always 1, but having it here allows for future expansion.
            Program.ProcessStorage.ListReservedStock.Add(reservedStock); //adds to the reserved stock list in the Storage Class
            stockName     = chosenCat3Item.Name;
            newStockQuant = quant - 1;                                   //sets the new quantity
            for (int i = 0; i < Program.ProcessStorage.ListStock.Count; i++)
            {
                if (Program.ProcessStorage.ListStock[i].Name == stockName)
                {                //loop through the stock list untill we find an object with the same name attribute.
                    stockID = i; //set the stock id for this item
                    break;       //drop out of the loop as we are done.
                }
            }
            Stock stockItem = new Stock();                                      //make new stock item

            stockItem     = Program.ProcessStorage.ListStock[stockID];          //copy the details from the original stock list
            quant         = stockItem.Quantity;                                 //gets and sets the current quantity
            newStockQuant = quant - 1;                                          //sets the new quantity
            Program.ProcessStorage.ListStock[stockID].Quantity = newStockQuant; //sets the new quantity in the stock list
            Program.ProcessStorage.SaveStockDataFile();                         //saves the stock file to the hdd
        }
Example #2
0
        public void ClearReservedStock()
        {   //clears the reserved items stock list and sets the default again.
            ListReservedStock.Clear();
            ReservedStock reservedPlaceHold = new ReservedStock();

            reservedPlaceHold.Name     = "reserved";
            reservedPlaceHold.Quantity = 1;
            ListReservedStock.Add(reservedPlaceHold);
            SaveReservedStock();
        }