📄 ar260report.~pas
字号:
unit AR260Report;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BaseReport, DB, DBTables, QRCtrls, QuickRpt, ExtCtrls;
type
TqrAR260 = class(TQuickReport)
qyReportCustomerID: TStringField;
qyReportCustomerAttribName: TStringField;
qyReportAR0030: TIntegerField;
qyReportAR3160: TIntegerField;
qyReportAR6190: TIntegerField;
qyReportAR9120: TIntegerField;
qyReportAR1200: TIntegerField;
qyReportARTOTL: TIntegerField;
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;
QRLabel16: TQRLabel;
qyReportPayDays: TBCDField;
QRDBText9: TQRDBText;
procedure qyReportBeforeOpen(DataSet: TDataSet);
private
{ Private declarations }
public
{ Public declarations }
procedure PrepareReport; override;
end;
var
qrAR260: TqrAR260;
implementation
uses DataModule, Main, PublicFunction;
{$R *.dfm}
{ TqrAR250 }
procedure TqrAR260.PrepareReport;
var
sTempDate, sYearMonth : String;
M0030, M3160, M6190, M9120, M1200 : String;
sReceiveDate, 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 CustomerID, DeliveryDate, ');
SQL.Add('(AccountReceivable - Received) AS UnAccountReceivable ');
SQL.Add('FROM DeliveryMaster ');
SQL.Add('WHERE CompanyID = :CompanyID ');
SQL.Add('AND DeliveryDate <= :DeliveryDate ');
SQL.Add('AND CustomerID >= :BeginCustomerID AND CustomerID <= :EndCustomerID ');
SQL.Add('AND DeliveryProperty IN (''1'', ''2'') ');
SQL.Add('AND AccountReceivable <> Received ');
ParamByName('CompanyID').AsString := sCompanyID;
ParamByName('DeliveryDate').AsString := DM.tbInput.FieldByName('BeginYear').AsString + '-' +
DM.tbInput.FieldByName('BeginMonth').AsString + '-31';
ParamByName('BeginCustomerID').AsString := DM.tbInput.FieldByName('BeginCustomerID').AsString;
ParamByName('EndCustomerID').AsString := DM.tbInput.FieldByName('EndCustomerID').AsString;
Open;
end;
DM.qyTemp1.First;
while not DM.qyTemp1.Eof do
begin
sYearMonth := LeftStr(DM.qyTemp1.FieldByName('DeliveryDate').AsString, 2) +
SubStr(DM.qyTemp1.FieldByName('DeliveryDate').AsString, 4, 2);
if qyReport.Locate('CustomerID', DM.qyTemp1.FieldByName('CustomerID').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;
sReceiveDate := AddMonth(DM.qyTemp1.FieldByName('DeliveryDate').AsString, iMonth);
if LeftStr(sReceiveDate, 5) > LeftStr(sStandarDate, 5) then
begin
DM.qyTemp1.Next;
Continue;
end;
sYearMonth := LeftStr(sReceiveDate, 2) + SubStr(sReceiveDate, 4, 2);
qyReport.Edit;
if sYearMonth = M0030 then
qyReport.FieldByName('AR0030').AsFloat :=
qyReport.FieldByName('AR0030').AsFloat +
DM.qyTemp1.FieldByName('UnAccountReceivable').AsFloat;
if sYearMonth = M3160 then
qyReport.FieldByName('AR3160').AsFloat :=
qyReport.FieldByName('AR3160').AsFloat +
DM.qyTemp1.FieldByName('UnAccountReceivable').AsFloat;
if sYearMonth = M6190 then
qyReport.FieldByName('AR6190').AsFloat :=
qyReport.FieldByName('AR6190').AsFloat +
DM.qyTemp1.FieldByName('UnAccountReceivable').AsFloat;
if sYearMonth = M9120 then
qyReport.FieldByName('AR9120').AsFloat :=
qyReport.FieldByName('AR9120').AsFloat +
DM.qyTemp1.FieldByName('UnAccountReceivable').AsFloat;
if sYearMonth <= M1200 then
qyReport.FieldByName('AR1200').AsFloat :=
qyReport.FieldByName('AR1200').AsFloat +
DM.qyTemp1.FieldByName('UnAccountReceivable').AsFloat;
qyReport.Post;
end;
DM.qyTemp1.Next;
end;
qyReport.First;
while not qyReport.Eof do
begin
qyReport.Edit;
qyReport.FieldByName('ARTOTL').AsFloat :=
qyReport.FieldByName('AR0030').AsFloat +
qyReport.FieldByName('AR3160').AsFloat +
qyReport.FieldByName('AR6190').AsFloat +
qyReport.FieldByName('AR9120').AsFloat +
qyReport.FieldByName('AR1200').AsFloat;
qyReport.Post;
if (qyReport.FieldByName('AR0030').AsFloat = 0) and
(qyReport.FieldByName('AR3160').AsFloat = 0) and
(qyReport.FieldByName('AR6190').AsFloat = 0) and
(qyReport.FieldByName('AR9120').AsFloat = 0) and
(qyReport.FieldByName('AR1200').AsFloat = 0) and
(qyReport.FieldByName('ARTOTL').AsFloat = 0) then
begin
qyReport.Delete;
Continue;
end;
qyReport.Next;
end;
end;
procedure TqrAR260.qyReportBeforeOpen(DataSet: TDataSet);
begin
inherited;
with qyReport do
begin
ParamByName('CompanyID').AsString := sCompanyID;
ParamByName('BeginCustomerID').AsString := DM.tbInput.FieldByName('BeginCustomerID').AsString;
ParamByName('EndCustomerID').AsString := DM.tbInput.FieldByName('EndCustomerID').AsString;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -