public MainViewModel() { try { productCommands = new ProductCommands(_connectionString); Products.AddRange(productCommands.GetList()); ProdCategoryCommands prodCategoryCommands = new ProdCategoryCommands(_connectionString); ProdCategories.AddRange(prodCategoryCommands.GetList()); LocationCommands locationCommands = new LocationCommands(_connectionString); Locations.AddRange(locationCommands.GetList()); LocCategoryCommands locCategoryCommands = new LocCategoryCommands(_connectionString); LocationCategories.AddRange(locCategoryCommands.GetList()); UnitCommands unitCommands = new UnitCommands(_connectionString); Units.AddRange(unitCommands.GetList()); UpdateAppStatus($"Database tables fetched.", Brushes.DarkGreen); } catch (Exception ex) { UpdateAppStatus($"Error on retrieving tables from SQL database:\n{ex.Message}", Brushes.Red); } GenerateTableProductsToDisplay(); InitializeAllPropertyFields(); Scheduler(); }
private void ReadTableFromDatabaseAfterModification(string successMessage, string failureMessage) { try { ProductsAllTablesMerged.Clear(); Products.Clear(); Products.AddRange(productCommands.GetList()); GenerateTableProductsToDisplay(); UpdateAppStatus(successMessage, Brushes.DarkGreen); } catch (Exception ex) { UpdateAppStatus(failureMessage + ex.Message, Brushes.Red); } }