Example #1
0
        private void RefreshList()
        {
            List <Product> productList = new ProductGetService(new Product()).GetsData();

            txtSearch.Text = string.Empty;

            int totalRow = productList.Count;

            if (totalRow > 0)
            {
                lblTotalRecord.Text      = "Total :: " + totalRow;
                lblTotalRecord.BackColor = System.Drawing.Color.AliceBlue;

                btnView.Enabled   = (totalRow > 0);
                btnEdit.Enabled   = (totalRow > 0);
                btnDelete.Enabled = (totalRow > 0);
            }
            else
            {
                lblTotalRecord.Text = "Total :: ";
                btnView.Enabled     = false;
                btnEdit.Enabled     = false;
                btnDelete.Enabled   = false;
            }

            RefreshGrid(productList);
        }
Example #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            Product oProduct = new Product();

            oProduct.ProductName = txtSearch.Text;
            List <Product> productList = new ProductGetService(oProduct).GetsProductByName();

            gvProducts.DataSource = productList;
            gvProducts.Refresh();
        }
Example #3
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            Product oProduct = new Product();

            oProduct.ProductCode = txtSearch.Text;

            var productList = new ProductGetService(oProduct).GetsProductByCode();

            RefreshGrid(productList);
        }
Example #4
0
        private void txtProductCode_TextChanged(object sender, EventArgs e)
        {
            List <Product> productList = new ProductGetService(new Product()).GetsAlreadyExistProductCode(txtProductCode.Text);

            if (_displayType == FormDisplayType.Add && productList.Count > 0)
            {
                errorProvider1.SetError(txtProductCode, "Product code exist.");
            }
            else
            {
                errorProvider1.SetError(txtProductCode, "");
            }
        }
Example #5
0
        private void ViewProduct()
        {
            frmProductViewDetail ofrmProduct = new frmProductViewDetail();

            ofrmProduct.RefreshParent += new System.EventHandler(this.RefreshParent);

            Product oProduct      = GetSelectedRowRecords();
            Product ProductEntity = new Product();

            ProductEntity = new ProductGetService(oProduct).GetProductByProductId();

            if (ofrmProduct.ShowDialog(ProductEntity, FormDisplayType.View))
            {
                RefreshList();
            }
        }
        public Product Added()
        {
            Product oProduct = new Product();

            oProduct = new ProductGetService(_product).GetProductByProductId();

            if (oProduct.ProductId > 0)
            {
                oProduct = new ProductModifiedService(_product).Modified();
            }
            else
            {
                oProduct = new ProductAddService(_product).Added();
            }

            return(oProduct);
        }
        public Product Modified()
        {
            Product oProductEntity = new Product();

            using (var context = new ColorStitchDataContext())
            {
                using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
                {
                    IRepositoryAsync <Product> productRepository = new Repository <Product>(context, unitOfWork);
                    oProductEntity = new ProductGetService(_product).GetProductByProductId();


                    oProductEntity.ProductName  = _product.ProductName;
                    oProductEntity.ProductCode  = _product.ProductCode;
                    oProductEntity.ProductPrice = _product.ProductPrice;
                    oProductEntity.ObjectState  = ObjectState.Modified;


                    productRepository.Update(oProductEntity);
                    unitOfWork.SaveChanges();
                }
            }
            return(oProductEntity);
        }