{*******************************************************} { } { Responsive Software http://www.responsive.co.nz } { } { Copyright (c) 2003-2006 Responsive Software Limited } { } {*******************************************************} unit ProxyObjectListingReportUnit; interface uses Windows, SysUtils, Messages, Classes, Graphics, Controls, StdCtrls, ExtCtrls, Forms, QuickRpt, QRCtrls, DatabaseObjects, DBTables, ProxyDatabaseObjectCollectionUnit; type TProxyObjectListingReport = class(TQuickRep) TitleBand1: TQRBand; PageFooterBand1: TQRBand; DetailBand1: TQRBand; ColumnHeaderBand1: TQRBand; CompanyNameQRLabel: TQRLabel; QRShape1: TQRShape; QRShape3: TQRShape; QRLabel8: TQRLabel; CurrentDateQRLabel: TQRLabel; QRShape4: TQRShape; DetailsQRLabel: TQRLabel; PageNumberQRLabel: TQRLabel; ColumnHeadingsQRLabel: TQRLabel; ReportFooterQRLabel: TQRLabel; HeadingQRLabel: TQRLabel; SummaryBand1: TQRBand; RecordCountQRLabel: TQRLabel; QRShape2: TQRShape; procedure QuickRepBeforePrint(Sender: TCustomQuickRep; var PrintReport: Boolean); procedure QuickRepNeedData(Sender: TObject; var MoreData: Boolean); procedure QuickRepStartPage(Sender: TCustomQuickRep); procedure QuickRepAfterPreview(Sender: TObject); private PageNumber : integer; FDatabaseObjectClass : TDatabaseObjectClass; FProxyDatabaseObjectCollection : TProxyDatabaseObjectCollection; FCollectionOwned : boolean; public CurrentItem : integer; procedure SetProxyCollection (DatabaseObjectClass : TDatabaseObjectClass; ProxyDatabaseObjectCollection : TProxyDatabaseObjectCollection; CollectionOwned : boolean); end; var ProxyObjectListingReport: TProxyObjectListingReport; implementation uses Globals, Utilities, GeneralUtilities; {$R *.DFM} procedure TProxyObjectListingReport.SetProxyCollection (DatabaseObjectClass : TDatabaseObjectClass; ProxyDatabaseObjectCollection : TProxyDatabaseObjectCollection; CollectionOwned : boolean); begin FDatabaseObjectClass := DatabaseObjectClass; FProxyDatabaseObjectCollection := ProxyDatabaseObjectCollection; FCollectionOwned := CollectionOwned; end; procedure TProxyObjectListingReport.QuickRepBeforePrint(Sender: TCustomQuickRep; var PrintReport: Boolean); begin QuickReportOpen := true; ReportFooterQRLabel.Caption := ReportFooterString; CurrentItem := 0; PageNumber := 0; CompanyNameQRLabel.Caption := GlobalConfiguration.CompanyName; CurrentDateQRLabel.Caption := FormatDate(Date); HeadingQRLabel.Caption := FDatabaseObjectClass.HeadingString; ColumnHeadingsQRLabel.Caption := FDatabaseObjectClass.ColumnHeadingsString; if FProxyDatabaseObjectCollection <> nil then RecordCountQRLabel.Caption := 'Total ' + FDatabaseObjectClass.HeadingString + ' = ' + IntToStr(FProxyDatabaseObjectCollection.Count); end; procedure TProxyObjectListingReport.QuickRepNeedData(Sender: TObject; var MoreData: Boolean); var DatabaseObject : TDatabaseObject; begin if (FProxyDatabaseObjectCollection <> nil) and (CurrentItem < FProxyDatabaseObjectCollection.Count) then MoreData := true else if (FProxyDatabaseObjectCollection <> nil) and (FProxyDatabaseObjectCollection.Count = 0) and (CurrentItem = 0) then begin DetailsQRLabel.Caption := 'No data.'; Inc(CurrentItem); Exit; end else begin MoreData := false; Exit; end; DatabaseObject := FProxyDatabaseObjectCollection[CurrentItem]; DetailsQRLabel.Caption := DatabaseObject.DetailsString; Inc(CurrentItem); end; procedure TProxyObjectListingReport.QuickRepStartPage(Sender: TCustomQuickRep); begin Inc(PageNumber); PageNumberQRLabel.Caption := 'Page ' + IntToStr(PageNumber); end; procedure TProxyObjectListingReport.QuickRepAfterPreview(Sender: TObject); begin if FCollectionOwned then begin FProxyDatabaseObjectCollection.Free; FProxyDatabaseObjectCollection := nil; end; QuickReportOpen := false; end; end.