-
Notifications
You must be signed in to change notification settings - Fork 0
/
UUsuario.pas
110 lines (96 loc) · 2.51 KB
/
UUsuario.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
unit UUsuario;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, UPadrao, FMTBcd, DB, SqlExpr, DBClient, Provider, StdCtrls, Buttons,
PngBitBtn, pngimage, ExtCtrls, Mask, DBCtrls;
type
TfrmUsuarios = class(TfrmPadrao)
GroupBox2: TGroupBox;
Label5: TLabel;
DBEdit1: TDBEdit;
DBRadioGroup1: TDBRadioGroup;
Label6: TLabel;
DBEdit2: TDBEdit;
Label7: TLabel;
DBEdit3: TDBEdit;
cdsTabCOD_USU: TIntegerField;
cdsTabDAT_CAD: TDateField;
cdsTabNOME: TStringField;
cdsTabLOGIN: TStringField;
cdsTabSENHA: TStringField;
cdsTabPOSICAO: TStringField;
DBEdit4: TDBEdit;
Label9: TLabel;
procedure btNovoClick(Sender: TObject);
procedure btGravarClick(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure AbreDados;
procedure btEditarClick(Sender: TObject);
procedure DBEdit3Exit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmUsuarios: TfrmUsuarios;
implementation
uses UDados, UFuncoes;
{$R *.dfm}
procedure TfrmUsuarios.AbreDados;
begin
cdsTab.Close;
sqlTab.Close;
sqlTab.ParamByName('CODIGO').AsInteger := Cod_Padrao;
cdsTab.Open;
end;
procedure TfrmUsuarios.btEditarClick(Sender: TObject);
begin
Cod_Padrao := cdsTabCOD_USU.AsInteger;
inherited;
end;
procedure TfrmUsuarios.btGravarClick(Sender: TObject);
begin
if DBRadioGroup1.ItemIndex = -1 then begin
application.MessageBox('Informe a Posição do Usuário.', 'Atenção', MB_IconQuestion);
DBRadioGroup1.SetFocus;
Exit;
end;
if Vazio(DBEdit2.Text) then begin
application.MessageBox('Informe o Nome do Usuário.', 'Atenção', MB_IconQuestion);
DBEdit2.SetFocus;
Exit;
end;
if Vazio(DBEdit3.Text) then begin
application.MessageBox('Informe a Senha do Usuário.', 'Atenção', MB_IconQuestion);
DBEdit3.SetFocus;
Exit;
end;
inherited;
AbreDados;
end;
procedure TfrmUsuarios.btNovoClick(Sender: TObject);
begin
inherited;
cdsTabCOD_USU.AsInteger := PegaSequencia('GEN_USUARIO_ID');
cdsTabPOSICAO.AsString := 'S';
Cod_Padrao := cdsTabCOD_USU.AsInteger;
DBEdit2.SetFocus;
end;
procedure TfrmUsuarios.FormKeyPress(Sender: TObject; var Key: Char);
begin
inherited;
if Key = #13 then begin
Key := #0;
Perform(WM_NEXTDLGCTL, 0, 0)
end;
end;
procedure TfrmUsuarios.DBEdit3Exit(Sender: TObject);
begin
inherited;
if dsTab.State in [dsEdit, dsInsert] then begin
cdsTabSENHA.AsString := MD5(cdsTabSENHA.AsString);
end;
end;
end.