public void DeleteProduct(BindingSource bidingSource, int productID) { using (NorthwindDataContext _context = new NorthwindDataContext()) { var querryProduct = from p in _context.LinqProducts where p.ProductID == productID select p; LinqProduct linqProd = querryProduct.Single(); _context.LinqProducts.DeleteOnSubmit(linqProd); Save(_context); // bidingSource.Remove(linqProd); } }
public void AddProduct(BindingSource bidingSource, Product product) { using (NorthwindDataContext _context = new NorthwindDataContext()) { LinqProduct linqProd = new LinqProduct(); //copiem valorile din produs in produsul linq linqProd.CategoryId = product.CategoryId;//TO DO: asta mai are int _idNext = GetNextID(_context); linqProd.ProductID = _idNext; linqProd.Discontinued = product.Discontinued; linqProd.ProductName = product.ProductName; linqProd.QuantityPerUnit = product.QuantityPerUnit; linqProd.UnitPrice = product.UnitPrice; linqProd.UnitsInStock = product.UnitsInStock; linqProd.UnitsOnOrder = product.UnitsOnOrder; //acum adaugam in contextul nostru/in tabelul nostru, produsul _context.LinqProducts.InsertOnSubmit(linqProd); bidingSource.Add(linqProd); Save(_context); } }
partial void DeleteLinqProduct(LinqProduct instance);
partial void UpdateLinqProduct(LinqProduct instance);
partial void InsertLinqProduct(LinqProduct instance);