/// <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); }
/// <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); } } }
public RefreshStock(Stocks sender) { this.manager = sender; }
public SaveStock(Stocks sender) { this.manager = sender; }
public RemoveStock(Stocks sender) { this.manager = sender; }
public NewStock(Stocks sender) { this.manager = sender; }