{*******************************************************} { } { Responsive Software http://www.responsive.co.nz } { } { Copyright (c) 2003-2006 Responsive Software Limited } { } {*******************************************************} unit AccountStatementReportUnit; interface uses Windows, SysUtils, Messages, Classes, Graphics, Controls, StdCtrls, ExtCtrls, Forms, QuickRpt, QRCtrls, DatabaseObjects, Utilities, GeneralUtilities; type TAccountStatementReport = class(TQuickRep) TitleBand1: TQRBand; PageFooterBand1: TQRBand; CompanyNameQRLabel: TQRLabel; QRShape1: TQRShape; HeadingQRLabel: TQRLabel; QRShape3: TQRShape; PageNumberQRLabel: TQRLabel; ReportFooterQRLabel: TQRLabel; DetailBand1: TQRBand; LineQRLabel: TQRLabel; QRShape2: TQRShape; AccountQRLabel: TQRLabel; PeriodQRLabel: TQRLabel; DescriptionQRLabel: TQRLabel; DateQRLabel: TQRLabel; procedure QuickRepBeforePrint(Sender: TCustomQuickRep; var PrintReport: Boolean); procedure QuickRepNeedData(Sender: TObject; var MoreData: Boolean); procedure QuickRepStartPage(Sender: TCustomQuickRep); procedure DetailBand1BeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean); procedure QuickRepAfterPreview(Sender: TObject); private PageNumber : integer; BoldLine : boolean; ItalicLine : boolean; FHeading : string; FReportData : TReportData; public CurrentItem : integer; AccountId : int64; UseBeginPeriod : boolean; BeginPeriodDate : TDateTime; UseEndPeriod : boolean; EndPeriodDate : TDateTime; procedure SetHeading (Heading : string); procedure SetReportData (ReportData : TReportData); end; var AccountStatementReport: TAccountStatementReport; implementation uses Globals, DatabaseManager; {$R *.DFM} procedure TAccountStatementReport.SetHeading (Heading : string); begin FHeading := Heading; end; procedure TAccountStatementReport.SetReportData (ReportData : TReportData); begin FReportData.Free; FReportData := ReportData; end; procedure TAccountStatementReport.QuickRepBeforePrint(Sender: TCustomQuickRep; var PrintReport: Boolean); begin QuickReportOpen := true; ReportFooterQRLabel.Caption := ReportFooterString; CurrentItem := 0; PageNumber := 0; CompanyNameQRLabel.Caption := GlobalConfiguration.CompanyName; HeadingQRLabel.Caption := FHeading; AccountQRLabel.Caption := 'Account :- ' + AccountName(AccountId) + ' ' + AccountCombinedAbbreviation(AccountId) + ' ' + '(' + ConvertAccountTypeToString(AccountType(AccountId)) + ')'; DescriptionQRLabel.Caption := AccountDescription(AccountId); DateQRLabel.Caption := 'Printed on :- ' + FormatDate(Date); if (not UseBeginPeriod) and (not UseEndPeriod) then PeriodQRLabel.Caption := 'Period :- All entries' else if (UseBeginPeriod) and (not UseEndPeriod) then PeriodQRLabel.Caption := 'Period :- Beginning ' + FormatDate(BeginPeriodDate) else if (not UseBeginPeriod) and (UseEndPeriod) then PeriodQRLabel.Caption := 'Period :- Ending ' + FormatDate(EndPeriodDate) else PeriodQRLabel.Caption := 'Period :- ' + FormatDate(BeginPeriodDate) + ' to ' + FormatDate(EndPeriodDate); end; procedure TAccountStatementReport.QuickRepNeedData(Sender: TObject; var MoreData: Boolean); begin if (FReportData <> nil) and (CurrentItem < FReportData.LineCount) then MoreData := true else begin MoreData := false; Exit; end; LineQRLabel.Caption := FReportData.Line(CurrentItem); BoldLine := FReportData.LineBold(CurrentItem) or FReportData.LineBoldItalic(CurrentItem); ItalicLine := FReportData.LineItalic(CurrentItem) or FReportData.LineBoldItalic(CurrentItem); Inc(CurrentItem); end; procedure TAccountStatementReport.QuickRepStartPage(Sender: TCustomQuickRep); begin Inc(PageNumber); PageNumberQRLabel.Caption := 'Page ' + IntToStr(PageNumber); end; procedure TAccountStatementReport.DetailBand1BeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean); begin if BoldLine then LineQRLabel.Font.Style := LineQRLabel.Font.Style + [fsBold] else LineQRLabel.Font.Style := LineQRLabel.Font.Style - [fsBold]; if ItalicLine then LineQRLabel.Font.Style := LineQRLabel.Font.Style + [fsItalic] else LineQRLabel.Font.Style := LineQRLabel.Font.Style - [fsItalic]; end; procedure TAccountStatementReport.QuickRepAfterPreview(Sender: TObject); begin QuickReportOpen := false; end; end.