110,535
社区成员
发帖
与我相关
我的任务
分享
//repname 是报表的名称,其他是一些取数的参数。
private void cOpenRep(string auid, string pici, DataSet dataSet,string repname) //打开报表
{
this.reportViewer1.LocalReport.ReportEmbeddedResource = repname;
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("myds", dataSet.Tables[0]));
ClassMyData.DbSystem db = new ClassMyData.DbSystem();
switch (repname)
{
case "c_report.bd2.rdlc":
ReportParameter rp = new ReportParameter("pici", pici);
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });
break;
case "c_report.bd3.rdlc":
ReportParameter rp1 = new ReportParameter("cdate", Convert.ToDateTime(db.GetValue("SELECT cvalue1 FROM tb_canshu WHERE cpici='" + _pici + "' AND bd_autoid=17")).ToShortDateString());
ReportParameter rp2 = new ReportParameter("beizhu", db.GetValue("SELECT cvalue2 FROM tb_canshu WHERE cpici='" + _pici + "' AND bd_autoid=25"));
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp1, rp2 });
break;
default:
break;
}
this.reportViewer1.RefreshReport();//显示报表
}