4,820
社区成员
发帖
与我相关
我的任务
分享
string[] paraNames = {"cs_ny"};//"cs_ny"
string[] paraValues = {time};//"201009"
DataTable dt = null;
DataBase db = new DataBase();
dt = db.GetTableFromProc("pk_zykdb.p_zykdb", paraNames, paraValues);
DataTable dt2 = null;
//第二个参数
string[] paraNames2 = { "cs_ny", "cs_cc" };//"cs_ny"
//string[] paraValues = { "201009", "4737", "郑州", "洛阳" };//"201009"
//MessageBox.Show(dt.Columns[1].ToString());
string[] paraValues2 = { year + month,"4737"};
dt2 = db.GetTableFromProc("pk_ccmxdb.p_ccmxdb", paraNames2, paraValues2);
//db.closeDBconn();
this.zongyingkui1.Load(@"C:\work\PTASS_ZZ\src\ptass_main\PTASS\PTASS\zongyingkui.rpt");
this.zongyingkui1.SetDataSource(dt);
this.zongyingkui1.Subreports[0].SetDataSource(dt2);
this.crystalReportViewer1.ReportSource = zongyingkui1;
this.crystalReportViewer1.Refresh();
private void loadData(string rdlcName,string dataSourseName)
{
string fyName = Program.report_itemName;
string cc = Program.report_cc;
string ny = Program.report_ny;
//这个格式化的年月值用于在报表中显示
string ny_Format = ny.Substring(0, 4) + "年" + ny.Substring(4, 2) + "月";
string[] paramName = { "cs_ny", "cs_cc", "cs_xm" };
string[] paramValue = { ny,cc,fyName};
DataTable dt_syfsr = null;
DataBase db_syfsr = new DataBase();
dt_syfsr = db_syfsr.GetTableFromProc("pk_jsgcms.p_jsgcms", paramName, paramValue);
db_syfsr.closeDBconn();
this.reportViewer1.LocalReport.ReportEmbeddedResource = rdlcName;
ReportParameter rp_ny = new ReportParameter("show_ny",ny_Format);
ReportParameter rp_cc = new ReportParameter("show_cc", cc);
ReportParameter rp_fyName = new ReportParameter("show_fyName", fyName);
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp_ny, rp_cc, rp_fyName });
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource(dataSourseName, dt_syfsr));
//显示报表
this.reportViewer1.RefreshReport();
}