Beispiel #1
0
        private void buttonDeleceProduct_Click(object sender, EventArgs e)
        {
            {
                try

                {
                    DialogResult cevap;

                    cevap = MessageBox.Show("Kaydı silmek istediğinizden emin misiniz?", "Uyarı", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (cevap == DialogResult.Yes)

                    {
                        var db = new electronicShopDbContext();
                        //db.Categories.Remove();
                    }
                }

                catch (Exception hata)

                {
                    MessageBox.Show(hata.Message);
                }
            }
        }
Beispiel #2
0
        private void buttonAddProduct_Click(object sender, EventArgs e)
        {
            var db = new electronicShopDbContext();

            Product newProduct = new Product();

            newProduct.Name        = textBoxProductName.Text;
            newProduct.Description = textBoxProductDescription.Text;
            Category selectedCategory = new Category();

            selectedCategory = db.Categories.ToList().Where <Category>(x => x.Name == comboBoxProductCategory.Text.Trim()).FirstOrDefault <Category>();
            //newProduct.CategoryId = selectedCategory.Id;
            newProduct.Category = selectedCategory;


            db.Products.Add(newProduct);
            int affectedRow = db.SaveChanges();

            if (affectedRow > 0)
            {
                MessageBox.Show("Ürün eklendi.");
                getProducts();
            }
            else
            {
                MessageBox.Show("Ürün ekleme başarısız.");
            }
        }
Beispiel #3
0
        private void buttonDeleteCategory_Click(object sender, EventArgs e)
        {
            {
                try

                {
                    DialogResult cevap;

                    cevap = MessageBox.Show("Kaydı silmek istediğinizden eminmisiniz", "Uyarı", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (cevap == DialogResult.Yes)

                    {
                        var db = new electronicShopDbContext();

                        Category newCategory = new Category();
                        newCategory = db.Categories.ToList().Where <Category>(x => x.Name == comboCategory.Text.Trim()).FirstOrDefault <Category>();
                        db.Categories.Remove(newCategory);
                        db.SaveChanges();
                        comboCategory.Text = "";
                        getCategories();
                    }
                }

                catch (Exception hata)

                {
                    MessageBox.Show(hata.Message);
                }
            }
        }
Beispiel #4
0
        void getCategories()
        {
            var db = new electronicShopDbContext();

            comboBoxProductCategory.Items.Clear();
            foreach (var item in db.Categories.ToList())
            {
                comboBoxProductCategory.Items.Add(item.Name);
            }
        }
Beispiel #5
0
        void getCategories()
        {
            var db = new electronicShopDbContext();

            dataGridViewCategories.DataSource = db.Categories.ToList();
            comboCategory.Items.Clear();
            foreach (var item in db.Categories.ToList())
            {
                comboCategory.Items.Add(item.Name);
            }
        }
        private void buttonAddCategory_Click(object sender, EventArgs e)
        {
            var      db          = new electronicShopDbContext();
            Category newCategory = new Category();

            newCategory.Name       = textBoxCategoryName.Text;
            newCategory.Desription = textBoxCategoryDescription.Text;

            db.Categories.Add(newCategory);
            int affectedRow = db.SaveChanges();

            if (affectedRow > 0)
            {
                MessageBox.Show("Kategori eklendi.");
                getCategories();
            }
            else
            {
                MessageBox.Show("Kategori ekleme başarısız.");
            }
        }
Beispiel #7
0
        void getProducts()
        {
            var db = new electronicShopDbContext();

            dataGridViewProducts.DataSource = db.Products.ToList();
        }
        void getCategories()
        {
            var db = new electronicShopDbContext();

            dataGridViewCategories.DataSource = db.Categories.ToList();
        }