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 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(); } } }