⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aphistoryreport.pas

📁 功能全面的商业财会系统源码,清晰,很有参考价值.扩展性强.
💻 PAS
字号:
unit APHistoryReport;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, DBTables, DB, quickrpt, Qrctrls, qrprntr;

type
  TrptAPHistory = class(TForm)
    QuickReport: TQuickRep;
    Title: TQRBand;
    PageHeader: TQRBand;
    PageFooter: TQRBand;
    QRSysData1: TQRSysData;
    QRLabel1: TQRLabel;
    QRLabel2: TQRLabel;
    QRLabel4: TQRLabel;
    PageNumber: TQRSysData;
    QRShape1: TQRShape;
    QRShape2: TQRShape;
    QRShape3: TQRShape;
    QRLabel3: TQRLabel;
    QRDateTime: TQRSysData;
    QRLabel5: TQRLabel;
    Master: TQRBand;
    txtVendorNo: TQRDBText;
    txtVendorName: TQRDBText;
    lblSelection: TQRLabel;
    tblVendor: TTable;
    tblVendorVendorID: TAutoIncField;
    tblVendorVendorNo: TStringField;
    tblVendorVendorName: TStringField;
    dsVendor: TDataSource;
    DetailInvoices: TQRSubDetail;
    tblAPInv: TTable;
    tblAPInvVendorID: TIntegerField;
    tblAPInvInvoiceNo: TStringField;
    tblAPInvInvoiceDate: TDateField;
    tblAPInvInvoiceAmount: TCurrencyField;
    DetailCheques: TQRSubDetail;
    tblAPCheq: TTable;
    tblAPCheqChequeNo: TIntegerField;
    tblAPCheqVendorID: TIntegerField;
    tblAPCheqChequeDate: TDateField;
    tblAPCheqChequeAmount: TCurrencyField;
    QRLabel8: TQRLabel;
    tblVendorCurrencyID: TIntegerField;
    tblAPInvGLPeriod: TSmallintField;
    tblAPInvGLYear: TSmallintField;
    tblAPCheqGLYear: TSmallintField;
    tblAPCheqGLPeriod: TSmallintField;
    lblPeriod: TQRLabel;
    Summary: TQRBand;
    QRLabel13: TQRLabel;
    lblTotRInvoiceAmount: TQRLabel;
    lblTotRChequeAmount: TQRLabel;
    txtInvoiceNo: TQRDBText;
    txtInvoiceDate: TQRDBText;
    txtInvoiceAmount: TQRDBText;
    txtChequeNo: TQRDBText;
    txtChequeDate: TQRDBText;
    txtChequeAmount: TQRDBText;
    totRChequeAmount: TQRExpr;
    totRInvoiceAmount: TQRExpr;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure tblVendorFilterRecord(DataSet: TDataSet;
      var Accept: Boolean);
    procedure tblAPInvFilterRecord(DataSet: TDataSet; var Accept: Boolean);
    procedure tblAPCheqFilterRecord(DataSet: TDataSet;
      var Accept: Boolean);
    procedure DetailInvoicesBeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure DetailInvoicesAfterPrint(Sender: TQRCustomBand;
      BandPrinted: Boolean);
    procedure DetailChequesBeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure DetailChequesAfterPrint(Sender: TQRCustomBand;
      BandPrinted: Boolean);
    procedure MasterBeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure SummaryBeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure QuickReportBeforePrint(Sender: TCustomQuickRep;
      var PrintReport: Boolean);
    procedure QuickReportPreview(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  rptAPHistory: TrptAPHistory;

implementation

uses BS1Form, APReportsForm, PreviewForm;

{$R *.DFM}

var
  totRInvoices, totRCheques: integer;

procedure TrptAPHistory.FormCreate(Sender: TObject);
begin
  tblVendor.DatabaseName := strDatabaseName;
  tblAPInv.DatabaseName := strDatabaseName;
  tblAPCheq.DatabaseName := strDatabaseName;
  tblVendor.Active := true;
  tblAPInv.Active := true;
  tblAPCheq.Active := true;

  if frmAPReports.GLPeriod <10 then lblPeriod.caption := 'Period: 0' + IntToStr(frmAPReports.GLPeriod) + '/' + IntToStr(frmAPReports.GLYear)
  else lblPeriod.caption := 'Period: ' + IntToStr(frmAPReports.GLPeriod) + '/' + IntToStr(frmAPReports.GLYear);

  tblAPInv.MasterSource := nil;   //Prevent report crash (Error: At beginning of table) that disables subsequent QuickReports.
  if tblAPInv.RecordCount > 0 then tblAPInv.MasterSource := dsVendor;
  tblAPCheq.MasterSource := nil;
  if tblAPCheq.RecordCount > 0 then tblAPCheq.MasterSource := dsVendor;
end;

procedure TrptAPHistory.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TrptAPHistory.tblVendorFilterRecord(DataSet: TDataSet;
  var Accept: Boolean);
begin
  Accept := true;
  if (frmAPReports.CurrencyID >0) and (frmAPReports.CurrencyID <> tblVendorCurrencyID.value) then Accept := false
  else if (frmAPReports.VendorID >0) and (frmAPReports.VendorID <> tblVendorVendorID.value) then Accept := false;
end;

procedure TrptAPHistory.tblAPInvFilterRecord(DataSet: TDataSet;
  var Accept: Boolean);
begin
  Accept := true;
  if ((tblAPInvGLPeriod.value <> frmAPReports.GLPeriod) or (tblAPInvGLYear.value <> frmAPReports.GLYear)) then Accept := false;
end;

procedure TrptAPHistory.tblAPCheqFilterRecord(DataSet: TDataSet;
  var Accept: Boolean);
begin
  Accept := true;
  if ((tblAPCheqGLPeriod.value <> frmAPReports.GLPeriod) or (tblAPCheqGLYear.value <> frmAPReports.GLYear)) then Accept := false;
end;

procedure TrptAPHistory.DetailInvoicesBeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
begin
  if (tblAPInv.RecordCount = 0) then PrintBand := false;
end;

procedure TrptAPHistory.DetailInvoicesAfterPrint(Sender: TQRCustomBand;
  BandPrinted: Boolean);
begin
  if BandPrinted = true then totRInvoices := totRInvoices + 1;
end;

procedure TrptAPHistory.DetailChequesBeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
begin
  if (tblAPCheq.RecordCount = 0) then PrintBand := false;
end;

procedure TrptAPHistory.DetailChequesAfterPrint(Sender: TQRCustomBand;
  BandPrinted: Boolean);
begin
  if BandPrinted = true then totRCheques := totRCheques + 1;
end;

procedure TrptAPHistory.MasterBeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
begin
  if (tblAPInv.RecordCount = 0) and (tblAPCheq.RecordCount = 0) then begin
    PrintBand := false;
  end;
end;

procedure TrptAPHistory.SummaryBeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
begin
  lblTotRInvoiceAmount.caption := IntToStr(totRInvoices) + ' invoices   ' + FloatToStrF(totRInvoiceAmount.value.dblResult,ffCurrency,18,2);
  lblTotRChequeAmount.caption := IntToStr(totRCheques) + ' cheques   ' + FloatToStrF(totRChequeAmount.value.dblResult,ffCurrency,18,2);
end;

procedure TrptAPHistory.QuickReportBeforePrint(Sender: TCustomQuickRep;
  var PrintReport: Boolean);
begin
  totRInvoices := 0;
  totRCheques := 0;
end;

procedure TrptAPHistory.QuickReportPreview(Sender: TObject);
begin
  frmPreview := TfrmPreview.Create(Application);
  frmPreview.QRPreview1.QRPrinter := TQRPrinter(sender);
  frmPreview.QuickReport := QuickReport;   //Set dummy quickreport so as to be able to apply selected printer and from/to page.
  frmPreview.show;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -