Beispiel #1
0
        //AddProduct
        private async void btnAddProduct_Click(object sender, EventArgs e)
        {
            Product product = new Product();

            product.Code     = txtAddProductCode.Text.ToLower().Trim();
            product.Name     = txtAddProductName.Text.Trim();
            product.Quantity = Convert.ToInt32(txtAddProductQuantity.Text.Trim());
            try
            {
                await GetAndSetData.SetProduct(product);
                await UpdateProductListAndSold();

                MessageBox.Show("با موفقیت ثبت شد ",
                                "موفق",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n",
                                "خطا",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        //btn Delete Product
        private async void btnAddUpdateProduct_Click(object sender, EventArgs e)
        {
            Product product = new Product();

            product.Id = DeleteId;
            try
            {
                if (soldProducts.Where(x => x.ProductId.Equals(product.Id)).Any())
                {
                    throw new Exception("محصولی که مصرف شده است امکان حذف ندارد ");
                }

                await GetAndSetData.DeleteProduct(product);
                await UpdateProductListAndSold();

                MessageBox.Show("با موفقیت ثبت شد ",
                                "موفق",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n",
                                "خطا",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        //update ProductsList and SoldProduct
        private async Task UpdateProductListAndSold()
        {
            products = await GetAndSetData.GetProductsAsync();

            soldProducts = await GetAndSetData.GetSoldProductsAsync();

            dgvSellProduct.DataSource    = products;
            dgvAddProductList.DataSource = products;
        }