public void NewDatabaseTables() { dependency_table = Database.ProductDependencyTable.CreateTable(); table = Database.ProductTable.CreateTable(); var row = table.NewRow(); row [0] = (int)Id; row [1] = "Change name"; row [2] = 0.0; row [3] = 1; Node = new ProductNode(row); table.Rows.Add(row); }
public bool LoadFromDatabase() { table = Database.ProductTable.Select(Product.ID, Id.ToString()); dependency_table = Database.ProductDependencyTable.Select(Dependency.PARENT_ID, Id.ToString()); if (table.Rows.Count == 0) { NewDatabaseTables(); return(true); } Node = new ProductNode(table.Rows[0]); //TODO Dep table could be null or empty()? foreach (var child in dependency_table.Select()) { int childid = (int)child [1]; int amount = (int)child [2]; AddProduct(childid, amount); } return(true); }