-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUGeracao.pas
128 lines (117 loc) · 3.74 KB
/
UGeracao.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
unit UGeracao;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, PngBitBtn, ComCtrls, ExtCtrls, DBCtrls, Mask,
rxToolEdit, rxCurrEdit, DateUtils, FMTBcd, DB, SqlExpr, DBClient, Provider;
type
TfrmGeracao = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
btCopia: TPngBitBtn;
Panel3: TPanel;
Label1: TLabel;
GroupBox1: TGroupBox;
DBLookupComboBox2: TDBLookupComboBox;
Label9: TLabel;
txtValor: TCurrencyEdit;
Label2: TLabel;
txtNumParc: TEdit;
Label3: TLabel;
txtPrazo: TEdit;
Label4: TLabel;
dsTab: TDataSource;
dspTab: TDataSetProvider;
cdsTab: TClientDataSet;
sqlTab: TSQLQuery;
txtDat_Venda: TDateEdit;
Label12: TLabel;
cdsTabCOD_REC: TIntegerField;
cdsTabDAT_LANC: TDateField;
cdsTabCOD_TRANSACAO: TIntegerField;
cdsTabCOD_CLIE: TIntegerField;
cdsTabHISTORICO: TStringField;
cdsTabPARCELA: TStringField;
cdsTabVENCIMENTO: TDateField;
cdsTabVLR_PRINC: TSingleField;
cdsTabVLR_DESC: TSingleField;
cdsTabVLR_ACRES: TSingleField;
cdsTabVLR_CREDITO: TSingleField;
cdsTabSALDO_DEV: TSingleField;
cdsTabPOSICAO: TStringField;
procedure btCopiaClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmGeracao: TfrmGeracao;
implementation
uses UDados, UFuncoes;
{$R *.dfm}
procedure TfrmGeracao.btCopiaClick(Sender: TObject);
var
i, pr: integer;
begin
if Vazio(DBLookupComboBox2.Text) then begin
Application.MessageBox('Informe o Cliente do Documento.', 'Atenção', MB_ICONQUESTION);
DBLookupComboBox2.SetFocus;
Exit;
end;
if Vazio(txtNumParc.Text) then begin
Application.MessageBox('Informe o Número do Parcelas.', 'Atenção', MB_ICONQUESTION);
txtNumParc.SetFocus;
Exit;
end;
if Vazio(txtPrazo.Text) then begin
Application.MessageBox('Informe o Prazo Padrão', 'Atenção', MB_ICONQUESTION);
txtPrazo.SetFocus;
Exit;
end;
if not DataValida(txtDat_Venda.Text) then begin
Application.MessageBox('Informe a Data da Venda', 'Atenção', MB_ICONQUESTION);
txtDat_Venda.SetFocus;
Exit;
end;
if application.MessageBox('Deseja Parcelas A Receber Agora?', 'Confirmação', mB_YesNO + MB_IconQuestion) = idYes then begin
i := 0; pr:=0;
cdsTab.Open;
for I := 0 to StrToInt(txtNumParc.Text) - 1 do begin
pr := pr + StrToInt(txtPrazo.Text);
cdsTab.Append;
cdsTabCOD_REC.AsInteger := PegaSequencia('GEN_CREC_ID');
cdsTabDAT_LANC.AsString := txtDat_Venda.Text;
cdsTabCOD_CLIE.AsInteger := Dados.cdsCompradorCOD_COMP.AsInteger;
cdsTabPARCELA.AsString := IntToStr(i + 1) + ' / ' + txtNumParc.Text;
cdsTabHISTORICO.AsString := 'COMPRAS DO DIA ' + txtDat_Venda.Text;
cdsTabVLR_PRINC.AsFloat := txtValor.Value;
cdsTabVENCIMENTO.AsDateTime := IncDay(txtDat_Venda.Date, pr);
cdsTabVLR_ACRES.AsFloat := 0;
cdsTabVLR_DESC.AsFloat := 0;
cdsTabSALDO_DEV.AsFloat := txtValor.Value;
cdsTabPOSICAO.AsString := 'A';
cdsTab.Post;
cdsTab.ApplyUpdates(-1);
end;
cdsTab.Close;
application.MessageBox('Processo Finalizado Com Sucesso...', 'Sucesso', MB_ICONQUESTION);
txtValor.Value := 0;
txtNumParc.Text := '';
txtDat_Venda.Clear;
end;
end;
procedure TfrmGeracao.FormClose(Sender: TObject; var Action: TCloseAction);
begin
dados.cdsComprador.Close;
release;
end;
procedure TfrmGeracao.FormShow(Sender: TObject);
begin
dados.cdsComprador.Open;
end;
end.