-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUAddCliente.pas
More file actions
141 lines (114 loc) · 2.93 KB
/
UAddCliente.pas
File metadata and controls
141 lines (114 loc) · 2.93 KB
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
unit UAddCliente;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, ThemeDBGrid, Buttons, Mask, ToolEdit,
RXDBCtrl;
type
TFAddCliente = class(TForm)
Label2: TLabel;
Label3: TLabel;
Label5: TLabel;
ThemeDBGrid1: TThemeDBGrid;
Edit2: TEdit;
BitBtn2: TBitBtn;
BitBtn1: TBitBtn;
DateEdit1: TDateEdit;
DateEdit2: TDateEdit;
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure ThemeDBGrid1KeyPress(Sender: TObject; var Key: Char);
procedure FormShow(Sender: TObject);
procedure DateEdit1KeyPress(Sender: TObject; var Key: Char);
procedure FormCreate(Sender: TObject);
procedure FormHide(Sender: TObject);
private
{ Private declarations }
public
Editing : Boolean;
{ Public declarations }
end;
var
FAddCliente: TFAddCliente;
implementation
uses UDados, UFvendas, Ufinaliza;
{$R *.dfm}
procedure TFAddCliente.Edit2KeyPress(Sender: TObject; var Key: Char);
var
i : integer;
begin
if (key = #13 ) then
begin
Banco.TB_Funcionarios.Close;
Banco.TB_Funcionarios.SQL.Clear;
Banco.TB_Funcionarios.SQL.Add('Select * from Funcionarios');
Banco.TB_Funcionarios.SQL.Add('where ativo = true');
if Banco.IsInt(Edit2.Text) then
Try
Banco.TB_Funcionarios.Open;
StrToInt(Edit2.Text);
if Banco.TB_Funcionarios.Locate(Banco.TB_FuncionariosCdigo.FieldName,i,[]) then
begin
Edit2.Text := Banco.TB_FuncionariosNome.Value;
DateEdit1.SetFocus;
exit;
end;
Except
end;
ThemeDBGrid1.Visible := true;
ThemeDBGrid1.SetFocus;
if Edit2.Text <> '' then
Banco.TB_Funcionarios.SQL.Add('and nome like '+chr(39)+Edit2.Text+'%'+chr(39));
Banco.TB_Funcionarios.Open
end;
end;
procedure TFAddCliente.ThemeDBGrid1KeyPress(Sender: TObject;
var Key: Char);
begin
if key = #13 then
begin
ThemeDBGrid1.Visible := false;
if Banco.TB_Funcionarios.RecordCount > 0 then
begin
Edit2.Text := Banco.TB_FuncionariosNome.Value;
DateEdit1.SetFocus;
end
else
Edit2.SetFocus;
end
else
if Banco.TB_Funcionarios.RecordCount = 0 then
Edit2.SetFocus;
end;
procedure TFAddCliente.FormShow(Sender: TObject);
begin
if Editing then
begin
BitBtn1.Caption := 'Editar';
DateEdit1.SetFocus;
end
else
Edit2.SetFocus;
end;
procedure TFAddCliente.DateEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
begin
Self.Perform(WM_NEXTDLGCTL,0,0);
Abort;
end;
end;
procedure TFAddCliente.FormCreate(Sender: TObject);
begin
Editing := false;
end;
procedure TFAddCliente.FormHide(Sender: TObject);
begin
if banco.TB_Funcionarios.SQL.Count > 1 then
begin
Banco.TB_Funcionarios.Close;
Banco.TB_Funcionarios.SQL.Clear;
Banco.TB_Funcionarios.SQL.Add('Select * from Funcionarios');
Banco.TB_Funcionarios.Open;
end;
end;
end.