private void Button11_Click(object sender, EventArgs e)
        {
            try
            {
                var EmptyArea = EmptyTextBoxControl(groupBox11);
                if (EmptyArea)
                {
                    MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    Category newCategory = new Category
                    {
                        CategoryName = textBox19.Text,
                        Description  = richTextBox1.Text,
                    };

                    var sorgu = DalCategory.CUD(newCategory, System.Data.Entity.EntityState.Added);

                    if (sorgu)
                    {
                        textBox19.Clear();
                        richTextBox1.Clear();

                        GuncelleKategoriler();
                        MessageBox.Show("Yeni kategori eklendi.", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        public void Delete(DalCategory entity)
        {
            var category = entity.ToCategory();

            category = _dbContext.Set <Category>().Single(c => c.CategoryId == category.CategoryId);
            _dbContext.Set <Category>().Remove(category);
        }
 public static BllCategorie ToBllCategorie(this DalCategory cat)
 {
     return(new BllCategorie()
     {
         Id = cat.Id,
         Name = cat.Name
     });
 }
Exemple #4
0
 public static CategoryEntity ToBllCategory(this DalCategory dalCategory)
 {
     return(dalCategory == null ? null : new CategoryEntity
     {
         Id = dalCategory.Id,
         Name = dalCategory.Name,
         ImageData = dalCategory.ImageData,
         ImageType = dalCategory.ImageType,
         Lots = dalCategory.Lots.Select(l => l.ToBllLot())
     });
 }
        public static Category ToOrmCategory(this DalCategory dalCategory)
        {
            Category newCategory = new Category
            {
                Id        = dalCategory.Id,
                Name      = dalCategory.Name,
                ImageData = dalCategory.ImageData,
                ImageType = dalCategory.ImageType
            };

            return(newCategory);
        }
 public static Category ToCategory(this DalCategory dalCategory)
 {
     return(new Category()
     {
         CategoryId = dalCategory.Id,
         CategoryName = dalCategory.CategoryName,
         CreationDate = dalCategory.CreationDate,
         IsBlocked = dalCategory.IsBlocked,
         IsConfirmed = dalCategory.IsConfirmed,
         SectionRefId = dalCategory.SectionRefId
     });
 }
        public void Update(DalCategory entity)
        {
            var updatedCategory = entity.ToCategory();
            var existedCategory = _dbContext.Entry <Category>(_dbContext.Set <Category>().Find(updatedCategory.CategoryId));

            if (existedCategory == null)
            {
                return;
            }
            existedCategory.State              = EntityState.Modified;
            existedCategory.Entity.IsBlocked   = entity.IsBlocked;
            existedCategory.Entity.IsConfirmed = entity.IsConfirmed;
        }
Exemple #8
0
 internal static bool CheckIfNameExist(IList <CATEGORY_TRANSLATION> catsT)
 {
     using (IDalCategory dal = new DalCategory())
     {
         bool          result   = false;
         List <string> nameList = dal.GetAllCategoryTrans().Select(n => n.nameCategory.ToLower()).ToList();
         foreach (var item in catsT)
         {
             if (item.nameCategory != null)
             {
                 if (nameList.Contains(item.nameCategory.ToLower()))
                 {
                     result = true;
                     break;
                 }
             }
         }
         return(result);
     }
 }
        private void TabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            var tab = sender as TabControl;

            switch (tab.SelectedIndex)
            {
            case 0:
                GuncelleMusteriler();
                break;

            case 1:
                label42.Text = karZararHesapla().ToString();
                break;

            case 2:
                comboBox3.DisplayMember = "CategoryName";
                comboBox3.ValueMember   = "CategoryID";
                comboBox3.DataSource    = DalCategory.GetCategories();

                comboBox4.ValueMember = "CustomerID";
                comboBox4.DataSource  = DalCustomer.GetCustomers();

                break;

            case 3:
                GuncelleUrunler();

                comboBox1.DisplayMember = "CategoryName";
                comboBox1.ValueMember   = "CategoryID";
                comboBox1.DataSource    = DalCategory.GetCategories();

                comboBox2.DisplayMember = "CategoryName";
                comboBox2.ValueMember   = "CategoryID";
                comboBox2.DataSource    = DalCategory.GetCategories();
                break;

            case 4:
                GuncelleKategoriler();
                break;
            }
        }
        private void GuncelleKategoriler()
        {
            try
            {
                listView3.Items.Clear();

                foreach (var category in DalCategory.GetCategories())
                {
                    ListViewItem c = new ListViewItem();

                    c.SubItems.Add(category.CategoryID.ToString());
                    c.SubItems.Add(category.CategoryName);
                    c.SubItems.Add(category.Description);

                    listView3.Items.Add(c);
                }
            }
            catch (Exception)
            {
            }
        }
        private void Button12_Click(object sender, EventArgs e)
        {
            try
            {
                var EmptyArea = EmptyTextBoxControl(groupBox12);
                if (EmptyArea)
                {
                    MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    Category categoryToUpdate = new Category
                    {
                        CategoryID   = Convert.ToInt32(textBox28.Text.ToString()),
                        CategoryName = textBox20.Text,
                        Description  = richTextBox2.Text,
                    };

                    var sorgu = DalCategory.CUD(categoryToUpdate, System.Data.Entity.EntityState.Modified);

                    if (sorgu)
                    {
                        textBox28.Clear();
                        textBox20.Clear();
                        richTextBox2.Clear();

                        GuncelleKategoriler();
                        MessageBox.Show("Yeni kategori eklendi.", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void Button10_Click(object sender, EventArgs e)
        {
            try
            {
                Category CategoryToDelete = new Category
                {
                    CategoryID   = Convert.ToInt32(listView3.SelectedItems[0].SubItems[1].Text),
                    CategoryName = listView3.SelectedItems[0].SubItems[2].Text,
                    Description  = listView3.SelectedItems[0].SubItems[3].Text,
                };

                var sorgu = DalCategory.CUD(CategoryToDelete, System.Data.Entity.EntityState.Deleted);

                if (sorgu)
                {
                    GuncelleKategoriler();
                    MessageBox.Show("Kategori silindi.", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Kategori seçilmedi.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
 public CategoryController()
 {
     dalCategory = new DalCategory();
 }
Exemple #14
0
 public static Categories[] allCategories()
 {
     return(DalCategory.allCategories());
 }
 public void Update(DalCategory entity)
 {
     _context.Set <Category>().AddOrUpdate(entity.ToOrmCategory());
 }
        public void Delete(DalCategory entity)
        {
            var category = _context.Set <Category>().Single(c => c.Id == entity.Id);

            _context.Set <Category>().Remove(category);
        }
 public void Create(DalCategory entity)
 {
     _context.Set <Category>().Add(entity.ToOrmCategory());
 }
        public void Create(DalCategory entity)
        {
            var category = entity.ToCategory();

            _dbContext.Set <Category>().Add(category);
        }
 public ProductController()
 {
     dalCategory = new DalCategory();
     dalProduct  = new DalProduct();
 }