Esempio n. 1
0
        //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);
            }
        }