private void SetDataSource(ReportDocument Report) { ReportDataset rptds = new ReportDataset(); DateTime PostingDateFrom = DateTime.MinValue; try { PostingDateFrom = Convert.ToDateTime(txtStartDate.Text + " " + txtStartTime.Text); } catch {} DateTime PostingDateTo = DateTime.MinValue; try { PostingDateTo = Convert.ToDateTime(txtEndDate.Text + " " + txtEndTime.Text); } catch {} DataClass clsDataClass = new DataClass(); System.Data.DataTable dt; string ReportType = cboReportType.SelectedItem.Text; switch (ReportType) { case "Posted SO": Data.SO clsSO = new Data.SO(); dt = clsDataClass.DataReaderToDataTable(clsSO.List(SOStatus.Posted, PostingDateFrom, PostingDateTo)); clsSO.CommitAndDispose(); foreach (System.Data.DataRow dr in dt.Rows) { DataRow drSO = rptds.SO.NewRow(); foreach (DataColumn dc in rptds.SO.Columns) { drSO[dc] = dr[dc.ColumnName]; } rptds.SO.Rows.Add(drSO); } break; case "Posted SO Returns": Data.SOReturns clsSOReturns = new Data.SOReturns(); dt = clsDataClass.DataReaderToDataTable(clsSOReturns.List(SOReturnStatus.Posted, PostingDateFrom, PostingDateTo)); clsSOReturns.CommitAndDispose(); foreach (System.Data.DataRow dr in dt.Rows) { DataRow drSOReturns = rptds.SOReturns.NewRow(); foreach (DataColumn dc in rptds.SOReturns.Columns) { drSOReturns[dc] = dr[dc.ColumnName]; } rptds.SOReturns.Rows.Add(drSOReturns); } break; case "Posted Credit Memo": Data.CreditMemos clsCreditMemos = new Data.CreditMemos(); dt = clsDataClass.DataReaderToDataTable(clsCreditMemos.List(CreditMemoStatus.Posted, PostingDateFrom, PostingDateTo)); clsCreditMemos.CommitAndDispose(); foreach (System.Data.DataRow dr in dt.Rows) { DataRow drCreditMemos = rptds.CreditMemo.NewRow(); foreach (DataColumn dc in rptds.CreditMemo.Columns) { drCreditMemos[dc] = dr[dc.ColumnName]; } rptds.CreditMemo.Rows.Add(drCreditMemos); } break; case "By Vendor": Data.SalesAnalysis clsSalesAnalysis = new Data.SalesAnalysis(); dt = clsSalesAnalysis.ByVendor(PostingDateFrom, PostingDateTo); clsSalesAnalysis.CommitAndDispose(); foreach (System.Data.DataRow dr in dt.Rows) { DataRow drPAByVendor = rptds.SalesAnalysisPerCustomer.NewRow(); foreach (DataColumn dc in rptds.SalesAnalysisPerCustomer.Columns) { drPAByVendor[dc] = dr[dc.ColumnName]; } rptds.SalesAnalysisPerCustomer.Rows.Add(drPAByVendor); } break; default: break; } Report.SetDataSource(rptds); SetParameters(Report); }
private void SetDataSource(ReportDocument Report) { ReportDataset rptds = new ReportDataset(); DateTime PostingDateFrom = DateTime.MinValue; try { PostingDateFrom = Convert.ToDateTime(txtStartDate.Text + " " + txtStartTime.Text); } catch{} DateTime PostingDateTo = DateTime.MinValue; try { PostingDateTo = Convert.ToDateTime(txtEndDate.Text + " " + txtEndTime.Text); } catch{} DataClass clsDataClass = new DataClass(); System.Data.DataTable dt; string ReportType = cboReportType.SelectedItem.Text; switch (ReportType) { case "Posted SO": Data.SO clsSO = new Data.SO(); dt = clsDataClass.DataReaderToDataTable(clsSO.List(SOStatus.Posted, PostingDateFrom, PostingDateTo)); clsSO.CommitAndDispose(); foreach(System.Data.DataRow dr in dt.Rows) { DataRow drSO = rptds.SO.NewRow(); foreach (DataColumn dc in rptds.SO.Columns) drSO[dc] = dr[dc.ColumnName]; rptds.SO.Rows.Add(drSO); } break; case "Posted SO Returns": Data.SOReturns clsSOReturns = new Data.SOReturns(); dt = clsDataClass.DataReaderToDataTable(clsSOReturns.List(SOReturnStatus.Posted, PostingDateFrom, PostingDateTo)); clsSOReturns.CommitAndDispose(); foreach(System.Data.DataRow dr in dt.Rows) { DataRow drSOReturns = rptds.SOReturns.NewRow(); foreach (DataColumn dc in rptds.SOReturns.Columns) drSOReturns[dc] = dr[dc.ColumnName]; rptds.SOReturns.Rows.Add(drSOReturns); } break; case "Posted Credit Memo": Data.CreditMemos clsCreditMemos = new Data.CreditMemos(); dt = clsDataClass.DataReaderToDataTable(clsCreditMemos.List(CreditMemoStatus.Posted, PostingDateFrom, PostingDateTo)); clsCreditMemos.CommitAndDispose(); foreach(System.Data.DataRow dr in dt.Rows) { DataRow drCreditMemos = rptds.CreditMemo.NewRow(); foreach (DataColumn dc in rptds.CreditMemo.Columns) drCreditMemos[dc] = dr[dc.ColumnName]; rptds.CreditMemo.Rows.Add(drCreditMemos); } break; case "By Vendor": Data.SalesAnalysis clsSalesAnalysis = new Data.SalesAnalysis(); dt = clsSalesAnalysis.ByVendor(PostingDateFrom, PostingDateTo); clsSalesAnalysis.CommitAndDispose(); foreach(System.Data.DataRow dr in dt.Rows) { DataRow drPAByVendor = rptds.SalesAnalysisPerCustomer.NewRow(); foreach (DataColumn dc in rptds.SalesAnalysisPerCustomer.Columns) drPAByVendor[dc] = dr[dc.ColumnName]; rptds.SalesAnalysisPerCustomer.Rows.Add(drPAByVendor); } break; default: break; } Report.SetDataSource(rptds); SetParameters(Report); }