Exemple #1
0
        private async void btnAdd_Click(object sender, EventArgs e)
        {
            if (numProducts.Value == 0)
            {
                MessageBox.Show("Not able to add 0 number of products!");
            }

            else
            {
                Model.Products product = (Model.Products)dgvProducts.SelectedRows[0].DataBoundItem;
                var            model   = await _productsService.GetById <Model.Products>(product.Id);

                if (GetExistedInModel(model.Id))
                {
                    SetQuantityFoExisting(model.Id);
                }

                else
                {
                    InputProductsAdd tmp = new InputProductsAdd
                    {
                        ProductId = model.Id,
                        Name      = model.Name,
                        Quantity  = (int)numProducts.Value
                    };
                    _productsAdd.Add(tmp);
                }
                dgvProducts.AutoGenerateColumns = false;
                dgvInputProducts.DataSource     = null;
                dgvProducts.DataSource          = null;
                dgvInputProducts.DataSource     = _productsAdd;
                await FilterProducts();
            }
        }
Exemple #2
0
        private async void dgvInputProducts_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            InputProductsAdd product = (InputProductsAdd)dgvInputProducts.SelectedRows[0].DataBoundItem;
            var model = _productsAdd.Where(x => x.ProductId == product.ProductId).FirstOrDefault();

            _productsAdd.Remove(model);
            dgvProducts.AutoGenerateColumns = false;
            dgvInputProducts.DataSource     = null;
            dgvProducts.DataSource          = null;
            dgvInputProducts.DataSource     = _productsAdd;
            await LoadProducts();
        }
Exemple #3
0
 private async void txtRemove_Click(object sender, EventArgs e)
 {
     if ((InputProductsAdd)dgvInputProducts.SelectedRows[0].DataBoundItem != null)
     {
         InputProductsAdd product = (InputProductsAdd)dgvInputProducts.SelectedRows[0].DataBoundItem;
         _productsAdd.Remove(product);
         dgvProducts.AutoGenerateColumns = false;
         dgvInputProducts.DataSource     = null;
         dgvProducts.DataSource          = null;
         dgvInputProducts.DataSource     = _productsAdd;
         await LoadProducts();
     }
     else
     {
         MessageBox.Show("Nothing selected to remove!");
     }
 }
Exemple #4
0
        private async void btnModify_Click(object sender, EventArgs e)
        {
            if (numModify.Value == 0)
            {
                MessageBox.Show("Not able to add 0 number of products!");
            }
            else
            {
                InputProductsAdd product = (InputProductsAdd)dgvInputProducts.SelectedRows[0].DataBoundItem;
                var model = _productsAdd.Where(x => x.ProductId == product.ProductId).FirstOrDefault();
                model.Quantity = (int)numModify.Value;

                dgvProducts.AutoGenerateColumns = false;
                dgvInputProducts.DataSource     = null;
                dgvProducts.DataSource          = null;
                dgvInputProducts.DataSource     = _productsAdd;
                await FilterProducts();
            }
        }
Exemple #5
0
        private async void dgvProducts_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            Model.Products product = (Model.Products)dgvProducts.SelectedRows[0].DataBoundItem;
            var            model   = await _productsService.GetById <Model.Products>(product.Id);

            InputProductsAdd tmp = new InputProductsAdd
            {
                ProductId = model.Id,
                Name      = model.Name,
                Quantity  = 1
            };

            _productsAdd.Add(tmp);
            dgvProducts.AutoGenerateColumns = false;
            dgvInputProducts.DataSource     = null;
            dgvProducts.DataSource          = null;
            dgvInputProducts.DataSource     = _productsAdd;
            await LoadProducts();
        }
Exemple #6
0
        private async Task SetMaxQunatityForModify()
        {
            InputProductsAdd product = (InputProductsAdd)dgvInputProducts.SelectedRows[0].DataBoundItem;

            numModify.Maximum = await Helper.numInStorage(product.ProductId);
        }