锐浪报表显示(含子报表)

到时候直接赋值给
(1)数据库连接字符串
(2)查询语句
(3)有子报表参照工艺用水的,这个有两个子报表

public GridppReport Report = new GridppReport();
        public GridppReport SonReport1 = new GridppReport();//子报表1
        public GridppReport SonReport2 = new GridppReport();//子报表2
        string 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)
            {

            }
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值