关于XtraReport报表分组

现在有个报表是要显示物资目录明细

要按物资品种(即分类的意思)来显示对应的物资。

01001010
010010100001
01002010
010020100001
010020100002
010020100003
010020100004

……

 


RPTWZMLMXBBMaster:物资目录明细报表分组主表窗口

界面上Detail中放置主表显示内容的表格,再插入一个Subreport,在属性面板将其ReportSource属性设为子表的类名称,将产生一个实例名:rptwzmlmxb1


  /// <summary>
        /// 打印前加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RPTWZMLMXBBMaster_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            string strSQL = "select * from wzpz where length(cwzpzbh)=8 order by cwzpzbh";
            DB2Command db2Cmd = new DB2Command(strSQL, new DB2Connection(pModel.ConnectionString));
            DB2DataAdapter db2Da = new DB2DataAdapter();
            db2Da.SelectCommand = db2Cmd;
            DataSet ds = new DataSet();
            db2Da.Fill(ds);
            this.DataMember = TABLE_WZPZ.NAME;
            this.DataSource = ds;
            this.xrTableCell8.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ds, TABLE_WZPZ.COLUMN_CWZPZBH) });
            this.xrTableCell4.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ds, TABLE_WZPZ.COLUMN_CWZPZMC) });

            xrLabel3.Text = DateTime.Now.ToString();
        }


        /// <summary>
        /// Detail加载事件,加载一行,向子表传递一次参数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            RPTWZMLMXB subRPT = subreport1.ReportSource as RPTWZMLMXB;
            subRPT.GetParameters(Convert.ToInt32(GetCurrentColumnValue(TABLE_WZPZ.COLUMN_IID)));//字段名区分大小写
        }


RPTWZMLMXB:物资目录明细表(子表)窗口

子表界面只保留Detail,放置显示内容的表格


        /// <summary>
        /// 接收主分组表参数,绑定数据
        /// </summary>
        /// <param name="IWZPZID"></param>
        public void GetParameters(int IWZPZID)
        {
            string strSQL = "select * from wz where ispbz=2 and iwzpzid=" + IWZPZID;
            DB2Command db2Cmd = new DB2Command(strSQL, new DB2Connection(pModel.ConnectionString));
            DB2DataAdapter db2Da = new DB2DataAdapter();
            db2Da.SelectCommand = db2Cmd;
            DataSet ds = new DataSet();
            db2Da.Fill(ds);
            this.DataMember = TABLE_WZ.NAME;
            this.DataSource = ds;

            this.xrTableCell2.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ds, TABLE_WZ.COLUMN_CWZBH) });
            this.xrTableCell7.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ds, TABLE_WZ.COLUMN_CWZMC) });
            this.xrTableCell8.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ds, TABLE_WZ.COLUMN_CXHGG) });
            this.xrTableCell9.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ds, TABLE_WZ.COLUMN_CTH) });
            this.xrTableCell10.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ds, TABLE_WZ.COLUMN_CCZ) });
            this.xrTableCell12.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ds, TABLE_WZ.COLUMN_CJLDW) });
        } 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值