public void initSmartShopping() { ssd = SmartShoppingData.Load(this.filename); SmartShoppingData.stream.Close(); Console.WriteLine(ssd.ToString()); Console.ReadLine(); Console.Clear(); }
public MainWindow() { //string filename = @"C:\Users\troels\troe3159\SC\src\SmartShoppingMerge\savefiles\databaseTest.ssd"; string filename = @"..\..\..\savefiles\databaseTest.ssd"; ssd = SmartShoppingData.Load(filename); InitializeComponent(); //basketListBox.ItemsSource = basketarray; basketListBox.ItemsSource = basketList; string url = ssd.Shops[0].Products[0].CanonicalProduct.ImageURL; for (int i = 0; i < 20; i++) { foreach (Product product in ssd.Shops[0].Products.Values) { addProductToGui(product.CanonicalProduct.Uid, product.Price, @"ProductPictures\" + product.CanonicalProduct.ImageURL); } } foreach (Product product in ssd.Shops[0].Products.Values) { addProductToGui(product.CanonicalProduct.Uid, product.Price, @"ProductPictures\" + product.CanonicalProduct.ImageURL); } }
private void generateSaveFile() { SmartShoppingData ssd = new SmartShoppingData(); ssd.addCanonicalProduct("Coca Cola", "Black sugerwater", "cola.jpg"); ssd.addCanonicalProduct("Lambi Toilet Paper", "Soft", "lambi.jpg"); ssd.addCanonicalProduct("Mix of candybars", "Tasty", "nestlebars.jpg"); ssd.addCanonicalProduct("Carrots", "Goldenrod color", "guleroedder.jpg"); ssd.addCustomer("John"); ssd.addShop("Bilka"); foreach (CanonicalProduct canonicalProduct in ssd.CanonicalProducts.Values) { Console.Write("Enter price of product " + canonicalProduct.ToString() + ": "); decimal price; if (decimal.TryParse(Console.ReadLine(), out price)) { // decimal tryparse does not handle , or . ?! ssd.Shops[0].addProduct(canonicalProduct, price); } else { Console.WriteLine("Invalid price, product not added"); } } ssd.Save(this.filename); }