Exemple #1
0
        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);
            }
        }
Exemple #2
0
 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);
     }
 }
Exemple #3
0
 partial void DeleteLinqProduct(LinqProduct instance);
Exemple #4
0
 partial void UpdateLinqProduct(LinqProduct instance);
Exemple #5
0
 partial void InsertLinqProduct(LinqProduct instance);