动态报表的创建 (XtraReport) 以及对字段的合计实现方法

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using yxgjjoracle2008.Entities;
using yxgjjoracle2008.Data;
using System.Data;
namespace FrameWork.web.Manager.Module.FrameWork.yxgjj.Report
{
    public partial class ZhuanChuList : DevExpress.XtraReports.UI.XtraReport
    {
        public ZhuanChuList()
        {
            InitializeComponent();
        }

       //下面的函数是自己定义的  (这里参数根据的需要进行设置)
        public ZhuanChuList(YxHuidan Huidan, TList ZhuanyiList)
        {
            
            InitializeComponent();
            this.DataSource = ZhuanyiList;
           
            if (Huidan.SDwzh != null)
            {
                xl_ZcDwzh.Text = Huidan.SDwzh;
                xl_ZcDwmc.Text = DataRepository.DwgjjxxProvider.GetBySDwzh(Huidan.SDwzh).SDwmc;

            }
            if (Huidan.SDestDwzh != null)
            {
                xl_ZrDwzh.Text = Huidan.SDestDwzh;
                xl_ZrDwmc.Text = DataRepository.DwgjjxxProvider.GetBySDwzh(Huidan.SDestDwzh).SDwmc;
            }
            YxHuidanKhzyTemp dd = new YxHuidanKhzyTemp();
            //dd.
                // dd.DcLjye  DcRealLixi
            //绑定相关字段
           
            xl_grzh.DataBindings.AddRange(new XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ZhuanyiList, "SGrzh", "") });
            xl_grxm.DataBindings.AddRange(new XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ZhuanyiList, "SGrxm", "") });
            xl_sfzhma.DataBindings.AddRange(new XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ZhuanyiList, "SSfzhm", "") });
            xl_snbf.DataBindings.AddRange(new XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ZhuanyiList, "DcLjye", "{0:N2}") });
            xl_jnbf.DataBindings.AddRange(new XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ZhuanyiList, "DcJnhj", "{0:N2}") });
            xl_lx.DataBindings.AddRange(new XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ZhuanyiList, "DcRealLixi", "{0:N2}") });

            xl_total_snbf.DataBindings.AddRange(new XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ZhuanyiList, "DcLjye", "{0:N2}") });
            xl_total_lx.DataBindings.AddRange(new XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ZhuanyiList, "DcRealLixi", "{0:N2}") });
            xl_total_jnbf.DataBindings.AddRange(new XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", ZhuanyiList, "DcJnhj", "{0:N2}") });
            //对相关数据项进行合计
          
            XRSummary xrye = new XRSummary();
            //指定对该列进行什么操作
            xrye.Func = DevExpress.XtraReports.UI.SummaryFunc.Sum;
            //指定以什么方式显示结果
            xrye.Running = DevExpress.XtraReports.UI.SummaryRunning.Report;
            //显示格式
            xrye.FormatString = "{0:N2}";
            xl_total_snbf.Summary = xrye;

            XRSummary xrlx = new XRSummary();
            //指定对该列进行什么操作
            xrlx.Func = DevExpress.XtraReports.UI.SummaryFunc.Sum;
            //指定以什么方式显示结果
            xrlx.Running = DevExpress.XtraReports.UI.SummaryRunning.Report;
            //显示格式
            xrlx.FormatString = "{0:N2}";
            xl_total_lx.Summary = xrlx;

            XRSummary xrjnbf = new XRSummary();
            //指定对该列进行什么操作
            xrjnbf.Func = DevExpress.XtraReports.UI.SummaryFunc.Sum;
            //指定以什么方式显示结果
            xrjnbf.Running = DevExpress.XtraReports.UI.SummaryRunning.Report;
            //显示格式
            xrjnbf.FormatString = "{0:N2}";
            xl_total_jnbf.Summary = xrjnbf;

            
        }

    }
}
 


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/xuzhuqing1234venture/archive/2008/12/28/3629108.aspx

你可能感兴趣的:(报表,n2,null,class)