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);

fastreport代码转的更多相关文章

  1. FastReport代码计算高度

    Dim iHeight As Double        Dim columnData_form As DataSourceBase             iHeight=Page1.TopMarg ...

  2. ERP开源框架 + 二次开发平台 介绍

    经历了多年软件开发,深受网络大侠们的资源共享才得以有所成绩, 本人主要是做企业ERP软件,一直有个感受,开发具体某个功能不难,但随着需求的增加,管理庞大的代码却成了最大的问题 而为企业管理所做的开发, ...

  3. Winform中使用FastReport的PictureObject时通过代码设置图片源并使Image图片旋转90度

    场景 FastReport安装包下载.安装.去除使用限制以及工具箱中添加控件: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/10 ...

  4. fastreport.net cdoe 自己的代码

      //初始             Report report1 = new Report();             report1.Clear();             string Re ...

  5. 使用fastreport以代码方式创建报表

    Report report = new Report();// register the "Products" tablereport.RegisterData(dataSet1. ...

  6. Winform中使用FastReport的DesignReport时怎样给通过代码Table添加数据

    场景 FastReport安装包下载.安装.去除使用限制以及工具箱中添加控件: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/10 ...

  7. 使用FastReport打印二维码

    简单介绍一下该功能所在的项目背景:C#语言编写的WPF客户端应用程序,在“结账”模块中,打印出的收款小票上需要显示一个二维码,服务生拿着小票去找顾客,顾客可以选择现金.银行卡等普通支付方式,也可以直接 ...

  8. FastReport.Net 常用功能总汇

    一.常用控件 文本框:输入文字或表达式 表格:设置表格的行列数,输入数字或表达式 子报表:放置子报表后,系统会自动增加一个页面,你可以在此页面上设计需要的报表.系统在打印处理时,先按主报表打印,当碰到 ...

  9. FastReport自定义数据源及ListView控件的使用

    ##1.想批量生成一堆物资信息卡,效果如下图所示,fastreport可以一下全部生成,并且发现不用单独写东西, ##2.发现FastReport官方给出的Demo.exe很友好,基本可以满足要求,想 ...

随机推荐

  1. List转DataSet

    public DataSet ConvertToDataSet<T>(IList<T> list) { if (list == null || list.Count <= ...

  2. 1058FBI<二叉树,递归,后序遍历>

    问题描述 我们可以把由"0"和"1"组成的字符串分为三类:全"0"串称为B串,全"1"串称为I串,既含"0&q ...

  3. N层架构实现的一个小例子

    主要用到了[单例,抽象工厂,缓存,N层,反射]等知识.架构图如下: 解决方案用到的项目列表如下: 在接口项目中,定义一个IUER接口. namespace IDAL { public interfac ...

  4. Xcode制作插件

    转发至:https://onevcat.com/2013/02/xcode-plugin/ Xcode 4 插件制作入门 本文欢迎转载,但烦请保留此行出处信息:http://www.onevcat.c ...

  5. 计算机学院大学生程序设计竞赛(2015’12) 1005 Bitwise Equations

    #include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using ...

  6. MAC 调整Launchpad 图标大小

    1.调整每一列显示图标数量 defaults write com.apple.dock springboard-rows -int 7 2.调整每一行显示图标数量 defaults write com ...

  7. openstack controller ha测试环境搭建记录(一)——操作系统准备

    为了初步了解openstack controller ha的工作原理,搭建测试环境进行学习. 在学习该方面知识时,当前采用的操作系统版本是centos 7.1 x64.首先在ESXi中建立2台用于测试 ...

  8. CDOJ 1272 Final Pan's prime numbers

    有些问题,不做实践与猜测,可能一辈子也想不出答案,例如这题. #include<stdio.h> #include<math.h> long long x; int main( ...

  9. Redis 代理 twemproxy

    4台 redis 服务器 172.16.1.37:6379   - 1 172.16.1.36:6379   - 2 172.16.1.35:6379   - 3 172.16.1.34:6379   ...

  10. 关于cin的用法一些小结

    在写二叉树的时候遇到if(!cin)那几个标志位弄得并不清楚,还遇到了诸如cin.clear()等函数,感觉C++又白学了,于是打算去网上搜了几篇靠谱的文章,有时候看来,一些事件处理类的工程代码,在A ...