zoukankan      html  css  js  c++  java
  • fastreport代码转

    2016-07-08

    //打印主从表数据
    string file = Application.StartupPath @"MasterDetail.frx";
    rptMasterDetail.Load(file);//加载报表模板文件

    DataSet ds = DAL.GetMasterDetailData();//取报表数据

    rptMasterDetail.RegisterData(ds.Tables[0], "tb_SO"); //注册数据源,主表
    rptMasterDetail.RegisterData(ds.Tables[1], "tb_SOs"); //注册数据源,从表

    //
    //直接注册DataSet也行,但必须对DataSet.Tables指定表名!
    //FastReport是跟据表名取DataTable对象的。
    //
    //rptMasterDetail.RegisterData(ds);
    //

    //给DataBand(主表数据)绑定数据源
    DataBand masterBand = rptMasterDetail.FindObject("Data1") as DataBand;
    masterBand.DataSource = rptMasterDetail.GetDataSource("tb_SO"); //主表

    //给DataBand(明细数据)绑定数据源
    DataBand detailBand = rptMasterDetail.FindObject("Data2") as DataBand;
    detailBand.DataSource = rptMasterDetail.GetDataSource("tb_SOs"); //明细表

    //重要!!给明细表设置主外键关系!
    detailBand.Relation = new Relation();
    detailBand.Relation.ParentColumns = new string[] { "SONO" };
    detailBand.Relation.ParentDataSource = rptMasterDetail.GetDataSource("tb_SO"); //主表
    detailBand.Relation.ChildColumns = new string[] { "SONO" };
    detailBand.Relation.ChildDataSource = rptMasterDetail.GetDataSource("tb_SOs"); //明细表

    //准备工作,显示报表预览窗体
    rptMasterDetail.Prepare();
    rptMasterDetail.ShowPrepared(true, this);

  • 相关阅读:
    转: PHP的"::"、"->"和"=>"的区别
    PHP命名空间
    PHP+MySQL数据库编程的步骤
    SQL基础
    Mysql的CMD操作
    Apache服务器配置
    【网关】SpringCloud-Gateway
    Oracle表分区
    MongoDB---分片
    MongoDB-BSON
  • 原文地址:https://www.cnblogs.com/lhyqzx/p/5652735.html
Copyright © 2011-2022 走看看