private void saveDBStoresLocally() { DiscountDataContext db = new DiscountDataContext(); var lStores = from c in db.Stores select c; foreach (var i in lStores) { db.Stores.DeleteOnSubmit(i); } db.SubmitChanges(); foreach (CStore store_i in stores) { var store = new StoresTable(); store.storeID = store_i.storeID; store.storeName = store_i.storeName; db.Stores.InsertOnSubmit(store); } db.SubmitChanges(); }
private void clearBuys() { using (var db = new DiscountDataContext()) { var res = from c in db.Buys select c; foreach (var r in res) { db.Buys.DeleteOnSubmit(r); } db.SubmitChanges(); InitializeSettings(); } }
private void delProduct_Click(object sender, RoutedEventArgs e) { using (var db = new DiscountDataContext()) { var res = from c in db.Buys where c.productID == productID select c; BuysTable buy = res.First(); //Debug.WriteLine(productID); db.Buys.DeleteOnSubmit(buy); db.SubmitChanges(); InitializeSettings(); } }
private void saveDBProductsLocally() { using (DiscountDataContext db = new DiscountDataContext()) { var lProducts = from c in db.Products select c; foreach (var i in lProducts) { db.Products.DeleteOnSubmit(i); } db.SubmitChanges(); foreach (CProduct prod_i in products) { var product = new ProductsTable(); product.productID = prod_i.productID; product.productName = prod_i.productName; product.storeID = prod_i.storeID; product.storeName = prod_i.storeName; product.productTypeID = prod_i.productsTypeID; product.productType = prod_i.productsType; product.discount = prod_i.discount; product.oldPrice = prod_i.oldPrice; product.newPrice = prod_i.newPrice; product.startDate = prod_i.startDate; product.endDate = prod_i.endDate; product.imageURL = prod_i.imageURL; db.Products.InsertOnSubmit(product); } db.SubmitChanges(); } cleanStorage(); }
private void addProduct_Click(object sender, RoutedEventArgs e) { using (var db = new DiscountDataContext()) { var res = from c in db.Buys where c.productID == productID select c; if (res.Count() == 0) { BuysTable buy = new BuysTable(); buy.productID = productID; db.Buys.InsertOnSubmit(buy); db.SubmitChanges(); } } }
private void saveBuy() { using (var db = new DiscountDataContext()) { var res = from c in db.Buys where c.productID == productID select c; if (res.Count() == 0) { BuysTable buy = new BuysTable(); buy.productID = productID; db.Buys.InsertOnSubmit(buy); db.SubmitChanges(); popupMsgText.Text = "Добавлено"; showPopup(); } else { popupMsgText.Text = "Уже есть в списке покупок"; showPopup(); } } }