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.
 

701 lines
22 KiB

unit uconfrelPrestacaoContas;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, System.UITypes,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.DBCtrls, Vcl.ComCtrls,
Data.DB, Vcl.ExtCtrls, ZAbstractRODataset, ZDataset, ZAbstractDataset,
Vcl.Menus;
type
TconfrelPrestacaoContas = class(TForm)
dtsBeneficiarios: TDataSource;
gb_data: TGroupBox;
Label1: TLabel;
dtp_inicio: TDateTimePicker;
dtp_fim: TDateTimePicker;
gb_beneficiario: TGroupBox;
dblucb_beneficiario: TDBLookupComboBox;
btn_viewreport: TButton;
rg_tipo: TRadioGroup;
ZReadOnlyQuery1: TZReadOnlyQuery;
dtsFiltro: TDataSource;
qryFiltro: TZQuery;
btn_imprimir: TButton;
ppm_marca: TPopupMenu;
IncluirTodos1: TMenuItem;
N1: TMenuItem;
DesmarcarTodos1: TMenuItem;
ZReadOnlyQuery2: TZReadOnlyQuery;
pg_tipo: TPageControl;
tbRel: TTabSheet;
lv_prestacao: TListView;
tbQuebra: TTabSheet;
lv_multi: TListView;
PopupMenu1: TPopupMenu;
ImprimirLista1: TMenuItem;
zroqryVerificador: TZReadOnlyQuery;
procedure btn_viewreportClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure btn_imprimirClick(Sender: TObject);
procedure IncluirTodos1Click(Sender: TObject);
procedure DesmarcarTodos1Click(Sender: TObject);
procedure ImprimirLista1Click(Sender: TObject);
procedure dtsBeneficiariosDataChange(Sender: TObject; Field: TField);
private
id_emp: integer;
procedure WMMoving(var Msg: TWMMoving); message WM_MOVING;
{ Private declarations }
public
str_titulos: string;
{ Public declarations }
end;
var
confrelPrestacaoContas: TconfrelPrestacaoContas;
meses: array [1 .. 12] of string = (
'JANEIRO',
'FEVEREIRO',
'MARCO',
'ABRIL',
'MAIO',
'JUNHO',
'JULHO',
'AGOSTO',
'SETEMBRO',
'OUTUBRO',
'NOVEMBRO',
'DEZEMBRO'
);
implementation
{$R *.dfm}
uses udtmSystem, urelPrestacaoContas, urelRelacaoAcordo, urelMulti;
// prestação de contas
procedure TconfrelPrestacaoContas.btn_viewreportClick(Sender: TObject);
begin
with dtmSystem do
begin
// mes1 := inttostr(strtoint(copy(FormatDateTime('yyyy-mm-dd',
// dtp_inicio.Date), 6, 2)));
// mes2 := inttostr(strtoint(copy(FormatDateTime('yyyy-mm-dd',
// dtp_fim.Date), 6, 2)));
// ano1 := copy(FormatDateTime('yyyy-mm-dd', dtp_inicio.Date), 1, 4);
// ano2 := copy(FormatDateTime('yyyy-mm-dd', dtp_fim.Date), 1, 4);
//
// tblEmpresaRepasse.Filtered := False;
// tblEmpresaRepasse.Filter := '(((ID_MES >= ' + mes1 + ') or (ID_MES <= ' +
// mes2 + ')) and ((ID_ANO >= ' + ano1 + ') or (ID_ANO <= ' + ano2 + ')))';
// tblEmpresaRepasse.Filtered := True;
//
// if tblEmpresaRepasse.IsEmpty then
// begin
// MessageDlg('Por favor monte um modelo de repasse para a empresa ' +
// tblCHGEmpresaTX_NOME.AsString +
// ' antes de realizar um relatório de Prestação de contas no período escolhido.',
// mtWarning, [mbOK], 0);
// Close;
// Abort;
// end;
if not tblAcordos.Active then
begin
tblAcordos.Open;
end;
end;
Screen.Cursor := crHourGlass;
if rg_tipo.ItemIndex = -1 then
begin
rg_tipo.ItemIndex := 0;
end;
lv_prestacao.Clear;
with qryFiltro.SQL do
begin
Clear;
Add('select distinct');
Add('A.tx_nome,');
Add('B.tx_produto,');
Add('B.dt_vencimento,');
Add('B.dt_pagamento,');
Add('B.vl_titulo,');
Add('B.vl_juros,');
Add('B.vl_multa,');
Add('B.vl_encargos,');
Add('B.vl_corrigido,');
Add('B.vl_desc_principal,');
Add('B.id_titulo,');
Add('AC.id_original');
// Add('(cast(B.dt_pagamento as date)- cast(B.dt_vencimento as date)) as atraso');
Add('from chg_titulos B');
Add('left join chg_devedores A on (A.id_devedor = B.id_devedor)');
Add('left join sys_acordos AC on (AC.id_original = B.id_titulo)');
Add('where (B.tp_situacao = ' + QuotedStr('QC') + ' or B.tp_situacao = ' +
QuotedStr('B') + ') and');
Add('B.tp_motivo <> ' + QuotedStr('Q') + ' and');
Add('B.id_empresa = ' + inttostr(dblucb_beneficiario.KeyValue) + ' and');
if rg_tipo.ItemIndex = 0 then
begin
Add('CAST(B.dt_pagamento AS DATE) >= ' +
QuotedStr(FormatDateTime('yyyy-mm-dd', dtp_inicio.Date)) + ' and');
Add('CAST(B.dt_pagamento AS DATE) <= ' +
QuotedStr(FormatDateTime('yyyy-mm-dd', dtp_fim.Date)));
Add('and B.dt_emissao_recibo is NULL');
end;
if rg_tipo.ItemIndex = 1 then
begin
Add('CAST(B.dt_emissao_recibo AS DATE) >= ' +
QuotedStr(FormatDateTime('yyyy-mm-dd', dtp_inicio.Date)) + ' and');
Add('CAST(B.dt_emissao_recibo AS DATE) <= ' +
QuotedStr(FormatDateTime('yyyy-mm-dd', dtp_fim.Date)));
end;
Add('and (AC.id_original is NULL');
Add('or AC.id_parcela in (select id_titulo from chg_titulos where id_empresa = 220))');
Add('order by A.tx_nome');
end;
qryFiltro.Open;
if not qryFiltro.IsEmpty then
begin
qryFiltro.First;
while not qryFiltro.Eof do
begin
// if not dtmSystem.tblAcordos.Locate('ID_ORIGINAL',
// qryFiltro.FieldByName('id_titulo').AsString, []) then
// begin
// with lv_prestacao.Items.Add do
// begin
// SubItems.Add(qryFiltro.FieldByName('tx_nome').AsString);
// SubItems.Add(qryFiltro.FieldByName('tx_produto').AsString);
// SubItems.Add(qryFiltro.FieldByName('dt_vencimento').AsString);
// SubItems.Add(qryFiltro.FieldByName('dt_pagamento').AsString);
// SubItems.Add(qryFiltro.FieldByName('vl_titulo').AsString);
// end;
// end
// else
// begin
// dtmSystem.tblTitulos.Locate('ID_TITULO',
// dtmSystem.tblAcordosID_PARCELA.AsString, []);
// if dtmSystem.tblTitulosID_EMPRESA.AsSingle = 220 then
// begin
// with lv_prestacao.Items.Add do
// begin
// SubItems.Add(qryFiltro.FieldByName('tx_nome').AsString);
// SubItems.Add(qryFiltro.FieldByName('tx_produto').AsString);
// SubItems.Add(qryFiltro.FieldByName('dt_vencimento').AsString);
// SubItems.Add(qryFiltro.FieldByName('dt_pagamento').AsString);
// SubItems.Add(qryFiltro.FieldByName('vl_titulo').AsString);
// end;
// end;
// end;
with lv_prestacao.Items.Add do
begin
SubItems.Add(qryFiltro.FieldByName('tx_nome').AsString);
SubItems.Add(qryFiltro.FieldByName('tx_produto').AsString);
SubItems.Add(qryFiltro.FieldByName('dt_vencimento').AsString);
SubItems.Add(qryFiltro.FieldByName('dt_pagamento').AsString);
SubItems.Add(qryFiltro.FieldByName('vl_titulo').AsString);
end;
qryFiltro.Next;
end;
lv_prestacao.Column[0].Alignment := taCenter;
end;
ZReadOnlyQuery2.SQL.Clear;
with ZReadOnlyQuery2.SQL do
begin
Add('select distinct');
Add('A.tx_nome,');
Add('B.tx_produto,');
Add('B.dt_vencimento,');
Add('B.dt_pagamento,');
Add('B.vl_titulo,');
Add('B.vl_juros,');
Add('B.vl_multa,');
Add('B.vl_encargos,');
Add('B.vl_corrigido,');
Add('B.vl_desc_principal,');
Add('B.id_titulo,');
Add('AC.id_original');
// Add('(cast(B.dt_pagamento as date)- cast(B.dt_vencimento as date)) as atraso');
Add('from chg_titulos B');
Add('left join chg_devedores A on (A.id_devedor = B.id_devedor)');
Add('left join sys_acordos AC on (AC.id_original = B.id_titulo)');
Add('where (B.tp_situacao = ' + QuotedStr('QC') + ' or B.tp_situacao = ' +
QuotedStr('B') + ') and');
Add('B.tp_motivo = ' + QuotedStr('Q') + ' and');
Add('B.id_empresa = ' + inttostr(dblucb_beneficiario.KeyValue) + ' and');
if rg_tipo.ItemIndex = 0 then
begin
Add('CAST(B.dt_pagamento AS DATE) >= ' +
QuotedStr(FormatDateTime('yyyy-mm-dd', dtp_inicio.Date)) + ' and');
Add('CAST(B.dt_pagamento AS DATE) <= ' +
QuotedStr(FormatDateTime('yyyy-mm-dd', dtp_fim.Date)));
Add('and B.dt_emissao_recibo is NULL');
end;
if rg_tipo.ItemIndex = 1 then
begin
Add('CAST(B.dt_emissao_recibo AS DATE) >= ' +
QuotedStr(FormatDateTime('yyyy-mm-dd', dtp_inicio.Date)) + ' and');
Add('CAST(B.dt_emissao_recibo AS DATE) <= ' +
QuotedStr(FormatDateTime('yyyy-mm-dd', dtp_fim.Date)));
end;
Add('and (AC.id_original is NULL');
Add('or AC.id_parcela in (select id_titulo from chg_titulos where id_empresa = 220))');
Add('order by A.tx_nome');
end;
ZReadOnlyQuery2.Open;
if ZReadOnlyQuery2.RecordCount > 0 then
begin
MessageDlg
('Há títulos com múltiplas formas de pagamento neste intervalo de prestação de contas.'
+ ' Por favor gere uma prestação manual também.', mtInformation,
[mbOK], 0);
end;
lv_multi.Clear;
if not ZReadOnlyQuery2.IsEmpty then
begin
ZReadOnlyQuery2.First;
while not ZReadOnlyQuery2.Eof do
begin
with lv_multi.Items.Add do
begin
Caption := ZReadOnlyQuery2.FieldByName('tx_nome').AsString;
SubItems.Add(ZReadOnlyQuery2.FieldByName('tx_produto').AsString);
SubItems.Add(ZReadOnlyQuery2.FieldByName('dt_vencimento').AsString);
SubItems.Add(ZReadOnlyQuery2.FieldByName('dt_pagamento').AsString);
SubItems.Add(ZReadOnlyQuery2.FieldByName('vl_titulo').AsString);
end;
ZReadOnlyQuery2.Next;
end;
end;
Screen.Cursor := crDefault;
pg_tipo.ActivePageIndex := 0;
btn_imprimir.Enabled := true;
// Close;
end;
procedure TconfrelPrestacaoContas.DesmarcarTodos1Click(Sender: TObject);
var
i: integer;
begin
if lv_prestacao.Items.Count > 0 then
begin
for i := 0 to lv_prestacao.Items.Count - 1 do
begin
lv_prestacao.Items.Item[i].Checked := False;
end;
end;
end;
procedure TconfrelPrestacaoContas.dtsBeneficiariosDataChange(Sender: TObject; Field: TField);
begin
if id_emp <> dtsBeneficiarios.DataSet.FieldByName('ID_EMPRESA').AsInteger then
begin
id_emp := dtsBeneficiarios.DataSet.FieldByName('ID_EMPRESA').AsInteger;
btn_imprimir.Enabled := false;
lv_prestacao.Items.Clear;
lv_multi.Items.Clear;
end;
end;
procedure TconfrelPrestacaoContas.btn_imprimirClick(Sender: TObject);
var
str_ids: string;
i, qtde_mes, counter: integer;
Checked: Boolean;
id_emp: integer;
d1, d2, d3, d4: TDate;
Dh1, M1, Y1: Word;
Dh2, M2, Y2: Word;
faltando: Boolean;
begin
Screen.Cursor := crHourGlass;
id_emp := dblucb_beneficiario.KeyValue;
if rg_tipo.ItemIndex = -1 then
begin
rg_tipo.ItemIndex := 0;
end;
str_titulos := '';
Checked := False;
if lv_prestacao.Items.Count > 0 then
begin
for i := 0 to lv_prestacao.Items.Count - 1 do
begin
if lv_prestacao.Items.Item[i].Checked then
begin
qryFiltro.RecNo := i + 1;
str_titulos := str_titulos + qryFiltro.FieldByName('id_titulo')
.AsString + ',';
Checked := True;
end;
end;
end;
setlength(str_titulos, length(str_titulos) - 1);
if Checked then
begin
zroqryVerificador.SQL.Text :=
'select dt_pagamento from chg_titulos where id_titulo in(' + str_titulos +
') order by dt_pagamento';
zroqryVerificador.Open;
with dtmSystem do
begin
tblCHGEmpresa.Locate('ID_EMPRESA', id_emp, []);
zroqryVerificador.First;
d1 := zroqryVerificador.FieldByName('dt_pagamento').AsDateTime;
DecodeDate(d1, Y1, M1, Dh1);
d3 := StrToDate('01/' + inttostr(M1) + '/' + inttostr(Y1));
zroqryVerificador.Last;
d2 := zroqryVerificador.FieldByName('dt_pagamento').AsDateTime;
DecodeDate(d2, Y2, M2, Dh2);
d4 := StrToDate('01/' + inttostr(M2) + '/' + inttostr(Y2));
qtde_mes := MonthsBetween(d3, d4) + 1;
counter := 0;
tblEmpresaRepasse.Filtered := False;
tblEmpresaRepasse.Filter := '(ID_ANO >= ' + inttostr(Y1) +
' and ID_ANO <= ' + inttostr(Y2) + ')';
tblEmpresaRepasse.Filtered := True;
faltando := tblEmpresaRepasse.Locate('ID_ANO;ID_MES',
VarArrayOf([Y1, M1]), []);
if faltando = False then
begin
MessageDlg('A empresa ' + tblCHGEmpresaTX_NOME.AsString +
' não possui modelos de repasse para todos os mêses dentro do período do pagamento mais antigo e o mais novo.'
+ ' Por favor crie os modelos de repasses que faltam antes de realizar esta operação (Entre '
+ meses[M1] + ' de ' + inttostr(Y1) + ' e ' + meses[M2] + ' de ' +
inttostr(Y2) + '.', mtWarning, [mbOK], 0);
Close;
Abort;
end
else
begin
while tblEmpresaRepasseID_MES.AsInteger <> M2 do
begin
if tblEmpresaRepasse.Eof then
begin
break;
end;
if tblEmpresaRepasseID_ANO.AsInteger > Y2 then
begin
break;
end;
if tblEmpresaRepasseID_ANO.AsInteger = Y2 then
begin
if tblEmpresaRepasseID_MES.AsInteger > M2 then
begin
break;
end;
end;
Inc(counter, 1);
tblEmpresaRepasse.Next;
end;
if tblEmpresaRepasseID_MES.AsInteger = M2 then
begin
Inc(counter, 1);
end;
end;
if counter < qtde_mes then
begin
MessageDlg('A empresa ' + tblCHGEmpresaTX_NOME.AsString +
' não possui modelos de repasse para todos os meses dentro do período do pagamento mais antigo e o mais novo.'
+ ' Por favor crie os modelos de repasses que faltam antes de realizar esta operação (Entre '
+ meses[M1] + ' de ' + inttostr(Y1) + ' e ' + meses[M2] + ' de ' +
inttostr(Y2) + '.', mtWarning, [mbOK], 0);
Close;
Abort;
end;
end;
relPrestacaoContas := TrelPrestacaoContas.Create(self);
with relPrestacaoContas.zqryTitulos.SQL do
begin
Clear;
Add('select');
Add('A.tx_nome,');
Add('A.id_devedor,');
Add('B.tx_produto,');
Add('B.dt_vencimento,');
Add('B.dt_pagamento,');
// Add('B.vl_titulo,');
Add('case when b.id_titulo in (select id_parcela from sys_acordos) then (b.vl_corrigido - b.vl_juros - b.vl_multa - b.vl_encargos)');
Add('when b.id_titulo not in (select id_parcela from sys_acordos) then (b.vl_titulo)');
Add('end as vl_titulo,');
Add('B.vl_desc_principal,');
Add('B.vl_repasse_prin,');
Add('B.vl_juros,');
Add('B.vl_desc_juros,');
Add('B.vl_repasse_juros,');
Add('B.vl_multa,');
Add('B.vl_desc_multa,');
Add('B.vl_repasse_multa,');
Add('B.vl_encargos,');
Add('B.vl_indicador,');
Add('B.vl_desc_indicador,');
Add('B.vl_repasse_encargos,');
Add('B.vl_corrigido,');
Add('B.vl_repasse_corrigido,');
Add('B.id_titulo,');
Add('B.id_empresa,');
Add('B.tp_prestacao,');
Add('(cast(B.dt_pagamento as date)- cast(B.dt_vencimento as date)) as atraso');
Add('from chg_devedores A');
Add('inner join chg_titulos B on (A.id_devedor = B.id_devedor)');
Add('where (B.id_titulo in (' + str_titulos + '))');
Add('order by A.tx_nome');
end;
with relPrestacaoContas do
begin
dtmSystem.tblEmpresa.Locate('ID_EMPRESA', id_emp, []);
frlbl_headertop.Caption :=
UpperCase(dtmSystem.tblEmpresaTX_TITULO.AsString + ' - CNPJ: ' +
dtmSystem.tblEmpresaTX_CNPJ.AsString);
RLMemo1.Lines[0] := StringReplace(RLMemo1.Lines[0], 'BENEF',
UpperCase(dtmSystem.tblCHGEmpresaTX_NOME.AsString),
[rfReplaceAll, rfIgnoreCase]);
RLMemo1.Lines[0] := StringReplace(RLMemo1.Lines[0], 'DT1',
FormatDateTime('dd/mm/yyyy', dtp_inicio.Date),
[rfReplaceAll, rfIgnoreCase]);
RLMemo1.Lines[0] := StringReplace(RLMemo1.Lines[0], 'DT2',
FormatDateTime('dd/mm/yyyy', dtp_fim.Date),
[rfReplaceAll, rfIgnoreCase]);
zqryTitulos.Open;
frPrestacao.PreviewModal;
zqryTitulos.Close;
end;
relRelacaoAcordo := TrelRelacaoAcordo.Create(self);
with relRelacaoAcordo do
begin
rel_acordo := false;
with zroqryAcordos.SQL do
begin
Clear;
Add('select distinct');
Add('A.tx_nome,');
Add('B.tx_produto,');
Add('B.dt_vencimento,');
Add('B.id_titulo,');
Add('B.vl_titulo,');
Add('B.qtde_parcelas,');
Add('C.id_acordo');
Add('from chg_devedores A');
Add('inner join chg_titulos B on (A.id_devedor = B.id_devedor)');
Add('inner join sys_acordos C on (A.id_devedor = C.id_devedor)');
Add('where (B.id_titulo in (' + str_titulos + '))');
// Add('and B.id_titulo in');
// Add('(select id_parcela from sys_acordos)');
Add('and (C.id_parcela in');
Add('(' + str_titulos + '))');
Add('order by A.tx_nome');
end;
zroqryAcordos.Open;
zroqryAcordos.First;
str_ids := '';
while not zroqryAcordos.Eof do
begin
str_ids := str_ids + zroqryAcordos.FieldByName('ID_ACORDO')
.AsString + ',';
zroqryAcordos.Next;
end;
setlength(str_ids, length(str_ids) - 1);
if length(str_ids) > 0 then
begin
with zroqry1.SQL do
begin
Clear;
Add('select distinct A.id_acordo, B.tx_nome from sys_acordos A');
Add('left join chg_devedores B on (A.id_devedor = B.id_devedor)');
Add('where id_acordo in (' + str_ids + ')');
Add('order by B.tx_nome');
end;
with zroqry2.SQL do
begin
Clear;
Add('select distinct A.id_acordo, A.id_original, B.tx_produto, B.dt_vencimento, B.vl_titulo, count(a.id_acordo) from sys_acordos A');
Add('left join chg_titulos B on (A.id_original = B.id_titulo)');
Add('where id_acordo in (' + str_ids + ')');
Add('group by A.id_acordo, A.id_original, B.tx_produto, B.dt_vencimento, B.vl_titulo');
end;
with zroqry3.SQL do
begin
Clear;
Add('select distinct A.id_acordo, A.id_parcela, B.tx_produto, B.dt_vencimento, B.vl_titulo, count(a.id_acordo) from sys_acordos A');
Add('left join chg_titulos B on (A.id_parcela = B.id_titulo)');
Add('where id_acordo in (' + str_ids + ')');
Add('group by A.id_acordo, A.id_parcela, B.tx_produto, B.dt_vencimento, B.vl_titulo');
end;
dtmSystem.tblEmpresa.Locate('ID_EMPRESA', id_emp, []);
RLMemo1.Lines[0] := StringReplace(RLMemo1.Lines[0], 'BENEF',
UpperCase(dtmSystem.tblCHGEmpresaTX_NOME.AsString),
[rfReplaceAll, rfIgnoreCase]);
RLMemo1.Lines[0] := StringReplace(RLMemo1.Lines[0], 'DT1',
FormatDateTime('dd/mm/yyyy', dtp_inicio.Date),
[rfReplaceAll, rfIgnoreCase]);
RLMemo1.Lines[0] := StringReplace(RLMemo1.Lines[0], 'DT2',
FormatDateTime('dd/mm/yyyy', dtp_fim.Date),
[rfReplaceAll, rfIgnoreCase]);
zroqry1.Open;
zroqry2.Open;
zroqry3.Open;
frrelRelacaoAcordo.PreviewModal;
zroqryAcordos.Close;
zroqry1.Close;
zroqry2.Close;
zroqry3.Close;
end;
end;
if rg_tipo.ItemIndex = 0 then
begin
with ZReadOnlyQuery1.SQL do
begin
Clear;
Add('select');
Add('A.tx_nome,');
Add('B.tx_produto,');
Add('B.dt_vencimento,');
Add('B.dt_pagamento,');
Add('B.vl_titulo,');
Add('B.vl_juros,');
Add('B.vl_multa,');
Add('B.vl_encargos,');
Add('B.vl_corrigido,');
Add('B.vl_desc_principal');
Add('from chg_devedores A');
Add('inner join chg_titulos B on (A.id_devedor = B.id_devedor)');
Add('where B.id_titulo in (' + str_titulos + ')');
Add('and B.dt_emissao_recibo <> B.dt_pagamento');
Add('order by A.tx_nome');
end;
ZReadOnlyQuery1.Open;
if ZReadOnlyQuery1.RecordCount > 0 then
begin
MessageDlg
('Existem recebimentos nesse período que possuem data de cálculo diferente da data de emissão do recibo.'
+ ' É recomendando fazer uma prestação de contas utilizando a data da emissão do recibo também.',
mtWarning, [mbOK], 0);
end;
end;
end;
Screen.Cursor := crDefault;
// Close;
end;
procedure TconfrelPrestacaoContas.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
dtmSystem.tblEmpresaRepasse.Filtered := False;
qryFiltro.Close;
ZReadOnlyQuery1.Close;
Action := caFree;
confrelPrestacaoContas := nil;
end;
procedure TconfrelPrestacaoContas.FormCreate(Sender: TObject);
begin
dtp_inicio.Date := Date;
dtp_fim.Date := Date;
if not dtmSystem.tblCHGEmpresa.Active then
begin
dtmSystem.tblCHGEmpresa.Open;
end;
id_emp := dtmSystem.tblCHGEmpresaID_EMPRESA.AsInteger;
if not dtmSystem.tblEmpresaRepasse.Active then
begin
dtmSystem.tblEmpresaRepasse.Open;
end;
if not dtmSystem.tblEmpresa.Active then
begin
dtmSystem.tblEmpresa.Open;
end;
dblucb_beneficiario.KeyValue := 1;
pg_tipo.ActivePageIndex := 0;
end;
procedure TconfrelPrestacaoContas.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_ESCAPE then
begin
Key := 0;
Close;
end;
end;
procedure TconfrelPrestacaoContas.ImprimirLista1Click(Sender: TObject);
begin
relMulti := TrelMulti.Create(self);
with relMulti do
begin
dtsRel.DataSet := ZReadOnlyQuery2;
rldbtxt1.DataField := 'tx_nome';
rldbtxt2.DataField := 'tx_produto';
rldbtxt3.DataField := 'vl_titulo';
rldbtxt4.DataField := 'dt_vencimento';
RLReport1.PreviewModal;
end;
end;
procedure TconfrelPrestacaoContas.IncluirTodos1Click(Sender: TObject);
var
i: integer;
begin
if lv_prestacao.Items.Count > 0 then
begin
for i := 0 to lv_prestacao.Items.Count - 1 do
begin
lv_prestacao.Items.Item[i].Checked := True;
end;
end;
end;
procedure TconfrelPrestacaoContas.WMMoving(var Msg: TWMMoving);
var
workArea: TRect;
begin
workArea := Screen.WorkareaRect;
with Msg.DragRect^ do
begin
if left < workArea.left then
OffsetRect(Msg.DragRect^, workArea.left - left, 0);
if top < workArea.top then
OffsetRect(Msg.DragRect^, 0, workArea.top - top);
if Right > workArea.Right then
OffsetRect(Msg.DragRect^, workArea.Right - Right, 0);
if Bottom > workArea.Bottom then
OffsetRect(Msg.DragRect^, 0, workArea.Bottom - Bottom);
end;
end;
end.