topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday April 19, 2024, 1:16 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Crystal Reports  (Read 6904 times)

shaik akbar

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 1
    • View Profile
    • Donate to Member
Crystal Reports
« on: July 01, 2006, 11:48 AM »
Hello all,

I am new to C++ builder 6.0
I want to generate the crystal reports dynamically with c++ builder. Can
anybody give me idea how can i start.

Anyone help me greatly appreciated.

Thanks
SA

Shed

  • Honorary Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 26
    • View Profile
    • Donate to Member
Re: Crystal Reports
« Reply #1 on: July 03, 2006, 09:52 AM »
Hello, ...well i just use the "default" components called QReport on Pallete component, in c++ builder environment
and this is for "design" time....not dinamically....

1) drop a Qreport1 component on the desired form that ACT as Report preview

2) configure the properties accordly to your preferences (link to DataSources etc)

3) first, add the HEADER of the Report (this can be totally void (or empty))

4) once you add the Header band, you can ADD the other QRBand's that for example, related to a certain registers on a Table, will be repeated until the End of File (EOF) (in this case, the registers of the table will be repeated on diferent lines)
For this DATA VISUALIZATION, we'll use the TQRDBText component (text from a database or table) or if the text is always the same....use TQRLabel......also for Table listings (called SubDetail Band), you must link the BAND property called DataSet to the Table we're using....

5) add the FOOTER section for print the Page footer....

6) Eventually, if you need "listings" of registers, you must LINK the DataSet property of QRSubDetail Band to the specified table

for example, this is a example QReport Page, as you can see, have the header, one QRSubDetailBand and the Footer





And this is (like example only) a supposed Events and code lines "behind" the Report Page

void __fastcall TForm24::QRSubDetail1BeforePrint(TQRCustomBand *Sender,
      bool &PrintBand)
{
  int encontrado = 0;
  TLocateOptions opciones;
  opciones.Clear();


   DataModule1->Tabla_envases->First();
        encontrado = DataModule1->Tabla_envases->Locate("TIPO_ENV", DataModule1->MyTable_STOCK_SALIDAS->FieldByName("TIPO_ENV")->AsString, opciones);
        if(!encontrado) {   }
        else {

                     //Product found on table
                     //we take the value from table, and assign to PAK_TYPE
              PAK_TYPE->Caption = DataModule1->Tabla_envases->FieldByName("PAK_TYPE")->AsString;
              PAK_TYPE->Refresh();

              }

   ///////////////////if TIPO_ENV == "GRANEL" we print the Liters, else ...we print the units//////////////////////////////
   if(DataModule1->MyTable_STOCK_SALIDAS->FieldByName("TIPO_ENV")->AsString == "GRANEL")
    {
      QRLabel_num_litros->Caption = FormatFloat("##,###", DataModule1->MyTable_STOCK_SALIDAS->FieldByName("LTS_TOTAL")->AsFloat);
      QRLabel_num_litros->Refresh();
      Label_unidades->Caption = "";
      Label_unidades->Refresh();
      contador_productos++;
     }
   else { QRLabel_num_litros->Caption = ""; QRLabel_num_litros->Refresh();
          Label_unidades->Caption = DataModule1->MyTable_STOCK_SALIDAS->FieldByName("UNIDADES")->AsInteger;
          Label_unidades->Refresh();
          contador_productos++;
            }
}
//---------------------------------------------------------------------------



void __fastcall TForm24::QuickRep1BeforePrint(TCustomQuickRep *Sender,
      bool &PrintReport)
{

 //////////here we assign to Label_PUERTO, the value from a editbox located on Form30////////////////////////
 Label_PUERTO->Caption = Form30->Edit_PUERTO->Text;
 Label_PUERTO->Refresh();

}
//---------------------------------------------------------------------------

void __fastcall TForm24::FormShow(TObject *Sender)
{
 contador_productos = 0;
}
//---------------------------------------------------------------------------


« Last Edit: July 09, 2006, 11:51 PM by Shed »