ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Borland C++ Builder Contest

Crystal Reports

(1/1)

shaik akbar:
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:
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;
}
//---------------------------------------------------------------------------


Navigation

[0] Message Index

Go to full version