      

    12  

            RENTMAN    
  .        
 . 
    Q -    . 
    Q     PROPERTY. 
    Q      . 

        Delphi 

     ,    Delphi,     
  . -,   ,   
 . -,      
 QuickReport. , -,   ,  
      Object Pascal.     
   . 

      

    , ,  ,       
,      ,   
Crystal Reports, R&R  ReportSmith.        
,          Delphi.  
,     ,  ,     
 Delphi 3         
ReportSmith,      ,    
       .  
  ,      Borland, 
    Delphi,  ,    
   .  ,     
 ,     QuickReport  
 ,       ,   ,  
  ReportSmith,            
  ,    ReportSmith. 

      

    ,   ,     : 
, ,     . - (form 
report)            
           
.       -   
       . 


     12.   259 

    - (label report)    , ..   
        
.           
   .       
     .     
 ,     CUSTOMER,    
,    . 
      (columnar report)        
.         .   
        .   
          
.        . 
      (cross-tab report)  ,    
 .     , ,   
 ,     ,    
 ,    ,      
 ,     ,   
    .    
        .   
    ,       
      .     
, ,     -  ,  
      ,  ,  
,      . 
             .  , 
  ,   Work Order   -.  
       fmRWORMDEO.  
     ,     
,       Delphi. 
         ,    
    PROPERTY.      
 QuickReport.      ,   
          
 . 
      19, "",  ,     Delphi 
DecisionCube   . 
        ,    
 QuickReport,      Delphi.  
 File=>New    Forms     
   . 
       ,      
   Object Pascal.      
          
  . 

    - Work Order 

    ,    - Work Order.      
      fmRWORMDEO. 
          RENTMAN, fmRSYSMANO,   
  Delphi.     printerSetupDialog  
  ps_RENTMAN.     Print  File 
     : 

    ps_RENTMAN.Execute; 

            sbPrintSetup  
  OnClick  Print   (  
   PrintsetuplClick).    
         PrintSetup 
   RENTMAN. 
      ,   Print Setup ()  
 ,      .   
 Windows       
 . 

          

        Work Order  Reports   Work 
Orders  Tables.       
 ,  ,    ,    
    ,     , 
fmRWORGRDO.         
Tables=>Work Orders, , ,      Reports=>Work Order. 


    260  II.   

     Print 

          fmRWORMDEO     
 paBottom      BitBtn.    
  bbPrint,     Caption  sprint,  
 Glyph   \lMAGES\BUTTONS\print.bmp ( Images  
      Delphi).   , 
          
      OnClick .  
,    12.1. 

     12.1.   fmRWORMDEO 

    Tag := Longint(WindowState); 
    WindowState:=wsMaximized; 
    for 1:=0 to ComponentCount-1 do 
       If (Components[I] is TButton) or 
          (Components[I] is TDBNavigator) or 
          (Components[I] is TSpeedButton) then 
              With Components[I] as TControl do begin 
                 Tag:=Longint(Visible) ; 
                 Visible:=False; 
            end; 
    Print; 
    for I:=0 to ComponentCount-1 do 
        If (Components[I] is TButton) or 
           (Components[I] is TDBNavigator) or 
           (Components[I] is TSpeedButton) then 
              With Components[I] as TControl do 
                 Visible:=Boolean(Tag) ; 
   WindowState :=TWindowState(Tag) ; 

    He    I    Integer  
 , : 

    procedure TfmRWORMDEO .bbPrintdick (Sender: TObject) ; 
    var 
    I: Integer; 

          . -,  
  ,       . 
,          . 
-,     Print   .   
   ,     ,      
,   .       
  . 
             
  .  ,     
  Tag.     Longint    
  Delphi  -  .   
         
 .     Tag  
  .  Tag      
  WindowsState,   Tag     
     Visible.      
,         
,      - , 
   . ,     , 
    WindowState  wsNormal.   ,  
 ,      ,    - 
       .     
,      ,   
           , 
   ,    .  ,  
       . 
            
  Components.     
- ,     
-,  TForm.      
         
      .    
     Visible   
.  ,    Components     
     ,   -. 


     12.   261 

    ,           
,          
(RTTI  RunTime Type Information).        
    with-as.   Delphi 
      , ,   ,  
         . 
 ,   ,     
,         
  Visual Basic. ,   ,    
  ,        
   ,   .    
    ,      
  .    Delphi  RTTI  
          
,   ,         
,  .       
    ,    ,   
    . 
    , ,      ,  
       visible . 
        (,    
  ),       
 : 

    with Components[I] fo begin 
         Tag :=Longint(Visible) ; 
         Visible:=False; 
    end; 

           visible,    
         
 Components [I].       
  ,      ,   
 ,     ,   
.      visible ,   
   . 

     Object Browser 

         ,   ,    
  visible.        
 Delphi    TControl.    ,  
  Delphi.      . 
,  ,     Object Browser.   
      ,   View Delphi  
  Browser.    View^ Browser,    
  Object Browser.        
,       .  ,  
     . ,     
TButton,  ,       
TButtonControl, ,   ,    
 TWinControl.     ,    
    TButton    Visible. 
       " "    
    VCL.      
   .    ,   Object 
Browser,        ,   
 ,   Object Browser.    
,      .     
 -  (, grep),   
  Borland      
,        .    
  ,         
      . ,  
   TButton   : 

    TButton = class(TButtonControl) 

     ,   TButton    
TButtonControl.    ,  ,    
  TButtonControl   : 

    TButtonControl = class(TWinControl) 


    262  II.   

        ,   TButtonControl  
  TWinControl.  TButton  TButtonControl  
  Stdctrls.    ,  ,    
       Visible,    
       TWinControl.      
Controls.     TWinControl   : 

    TWinControl = class(TControl) 

       TWinControl,       
  visible.      TControl,  
- ""   .      
     visible    TControl. 

      

     ,      , 
     (checked typecast).   
          
,     .    
 ,   ,     ,   
     ,   ,  
  . 
         ,      
.   .

    With TControl (Components [I] ) do 

             .  
      ,  , 
      .    
    ,      
, ,    ,    . 
 ,   ,     . 
    ,   ,    , 
    TBitBtn.    ?   
    TBitBtn, , ,     
.   ,    bbPrint,   
  .        
    TBitBtn? 

    if (Components[I] is TButton) or 
    (Components[I] is TDBNavigator) or 
    (Components[I] is TSpeedButton) then 

        .    ,  is 
  True,       
         .  
        TBitBtn.  
  TBitBtn    TButton,     
TBitBtn    TButton  is   True.  
,  TSpeedButton     TButton,  
  ,       . 

       ? 

      ,        
   ,      ,   
     . ,   
        : 

    DBNavigator.Visisble:=False; 
    bbOK.Visisble:=False; 
    bbCancel.Visisble:=False; 
    bbPrint.Visisble:=False; 

    ,        ,   
     ,   
     . ,      
           
 ,         


     12.   263 


. -,    ,    , 
   ,   -   
  (, ). -,     
 ,  -     
   .     ,  
        , 
    Visible   . 
 ,         
.          
  ,   , ,       
. ,        , 
       .       
,      .      
     . 
        Ondick  bbprint  
   ,    Delphi,    
.             
 fmAnyForm   ,    
      RENTMAN. 

       

             ,   
  . ,      , 
   ,    : 

    With taWORDER do begin 
        First; 
        While not(EOF) do begin 
            fmRWORMDEO.bbPrintCiick(Self) ; 
            Next; 
        end; 
    end; 


        

        ,    ,  
  . ,       
"-"      ,   
  . ,   ,    
,      ,   
. ,        
(,         
)   ,   .  ,   
      ,   
   .      
,   visible  ,      
,    False     .    
     ,    ,    
    . 

      

             ,   
    .   ,    
          
,        . 
       .  , 
     ,    
,     . ,    
     ,    
       ,   
  . 

       - 

    -        QuickReport 
Delphi,       .   
 -         
   ,    , 


    264  II.   

   .   -,   
   ,    print 
 .    ,    
QuickReport        ,    
 . 

     - 

    ,      .    
   .    Reports^Work Order  
 <F7>.      Work Order Selection.  
,      Edit.       
Print.    ,     
 ,       ,   
  .       Delphi. 

      

             Print 
  printScale  TForm.    
 poProportional     ,     
     .     
      ,     . 
 poPrintToFit   ,      
,          
.    poNone    
.    ,       
    -   
    . 
            QuickReport. 
      ,  ,  
     QuickReport    
       . 
 ,  ,   QuickReport    
     ,    
   . 

      PROPERTY Listing Report 

    ,      ,    
 PROPERTY.       QuickReport,  
   QuickReport Wizard Delphi. 
        File'=>New     New Items  
 Business.     QuickReport Wizard,  
  .       
    .        
   . 
               
 .      dbRENTMAN. 
           ,    
 .    ,      
 PROPERTY.    Next. 
            ,  
     .   PROPERTY_NUMBER, 
ADRRESS, CITY, STATE, ZIP, ADDITION  SCHOOLDISTRICT.    
  Available  Selected      
  .     ,   
 Next. 
              
.   PROPERTY Listing Report.    ,  , 
    ,   ,    
  Arial     . 
      ,    Finish,    
   ,       
 . 
    ,      ,  ,     
,   ,    "",  . 
  Active   taPROPERTY  True,   
     ,      
Preview,  ,         
(. 12.1). 


     12.   265 


    . 12.1.   ,   QuickReport Wizard 

    Puc. 12.2.       


     II.   266

    
             QuickReport, 
  ,      (. 12.2), 
       ,   . 
        ,       . 
    Q  .       
,     .  QuickReport 
  ,      
   .. 
    Q .       ,   
 . 
    Q  .           
.      QRSysData  
 QuickReport. 

     

     ,    ,   QRExpr, 
   ,    ANSI SQL  
  . ,    COUNT (*)  
     .      
COUNT (PRO PERTY_NUMBER) .  -COUNT     
,     QRExpr,     
   , ,  ,    ANSI SQL. 

      

       ,    ,   
   -. 

      ,   QuickReport Wizard, 
   frRPROLSTO     
   RPROLSTO. . 

        

         ,     
 RENTMAN.      . 
    Q         
 RSYSMANO. 
    Q          
    ,       
 RENTMAN. 
         fmRSYSMANO    
.   File^Use Unit      RPROLSTO 
 .          
  . 
        MainMenu  ,     
  ,    Reports.   
( Caption)    sProperty List,   Shortcut 
  F11.          
     : 

    frRPROLSTO.QuickRepI.Preview; 

              
 ,         
,    , ,     . 
      ,  ,    .  
   .  . 12.3      
   . 


     12.   267 


    . 12.3.  PROPERTY Listing Report     

         

     ,      ,    
   Object Pascal.    , 
   ,     
QuickReport Delphi.     Object Pascal  
           
 ,  .       
   ,          
  .   Object Pascal    
   ,      
 ,        , 
      , BASIC, Pascal  ..   
Object Pascal  ,       , 
        . 
         dmRENTMAN   Query.  
  quTaskList,       SQL  
 . 

    SELECT E.Name, P.Address, P.City, P.Addition, .Description, T.TaskDuration 
    FROM EMPLOYEE E, 
    WORDER W, 
    PROPERTY P, 
    WODETAIL D, 
    WORKTYPE T 
    WHERE E.EMPLOYEE_NUMBER=W.EMPLOYEE_NUMBER 
    and W.WORDER_NUMBER=D.WORDER_NUMBER 
    and W.PROPERTY_NUMBER=P.PROPERTY_NUMBER 
    and D.WORK_TYPE_CODE=T.WORK_TYPE_CODE 
    and W.StartDate <= :ListDate 
    and W.EndDate >= :ListDate 
    ORDER BY E.Name, P.Address, P.City, P.Addition, T.Description 

          EMPLOYEE, WORDER, PROPERTY, 
WODETAIL  WORKTYPE     ,  
    .       
  :ListDate,      


    268  II.   

 .     params  Query  
   ListDate  Date.    
Database  dbRENTMAN,          
    TField. 
         ,  ,  
 Object Pascal.        
, fmRSYSMANO,       MainMenu,  
   .    Task List  Reports  
 F10     Shortcut   .  
    Task List       
   OnClick,    12.2. 

     12.2.   TaskListlClick 

    procedure TfmRSYSMANO.TaskListlClick(Sender: TObject); 
    var 
       LastName : String; 
       CurrentLine : Byte; 

       procedure PrintColumnHeadings; 
       begin 
        Writeln(PrintFile,'     '+Pad('Address',30) , 
            Pad('City',20),Pad('Addition',20), 
           Pad('Work',30),Pad('Time (Days)',15)); 
       end; 

    begin 
        inherited; 
        try 
        Cursor:=crHourGlass; 
             With dmRENTMAN, quTaskList do begin 
             ParamByName('ListDate').AsDate:= 
               StrToDatef'04/05/97') ; 
                //       ,    
                //       . 
               //    ParamByName('ListDate').AsDate:=Date; 
           Open; 
           try 
           BeginReport(poPortrait,Caption) ; 
          try 
          While not eof do begin 
             CurrentLine: =9; 
             PrintHeader('RTSKLSTO',Caption,'Employee Task List', 
             ParamByName('ListDate').AsString) ; 
             PrintColumnHeadings; 
             While (not eof) and (CurrentLineOPageLength) do begin 
                  Writeln(PrintFile); 
                 Writeln(PrintFile,'EMPLOYEE:  '+quTaskListName.AsString); 
                 Inc(CurrentLine,2) ; 
                Repeat 
                    LastName:=quTaskListName.AsString; 
                   Writein(PrintFile,'     '+Pad(quTaskListAddress.AsString,30), 
                       Pad(quTaskListCity.AsString,20), 
                       Pad(quTaskListAddition.AsString,20), 
                      Pad(quTaskListDescription.As String,30), 
                      Pad(quTaskListTaskDuration.AsString,15) ); 
                 Next; 
                 Inc(CurrentLine) ; 
            Until (eof) or (CurrentLine=PageLength) or 
                 (quTaskListName .AsStringOLastName) ; 
         end; 
    end; 
    finally 
         EndReport; 
    end; 
    finally 


     12.   269 

                 quTaskList.Close; 
            end; 
       end; 
       finally 
       Cursor:=crDefault; 
       end; 
    end. 

            
.     12.3    RSYSMANO, 
    TaskListlclick. 

     12.3.       
-  

    function Pad(InStr : String; TotalLen : Integer) : String; 
    begin 
         Result:=InStr; 
         While (Length(Result)<TotalLen) do Result:=Result+' '; 
    end; 

    function LPad(InStr : String; TotalLen : Integer) : String; 
    begin 
           Result:=InStr; 
           While (Length(Result)<TotalLen) do Result:^' '+Result; 
    end; 

    function Center(InStr : String; TotalLen : Integer) : String; 
    var 
        NumSpace : Integer; 
        Temp : String; 
    begin 
        NumSpace := (TotalLen-Length(InStr)) div 2; 
        Temp:='' ; 
        While Length(Temp)<NumSpace do Temp:=Temp+' '; 
        Result:=Temp+InStr+Temp; 
        While Length(Result)<TotalLen do Result:=Result+' '; 
    end; 

    procedure PrintHeader(ReportName,SystemTitle,ReportTitle,Criteria : String); 
    begin 
          If (Printer.PageNumber <> 1) then Write(PrintFile,^L) ; 
          Writein(Print File,Pad('Report: '+ReportName,25), 
              Center(SystemTitle,LineLength-45), 
              LPad('Page: '+IntToStr(Printer.PageNumber),25)); 
         Writein(PrintFile) ; 
         Writein(PrintFile,Pad('Print date: '+DateToStr (Date),25), 
            Center(ReportTitle,LineLength-45), 
            LPad('Print time: '+TimeToStr(Time),25)) ; 
        Writein(PrintFile) ; 
        Writein (PrintFile, Pad ( 'User name: ' 4-UserName, 25) , 
              Center('For: 4-Criteria,LineLength-45)) ; 
        Writein(PrintFile) ; 
    end;

    procedure BeginReport(Orientation : TPrinterOrientation; Title :String); 
    begin 
         Printer.Orientation:^Orientation; 
         Printer.Title:=Title; 
        AssignPrn(PrintFile) ; 
        Rewrite(PrintFile) ; 
        With Printer.Canvas.Font do begin 
             Name:='Courier New'; 
             Height:=-13 ; 
             Style:=[]; 
       end; 
       LineLength:=(Printer.PageWidth div Printer.Canvas.TextWidth('X'))-5; 
    

    270  II.   

       PageLength:=(Printer.PageHeight div Printer.Canvas.TextHeight('X'))-2; 
    end; 
  
    procedure EndReport; 
    begin 
       CloseFile(PrintFiie); 
    end; 
   
       12.2  12.3     
    RSYSMANO.     
  {$R *.DFM}        
  RSYSMANO. 

    var 
       PrintFiie : Text; 
       LineLength : Integer; 
       PageLength : Integer; 
       UserName : String; 

     ,         
Printers,        
Windows.    Printers   uses  RSYSMANO. 

      TaskListlClick 

          TaskListlClick  
   . -, ,  
   Writein  Object Pascal    
.         
AssignPrn.         
   Windows.  ,   
 AssignPrn         
 ,      (   ). 
       . 
        ,     
   Windows  .    ,  
      BeginDoc,    
     TextOut.     
,         
  .    ,     
      .    
     ,   
         
   . 
        ,  
  .  ,     
,         
,       ,  
    .    
,     ,   
,    ,   .  
,   ,      
    . 

    BeginReport 

           
 .    BeginReport. 

    procedure BeginReport(Orientation : TPrinterOrientation; Title :String); 
    begin 
       Printer.Orientation:=0rientation; 
       Printer.Title:=Title; 
       AssignPrn(PrintFiie) ; 
       Rewrite(PrintFiie) ; 
       With Printer.Canvas.Font do begin 
          Name:='Courier New'; 
          Heights-13; 
         Style:=[]; 
       end; 
       LineLength:=(Printer.PageWidth div Printer.Canvas.TextWidth('X'))-5; 
       PageLength:=(Printer.PageHeight div Printer.Canvas.TextHeight('X'))-2; 
    end; 


     12.   271 

         , ,   
 ,        
TPrinterOrientation.      printers     
  poPortrait  poLandscape.     
   ,      
  BeginReport    . 
       with printer.Canvas.Font   
,    .       
     .  ,   
  TrueType- Courier New.    
     ,    
        (    ). 
        ,      
(LineLength)    (PageLength): 

    LineLength:=(Printer.PageWidth div Printer.Canvas.TextWidth('X'))-5; 

         (  , )  
   ''  .       
  .       
  ,       ,  
   TextWidth,    .  
        
        ,  
  .  ,     
  5,       . 
     Title,   ,    
  ,       
Windows.           
 .         
,    Title  TPrinter   
,    . 
     Pad, LPad  Center    .    
      ,  
  .        , 
  ,    .   
     ,   
  ,  , ,     
         .  
      ,   
   ,     .  
       
        ,  
  . 

    PrintHeader 

         PrintHeader,    
        .     
         , 
  ,      ,  
    ,      
PrintHeader.       , 
   (ReportName),   (SystemTitle), 
  (ReportTitle),    (Criteria).   
  ,         
 . 

       

    If (Printer. PageNumber  1) then Write (PrintFile, "L) ; 

      PrintHeader,    
,      12.    
        .   
  ,         
   . 
          Date  Time.  
       ,    
,   ,   ,  
      ,       
  .   ,       Time  
  ,    .  
  ,         .  
   Date,      ,  
  .       
        . 


    272  II.   

    ,      ,     Center  
 LineLength    ,  
     .     
        
.         , 
       . 

       TaskListlClick 

       

    ParamByName('ListDate').AsDate:=Date; 

     quTaskList    
ListDate.   ,      ,  
 ,    ,     
 ,     5  1997 .  
   ListDate   Open  
quTaskList,  ,      
  . 
         try-finally   
         
  .         
 .      ,  
      Windows,   , 
         
. ,        
       . 
     repeat-until (quTeskListName .AsStringobastName)   
  .  ,        
    .      
  ORDER BY   SQL ,    
"",   . 
    , ,      .    , 
       ,     
   .      
       .    
            , 
    Windows      
.      ,  .   
       
TProgressBar,      .   
      ,   
quTaskList,        . 
      ,    
 ,    ,   
   . 

       

      ,    ,   
     .   , 
,   Assign,    AssignPrn.  
     ,    
,   .      
  ,    Delphi,   
LoadFromFile  TMemo,       
.         
 ,    ,    
AssignPrn    ,    Lines  
TMemo,      . 
     ,  <F9>  ,     
.   RENTMAN ,  <F10>,  
  . 

     

             Delphi. 
 ,       ,   
 QuickReport         
Object Pascal.         
   QuickReport.   ,    
        ,   
 Delphi. 


     12.   273 

     ... 

      13, " ",     RENTMAN  
    .     
     .    ,   
    ,  ,  
,    .       
,      . 


    274  II.  