-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUTransacao.pas
296 lines (278 loc) · 9.2 KB
/
UTransacao.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
unit UTransacao;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, UPadrao, FMTBcd, DB, SqlExpr, DBClient, Provider, StdCtrls, Buttons,
PngBitBtn, pngimage, ExtCtrls, rxToolEdit, RXDBCtrl, Mask, DBCtrls, ComCtrls,
Menus;
type
TfrmTransacao = class(TfrmPadrao)
cdsTabCOD_TRANS: TIntegerField;
cdsTabDAT_CAD: TDateField;
cdsTabTP_TRANS: TStringField;
cdsTabCOD_COMP: TIntegerField;
cdsTabCOD_VEND: TIntegerField;
cdsTabVLR_TRANS: TSingleField;
cdsTabDESCRICAO: TStringField;
cdsTabMARCA: TStringField;
cdsTabANO: TStringField;
cdsTabKM: TStringField;
cdsTabMODELO: TStringField;
cdsTabCOR: TStringField;
cdsTabPLACA: TStringField;
cdsTabCHASSI: TStringField;
cdsTabRENAVAN: TStringField;
cdsTabCOMBUSTIVEL: TStringField;
cdsTabF_PAG: TStringField;
cdsTabBASE_CALCULO: TSingleField;
cdsTabPERCENTUAL: TSingleField;
cdsTabPRAZO: TIntegerField;
cdsTabPARCELAS: TIntegerField;
cdsTabENTRADA: TSingleField;
cdsTabENTRADA_VEIC: TSingleField;
cdsTabOBS: TBlobField;
cdsTabPOSICAO: TStringField;
cdsTabHORA_REC: TTimeField;
btImprimir: TPngBitBtn;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
GroupBox2: TGroupBox;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Label20: TLabel;
Label21: TLabel;
Label22: TLabel;
Label23: TLabel;
Label24: TLabel;
Label25: TLabel;
DBEdit1: TDBEdit;
DBDateEdit1: TDBDateEdit;
DBRadioGroup1: TDBRadioGroup;
DBEdit2: TDBEdit;
DBLookupComboBox1: TDBLookupComboBox;
DBLookupComboBox2: TDBLookupComboBox;
DBEdit4: TDBEdit;
DBEdit5: TDBEdit;
DBEdit6: TDBEdit;
DBEdit7: TDBEdit;
DBEdit8: TDBEdit;
DBEdit9: TDBEdit;
DBEdit10: TDBEdit;
DBEdit11: TDBEdit;
DBEdit12: TDBEdit;
DBEdit13: TDBEdit;
DBEdit14: TDBEdit;
DBEdit15: TDBEdit;
DBEdit16: TDBEdit;
DBEdit17: TDBEdit;
DBMemo1: TDBMemo;
cdsTabDESC_VEICCOMP: TStringField;
cdsTabMARCA_COMP: TStringField;
cdsTabANO_COMP: TStringField;
cdsTabKM_COMP: TStringField;
cdsTabMODELO_COMP: TStringField;
cdsTabCOR_COMP: TStringField;
cdsTabPLACA_COMP: TStringField;
cdsTabCHASSI_COMP: TStringField;
cdsTabRENAVAN_COMP: TStringField;
cdsTabCOMBUSTIVEL_COMP: TStringField;
GroupBox3: TGroupBox;
Label26: TLabel;
DBEdit19: TDBEdit;
Label27: TLabel;
Label28: TLabel;
DBEdit20: TDBEdit;
Label29: TLabel;
DBEdit21: TDBEdit;
DBEdit22: TDBEdit;
Label30: TLabel;
Label31: TLabel;
DBEdit23: TDBEdit;
DBEdit24: TDBEdit;
Label32: TLabel;
DBEdit25: TDBEdit;
Label33: TLabel;
DBEdit26: TDBEdit;
Label34: TLabel;
Menu: TPopupMenu;
Contrato1: TMenuItem;
ermodeGarantia1: TMenuItem;
FaturarVenda1: TMenuItem;
FaturaTransacao: TSQLStoredProc;
DBLookupComboBox3: TDBLookupComboBox;
cdsTabCOD_VEICULO: TIntegerField;
cdsTabCOD_VEICULOTROCA: TIntegerField;
DBLookupComboBox4: TDBLookupComboBox;
procedure btNovoClick(Sender: TObject);
procedure btEditarClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btImprimirClick(Sender: TObject);
procedure Contrato1Click(Sender: TObject);
procedure ermodeGarantia1Click(Sender: TObject);
procedure FaturarVenda1Click(Sender: TObject);
procedure DBLookupComboBox3Exit(Sender: TObject);
procedure DBLookupComboBox4Exit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmTransacao: TfrmTransacao;
implementation
uses UDados, UFuncoes, URContrato, UTermoGarantia;
{$R *.dfm}
procedure TfrmTransacao.btEditarClick(Sender: TObject);
begin
inherited;
DBEdit2.SetFocus;
end;
procedure TfrmTransacao.btImprimirClick(Sender: TObject);
begin
Menu.PopUp(Mouse.CursorPos.X, Mouse.CursorPos.Y);
inherited;
{if application.MessageBox('Deseja Imprimir Transação Agora?', 'Confirmação', mb_yesNo + mb_IconQuestion) = idYes then begin
Application.CreateForm(TfrmContrato, frmContrato);
frmContrato.cdsTab.Close;
frmContrato.sqlTab.Close;
frmContrato.sqlTab.ParamByName('COD_TRANS').AsInteger := cdsTabCOD_TRANS.AsInteger;
frmContrato.cdsTab.Open;
if not frmContrato.cdsTab.Eof then begin
if cdsTabTP_TRANS.AsString <> 'T' then begin
frmContrato.RLReport1.PreviewModal;
end else begin
frmContrato.RLReport2.PreviewModal;
end;
frmContrato.cdsTab.Close;
frmContrato.FreeOnRelease;
end else begin
Application.MessageBox('Não Há Dados a Serem Impressos', 'Atenção', MB_ICONEXCLAMATION);
frmContrato.cdsTab.Close;
frmContrato.FreeOnRelease;
end;
end;}
end;
procedure TfrmTransacao.btNovoClick(Sender: TObject);
begin
inherited;
cdsTabCOD_TRANS.AsInteger := PegaSequencia('GEN_TRANSACAO_ID');
cdsTabDAT_CAD.AsDateTime := Date;
DBEdit2.SetFocus;
end;
procedure TfrmTransacao.Contrato1Click(Sender: TObject);
begin
inherited;
if application.MessageBox('Deseja Imprimir Contrato de Compra e Venda?', 'Confirmação', mb_yesNo + mb_IconQuestion) = idYes then begin
Application.CreateForm(TfrmContrato, frmContrato);
frmContrato.cdsTab.Close;
frmContrato.sqlTab.Close;
frmContrato.sqlTab.ParamByName('COD_TRANS').AsInteger := cdsTabCOD_TRANS.AsInteger;
frmContrato.cdsTab.Open;
if not frmContrato.cdsTab.Eof then begin
if cdsTabTP_TRANS.AsString <> 'T' then begin
frmContrato.RLReport1.PreviewModal;
end else begin
frmContrato.RLReport2.PreviewModal;
end;
frmContrato.cdsTab.Close;
frmContrato.FreeOnRelease;
end else begin
Application.MessageBox('Não Há Dados a Serem Impressos', 'Atenção', MB_ICONEXCLAMATION);
frmContrato.cdsTab.Close;
frmContrato.FreeOnRelease;
end;
end;
end;
procedure TfrmTransacao.DBLookupComboBox3Exit(Sender: TObject);
begin
inherited;
if dsTab.State in [dsInsert, dsEdit] then begin
dados.sqlBusca.Close;
dados.sqlBusca.SQL.Clear;
dados.sqlBusca.SQL.Add('SELECT * FROM VEICULOS WHERE COD_VEICULO = '+QuotedStr(cdsTabCOD_VEICULO.AsString));
dados.sqlBusca.Open;
cdsTabPLACA.AsString := Dados.sqlBusca.FieldByName('PLACA').AsString;
cdsTabCHASSI.AsString := dados.sqlBusca.FieldByName('CHASSI').AsString;
cdsTabRENAVAN.AsString := Dados.sqlBusca.FieldByName('RENAVAN').AsString;
cdsTabMARCA.AsString := Dados.sqlBusca.FieldByName('MARCA').AsString;
cdsTabMODELO.AsString := dados.sqlBusca.FieldByName('MODELO').AsString;
cdsTabCOR.AsString := Dados.sqlBusca.FieldByName('COR').AsString;
cdsTabANO.AsString := Dados.sqlBusca.FieldByName('ANO').AsString;
Dados.sqlBusca.Close;
end;
end;
procedure TfrmTransacao.DBLookupComboBox4Exit(Sender: TObject);
begin
inherited;
if dsTab.State in [dsInsert, dsEdit] then begin
dados.sqlBusca.Close;
dados.sqlBusca.SQL.Clear;
dados.sqlBusca.SQL.Add('SELECT * FROM VEICULOS WHERE COD_VEICULO = '+QuotedStr(cdsTabCOD_VEICULOTROCA.AsString));
dados.sqlBusca.Open;
cdsTabPLACA_COMP.AsString := Dados.sqlBusca.FieldByName('PLACA').AsString;
cdsTabCHASSI_COMP.AsString := dados.sqlBusca.FieldByName('CHASSI').AsString;
cdsTabRENAVAN_COMP.AsString := Dados.sqlBusca.FieldByName('RENAVAN').AsString;
cdsTabMARCA_COMP.AsString := Dados.sqlBusca.FieldByName('MARCA').AsString;
cdsTabMODELO_COMP.AsString := dados.sqlBusca.FieldByName('MODELO').AsString;
cdsTabCOR_COMP.AsString := Dados.sqlBusca.FieldByName('COR').AsString;
cdsTabANO_COMP.AsString := Dados.sqlBusca.FieldByName('ANO').AsString;
Dados.sqlBusca.Close;
end;
end;
procedure TfrmTransacao.ermodeGarantia1Click(Sender: TObject);
begin
inherited;
if application.MessageBox('Deseja Imprimir Termo de Garantia?', 'Confirmação', mb_yesNo + mb_IconQuestion) = idYes then begin
Application.CreateForm(TfrmTermoGarantia, frmTermoGarantia);
frmTermoGarantia.RLReport1.PreviewModal;
frmTermoGarantia.FreeOnRelease;
end else begin
Application.MessageBox('Não Há Dados a Serem Impressos', 'Atenção', MB_ICONEXCLAMATION);
end;
end;
procedure TfrmTransacao.FaturarVenda1Click(Sender: TObject);
begin
inherited;
if cdsTabPOSICAO.AsString = 'F' then begin
Application.MessageBox('Transação Já Finalizada', 'Atenção', MB_ICONEXCLAMATION);
Exit;
end;
if Application.MessageBox('Deseja Realmente Faturar a Transação Selecionada?', 'Confirmação', mb_YesNo + MB_ICONQUESTION) = idYes then begin
FaturaTransacao.Close;
FaturaTransacao.ParamByName('COD_TRANS').AsInteger := cdsTabCOD_TRANS.AsInteger;
FaturaTransacao.ParamByName('DAT_BASE').AsDate := cdsTabDAT_CAD.AsDateTime;
FaturaTransacao.ExecProc;
cdsTab.Refresh;
Application.MessageBox('Transação Faturada Com Sucesso!!!', 'Sucesso', MB_ICONQUESTION);
end;
end;
procedure TfrmTransacao.FormClose(Sender: TObject; var Action: TCloseAction);
begin
dados.cdsComprador.Close;
dados.cdsVendedor.Close;
dados.cdsVeiculo.Close;
inherited;
end;
procedure TfrmTransacao.FormShow(Sender: TObject);
begin
inherited;
dados.cdsComprador.Open;
dados.cdsVendedor.Open;
DADOS.cdsVeiculo.Open;
end;
end.