Beispiel #1
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);
            }
        }