Exemplo n.º 1
0
		private void SetDataSource(ReportDocument Report)
		{
            ReportDataset rptds = new ReportDataset();

            string ProductGroupName = string.Empty;
            if (cboGroup.SelectedItem.Value != Constants.ZERO_STRING) ProductGroupName = cboGroup.SelectedItem.Text;
            string SubGroupName = string.Empty;
            if (cboSubGroup.SelectedItem.Value != Constants.ZERO_STRING) SubGroupName = cboSubGroup.SelectedItem.Text;

            DateTime dteIDCStartDate = DateTime.Now.AddDays(-14);
            DateTime dteIDCEndDate = DateTime.Now;
            
            try { dteIDCStartDate = Convert.ToDateTime(txtStartTransactionDate.Text + " " + txtStartTime.Text);}catch{}
            try { dteIDCEndDate = Convert.ToDateTime(txtEndTransactionDate.Text + " " + txtEndTime.Text);}catch{}

			Products clsProduct = new Products();
            
            if (cboSupplier.SelectedItem.Text == Constants.ALL)
            { 
                if (cboSubGroup.SelectedItem.Text == Constants.ALL)
                { clsProduct.UpdateProductReorderOverStockPerSubGroup(long.Parse(cboSubGroup.SelectedItem.Value), dteIDCStartDate, dteIDCEndDate); }
                else if (cboSubGroup.SelectedItem.Text == Constants.ALL)
                { clsProduct.UpdateProductReorderOverStockPerGroup(long.Parse(cboGroup.SelectedItem.Value), dteIDCStartDate, dteIDCEndDate); }
                else
                { clsProduct.UpdateProductReorderOverStock(dteIDCStartDate, dteIDCEndDate); }
            }
            else
            {
                if (cboSubGroup.SelectedItem.Text == Constants.ALL)
                { clsProduct.UpdateProductReorderOverStockPerSupplierPerSubGroup(long.Parse(cboSupplier.SelectedValue), long.Parse(cboSubGroup.SelectedItem.Value), dteIDCStartDate, dteIDCEndDate); }
                else if (cboSubGroup.SelectedItem.Text == Constants.ALL)
                { clsProduct.UpdateProductReorderOverStockPerSupplierPerGroup(long.Parse(cboSupplier.SelectedValue), long.Parse(cboGroup.SelectedItem.Value), dteIDCStartDate, dteIDCEndDate); }
                else
                { clsProduct.UpdateProductReorderOverStockPerSupplier(long.Parse(cboSupplier.SelectedValue), dteIDCStartDate, dteIDCEndDate); }
            }
            clsProduct.CommitAndDispose();

            clsProduct = new Products();
            System.Data.DataTable dt = (clsProduct.SearchDataTable(ProductListFilterType.ShowActiveOnly, string.Empty, long.Parse(cboSupplier.SelectedValue),
                                            long.Parse(cboGroup.SelectedItem.Value), string.Empty, long.Parse(cboSubGroup.SelectedItem.Value), string.Empty, 0, false, false, string.Empty, SortOption.Ascending));
            clsProduct.CommitAndDispose();

            foreach(System.Data.DataRow dr in dt.Rows)
            {
                DataRow drProducts = rptds.Products.NewRow();

                foreach (DataColumn dc in rptds.Products.Columns)
                    drProducts[dc] = dr[dc.ColumnName];

                rptds.Products.Rows.Add(drProducts);
            }

            //ProductVariationsMatrix clsMatrix = new ProductVariationsMatrix(clsProduct.Connection, clsProduct.Transaction);
            //rptds.Tables.Add(clsMatrix.BaseListAsDataTable(0, "a.ProductID", SortOption.Ascending));
            // ds.Tables.Add(clsMatrix.ForReorder("a.Quantity", SortOption.Ascending));

            Report.SetDataSource(rptds);

			SetParameters(Report);
		}