Пример #1
0
        private async void btnDeleteSup_Click(object sender, EventArgs e)
        {
            if (dataSupliers.SelectedRows.Count == 1)
            {
                try
                {
                    Suppliers supplier = (Suppliers)dataSupliers.SelectedRows[0].DataBoundItem;
                    await ControlerMethods.DeleteSupplier(supplier);

                    dataSupliers.DataSource = await ControlerMethods.GetSupliersAsync();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\n",
                                    "خطا",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("لطفا یک سطر را انتخاب نمایید   " + "\n",
                                "خطا",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private async void btnUpdateAddedProduct_Click(object sender, EventArgs e)
        {
            if (dataQtyProduct.SelectedRows.Count == 1)
            {
                Product product = (Product)dataQtyProduct.SelectedRows[0].DataBoundItem;

                List <Category> categories = await ControlerMethods.GetCategoryAsync();

                List <Suppliers> suppliers = await ControlerMethods.GetSupliersAsync();

                comboCat.SelectedIndex      = comboCat.Items.IndexOf(categories.Where(x => x.CategoryId.Equals(product.CategoryId)).FirstOrDefault <Category>().CategoryName);
                comboSup.SelectedIndex      = comboSup.Items.IndexOf(suppliers.Where(x => x.SupplierId.Equals(product.SupplierId)).FirstOrDefault <Suppliers>().CompanyName);
                txtAddProductName.Text      = product.ProductName;
                txtAddProductCode.Text      = product.ProuductCode;
                txtAddProductQty.Text       = (product.Qty).ToString();
                txtAddProductTax.Text       = (product.Tax * 100).ToString();
                txtAddProductBuy.Text       = product.UnitPriceBuy.ToString();
                txtAddProductSale.Text      = product.UnitPriceSales.ToString();
                txtAddProductDiscount.Text  = (product.Discount * 100).ToString();
                btnDbAddProduct.Enabled     = false;
                txtAddProductCode.Enabled   = false;
                btnAddEditedProduct.Visible = true;
            }
            else
            {
                MessageBox.Show("لطفا یک سطر را انتخاب نمایید   " + "\n",
                                "خطا",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Пример #3
0
        //tab selection change uncompited
        private async void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl1.SelectedIndex == 2)
            {
                dataQtyProduct.DataSource = await ControlerMethods.GetProductsAsync();

                dataSupliers.DataSource = await ControlerMethods.GetSupliersAsync();

                DataCategory.DataSource = await ControlerMethods.GetCategoryAsync();

                dataSupliers.Columns["SupplierId"].Visible = false;
                DataCategory.Columns["CategoryId"].Visible = false;
                if (comboCat.Items.Count < 1)
                {
                    List <Category> categories = await ControlerMethods.GetCategoryAsync();

                    foreach (Category cat in categories)
                    {
                        comboCat.Items.Add(cat.CategoryName);
                    }
                    List <Suppliers> suppliers = await ControlerMethods.GetSupliersAsync();

                    foreach (Suppliers sup in suppliers)
                    {
                        comboSup.Items.Add(sup.CompanyName);
                    }
                }
            }
            else if (tabControl1.SelectedIndex == 0)
            {
                FrmEmpMain_Load(sender, e);
            }
            else if (tabControl1.SelectedIndex == 3)
            {
                List <SqlParameter> sqlParameters = new List <SqlParameter>();
                sqlParameters.Add(new SqlParameter("date1", dateSumOrder1.Value.Date));
                sqlParameters.Add(new SqlParameter("date2", dateSumOrder2.Value.Date.AddMinutes(1439)));

                dataSumOrders.DataSource = await DataAccessAsync.ExecSPAsync("Sales.dvgSumOrders", sqlParameters);

                dataSumOrders.Columns["sumProfit"].DefaultCellStyle.Format = "#,#";
                dataSumOrders.Columns["sumSell"].DefaultCellStyle.Format   = "#,#";
                dataSumOrders.Columns["sumBuy"].DefaultCellStyle.Format    = "#,#";
                dataSumOrders.Columns["Column1"].HeaderText   = "نام کارمند";
                dataSumOrders.Columns["sumProfit"].HeaderText = "مجموع سود";
                dataSumOrders.Columns["sumBuy"].HeaderText    = "محموع خرید";
                dataSumOrders.Columns["sumSell"].HeaderText   = "مجموع فروش ";
                dataSumOrders.Columns["Column2"].Visible      = false;
            }
            else if (tabControl1.SelectedIndex == 4)
            {
                dgvExistProduct.DataSource = await DataAccessAsync.ExecSPAsync("Production.GetProductByCode");
            }
        }
Пример #4
0
        //add product available COMPITED
        private async void btnDbAddProduct_Click(object sender, EventArgs e)
        {
            try
            {
                List <Category> categories = await ControlerMethods.GetCategoryAsync();

                List <Suppliers> suppliers = await ControlerMethods.GetSupliersAsync();

                List <Product> products = await ControlerMethods.GetProductsAsync();

                Product product = new Product();
                product.CategoryId     = categories.Where(x => x.CategoryName.Equals(comboCat.Text.ToString())).FirstOrDefault <Category>().CategoryId;
                product.SupplierId     = suppliers.Where(x => x.CompanyName.Equals(comboSup.Text.ToString())).FirstOrDefault <Suppliers>().SupplierId;
                product.ProductName    = txtAddProductName.Text;
                product.ProuductCode   = txtAddProductCode.Text;
                product.Qty            = Convert.ToInt32(txtAddProductQty.Text);
                product.Tax            = Convert.ToInt32(txtAddProductTax.Text) / 100;
                product.UnitPriceBuy   = Convert.ToInt32(txtAddProductBuy.Text);
                product.UnitPriceSales = Convert.ToInt32(txtAddProductSale.Text);
                product.Discount       = Convert.ToDouble(txtAddProductDiscount.Text) / 100;
                FrmEmpMain_Load(sender, e);

                if (products.Where(x => x.ProuductCode.Equals(product.ProuductCode)).Count() > 0)
                {
                    DialogResult dialogResult = MessageBox.Show(String.Format("محصول موجود می باشد آیا مایل به افزودن تعداد وارد شده می باشید  "),
                                                                "اخطار",
                                                                MessageBoxButtons.YesNo,
                                                                MessageBoxIcon.Warning);
                    if (dialogResult == DialogResult.Yes)
                    {
                        await ControlerMethods.CheckAndSetProduct(product);

                        MessageBox.Show(String.Format("با موفقیت ثبت گردید "),
                                        "موفق",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                }
                else
                {
                    await ControlerMethods.CheckAndSetProduct(product);
                }

                dataQtyProduct.DataSource = await ControlerMethods.GetProductsAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show("خطا در هنگام انجام عملایات  " + "\n" + ex.GetBaseException().ToString(),
                                "خطا",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Пример #5
0
        // add edited product and update product
        private async void btnAddEditedProduct_Click(object sender, EventArgs e)
        {
            try
            {
                List <Category> categories = await ControlerMethods.GetCategoryAsync();

                List <Suppliers> suppliers = await ControlerMethods.GetSupliersAsync();

                List <Product> products = await ControlerMethods.GetProductsAsync();

                Product product = new Product();
                product.ProductId      = products.Where(x => x.ProuductCode.Equals(txtAddProductCode.Text)).FirstOrDefault <Product>().ProductId;
                product.CategoryId     = categories.Where(x => x.CategoryName.Equals(comboCat.Text.ToString())).FirstOrDefault <Category>().CategoryId;
                product.SupplierId     = suppliers.Where(x => x.CompanyName.Equals(comboSup.Text.ToString())).FirstOrDefault <Suppliers>().SupplierId;
                product.ProductName    = txtAddProductName.Text;
                product.ProuductCode   = txtAddProductCode.Text;
                product.Qty            = Convert.ToInt32(txtAddProductQty.Text);
                product.Tax            = Convert.ToInt32(txtAddProductTax.Text) / 100;
                product.UnitPriceBuy   = Convert.ToInt32(txtAddProductBuy.Text);
                product.UnitPriceSales = Convert.ToInt32(txtAddProductSale.Text);
                product.Discount       = Convert.ToDouble(txtAddProductDiscount.Text) / 100;

                FrmEmpMain_Load(sender, e);
                await ControlerMethods.UpdateProductAsync(product);

                MessageBox.Show(String.Format("با موفقیت ثبت گردید "),
                                "موفق",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                dataQtyProduct.DataSource = await ControlerMethods.GetProductsAsync();

                btnAddEditedProduct.Visible = false;
                btnDbAddProduct.Enabled     = true;
                txtAddProductCode.Enabled   = true;
                txtAddProductName.Text      = "";
                txtAddProductCode.Text      = "";
                txtAddProductQty.Text       = "";
                txtAddProductTax.Text       = "0";
                txtAddProductBuy.Text       = "";
                txtAddProductSale.Text      = "";
                txtAddProductDiscount.Text  = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show("خطا در هنگام انجام عملایات  " + "\n" + ex.GetBaseException().ToString(),
                                "خطا",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Пример #6
0
        //btn add supliers COMPLITED
        private async void btnAddSup_Click(object sender, EventArgs e)
        {
            if (!txtSupName.Text.Equals(""))
            {
                Suppliers supplier = new Suppliers();
                supplier.CompanyName = txtSupName.Text;
                supplier.Phone       = txtSupPhone.Text;

                await ControlerMethods.SetSuplierAsync(supplier);

                txtSupPhone.Text = "";
                txtSupName.Text  = "";
            }
            dataSupliers.DataSource = await ControlerMethods.GetSupliersAsync();
        }
Пример #7
0
        private async void txtTabAddSupSearch_TextChanged(object sender, EventArgs e)
        {
            List <Suppliers> suppliersTab2 = await ControlerMethods.GetSupliersAsync();

            if (txtTabAddSupSearch.Text.Equals(""))
            {
                if (suppliersTab2 != null)
                {
                    dataSupliers.DataSource = suppliersTab2;
                }
            }
            else
            {
                if (suppliersTab2 != null)
                {
                    dataSupliers.DataSource = suppliersTab2.Where(x => x.CompanyName.Contains(txtTabAddSupSearch.Text.Trim())).ToList <Suppliers>();
                }
            }
        }
Пример #8
0
        //COMPLITED
        private async void txtAddProductCode_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                try
                {
                    List <Category> categories = await ControlerMethods.GetCategoryAsync();

                    List <Suppliers> suppliers = await ControlerMethods.GetSupliersAsync();

                    List <Product> products = await ControlerMethods.GetProductsAsync();

                    if (products.Where(x => x.ProuductCode.Equals(txtAddProductCode.Text)).Count() == 1)
                    {
                        DialogResult dialogResult = MessageBox.Show("محصول موجود می باشد \n یک عدد به محصول افزوده شود ؟ ", "توجه", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (dialogResult == DialogResult.Yes)
                        {
                            Product product = (Product)products.Where(x => x.ProuductCode.Equals(txtAddProductCode.Text)).FirstOrDefault <Product>();
                            product.Qty = 1;
                            await ControlerMethods.CheckAndSetProduct(product);

                            dataQtyProduct.DataSource = await ControlerMethods.GetProductsAsync();

                            if (CheckShowDialog.Equals(null))
                            {
                                CheckShowDialog =
                                    MessageBox.Show("هر بار سوال شود ؟", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning).Equals(DialogResult.Yes) ?   true :  false;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("لطفا مقادیر را برسی نمایید  " + "\n" + ex.Message.ToString(),
                                    "خطا",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
        }