//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");
            }
        }
        //btn search Sum Order
        private async void btnSearchSumOrder_Click(object sender, EventArgs e)
        {
            int empId = -1;

            if (dataSumOrders.SelectedRows.Count == 1 && !dataSumOrders.SelectedRows[0].Cells["Column2"].Value.Equals(0))
            {
                empId = Convert.ToInt32(dataSumOrders.SelectedRows[0].Cells["Column2"].Value);
            }
            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);

            if (rbtnProduct.Checked)
            {
                List <SqlParameter> sqlParameters2 = new List <SqlParameter>();
                sqlParameters2.Add(new SqlParameter("date1", dateSumOrder1.Value.Date));
                sqlParameters2.Add(new SqlParameter("date2", dateSumOrder2.Value.Date.AddMinutes(1439)));
                sqlParameters2.Add(new SqlParameter("empId", -1));

                dataEmpSoldOrderDetails.DataSource = await DataAccessAsync.ExecSPAsync("Sales.dvgOrderDetailsAll", sqlParameters2);
            }
            else if (rbtnProductCode.Checked)
            {
                List <SqlParameter> sqlParameters2 = new List <SqlParameter>();
                sqlParameters2.Add(new SqlParameter("date1", dateSumOrder1.Value.Date));
                sqlParameters2.Add(new SqlParameter("date2", dateSumOrder2.Value.Date.AddMinutes(1439)));
                sqlParameters2.Add(new SqlParameter("empId", empId));
                //dataEmpSoldOrderDetails.DataSource = await DataAccessAsync.ExecSPAsync("Sales.dvgOrderDetailsGroupCode", sqlParameters2);
                DataTable dt = await DataAccessAsync.ExecSPAsync("Sales.dvgOrderDetailsGroupCode", sqlParameters2);

                List <OrderDetail>    orderDetails    = ControlerMethods.DataTableToList <OrderDetail>(dt);
                List <AmountSellShow> amountSellShows = await AmountSellForShow(orderDetails);

                dataEmpSoldOrderDetails.DataSource = amountSellShows.ToList();
                dataEmpSoldOrderDetails.Columns[2].DefaultCellStyle.Format = "#,#";
            }
            else if (rbtnCategory.Checked)
            {
                List <SqlParameter> sqlParameters2 = new List <SqlParameter>();
                sqlParameters2.Add(new SqlParameter("date1", dateSumOrder1.Value.Date));
                sqlParameters2.Add(new SqlParameter("date2", dateSumOrder2.Value.Date.AddMinutes(1439)));
                sqlParameters2.Add(new SqlParameter("empId", -1));
                dataEmpSoldOrderDetails.DataSource = await DataAccessAsync.ExecSPAsync("Sales.dvgOrderDetailsGroupCat", sqlParameters2);
            }
        }
 private async void rbtnShowExistProductByCode_CheckedChanged(object sender, EventArgs e)
 {
     dgvExistProduct.DataSource = await DataAccessAsync.ExecSPAsync("Production.GetProductByCode");
 }