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

类别:编程语言 点击:0 评论:0 推荐:
从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[i].ITEM_NAME

        ,(short)(seqReportExchange[i].CARDTYPE)

        ,(AnsiString)seqReportExchange[i].AREA_NAME

        ,(AnsiString)seqReportExchange[i].OPER_NAME

        , (AnsiString)seqReportExchange[i].FEECOUNT

        ,(AnsiString)seqReportExchange[i].ConsumeTimes)));

  }

  Table1->Close();

  Table1->Active = true;

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

  frReport1->ShowPreparedReport();

  frReport1->ShowReport();

  }

 

本文地址:http://com.8s8s.com/it/it29049.htm