public void ShowReport(ReportData reportData) { BaseReportView frmReport = new BaseReportView(); List <ReportDataSource> reportDataSource = CreatReportDataSource(reportData); foreach (ReportDataSource rds in reportDataSource) { frmReport.reportViewer1.LocalReport.DataSources.Add(rds); } frmReport.reportViewer1.LocalReport.ReportEmbeddedResource = reportData.ReportName; List <ReportParameter> paraList = new List <ReportParameter>(); foreach (ReportParameterInfo rpi in frmReport.reportViewer1.LocalReport.GetParameters()) { if (rpi.Prompt.Equals("单位名称")) { paraList.Add(new ReportParameter(rpi.Name, "单位名称测试")); } } frmReport.reportViewer1.LocalReport.SetParameters(paraList); frmReport.Show(); }
public void ShowReport(object DataSetObj, object DataAdapterObj, string DataTableName, string ReportName, string DataSourceName, long pid) { BaseReportView frmReport = new BaseReportView(); BindingSource ReportBindingSource = new BindingSource(); ReportBindingSource.DataSource = DataSetObj; ReportBindingSource.DataMember = DataTableName; ReportDataSource reportDataSource = new ReportDataSource(); reportDataSource.Name = DataSourceName; reportDataSource.Value = ReportBindingSource; frmReport.ReportResource = ReportName; frmReport.ReportDataSource = new List <ReportDataSource>() { reportDataSource }; frmReport.Show(); }