     

    19  

    Delphi        ,   
     .     
Delphi   QuickReport    ,  
       .  
,  DecisionCube,      Delphi 3.0, 
    .    
, Delphi     .      
    DecisionCube    
    .    ,    Delphi. 

      

        ,      EMPLOYEE. GDB  
InterBase,     Delphi  Client/Server,  
  :   ,    
   ,   "-",  
    ,      
      .  ,     
         
,       
  . 

      EMPLOYEE . GDB 

      EMPLOYEE. GDB     Delphi (  
Client/Server),    InterBase. 
       InterBase   ,     
   ,     
  .  . 19.1    EMPLOYEE.GDB. 
     , Delphi     BDE IBLOCAL, 
      EMPLOYEE . GDB.     
       ,   
   EMPLOYEE . GDB. 

     Customer List Report 

          ,     
  CUSTOMER   EMPLOYEE . GDB,   . 
    1.    File^New Application  ,   
  . 
    2.       Name   
CustomerReport (      Caption). 

    394 IV.    

    3.      TQuickRep    
 ReportTitle  Customer List Report. 
    4.     TQuery     Name 
 MasterQuery. 

      
            
 QuickReport,     Delphi. -,  
 .     ,    
Forms  Object Repository,  QuickReport      
.     TQuickRep.  ,   
        ,    
,     -   TPanel  TForm   
 TQuickRep.         Forms 
 Screen.          ,  
       REPORTS,   
   . ,          
     RTTI (Runtime Type 
Information),          TQuickRep. 

    . 19.1.    EMPLOYEE . GDB 

    5.    DataBaseName  MasterQuery  
IBLOCAL.       SQL  . 

    SELECT * FROM CUSTOMER 

    6.     Active  MasterQuery,  
   (,   InterBase     
     ). 
    7.    DataSet  QuickRep  , 
     MasterQuery. 
    8.    QRBand   QuickRep.  
  BandType     rbTitle,    
rbColumnHeader,    rbDetaii     rbPageFooter. 

     19.  395 

    9.   QRSy5Data       
   Alignment  taCenter,   Data  qrsReportTitle. 
    10.    QRDBText       
   DataSet  MasterQuery.     
. ,          
   ,    <Shift>. 
    11.    DataField   QRDBText  
CUSTOMER,    CITY,    STATE_PROVINCE,     COUNTRY. 
    12.    QRLabel    .  
           
.       QRDBText   
   Caption  ,     
   . ,  Caption   
QRLabel    Customer,      
  CUSTOMER. 
    13.     ,    
Font    QRLabel  ,     
 Bold  Underline. 
    14.   QRLabel         
   Caption  Report Date:. 
    15.    Report Date:    QRLabel   
    Caption  Report Time:. 
    16.   QRSysData    Report Date:    
    Data  qrsDate.  QRSysData 
    ,     
,    ..       
      . 
    17.    QRSysData    Report Date:.  
 Data     qrsTime.     
     . 
    18.        LISTREPO. PAS. 
        ,  Customer List Report  
  .  . 19.2 ,     
 . 
     ,     ,   
            
Preview. ,    ,   , 
   . 19.3. 
    ,         
,          . 
         ,  
       ,   
.          
  Delphi. 

    . 19.2. .     Customer List Report 

    396 IV.    

    . 19.3.    Customer List Report 

     Customer Group Report 

         ,     
    ,      
  . 
    1.        Customer List Report  
      Add To Repository. 
    2.    ,  Customer Report,  
   Description  Generic Customer Report Class. 
       Forms ,   
   . 
    3.   File^New,     Forms  
  New Items     Customer Report. 
    4.   Inherit,      .  
   Delphi     Customer Report. 
     ,  ,   DataSet   
      .   
,   Delphi,   ,   
     Customer Report,  . 
    ,      ,     
     Customer Group Report.    
  . 
    1.    Name    CustomerGroupReport. 
    2.    ReportTitle  QuickRep   
, , Customer Group Report. 
    3.      TQRGroup     
   Master    QuickRep.   
 Expression  MasterQuery. Country. 
    4.    TQRGroup  TQRExpr    
  Expression  MasterQuery.Country. 

     19.  397 

    5.    Font  TQRExpr  Bold   
   12 ,       . 
    6.   MasterQuery ,   (   
Active  False). 
    7.    SQL    ORDER BY Country  
   SELECT.      
  . 

    SELECT   *   FROM  CUSTOMER  ORDER  BY   Country 

    8.   MasterQuery,    Active  True. 
      .       GRPREPO.PAS. 
            
     Preview (. . 19.4). 

    . 19.4.    Customer Group Report 

     ,       . 
     (level-break  control-break). 
          
 . ,     , 
     .     
,    ,  ,    . 

      
    ,     SQL   ,  
       country.   
       ,  
   .    ,  
 ,          
 ,     .   
   ,    ,  
  ,     . 

    398 IV.    

      "-" 

          "-".  
   , ,      
    .       . 
    1.    File^New    New Items,  
  Forms  Customer Report,    Inherit,  
   .     Delphi   , 
   Customer Report,    . 
    2.    Name    CustomerMDReport. 
    3.    ReportTitle  Report  Sales By 
Customer Report. 
    4.     TDataSource      
  DataSet    MasterQuery. 
    5.     TQuery      
DatabaseName  IBLOCAL.       SQL 
 . 

    SELECT * FROM SALES WHERE Cust_No=:Cust_No ORDER BY Order_Date 

    6.     DataSource     
    TDataSource.      
 "-"   CUSTOMER,     
  MasterQuery,   SALES,      
  TQuery. 
    7.    TQuery,    Active  True. 
    8.      TQRSubDetail     
   Master    CustomerMDReport.  
  DataSet  ,      
 TQuery. 
    9.    TQRLabel    TQRDBText  
 QRSubDetail.      DataSet   
 QRDBText         
 TQuery. 
    10.    DataField   QRDBText  
OrderDate,    Discount,     Total_Value. 
    11.  .#0  #,##0.00     Mask  
Discount  Total_Value, .   Mask  
 ,   .  ,   Discount 
       ,    
    .   Total_Value   
  ,    . 

      
       DECIMAL  NUMERIC    InterBase (,  
 Total_Value)    Delphi,  
   Enable BCD  IBLOCAL  True.   
 , BDE , , Delphi,      
 .         
,    ,  DBEdit,     
 .       17, "InterBase". 

    12.      QRDBText  QRLabel, 
   ,      . 
  Caption  QRLabel ,    
  . 
    13.    ,    Font  
 QRLabel,   , QRSubDetail  Bold Italic. 

     19.  399 

        .  . 19.5 ,    
     Delphi. 
          MDREPO.PAS.  
           
     Preview (. . 19.6). 

    . 19.5.    "-"    
 Delphi 

    . 19.6.    "-" 

    400 IV.    

     
       ,       
QyickReport.        
"-",    ~   (Access 
Violation).           
.     ,  ,   
 Order_Date ( TQRDBText)   .  
    .         
.             
.          
TField   ,     TQuery,  
    SALES,   <CTRL+A>.     
.       , ,    . 
      QuickReport  ,   
   Web QuickReports (http://www.qusoft.com).   Delphi  
  QRPTZMAN.DOC (  Program Files \Delphi 3\Quickrpt), 
      QuickReport 
  Delphi. 

      .       
    Delphi. 

      

            (cross-tab 
report)   ,      
 QuickReport.   ,     
 DecisionCube.  ,         
    ,     
  QuickReport.      
  Print. 
          . 
    1.         Name  CustomerCTReport. 
    2.        Panel.   
 Align     alTop,    alBottom,     alClient. 
    3.   Caption    . 
    4.    Caption   TPanel  Sales 
By Country and Year,   Font Arial 18pt. Regular. 
    5.   DecisionQuery (   DecisionCube 
 )      DatabaseName  IBLOCAL. 
    6.     DecisionCube      
  DataSet    DecisionQuery,     
   . 
    7.     DecisionSource     
   DecisionCube    DecisionCube,  
      . 
    8.   DecisionGrid    TPanel (  
   )      Align 
 alClient. 
    9.      DataSource  DecisionGrid 
   DecisionSource,      . 7. 
    10.     TPanel (    
)  DecisionPivot      Align  alClient. 
    11.      DataSource  
DecisionPivot     DecisionSource. 
    12.       DecisionQuery    
    Decision Query Editor. 
    13.        Query Builder. 

     19.  401 

    14.    Add Table    
Visual Query Builder.     CUSTOMER  SALES,  
  ,     Close. 
    15.   Cust_No  CUSTOMER   Cust_No  
SALES.      . 
    16.   Country  CUSTOMER     Visual 
Query Builder,       . 
    17.     order_Date  Total_Value  SALES, 
      Visual Query Builder.    
  . 
    18.    Decision Query Editor,   Country  
Order_Date   Dimension.   Total_Value   
Summaries.         
,   sum.     Total_Value  
  . 
        ,  Query Text   SQL 
Query     SQL. 

    SELECT CUSTOMER.COUNTRY, SALES.ORDER_DATE, SUM! 
    FROM CUSTOMER CUSTOMER 
    INNER JOIN SALES SALES 
    ON (CUSTOMER.CUST_NO = SALES.CUST_NO) 
    GROUP BY CUSTOMER.COUNTRY, SALES.ORDER_DATE 
    FROM CUSTOMER CUSTOMER 

      , ,   -    
 Visual Query Editor,     Decision Query Editor. 
    19.   SQL  ,    Decision Query 
Editor,    . 
    20.       DecisionCube   
     Decision Cube Editor.  
  SUM     Format  #,##0.00.  
        
Total_Value.         . 
    21.   Active  DecisionQuery  True.  
  DecisionGrid    (. 19.7).  
     ,  . 
    22.          CTREPO. PAS. 

    SALES.TOTAL VALUE 

    . 19.7.      

    402 IV.    

      

            
 DecisionCube    ,  
    .  ,    , 
        .  
 19.119.3     REPORTS.  
   ,     (  
   )         . 

      
       REPORTS      
        -. 

     19.1.      REPORTS (Reports. DPR) 

    program reports; 
    uses 
    Forms, 
    repoOO in 'repoOO.pas' {Formi}, 
    listrepo in 'listrepo.pas' {CustomerReport}, 
    grprepo in 'grprepo.pas' {CustomerGroupReport}, 
    mdrepo in 'mdrepo.pas' {CustomerMDReport}, 
    ctrepo in 'ctrepo.pas' (CustomerCTReport); 
    ($R *.RES} 
    begin 
    Application.Initializer
    Application.CreateForm(TForml, Formi); 
    Application.CreateForm(TCustomerReport, CustomerReport); 
    Application.CreateForm(TCustomerGroupReport, CustomerGroupReport); 
    Application.CreateForm(TCustomerMDReport, CustomerMDReport); 
    Application.CreateForm(TCustomerCTReport, CustomerCTReport) ; 
    Application.Runt
    end. 

     19,2.        
(repoOO. PAS) 

    unit repoOO; 
    interface 
    uses 
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 
    StdCtrls, QuickRpt; 
    type 
    TFormI = -class(TForm) 
    btPreview: TButton; 
    btPrint: TButton; 
    ListBoxl: TListBox; 
    btCustomerCTPreview: TButton; 
    btCustomerCTPrint: TButton; 
    Labell: TLabel; 
    Label2: TLabel; 
    procedure btPreviewClick(Sender: TObject); 
    procedure FormShow(Sender: TObject); 
    procedure btPrintClick(Sender: TObject); 
    procedure btCustomerCTPreviewClick(Sender: TObject); 
    procedure btCustomerCTPrint-Click (Sender: TObject); 

     19.  403 

    private 
    { Private declarations } public 
    { Public declarations } end; 
    var 
    Formi: TFormI; 
    implementation uses listrepo, ctrepo; 
    {$R *.DFM) 
    procedure TFormI.btPreviewClick(Sender: TObject); 
    var c,f : Integer; 
    begin 
    if (ListBoxl. Itemlndexo-1) then 
    With Screen do For f:=0 to FormCount - 1 do 
    With Forms[f] fo For c:=0 to ComponentCount - 1 do 
    if (Components[c] is TQuickRep) and 
    (TQuickRep(Components[c])-ReportTitle = 
    ListBoxl.Items[ListBoxl.Itemlndex]) then begin 
    TQuickRep(Components[c]).Preview; 
    break; 
    end; 
    end; 
    procedure TFormI.FormShow(Sender: TObject); 
    var c, f : Integer; 
    begin 
    With Screen do For f:=0 to FormCount - 1 do 
    With Forms[f] do For c:=0 to ComponentCount - 1 do 
    if Components[c] is TQuickRep then 
    ListBoxl.Items.Add( 
    TQuickRep(Components[c]).ReportTitle; 
    If (ListBoxl.Items.Count  0) then 
    ListBoxl.Itemlndex:=0; 
    end; 
    procedure TFormI.btPrintClick(Sender: TObject); 
    var c,f : Integer; 
    begin if (ListBoxl. Itemlndexo-1) then 
    With Screen do For f:=0 to FormCount - 1 do 
    With Forms[f] fo For c:=0 to ComponentCount - 1 do 
    if (Components[c] is TQuickRep) and 
    (TQuickRep(Components[c]).ReportTitle = 
    ListBoxl.Items[ListBoxl.Itemlndex]) then begin 
    TQuickRep(Components[c]).Print; 
    break; 
    end; 
    end; 
    procedure TFormI.btCustomerCTPreviewClick(Sender: TObject) 
    begin 
    CustomerCTReport.Show; 
    end; 
    procedure TFormI.btCustomerCTPrintClick(Sender: TObject); 
    begin 
    CustomerCTReport.Print; 
    end; 
    end. 

    404 IV.    

     19.3.      

    object Formi: TFormI 
    Left = 200 
    Top = 109 
    Width = 544 
    Height = 375 
    Caption = 'Reports' 
    Font.Charset = DEFAULT_CHARSET 
    Font.Color = clWindowText 
    Font.Height = -11 
    Font.Name = 'MS Sans Serif 
    Font.Style = [] 
    OnShow = FormShow 
    PixelsPerInch = 96 
    TextHeight = 13 
    object Labell: TLabel 
    Left = 0 
    Top =40 
    Width =79 
    Height = 13 
    Caption = 'Sales by Country' 
    end 
    object Label2: TLabel 
    Left = 0 
    Top = 120 
    Width = 34 
    Height = 13 
    Caption = 'Others:' 
    end 
    object btPreview: TButton 
    Left = 0 
    Top = 288 
    Width = 75 
    Height = 25 
    Caption = 'Pre&view' 
    TabOrder = 0 
    OnClick = btPreviewClick 
    end 
    object btPrint: TButton 
    Left = 96 
    Top = 288 
    Width = 75 
    Height = 25 
    Caption = 'sprint' 
    TabOrder = 1 
    OnClick = btPrintClick 
    end 
    object ListBoxl: TListBox 
    Left = 0 
    Top = 136 
    Width = 169 
    Height = 137 
    ItemHeight = 13 
    TabOrder = 2 
    end 
    object btCustomerCTPreview: TButton 
    Left = 0 
    Top = 56 
    Width = 75 
    Height = 25 
    Caption = 'Preview' 
    TabOrder = 3 
    OnClick = btCustomerCTPreviewClick 
    end 

     19.  

    object btCustomerCTPrint: TButton 
    Left = 88 
    Top = 56 
    Width = 75 
    Height = 25 
    Caption = 'Print' 
    TabOrder = 4 
    OnClick = btCustomerCTPrintClick 
    end 
    end 

     . 19.8     REPORTS. 

    Salsa by Country 
    Pieview   |        F'fint 
    . /^.6'.  REPORTS 

      REPORTS    .   
   OnShow  . 

    procedure TFormI.FormShow(Sender: TObject); 
    var c, f : Integer; 
    begin 
    With Screen do For f:=0 to FormCount - 1 do 
    With Forms[f] do For c:=0 to ComponentCount - 1 do 
    if Components[c] is TQuickRep then 
    ListBoxl.Items.Add( 
    TQuickRep(Components[c]).ReportTitle; 
    If (ListBoxl.Items.Count <> 0) then 
    ListBoxl.Itemlndex:=0; 
    end; 

                
 TQuickRep. 
        ,      
   Screen.   ,   
TQuickRep,    ListBoxl. ,   
TCustomerReport   TQuickRep      
,    . 
      ListBoxl ,     Count, 
 ,       TQuickRep.    
(CountoO),    ListBoxl     . 
             
         
 (RTTI  Runtime Type Information)    
  .       ,  
 TQuickRep,       . 

    406 IV.    

           OnClick 
 Preview. 

    procedure TFormI.btPreviewClick(Sender: TObject); 
    var 
    c,f : Integer; 
    begin 
    if (ListBoxl. Itemlndexo-1) then 
    With Screen do For f:=0 to FormCount - 1 do 
    WitTh"Forms [f] fo For c:=0 to ComponentCount - 1 do 
    if (Components[c] is TQuickRep) and 
    (TQuickRep(Components[c]).ReportTitle = 
    ListBoxl.Items[ListBoxl.Itemlndex]) then begin 
    TQuickRep(Components[c]).Preview; "^^ 
    Break;           .                   ^^^ 
    end;                                       s^ 
    end;                                                   ' ''^^ 

           .  
 ,     ListBoxl,    
   TQuickRep    Preview.    
   .     
        . 
            RTTI. 

          

    ,      ,      
 .    Preview,    
Sales by Country.   ,   . 19.9. 

    . 19.9.        

     19.  407 

      ,     DecisionCube. 
    1.    Order_Date    Country. 
      .   
  (pivoting)       
  Deci5ionCube,     
(pivot table). 
    2.    Order_Date  Customer,    
DecisionPivot    .   ,   
  .      : Order_Date   
  Customer   .     .  
            DecisionPivot. 
    3.       Order_Date  Customer   
     Drilled In.    
     .      
. ,      Order_Date 
 .       Country  
, ,     . 

       

      Delphi       ,  
    .      DBChart, 
QRChart  DecisionGraph. 

    QRChart 

            QRChart, 
     QuickReport.   
QRChart    QuickReport,      
,           
  TQuickRep,  Preview  Print.     
QRChart   . 
    1.   ,    CustomerReport,  
   
    CustomerGraphReport. 
    2.    TQuickRep       
 ReportTitle  Graph of Sales by Country. 
    3.     QRLabel     
      Caption.     
.    ,      
 . 
    4.     QRDBText     , 
    DataField      Width  
0.    . 
    5.    ,     
      Enabled  False,   
Height  0.   ""  . 
    6.      ,     
  .   ,     . 
    7.   QRChart        
 ,       . 
    8.   MasterQuery      SQL  . 

    SELECT .COUNTRY, SUM(S.TOTAL_VALUE) 
    FROM SALES S, 
    CUSTOMER  
    WHERE S.CUST_NO=C.CUST_NO 
    GROUP BY C.COUNTRY 

    9.    ,     Active  
True.        CUSTOMER   
      SALES.      
  . 

    408 IV.    

    10.     QRChart,      Add, 
   Series    Chart. 
    11.    Pie,   ,  
   . 
    12.    Titles   Chart    
: Country Sales Figures. 
    13.    Series (   Chart),    
 DataSource  Series. 
    14.   DataSource       
  DataSet       MasterQuery. 
    15.      Labels    
Country ,      pie     SUM.  
        
  SUM,       , 
   Country.      
    . 
    ,    .    Close. 
    . 19.10. 

    . 19.10.       Delphi 

         SALEGRAP. PAS.    
  REPORTS         
 SALEGRAP.  <F9>,      
REPORTS.    ,      
       Preview (. . 19.11). 
       ,    
       Delphi. 

    DecisionGraph 

         ,     
 DecisionCube,    DecisionGraph.   
 DecisionGraph     CustomerCTReport.   
,        DecisionCube. 
           CustomerCTReport,  
 . 
    1.  <Shift+F12>      CustomerCTReport. 
    2.   Align  DecisionGrid  alTop   
    ,      
    . 
    3.   DecisionGraph  ,   
DecisionGrid,      Align  alClient.  
      . 
    4.       DecisionSource   
  DecisionSource.     . 

     19.  409 

    5.      ,    . 
   Titles,     Title  Sales by 
Country and Year,     Close.  .   X 
     DecisionCube,    Y  
  .  ,    .  
,   REPORTS     Preview, 
    Sales by Country.   
,   . 19.12. 

    . 19.11.       

    Puc. 19.12.   ,     DecisionGraph 

    410 IV.    

     ,     DecisionGrid  
DecisionGraph,   Order_Date   Country   
DecisionPivot.    (   ),  
   "".  ,    
DecisionCube   ,   (. 19.13). 
     .    REPORTS    Delphi. 

    . 19.13.    DecisionPivot   
 DecisionGrid  DecisionGraph  


      

             
    ,     . 
 ,       CustomerReport,  
       . 
          ,  . 
    1.         Delphi  CustomerReport. 
    2.              
   QRLabel.      UserNameLabel,  
  laUserName.       
,         . , 
 Delphi     ,     
  . 
    3.         ,  ,  
      . 
    4.       Caption  UserNameLabel  
UserName:,   Allignment  laUserName   taRightJustify. 
    5.       OnPrint  laUserName   
      . 

    procedure  TCustomerReport.laUserNamePrint(Sender:   TObject;   var  
Value:   String); var 
    MaxNameLen   :   Integer; begin 
    MaxNameLen   :=   30; 
    SetLength(Value,MaxNameLen); 
    GetUserName(PChar(Value),MaxNameLen); 
    SetLength(Value,Pred(MaxNameLen)); 

     19.  411 

    //            . end; 
        Value     
GetUserNarae API Windows.  Value    .  
    Value    PChar     
   GetUserName. ,    
 ,   Value.      
MaxNameLen (   GetUserName   , 
  Value).     
 . 
        ,    
REPORTS  ,     .  ,   
    ,   ,  
  .        ,  
    . ,  
    ,     Delphi 
 ,     .  . 19.14 
  Customer List Report   . 
    . 19.14.       
   

     

      ,        
  QuickReport:   -, 
 ,      "-". 
        , 
   DecisionCube.  ,      
       ,  , 
      .    
 -   .    
   ,   ,    
    Delphi      /. 

    412 IV.    


     ... 

      20, "-    ",  
   -  ,   
  Delphi.     -  
     , , 
   ,   . 

     19. 	413