private void btnAddCategory_Click(object sender, EventArgs e) { string categoryName = txtCategoryName.Text.Trim(); if (categoryName == "") { MessageBox.Show("Enter a category name!"); return; } if (categoryEdited == null) { db.Categories.Add(new Category { CategoryName = categoryName }); db.SaveChanges(); txtCategoryName.Clear(); ListCategories(); } else { categoryEdited.CategoryName = categoryName; db.SaveChanges(); ListCategories(); ResetCategoryForm(); } }
private void btnCategoryAdd_Click(object sender, EventArgs e) { string categoryName = txtCategoryName.Text.Trim(); if (categoryName == "") { MessageBox.Show("Enter category name"); return; } if (categoryEdited == null) //veritabanina ekleme yapar { db.Categories.Add(new Category { CategoryName = categoryName }); db.SaveChanges(); txtCategoryName.Clear(); ListCategories(); } else //duzenleme yapar { categoryEdited.CategoryName = categoryName; db.SaveChanges(); ListCategories(); ResetCategoryForm(); } }
public void DeleteCategory(Product product) { using (BazaarContext context = new BazaarContext()) { context.Entry(product).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } }
public void SaveCategory(Product product) { using (BazaarContext context = new BazaarContext()) { context.Products.Add(product); context.SaveChanges(); } }
public void UpdateCategory(Category category) { using (BazaarContext context = new BazaarContext()) { context.Entry(category).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void SaveCategory(Category category) { using (BazaarContext context = new BazaarContext()) { context.Categories.Add(category); context.SaveChanges(); } }