예제 #1
0
        public bool SaveProduct(Product pro)
        {
            bool result = false;

            using (AccessoriesEntitiesProduct _entity = new AccessoriesEntitiesProduct())
            {
                _entity.Products.Add(pro);
                _entity.SaveChanges();
                result = true;
            }
            return(result);
        }
예제 #2
0
        public bool DeleteProduct(Product pro) // UpdateStudentDetails method for update a existing Record
        {
            bool result = false;

            using (AccessoriesEntitiesProduct _entity = new AccessoriesEntitiesProduct())
            {
                Product _product = new Product();
                _product = _entity.Products.Where(x => x.ProductName == pro.ProductName).Select(x => x).FirstOrDefault();
                _entity.Products.Remove(_product);
                _entity.SaveChanges();
                result = true;
            }
            return(result);
        }
예제 #3
0
 public void DisplayPro()
 {
     using (AccessoriesEntitiesProduct _entity = new AccessoriesEntitiesProduct())
     {
         /*List<Product> _productlist = new List<Product>();
          * _productlist = _entity.Products.Select(x => new Product
          * {
          *  Id = x.Id,
          *  ProductName = x.ProductName,
          *  Provider = x.Provider,
          *  Price = x.Price,
          *  Quantity = x.Quantity
          * }).ToList();
          * dataGridView.DataSource = _productlist;*/
         dataGridView.DataSource = _entity.Products.ToList();
     }
 }