示例#1
0
 public void DeleteCategory(Product product)
 {
     using (BazaarContext context = new BazaarContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }
示例#2
0
 public void UpdateCategory(Category category)
 {
     using (BazaarContext context = new BazaarContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
示例#3
0
        private void lstCategoryProducts_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete && lstCategoryProducts.SelectedIndex > -1)
            {
                Product p = (Product)lstCategoryProducts.SelectedItem;
                db.Entry(p).State = EntityState.Deleted;
                db.SaveChanges();

                ListCategories();
                ListProducts();
            }
        }