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

📄 arinvoicereport.pas

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

interface

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

type
  TrptARInvoice = class(TForm)
    QuickReport: TQuickRep;
    Detail: TQRSubDetail;
    Footer: TQRBand;
    Header: TQRBand;
    Master: TQRBand;
    shapeShipTo: TQRShape;
    lblShipTo: TQRLabel;
    txtCustomerName: TQRDBText;
    shapeBillTo: TQRShape;
    lblBillTo: TQRLabel;
    txtBillToName: TQRDBText;
    txtAddressLine1: TQRDBText;
    txtAddressLine2: TQRDBText;
    txtCityStateZip: TQRDBText;
    lblInvoice: TQRLabel;
    shapeInvoiceNo: TQRShape;
    lblInvoiceNo: TQRLabel;
    txtInvoiceNo: TQRDBText;
    lblOriginalInvNo: TQRLabel;
    txtOriginalInvNo: TQRDBText;
    lblPurchaseOrderNo: TQRLabel;
    txtPurchaseOrderNo: TQRDBText;
    QRShape3: TQRShape;
    lblQuantity: TQRLabel;
    lblItemNo: TQRLabel;
    lblItemDescription: TQRLabel;
    lblUnitPrice: TQRLabel;
    lblTaxCodes: TQRLabel;
    lblExtAmount: TQRLabel;
    txtBillToNo: TQRDBText;
    txtCountry: TQRDBText;
    txtCustomerNo: TQRDBText;
    QRShape9: TQRShape;
    shapeDescription: TQRShape;
    txtDescription: TQRDBText;
    lblDescription: TQRLabel;
    shapeInvoiceDate: TQRShape;
    lblInvoiceDate: TQRLabel;
    txtInvoiceDate: TQRDBText;
    txtTax1Amount: TQRDBText;
    txtTax2Amount: TQRDBText;
    txtTax1DescriptionRate: TQRDBText;
    txtTax2DescriptionRate: TQRDBText;
    QRShape12: TQRShape;
    lblInvoiceTotal: TQRLabel;
    QRLabel1: TQRLabel;
    QRShape13: TQRShape;
    txtInvoiceAmount: TQRDBText;
    txtSubtotal: TQRDBText;
    txtCustomerMessage: TQRDBText;
    txtCurrencyName: TQRDBText;
    QRShape14: TQRShape;
    txtTerms: TQRDBText;
    txtBAddressLine1: TQRDBText;
    txtBAddressLine2: TQRDBText;
    txtBCityStateZip: TQRDBText;
    txtBCountry: TQRDBText;
    lblHQuantity: TQRLabel;
    lblHItemNo: TQRLabel;
    lblHItemDescription: TQRLabel;
    lblHUnitPrice: TQRLabel;
    lblHTaxCodes: TQRLabel;
    lblHExtAmount: TQRLabel;
    shapeHInvoiceDate: TQRShape;
    lblHInvoiceDate: TQRLabel;
    shapeHInvoiceNo: TQRShape;
    lblHInvoiceNo: TQRLabel;
    lblHOriginalInvNo: TQRLabel;
    lblHPurchaseOrderNo: TQRLabel;
    shapeHBillTo: TQRShape;
    shapeHShipTo: TQRShape;
    lblHBillTo: TQRLabel;
    lblHShipTo: TQRLabel;
    lblHInvoice: TQRLabel;
    shapeHDescription: TQRShape;
    lblHDescription: TQRLabel;
    txtHDescription: TQRDBText;
    txtHBillToName: TQRDBText;
    txtHBAddressLine1: TQRDBText;
    txtHBAddressLine2: TQRDBText;
    txtHBCityStateZip: TQRDBText;
    txtHBCountry: TQRDBText;
    txtHBillToNo: TQRDBText;
    txtHCustomerName: TQRDBText;
    txtHAddressLine1: TQRDBText;
    txtHAddressLine2: TQRDBText;
    txtHCityStateZip: TQRDBText;
    txtHCountry: TQRDBText;
    txtHCustomerNo: TQRDBText;
    txtHInvoiceDate: TQRDBText;
    txtHPurchaseOrderNo: TQRDBText;
    txtHOriginalInvNo: TQRDBText;
    txtHInvoiceNo: TQRDBText;
    lblSame: TQRLabel;
    lblHSame: TQRLabel;
    lblPageNumber: TQRLabel;
    lblCompanyName: TQRLabel;
    QRShape1: TQRShape;
    lblCompanyAddress: TQRLabel;
    QRShape2: TQRShape;
    lblHCompanyName: TQRLabel;
    lblHCompanyAddress: TQRLabel;
    txtQuantity: TQRDBText;
    txtItemNo: TQRDBText;
    txtItemOvDesc: TQRDBText;
    txtUnitPrice: TQRDBText;
    txtApplicableTaxCodes: TQRDBText;
    txtExtAmount: TQRDBText;
    QRShape8: TQRShape;
    txtItemDescription: TQRDBText;
    QRShape6: TQRShape;
    QRShape5: TQRShape;
    QRShape4: TQRShape;
    QRShape7: TQRShape;
    totILines: TQRExpr;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure HeaderBeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure MasterBeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure DetailBeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure FooterBeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure QuickReportBeforePrint(Sender: TCustomQuickRep;
      var PrintReport: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  rptARInvoice: TrptARInvoice;

implementation

uses ARInvoicesPrintForm, BS1Form;

{$R *.DFM}

var
  PageNumber: integer;
  intInvoicesPrinted: integer;

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

procedure TrptARInvoice.FormCreate(Sender: TObject);
begin
  lblCompanyName.caption := frmBS1.tblCompanyCompanyName.value;
  lblCompanyAddress.caption := frmBS1.tblCompanyAddressLine1.value;
  if frmBS1.tblCompanyAddressLine2.value <> '' then lblCompanyAddress.caption := lblCompanyAddress.caption + ', ' + frmBS1.tblCompanyAddressLine2.value;
  if frmBS1.tblCompanyAddressLine3.value <> '' then lblCompanyAddress.caption := lblCompanyAddress.caption + ', ' + frmBS1.tblCompanyAddressLine3.value;
  lblHCompanyName.caption := lblCompanyName.caption;
  lblHCompanyAddress.caption := lblCompanyAddress.caption;
end;

procedure TrptARInvoice.HeaderBeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
begin
  if totILines.value.intResult > 0 then PrintBand := true   //Only print header on page overflow.
  else                                  PrintBand := false;
  PageNumber := PageNumber + 1;
  lblPageNumber.caption := 'Page ' + IntToStr(PageNumber);

  if frmARInvoicesPrint.qryARInvAddressLine2.value = '' then begin
    txtHCityStateZip.top := 226;
    txtHCountry.top := 243;
  end else begin
    txtHCityStateZip.top := 243;
    txtHCountry.top := 260;
  end;

  if frmARInvoicesPrint.qryARInvBAddressLine2.value = '' then begin
    txtHBCityStateZip.top := 226;
    txtHBCountry.top := 243;
  end else begin
    txtHBCityStateZip.top := 243;
    txtHBCountry.top := 260;
  end;

  if frmARInvoicesPrint.qryARInvCustomerNo.value = frmARInvoicesPrint.qryARInvBillToNo.value then begin
    txtHCustomerNo.enabled := false;
    txtHCustomerName.enabled := false;
    txtHAddressLine1.enabled := false;
    txtHAddressLine2.enabled := false;
    txtHCityStateZip.enabled := false;
    txtHCountry.enabled := false;
    lblHSame.enabled := true;
  end else begin
    txtHCustomerNo.enabled := true;
    txtHCustomerName.enabled := true;
    txtHAddressLine1.enabled := true;
    txtHAddressLine2.enabled := true;
    txtHCityStateZip.enabled := true;
    txtHCountry.enabled := true;
    lblHSame.enabled := false;
  end;
end;

procedure TrptARInvoice.MasterBeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
begin
  if intInvoicesPrinted >0 then QuickReport.NewPage;   //Force new page for each new invoice after the 1st one. Delphi 4 (QR 3.0) gives Access Violation if you use ForceNewPage property of band.
  inc(intInvoicesPrinted);
  
  PageNumber := 1;

  if frmARInvoicesPrint.qryARInvAddressLine2.value = '' then begin
    txtCityStateZip.top := 226;
    txtCountry.top := 243;
  end else begin
    txtCityStateZip.top := 243;
    txtCountry.top := 260;
  end;

  if frmARInvoicesPrint.qryARInvBAddressLine2.value = '' then begin
    txtBCityStateZip.top := 226;
    txtBCountry.top := 243;
  end else begin
    txtBCityStateZip.top := 243;
    txtBCountry.top := 260;
  end;

  if frmARInvoicesPrint.qryARInvCustomerNo.value = frmARInvoicesPrint.qryARInvBillToNo.value then begin
    txtCustomerNo.enabled := false;
    txtCustomerName.enabled := false;
    txtAddressLine1.enabled := false;
    txtAddressLine2.enabled := false;
    txtCityStateZip.enabled := false;
    txtCountry.enabled := false;
    lblSame.enabled := true;
  end else begin
    txtCustomerNo.enabled := true;
    txtCustomerName.enabled := true;
    txtAddressLine1.enabled := true;
    txtAddressLine2.enabled := true;
    txtCityStateZip.enabled := true;
    txtCountry.enabled := true;
    lblSame.enabled := false;
  end;
end;

procedure TrptARInvoice.DetailBeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
begin
  if frmARInvoicesPrint.tblARInvDetItemOvDesc.value = '' then begin
    txtItemOvDesc.enabled := false;
    txtItemDescription.enabled := true;
  end else begin
    txtItemOvDesc.enabled := true;
    txtItemDescription.enabled := false;
  end;
end;

procedure TrptARInvoice.FooterBeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
begin
  if frmARInvoicesPrint.qryARInvTax1Amount.AsCurrency = 0 then txtTax1Amount.enabled := false
  else                                                         txtTax1Amount.enabled := true;
  if frmARInvoicesPrint.qryARInvTax2Amount.AsCurrency = 0 then txtTax2Amount.enabled := false
  else                                                         txtTax2Amount.enabled := true;
end;

procedure TrptARInvoice.QuickReportBeforePrint(Sender: TCustomQuickRep;
  var PrintReport: Boolean);
begin
  intInvoicesPrinted := 0;
end;

end.

⌨️ 快捷键说明

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