コード例 #1
0
ファイル: Form1.cs プロジェクト: canberksahin/ArmadaMarket
        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();
            }
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
 public void DeleteCategory(Product product)
 {
     using (BazaarContext context = new BazaarContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }
コード例 #4
0
 public void SaveCategory(Product product)
 {
     using (BazaarContext context = new BazaarContext())
     {
         context.Products.Add(product);
         context.SaveChanges();
     }
 }
コード例 #5
0
 public void UpdateCategory(Category category)
 {
     using (BazaarContext context = new BazaarContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #6
0
 public void SaveCategory(Category category)
 {
     using (BazaarContext context = new BazaarContext())
     {
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }