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

📄 ap260report.pas

📁 一套融入了系统营销管理思想的管理软件产品
💻 PAS
字号:
unit AP260Report;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, BaseReport, DB, DBTables, QRCtrls, QuickRpt, ExtCtrls;

type
  TqrAP260 = class(TQuickReport)
    QRLabel6: TQRLabel;
    QRLabel7: TQRLabel;
    QRLabel8: TQRLabel;
    QRLabel9: TQRLabel;
    QRLabel10: TQRLabel;
    QRLabel11: TQRLabel;
    QRLabel13: TQRLabel;
    QRDBText1: TQRDBText;
    QRDBText2: TQRDBText;
    QRDBText3: TQRDBText;
    QRDBText4: TQRDBText;
    QRDBText5: TQRDBText;
    QRDBText6: TQRDBText;
    QRDBText7: TQRDBText;
    QRDBText8: TQRDBText;
    QRBand1: TQRBand;
    QRExpr1: TQRExpr;
    QRExpr2: TQRExpr;
    QRExpr3: TQRExpr;
    QRExpr4: TQRExpr;
    QRExpr5: TQRExpr;
    QRExpr6: TQRExpr;
    QRLabel14: TQRLabel;
    QRLabel15: TQRLabel;
    UpdateSQL1: TUpdateSQL;
    qyReportSupplierID: TStringField;
    qyReportSupplierAttribName: TStringField;
    qyReportAP0030: TIntegerField;
    qyReportAP3160: TIntegerField;
    qyReportAP6190: TIntegerField;
    qyReportAP9120: TIntegerField;
    qyReportAP1200: TIntegerField;
    qyReportAPTOTL: TIntegerField;
    QRLabel12: TQRLabel;
    qyReportPayDays: TBCDField;
    QRDBText9: TQRDBText;
    procedure qyReportBeforeOpen(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure PrepareReport; override;
  end;

var
  qrAP260: TqrAP260;

implementation

uses DataModule, Main, PublicFunction;

{$R *.dfm}

{ TqrAP260 }

procedure TqrAP260.PrepareReport;
var
  sTempDate, sYearMonth : String;
  M0030, M3160, M6190, M9120, M1200 : String;
  sPayDate, sStandarDate : String;
  iMonth : Integer;
begin
  inherited;
  M0030 := DM.tbInput.FieldByName('BeginYear').AsString +
           DM.tbInput.FieldByName('BeginMonth').AsString;
  sTempDate := DecMonth(DM.tbInput.FieldByName('BeginYear').AsString + '-' +
                        DM.tbInput.FieldByName('BeginMonth').AsString + '-01', 1);
  M3160 := LeftStr(sTempDate, 2) + SubStr(sTempDate, 4, 2);
  sTempDate := DecMonth(DM.tbInput.FieldByName('BeginYear').AsString + '-' +
                        DM.tbInput.FieldByName('BeginMonth').AsString + '-01', 2);
  M6190 := LeftStr(sTempDate, 2) + SubStr(sTempDate, 4, 2);
  sTempDate := DecMonth(DM.tbInput.FieldByName('BeginYear').AsString + '-' +
                        DM.tbInput.FieldByName('BeginMonth').AsString + '-01', 3);
  M9120 := LeftStr(sTempDate, 2) + SubStr(sTempDate, 4, 2);
  sTempDate := DecMonth(DM.tbInput.FieldByName('BeginYear').AsString + '-' +
                        DM.tbInput.FieldByName('BeginMonth').AsString + '-01', 4);
  M1200 := LeftStr(sTempDate, 2) + SubStr(sTempDate, 4, 2);
  sStandarDate := DM.tbInput.FieldByName('BeginYear').AsString + '-' +
                  DM.tbInput.FieldByName('BeginMonth').AsString + '-01';
  with DM.qyTemp1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('SELECT SupplierID, PurchaseDate, ');
    SQL.Add('(AccountPayable - Paid) AS UnAccountPayable ');
    SQL.Add('FROM PurchaseMaster ');
    SQL.Add('WHERE CompanyID = :CompanyID ');
    SQL.Add('AND PurchaseDate <= :PurchaseDate ');
    SQL.Add('AND SupplierID >= :BeginSupplierID AND SupplierID <= :EndSupplierID ');
    SQL.Add('AND PurchaseProperty IN (''5'', ''6'') ');
    SQL.Add('AND AccountPayable <> Paid ');
    ParamByName('CompanyID').AsString := sCompanyID;
    ParamByName('PurchaseDate').AsString := DM.tbInput.FieldByName('BeginYear').AsString + '-' +
                                            DM.tbInput.FieldByName('BeginMonth').AsString + '-31';
    ParamByName('BeginSupplierID').AsString := DM.tbInput.FieldByName('BeginSupplierID').AsString;
    ParamByName('EndSupplierID').AsString := DM.tbInput.FieldByName('EndSupplierID').AsString;
    Open;
  end;
  DM.qyTemp1.First;
  while not DM.qyTemp1.Eof do
  begin
    sYearMonth := LeftStr(DM.qyTemp1.FieldByName('PurchaseDate').AsString, 2) +
                  SubStr(DM.qyTemp1.FieldByName('PurchaseDate').AsString, 4, 2);
    if qyReport.Locate('SupplierID', DM.qyTemp1.FieldByName('SupplierID').AsString, []) then
    begin
      iMonth := (qyReport.FieldByName('PayDays').AsInteger div 30);
      if (qyReport.FieldByName('PayDays').AsInteger mod 30) <> 0 then
        iMonth := iMonth + 1;
      if iMonth = 0 then
        iMonth := 1;
      sPayDate := AddMonth(DM.qyTemp1.FieldByName('PurchaseDate').AsString, iMonth);
      if LeftStr(sPayDate, 5) > LeftStr(sStandarDate, 5) then
      begin
        DM.qyTemp1.Next;
        Continue;
      end;
      sYearMonth := LeftStr(sPayDate, 2) + SubStr(sPayDate, 4, 2);
      qyReport.Edit;
      if sYearMonth = M0030 then
        qyReport.FieldByName('AP0030').AsFloat :=
                 qyReport.FieldByName('AP0030').AsFloat +
                 DM.qyTemp1.FieldByName('UnAccountPayable').AsFloat;
      if sYearMonth = M3160 then
        qyReport.FieldByName('AP3160').AsFloat :=
                 qyReport.FieldByName('AP3160').AsFloat +
                 DM.qyTemp1.FieldByName('UnAccountPayable').AsFloat;
      if sYearMonth = M6190 then
        qyReport.FieldByName('AP6190').AsFloat :=
                 qyReport.FieldByName('AP6190').AsFloat +
                 DM.qyTemp1.FieldByName('UnAccountPayable').AsFloat;
      if sYearMonth = M9120 then
        qyReport.FieldByName('AP9120').AsFloat :=
                 qyReport.FieldByName('AP9120').AsFloat +
                 DM.qyTemp1.FieldByName('UnAccountPayable').AsFloat;
      if sYearMonth <= M1200 then
        qyReport.FieldByName('AP1200').AsFloat :=
                 qyReport.FieldByName('AP1200').AsFloat +
                 DM.qyTemp1.FieldByName('UnAccountPayable').AsFloat;
      qyReport.Post;
    end;
    DM.qyTemp1.Next;
  end;
  qyReport.First;
  while not qyReport.Eof do
  begin
    qyReport.Edit;
    qyReport.FieldByName('APTOTL').AsFloat :=
             qyReport.FieldByName('AP0030').AsFloat +
             qyReport.FieldByName('AP3160').AsFloat +
             qyReport.FieldByName('AP6190').AsFloat +
             qyReport.FieldByName('AP9120').AsFloat +
             qyReport.FieldByName('AP1200').AsFloat;
    qyReport.Post;
    if (qyReport.FieldByName('AP0030').AsFloat = 0) and
       (qyReport.FieldByName('AP3160').AsFloat = 0) and
       (qyReport.FieldByName('AP6190').AsFloat = 0) and
       (qyReport.FieldByName('AP9120').AsFloat = 0) and
       (qyReport.FieldByName('AP1200').AsFloat = 0) and
       (qyReport.FieldByName('APTOTL').AsFloat = 0) then
    begin
      qyReport.Delete;
      Continue;
    end;
    qyReport.Next;
  end;
end;

procedure TqrAP260.qyReportBeforeOpen(DataSet: TDataSet);
begin
  inherited;
  with qyReport do
  begin
    ParamByName('CompanyID').AsString := sCompanyID;
    ParamByName('BeginSupplierID').AsString := DM.tbInput.FieldByName('BeginSupplierID').AsString;
    ParamByName('EndSupplierID').AsString := DM.tbInput.FieldByName('EndSupplierID').AsString;
  end;
end;

end.

⌨️ 快捷键说明

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