private void FillCategoryComboBox()
        {
            var categoryMapper = new CategoryDataMapper();

            cmbCategory.DataSource    = categoryMapper.GetAll();
            cmbCategory.DisplayMember = "Name";
            cmbCategory.ValueMember   = "Id";
        }
 private void CategoryEditForm_Load(object sender, EventArgs e)
 {
     if (_categoryId != 0)
     {
         var categoryMapper = new CategoryDataMapper();
         var category       = categoryMapper.Get(_categoryId);
         FillFormByCategory(category);
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            var category           = CreateCategoryByForm();
            var categoryDataMapper = new CategoryDataMapper();

            if (_categoryId == 0)
            {
                categoryDataMapper.Insert(category);
            }
            else
            {
                category.Id = _categoryId;
                categoryDataMapper.Update(category);
            }
            Dispose();
        }
예제 #4
0
        public static void ProductDynamic()
        {
            IDataMapper test       = new ProductDataMapper(connStr);
            IDataMapper categories = new CategoryDataMapper(connStr);
            IDataMapper suppliers  = new SupplierDataMapper(connStr);
            IEnumerable res        = test.GetAll();
            Category    c          = (Category)categories.GetById(4);
            Supplier    s          = (Supplier)suppliers.GetById(17);

            object  id     = test.Insert(ProductBuilder(c, s));
            Product actual = (Product)test.GetById(id);

            test.Delete(actual);

            Product original = (Product)test.GetById(10);

            c = (Category)categories.GetById(4);
            s = (Supplier)suppliers.GetById(17);


            test.Update(ProductBuilder(c, s));
            test.Update(original);
        }