从Corba接口中取到的数据填充FastReport报表

环境:

编程工具:Borland C++ Builder 6.0

操作系统:windows 2000

应用软件:FastReport5.2破解版



1.安装FastReport
如安装到c:/program files/fastreports

2.在bcb 6中使用FastReport(本过程从RastReport中抄写)
l         复制c:/program files/fastreports/ fastreport /RES/chinese文件夹到c:/program files/fastreports/ fastreport/SOURCE

l         Copy fr_class.pas to the installation folder

l         "/FastReports/FastReport/sources/" (default folder)

l         Run C++ Builder 6.0

l         Select menu Component->Install Packages. Check in packages list "FastReport 2.5 Components" and click Remove button,  Answer "Yes" to all questions. Click "OK".

l         Select menu File->Open, select file fr6.bpk from folder"/FastReports/FastReport/sources/"

l         Press buttons "Compile" and "Install" in opened window

l         Close C++ Builder. On query about save fr6.bpk ansver "No".

l         Run C++ Builder.

l         Select menu "Component"->"Install Packages" and set select for all installed FastReport related packages (ADO, BDE, DBX etc)

l         安装用到的其它额外的组件:There are three additional components included in standard FR package.These components can be found in SOURCE/BDE, SOURCE/IBX and SOURCE/ADO folders. They supersede old datamanager (TfrDataStorage component). To install them, use same technique as described above. Each component have a package file. To install in Delphi2, use file with Reg suffix (for example,FR_BDEReg.pas).

3.使用内存表
l         从BDE中拉Ttable控件,在窗体的构造函数中写如下代码,创建数据库和表和表字段和字段类型:

    Table1->Close();

    Table1->DatabaseName = "c://tempDB";

    Table1->TableType = ttParadox;//数据库类型

    Table1->TableName = "TREPORT_EXCHANGE";

    if (!Table1->Exists) // Don't overwrite an existing table

    {

    // describe the fields in the table

    Table1->FieldDefs->Clear();

    TFieldDef *pNewDef = Table1->FieldDefs->AddFieldDef();

    pNewDef->Name = "ITEM_NAME";

    pNewDef->DataType = ftString;



    pNewDef = Table1->FieldDefs->AddFieldDef();

    pNewDef->Name = "CARDTYPE";

    pNewDef->DataType = ftInteger;



    pNewDef = Table1->FieldDefs->AddFieldDef();

    pNewDef->Name = "AREA_NAME";

    pNewDef->DataType = ftString;



    pNewDef = Table1->FieldDefs->AddFieldDef();

    pNewDef->Name = "OPER_NAME";

    pNewDef->DataType = ftString;



    pNewDef = Table1->FieldDefs->AddFieldDef();

    pNewDef->Name = "FEECOUNT";

    pNewDef->DataType = ftString;



    pNewDef = Table1->FieldDefs->AddFieldDef();

    pNewDef->Name = "ConsumeTimes";

    pNewDef->DataType = ftString;



    Table1->CreateTable();

    }

l         编译后设置Ttable属性:

n         DatabaseName=c:/tempDB文件夹路径

n         Tablename=TREPORT_EXCHANGE

拉FastReport中的frReport和frDbDataSet控件。

设置frDbDataSet的DataSet属性为Ttable,frReport的Dataset属性为frDbDataSet

l         双击frReport设计报表视图。

保存到当前目录下的BusiStatByBusiItem.frf文件

l         添加一个按钮,并添加单击事件代码如下,注意在头文件中添加idl2cpp生成的.h文件:

CORBA::ORB_var orb = ::CORBA::ORB_init(__argc, __argv);

  Table1->Open();

//每次报表前清空数据

  while(Table1->FindFirst())

  {

        Table1->Delete();

  }



  PortableServer::ObjectId_var managerId =

          PortableServer::string_to_ObjectId("InterfaceReport");

  VipCenter::InterfaceReport_var manager =VipCenter::InterfaceReport::_bind("/InterfaceReport_poa",managerId);

  VipCenter::StructRet_var retVar1;

  VipCenter::SeqReportExchange_var seqReportExchange;



  CORBA::ULong i=0;

  VipCenter::date_time dt_start,dt_end;



dt_start.year=2002;

dt_start.month=1;

dt_start.day=1;

dt_start.hour=0;

dt_start.minute=0;

dt_start.second=0;



dt_end.year=2004;

dt_end.month=1;

dt_end.day=1;

dt_end.hour=0;

dt_end.minute=0;

dt_end.second=0;

   //retVar1 = manager->BusiStatByVipCardType("571000100001",dt_start,dt_end,"1",571,seqReportExchange.out());

   retVar1 = manager->BusiStatByBusiItem("571000100001",dt_start,dt_end,1,571,seqReportExchange.out());



  for(i=0;i<seqReportExchange->length();i++)

  {

        Table1->AppendRecord(ARRAYOFCONST((

        (AnsiString)seqReportExchange .ITEM_NAME

        ,(short)(seqReportExchange.CARDTYPE)

        ,(AnsiString)seqReportExchange.AREA_NAME

        ,(AnsiString)seqReportExchange.OPER_NAME

        , (AnsiString)seqReportExchange.FEECOUNT

        ,(AnsiString)seqReportExchange.ConsumeTimes)));

  }

  Table1->Close();

  Table1->Active = true;

  frReport1->LoadFromFile("BusiStatByBusiItem.frf");

  frReport1->ShowPreparedReport();

  frReport1->ShowReport();

  }
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值