📄 ap230report.~pas
字号:
unit AP230Report;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BaseReport, DB, DBTables, QRCtrls, QuickRpt, ExtCtrls;
type
TqrAP230 = class(TQuickReport)
UpdateSQL1: TUpdateSQL;
QRLabel6: TQRLabel;
QRLabel7: TQRLabel;
QRLabel8: TQRLabel;
QRLabel9: TQRLabel;
QRLabel10: TQRLabel;
QRLabel11: TQRLabel;
QRDBText1: TQRDBText;
QRDBText2: TQRDBText;
QRDBText3: TQRDBText;
QRDBText4: TQRDBText;
QRDBText5: TQRDBText;
QRDBText6: TQRDBText;
qyReportSupplierID: TStringField;
qyReportSupplierAttribName: TStringField;
qyReportLastAP: TIntegerField;
qyReportPeriodAP: TIntegerField;
qyReportPaid: TIntegerField;
qyReportTotalAP: TIntegerField;
procedure qyReportBeforeOpen(DataSet: TDataSet);
private
{ Private declarations }
public
{ Public declarations }
procedure PrepareReport; override;
end;
var
qrAP230: TqrAP230;
implementation
uses DataModule, Main;
{$R *.dfm}
procedure TqrAP230.PrepareReport;
begin
inherited;
with DM.qyTemp1 do
begin
Close;
SQL.Clear;
SQL.Add('SELECT SupplierID, BeginningBalance ');
SQL.Add('FROM AccountPayableBeginning ');
SQL.Add('WHERE CompanyID = :CompanyID ');
SQL.Add('AND SupplierID >= :BeginSupplierID AND SupplierID <= :EndSupplierID ');
ParamByName('CompanyID').AsString := sCompanyID;
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
if qyReport.Locate('SupplierID', DM.qyTemp1.FieldByName('SupplierID').AsString, []) then
begin
qyReport.Edit;
qyReport.FieldByName('LastAP').AsFloat := DM.qyTemp1.FieldByName('BeginningBalance').AsFloat;
qyReport.Post;
end;
DM.qyTemp1.Next;
end;
with DM.qyTemp1 do
begin
Close;
SQL.Clear;
SQL.Add('SELECT SupplierID, AccountPayable ');
SQL.Add('FROM PurchaseMaster ');
SQL.Add('WHERE CompanyID = :CompanyID ');
SQL.Add('AND SupplierID >= :BeginSupplierID AND SupplierID <= :EndSupplierID ');
SQL.Add('AND PurchaseDate >= :BeginPurchaseDate AND PurchaseDate <= :EndPurchaseDate ');
SQL.Add('AND PurchaseProperty IN (''5'', ''6'') ');
ParamByName('CompanyID').AsString := sCompanyID;
ParamByName('BeginSupplierID').AsString := DM.tbInput.FieldByName('BeginSupplierID').AsString;
ParamByName('EndSupplierID').AsString := DM.tbInput.FieldByName('EndSupplierID').AsString;
ParamByName('BeginPurchaseDate').AsString :=
DM.tbInput.FieldByName('BeginYear').AsString + '-' +
DM.tbInput.FieldByName('BeginMonth').AsString + '-01';
ParamByName('EndPurchaseDate').AsString :=
DM.tbInput.FieldByName('BeginYear').AsString + '-' +
DM.tbInput.FieldByName('BeginMonth').AsString + '-31';
Open;
end;
DM.qyTemp1.First;
while not DM.qyTemp1.Eof do
begin
if qyReport.Locate('SupplierID', DM.qyTemp1.FieldByName('SupplierID').AsString, []) then
begin
qyReport.Edit;
qyReport.FieldByName('PeriodAP').AsFloat :=
qyReport.FieldByName('PeriodAP').AsFloat +
DM.qyTemp1.FieldByName('AccountPayable').AsFloat;
qyReport.Post;
end;
DM.qyTemp1.Next;
end;
with DM.qyTemp1 do
begin
Close;
SQL.Clear;
SQL.Add('SELECT SupplierID, TotalBalance ');
SQL.Add('FROM AccountPayableMaster ');
SQL.Add('WHERE CompanyID = :CompanyID ');
SQL.Add('AND SupplierID >= :BeginSupplierID AND SupplierID <= :EndSupplierID ');
SQL.Add('AND PayDate >= :BeginPayDate AND PayDate <= :EndPayDate ');
ParamByName('CompanyID').AsString := sCompanyID;
ParamByName('BeginSupplierID').AsString := DM.tbInput.FieldByName('BeginSupplierID').AsString;
ParamByName('EndSupplierID').AsString := DM.tbInput.FieldByName('EndSupplierID').AsString;
ParamByName('BeginPayDate').AsString :=
DM.tbInput.FieldByName('BeginYear').AsString + '-' +
DM.tbInput.FieldByName('BeginMonth').AsString + '-01';
ParamByName('EndPayDate').AsString :=
DM.tbInput.FieldByName('BeginYear').AsString + '-' +
DM.tbInput.FieldByName('BeginMonth').AsString + '-31';
Open;
end;
DM.qyTemp1.First;
while not DM.qyTemp1.Eof do
begin
if qyReport.Locate('SupplierID', DM.qyTemp1.FieldByName('SupplierID').AsString, []) then
begin
qyReport.Edit;
qyReport.FieldByName('Paid').AsFloat :=
qyReport.FieldByName('Paid').AsFloat +
DM.qyTemp1.FieldByName('TotalBalance').AsFloat;
qyReport.Post;
end;
DM.qyTemp1.Next;
end;
qyReport.First;
while not qyReport.Eof do
begin
qyReport.Edit;
qyReport.FieldByName('TotalAP').AsFloat :=
qyReport.FieldByName('LastAP').AsFloat +
qyReport.FieldByName('PeriodAP').AsFloat -
qyReport.FieldByName('Paid').AsFloat;
qyReport.Post;
if (qyReport.FieldByName('TotalAP').AsFloat = 0) and
(qyReport.FieldByName('LastAP').AsFloat = 0) and
(qyReport.FieldByName('PeriodAP').AsFloat = 0) and
(qyReport.FieldByName('Paid').AsFloat = 0) then
begin
qyReport.Delete;
Continue;
end;
qyReport.Next;
end;
end;
procedure TqrAP230.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 + -