You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
157 lines
3.7 KiB
157 lines
3.7 KiB
unit urelTCC;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
|
System.Classes, Vcl.Graphics,
|
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, RLReport, ZAbstractRODataset,
|
|
ZDataset, RLFilters, RLPDFFilter, RLXLSFilter, RLXLSXFilter;
|
|
|
|
type
|
|
TrelTCC = class(TForm)
|
|
frrelTCC: TRLReport;
|
|
RLBand1: TRLBand;
|
|
dtsRelatorio: TDataSource;
|
|
RLDBText3: TRLDBText;
|
|
RLDBText4: TRLDBText;
|
|
RLDBText5: TRLDBText;
|
|
RLDBText6: TRLDBText;
|
|
RLDBText7: TRLDBText;
|
|
roqryRelatorio: TZReadOnlyQuery;
|
|
frbnd_header: TRLBand;
|
|
frpnl_logo: TRLPanel;
|
|
frdbimg_logo: TRLDBImage;
|
|
frlbl_titulorel: TRLLabel;
|
|
RLBand2: TRLBand;
|
|
RLLabel1: TRLLabel;
|
|
RLBand3: TRLBand;
|
|
RLLabel2: TRLLabel;
|
|
RLLabel3: TRLLabel;
|
|
RLLabel4: TRLLabel;
|
|
RLLabel5: TRLLabel;
|
|
RLLabel6: TRLLabel;
|
|
RLLabel7: TRLLabel;
|
|
roqryRelatorioTX_NOME: TWideStringField;
|
|
roqryRelatorioTX_DOCUMENTO: TWideStringField;
|
|
roqryRelatorioTX_PRODUTO: TWideStringField;
|
|
roqryRelatorioDT_VENCIMENTO: TDateTimeField;
|
|
roqryRelatorioVL_TITULO: TFloatField;
|
|
roqryRelatorioDT_PAGAMENTO: TDateTimeField;
|
|
roqryRelatorioVL_CORRIGIDO: TFloatField;
|
|
RLDBText1: TRLDBText;
|
|
RLDBText2: TRLDBText;
|
|
RLDBResult1: TRLDBResult;
|
|
RLDBResult2: TRLDBResult;
|
|
RLBand4: TRLBand;
|
|
frlbl_usuario: TRLLabel;
|
|
frdblbl_usuario: TRLDBText;
|
|
RLSystemInfo2: TRLSystemInfo;
|
|
RLSystemInfo1: TRLSystemInfo;
|
|
frfilterpdf: TRLPDFFilter;
|
|
RLXLSXFilter1: TRLXLSXFilter;
|
|
procedure frrelTCCAfterPrint(Sender: TObject);
|
|
procedure frrelTCCBeforePrint(Sender: TObject; var PrintIt: Boolean);
|
|
private
|
|
|
|
procedure SalvarPDF;
|
|
{ Private declarations }
|
|
public
|
|
tipo: string;
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
relTCC: TrelTCC;
|
|
|
|
meses: array [1 .. 12] of string = (
|
|
'JANEIRO',
|
|
'FEVEREIRO',
|
|
'MARCO',
|
|
'ABRIL',
|
|
'MAIO',
|
|
'JUNHO',
|
|
'JULHO',
|
|
'AGOSTO',
|
|
'SETEMBRO',
|
|
'OUTUBRO',
|
|
'NOVEMBRO',
|
|
'DEZEMBRO'
|
|
);
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses udtmSystem;
|
|
|
|
procedure TrelTCC.frrelTCCAfterPrint(Sender: TObject);
|
|
begin
|
|
SalvarPDF;
|
|
end;
|
|
|
|
procedure TrelTCC.frrelTCCBeforePrint(Sender: TObject; var PrintIt: Boolean);
|
|
begin
|
|
if tipo = 'ac' then
|
|
begin
|
|
frlbl_titulorel.Caption := 'Prestação de Contas de Acordos.';
|
|
end;
|
|
roqryRelatorio.Open;
|
|
roqryRelatorio.First;
|
|
end;
|
|
|
|
procedure TrelTCC.SalvarPDF;
|
|
var
|
|
path, file_name: string;
|
|
Fmt: TFormatSettings;
|
|
i: integer;
|
|
begin
|
|
Fmt := TFormatSettings.Create;
|
|
for I := Low(meses) to High(meses) do
|
|
begin
|
|
Fmt.LongMonthNames[i] := meses[i];
|
|
end;
|
|
path := ExtractFilePath(Application.ExeName) + 'RELATORIOS';
|
|
if not DirectoryExists(path) then
|
|
begin
|
|
CreateDir(path);
|
|
end;
|
|
path := path + '\PRESTACAO_CONTAS_TCC';
|
|
if not DirectoryExists(path) then
|
|
begin
|
|
CreateDir(path);
|
|
end;
|
|
path := TrimRight(path);
|
|
path := path + '\' + FormatDateTime('YYYY', Date);
|
|
if not DirectoryExists(path) then
|
|
begin
|
|
CreateDir(path);
|
|
end;
|
|
path := path + '\' + FormatDateTime('mmmm', Date, Fmt);
|
|
if not DirectoryExists(path) then
|
|
begin
|
|
CreateDir(path);
|
|
end;
|
|
path := path + '\' + FormatDateTime('dd', Date);
|
|
if not DirectoryExists(path) then
|
|
begin
|
|
CreateDir(path);
|
|
end;
|
|
if tipo = 'liq' then
|
|
begin
|
|
file_name := path + '\RELATORIO_PRESTACAO_CONTAS-LIQ-' +
|
|
FormatDateTime('HH-mm', Time) + '.pdf';
|
|
end;
|
|
if tipo = 'ac' then
|
|
begin
|
|
file_name := path + '\RELATORIO_PRESTACAO_CONTAS-ACORDOS-' +
|
|
FormatDateTime('HH-mm', Time) + '.pdf';
|
|
end;
|
|
frfilterpdf.FileName := file_name;
|
|
frrelTCC.SaveToFile(file_name);
|
|
StringReplace(file_name, '.pdf', '.xls', []);
|
|
// RLXLSXFilter1.FileName := file_name;
|
|
// RLXLSXFilter1.Workbook.SaveToFile(file_name);
|
|
end;
|
|
|
|
end.
|