{*******************************************************} { } { Responsive Software http://www.responsive.co.nz } { } { Copyright (c) 2003-2006 Responsive Software Limited } { } {*******************************************************} unit BalanceSheetReportUnit; interface uses Windows, SysUtils, Messages, Classes, Graphics, Controls, StdCtrls, ExtCtrls, Forms, QuickRpt, QRCtrls, DatabaseObjects, Utilities, GeneralUtilities; type TBalanceSheetReport = class(TQuickRep) TitleBand1: TQRBand; PageFooterBand1: TQRBand; CompanyNameQRLabel: TQRLabel; QRShape1: TQRShape; QRLabel4: TQRLabel; QRShape3: TQRShape; PageNumberQRLabel: TQRLabel; ReportFooterQRLabel: TQRLabel; DetailBand1: TQRBand; LineQRLabel: TQRLabel; QRShape2: TQRShape; CompanyQRLabel: TQRLabel; AsAtDateQRLabel: 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; FReportData : TReportData; public CurrentItem : integer; CompanyId : int64; AsAtDate : TDateTime; procedure SetReportData (ReportData : TReportData); end; var BalanceSheetReport: TBalanceSheetReport; implementation uses Globals, DatabaseManager; {$R *.DFM} procedure TBalanceSheetReport.SetReportData (ReportData : TReportData); begin FReportData.Free; FReportData := ReportData; end; procedure TBalanceSheetReport.QuickRepBeforePrint(Sender: TCustomQuickRep; var PrintReport: Boolean); begin QuickReportOpen := true; ReportFooterQRLabel.Caption := ReportFooterString; CurrentItem := 0; PageNumber := 0; CompanyNameQRLabel.Caption := GlobalConfiguration.CompanyName; if CompanyId = 0 then CompanyQRLabel.Caption := '' else CompanyQRLabel.Caption := 'Company :- ' + CompanyName(CompanyId); DateQRLabel.Caption := 'Printed on :- ' + FormatDate(Date); AsAtDateQRLabel.Caption := 'As At :- ' + FormatDate(AsAtDate); end; procedure TBalanceSheetReport.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 TBalanceSheetReport.QuickRepStartPage(Sender: TCustomQuickRep); begin Inc(PageNumber); PageNumberQRLabel.Caption := 'Page ' + IntToStr(PageNumber); end; procedure TBalanceSheetReport.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 TBalanceSheetReport.QuickRepAfterPreview(Sender: TObject); begin QuickReportOpen := false; end; end.