-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUVenApartamento.pas
217 lines (185 loc) · 5.34 KB
/
UVenApartamento.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
unit UVenApartamento;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons, Vcl.ComCtrls,
Vcl.DBCtrls, Data.DB, Vcl.Mask, Vcl.ExtCtrls;
type
TfrmVenApartamento = class(TForm)
lblCodCli: TLabel;
dsVendas: TDataSource;
lblCodImo: TLabel;
dbeCodImo: TDBEdit;
lblCodFunc: TLabel;
lblPreco: TLabel;
dbePreco: TDBEdit;
lblDtVenda: TLabel;
dbeDtVnd: TDBEdit;
lblCodigo: TLabel;
dbSit: TDBCheckBox;
dtpVenda: TDateTimePicker;
DBText1: TDBText;
pnlPrimeiro: TPanel;
pnlSegundo: TPanel;
pnlTerceiro: TPanel;
pnlQuarto: TPanel;
dsClientes: TDataSource;
dsFuncionarios: TDataSource;
cbbCliente: TDBLookupComboBox;
cbbFuncionario: TDBLookupComboBox;
Shape1: TShape;
Shape2: TShape;
spExcluir: TShape;
spEditar: TShape;
spInserir: TShape;
spCancelar: TShape;
spSalvar: TShape;
lblExcluir: TLabel;
lblEditar: TLabel;
lblInserir: TLabel;
lblCancelar: TLabel;
lblSalvar: TLabel;
btnExcluir: TImage;
btnEditar: TImage;
btnInserir: TImage;
btnCancelar: TImage;
btnSalvar: TImage;
Shape3: TShape;
lblBuscar: TLabel;
btnBusca: TImage;
Shape4: TShape;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure btnInserirClick(Sender: TObject);
procedure btnCancelarClick(Sender: TObject);
procedure btnExcluirClick(Sender: TObject);
procedure dsVendasStateChange(Sender: TObject);
procedure dtpVendaChange(Sender: TObject);
procedure dsVendasDataChange(Sender: TObject; Field: TField);
procedure btnSalvarClick(Sender: TObject);
procedure btnEditarClick(Sender: TObject);
procedure btnBuscaClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmVenApartamento: TfrmVenApartamento;
implementation
{$R *.dfm}
uses UDM, UConImovel;
procedure TfrmVenApartamento.btnBuscaClick(Sender: TObject);
begin
frmConImovel:=TfrmConImovel.Create(self);
frmConImovel.btnSelecionar.Tag:= 1 ; // tag 1 é consulta VenApart
try
frmConImovel.ShowModal;
finally
frmConImovel.Release;
frmConImovel:= nil;
end;
end;
procedure TfrmVenApartamento.btnCancelarClick(Sender: TObject);
begin
dsVendas.DataSet.Cancel;
end;
procedure TfrmVenApartamento.btnEditarClick(Sender: TObject);
begin
dsVendas.DataSet.Edit;
end;
procedure TfrmVenApartamento.btnExcluirClick(Sender: TObject);
begin
if MessageBox(Application.Handle, 'Dejesa realmente excluir este registro', 'Excluir', 36)
= idYes then
begin
dsVendas.DataSet.Delete;
end;
end;
procedure TfrmVenApartamento.btnInserirClick(Sender: TObject);
begin
dsVendas.DataSet.Append;
dbeDtVnd.Text := DateToStr(Date);
dtpVenda.Date := Date;
dm.qryVendasvenSituacaoDePagamento.Value:=true;
end;
procedure TfrmVenApartamento.btnSalvarClick(Sender: TObject);
var
confValida : Boolean;
begin
confValida := True;
if dbeDtVnd.Text = DateToStr(date) then
begin
if MessageBox(Application.Handle,
'A data da venda é hoje?', 'Confirmação', 36) = idNo then
begin
confValida := False;
dtpVenda.SetFocus;
end
else
begin
confValida := True;
end;
end;
if dbePreco.Text = '' then
begin
Application.MessageBox('Informe o preço da venda!', 'ERRO', 16);
confValida := False;
dbePreco.SetFocus;
end;
if confValida = True then
begin
dsVendas.DataSet.Post;
Application.MessageBox('Registro gravado com sucesso', 'Confirmação', 64);
end;
end;
procedure TfrmVenApartamento.dsVendasDataChange(Sender: TObject; Field: TField);
begin
if dsVendas.State <> dsInsert then
begin
dbeDtVnd.Text := DateToStr(dtpVenda.Date);
end;
end;
procedure TfrmVenApartamento.dsVendasStateChange(Sender: TObject);
begin
btnInserir.Enabled := dsVendas.State = dsBrowse;
btnEditar.Enabled := dsVendas.State = dsBrowse;
btnExcluir.Enabled := dsVendas.State = dsBrowse;
btnSalvar.Enabled := dsVendas.State in [dsInsert, dsEdit];
btnCancelar.Enabled := dsVendas.State in [dsInsert, dsEdit];
dtpVenda.Enabled := dsVendas.State in [dsInsert, dsEdit];
if dsVendas.State in [dsInsert, dsEdit] then // modo inserção deixa o shape em cinza
begin
spInserir.Brush.Color:=clgray;
spEditar.Brush.Color:=clgray;
spExcluir.Brush.Color:=clgray;
spCancelar.Brush.Color:=$00D37A48;
spSalvar.Brush.Color:=$00D37A48;
end
else
begin
spInserir.Brush.Color:=$00D37A48;
spEditar.Brush.Color:=$00D37A48;
spExcluir.Brush.Color:=$00D37A48;
spCancelar.Brush.Color:=clgray;
spSalvar.Brush.Color:=clgray;
end;
end;
procedure TfrmVenApartamento.dtpVendaChange(Sender: TObject);
begin
dbeDtVnd.Text := DateToStr(dtpVenda.Date);
end;
procedure TfrmVenApartamento.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
DM.qryVendas.Close;
dm.qryFuncionarios.Close;
dm.qryClientes.Close;
end;
procedure TfrmVenApartamento.FormShow(Sender: TObject);
begin
DM.qryVendas.Open;
dm.qryFuncionarios.Open;
dm.qryClientes.Open;
end;
end.