public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { FertilizerIssueRegisterRPT rpt = new FertilizerIssueRegisterRPT(); rpt.Site = this.Site; return(rpt); }
private void btnDisplay_Click(object sender, EventArgs e) { try { DataSet dataSetReport = new DataSet(); BoughtLeafBusinessLayer.Reports myReports = new BoughtLeafBusinessLayer.Reports(); ReportViewer myReportViewer = new ReportViewer(); if (chkSupplier.Checked) { if (chkFertilizerAll.Checked) { dataSetReport = myReports.getFertlizerIssuesSummary(Convert.ToInt32(cmbYear.Text), Convert.ToInt32(cmbMonth.SelectedValue.ToString())); myReportViewer.crystalReportViewer1.DisplayGroupTree = true; // because report group by fertilzer there for display group tree of report } else { dataSetReport = myReports.getFertlizerIssuesSummaryByFert(Convert.ToInt32(cmbYear.Text), Convert.ToInt32(cmbMonth.SelectedValue.ToString()), cmbFertilizer.SelectedValue.ToString()); } } else { dataSetReport = myReports.getFertlizerIssuesSummaryBySup(Convert.ToInt32(cmbYear.Text), Convert.ToInt32(cmbMonth.SelectedValue.ToString()), cmbSupplier.SelectedValue.ToString()); myReportViewer.crystalReportViewer1.DisplayGroupTree = true; // because report group by fertilzer there for display group tree of report } dataSetReport.WriteXml("FertilizerIssueSummary.xml"); FertilizerIssueRegisterRPT myaclist = new FertilizerIssueRegisterRPT(); myaclist.SetDataSource(dataSetReport); myaclist.SetParameterValue("Year", cmbYear.Text); myaclist.SetParameterValue("Month", cmbMonth.Text); myaclist.SetParameterValue("Company", BoughtLeafBusinessLayer.BLUser.getCompanyName()); myReportViewer.crystalReportViewer1.ReportSource = myaclist; myReportViewer.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }