本文主要是介绍锐浪报表显示(含子报表),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
到时候直接赋值给
(1)数据库连接字符串
(2)查询语句
(3)有子报表参照工艺用水的,这个有两个子报表
public GridppReport Report = new GridppReport();public GridppReport SonReport1 = new GridppReport();//子报表1public GridppReport SonReport2 = new GridppReport();//子报表2string ReportStr = "";string ReportStr1 = "";//子报表1查询语句string ReportStr2 = "";//子报表2查询语句public void ReportMain()//主报表{Report.DetailGrid.Recordset.ConnectionString = "Provider=SQLNCLI10.1;" + mycon.connect.constr;//报表sql数据库字符串,NativeClient和oledb方式均可//Report.DetailGrid.Recordset.ConnectionString = "Provider=SQLOLEDB.1;" + mycon.connect.constr;//报表sql数据库字符串//声明是OLEDB方式,不然报错“未能用指定连接串 "连接字段"连接到数据源,连接串中的用户名和密码已隐藏”Report.DetailGrid.Recordset.QuerySQL = ReportStr;//查询语句字符串// Report.ParameterByName("custinfo").AsString = custinfo;//报表参数}private void ReportWithSonReport1()//子报表1{ //用推模式为报表提供数据,将按条件生成的SQL设置到报表上SonReport1.DetailGrid.Recordset.QuerySQL = ReportStr1;}private void ReportWithSonReport2()//子报表2{//用推模式为报表提供数据,将按条件生成的SQL设置到报表上SonReport2.DetailGrid.Recordset.QuerySQL = ReportStr2;}private void button6_Click(object sender, EventArgs e){try{axGRPrintViewer1.Stop();if (comboBox9.Text == "成品报告")//成品报告:法定标准{ReportStr = "SELECT checkitem,legalstandard,legal from d_CheckData where suid='"+label27.Text+"'";Report.LoadFromFile(Application.StartupPath + "\\reports\\成品检验报告书.grf");Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportMain);//报表显示}else if (comboBox9.Text == "工艺用水")//工艺用水:内控标准{//1.查询语句及报表ReportStr1 = "SELECT top 12 checkitem,legalstandard,legal from d_CheckData where suid='" + label27.Text + "'";ReportStr2 = "SELECT top 12 checkitem,legalstandard,legal from d_CheckData where suid='" + label27.Text + "'";Report.LoadFromFile(Application.StartupPath + "\\reports\\工艺用水检验报告书.grf");//2.报表数据调用Report.ControlByName("SubReport1").AsSubReport.Report = SonReport1;SonReport1.DetailGrid.Recordset.ConnectionString = "Provider=SQLNCLI10.1;" + mycon.connect.constr;Report.ControlByName("SubReport2").AsSubReport.Report = SonReport2;SonReport2.DetailGrid.Recordset.ConnectionString = "Provider=SQLNCLI10.1;" + mycon.connect.constr;Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportMain);SonReport1.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportWithSonReport1);SonReport2.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportWithSonReport2); }//Report.PrintPreview(true);axGRPrintViewer1.Report = Report;axGRPrintViewer1.Start();}catch (System.Exception ex){}}
这篇关于锐浪报表显示(含子报表)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!