Beispiel #1
0
        /// <summary>
        /// Load from database.
        /// </summary>
        /// <returns></returns>
        public DatabaseObject LoadFromFile()
        {
            Stocks output = base.LoadFromFile() as Stocks;

            foreach (Stock item in output.Stock)
            {
                var inventories = from f in DatabaseObject.Inventories.Inventory
                                  where f.Stock.Name1.Equals(item.Name1)
                                  select f;
                foreach (Inventory i in inventories)
                {
                    item.Inventories.Add(i);
                }
            }

            return(output);
        }
Beispiel #2
0
        /// <summary>
        /// Discard all the changes and read again from database file.
        /// </summary>
        public void Refresh()
        {
            //DatabaseObject.Stocks.Stock
            //sort collection by name1 alphabetically
            Stocks target = new Stocks();

            target = target.LoadFromFile() as Stocks;
            if (target != null)
            {
                var          hold = from f in target.Stock select f;
                List <Stock> temp = hold.OrderBy(f => f.Name1).ToList();
                if (temp.Count > 0)
                {
                    this.stockField.Clear();                //tips: don't use new it will break all the binding = new ObservableCollection<Stock>();
                }
                foreach (Stock s in temp)
                {
                    this.stockField.Add(s);
                }
            }
        }
Beispiel #3
0
 public RefreshStock(Stocks sender)
 {
     this.manager = sender;
 }
Beispiel #4
0
 public SaveStock(Stocks sender)
 {
     this.manager = sender;
 }
Beispiel #5
0
 public RemoveStock(Stocks sender)
 {
     this.manager = sender;
 }
Beispiel #6
0
 public NewStock(Stocks sender)
 {
     this.manager = sender;
 }