-
Notifications
You must be signed in to change notification settings - Fork 3
/
uFormLogin.pas
148 lines (123 loc) · 3.99 KB
/
uFormLogin.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
unit uFormLogin;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, uniGUITypes, uniGUIAbstractClasses,
uniGUIClasses, uniGUIRegClasses, uniGUIForm, Vcl.Imaging.pngimage,
uniImage, uniLabel, uniEdit, uniSpeedButton, uniButton, uniBitBtn,
uniGUIBaseClasses, uniPanel, uniSweetAlert, uniImageList, UniFSiGrowl,
UniFSToast, UniFSButton;
type
TformLogin = class(TUniLoginForm)
Toast: TUniFSToast;
FSiGrowl: TUniFSiGrowl;
imgl20: TUniNativeImageList;
UniSweetAlert1: TUniSweetAlert;
UniNativeImageList1: TUniNativeImageList;
UniImage2: TUniImage;
UniLabel3: TUniLabel;
lbA: TUniLabel;
lbF: TUniLabel;
edUsuario: TUniEdit;
edSenhaLogin: TUniEdit;
PnlBottom: TUniPanel;
sbConectar: TUniFSButton;
sbSair: TUniFSButton;
procedure lbAClick(Sender: TObject);
procedure lbFClick(Sender: TObject);
procedure UniLoginFormScreenResize(Sender: TObject; AWidth,
AHeight: Integer);
procedure edSenhaLoginKeyPress(Sender: TObject; var Key: Char);
procedure UniLoginFormCreate(Sender: TObject);
procedure UniFSButton1Click(Sender: TObject);
procedure sbSairClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function formLogin: TformLogin;
implementation
{$R *.dfm}
uses
uniGUIVars, MainModule, uniGUIApplication, uDados, Main;
function formLogin: TformLogin;
begin
Result := TformLogin(UniMainModule.GetFormInstance(TformLogin));
end;
procedure TformLogin.edSenhaLoginKeyPress(Sender: TObject; var Key: Char);
begin
sbConectar.SetFocus;
end;
procedure TformLogin.lbAClick(Sender: TObject);
begin
lbF.Visible := True ;
lbA.Visible := False ;
edSenhaLogin.PasswordChar := #0;
end;
procedure TformLogin.lbFClick(Sender: TObject);
begin
lbF.Visible := False ;
lbA.Visible := True;
edSenhaLogin.PasswordChar := '*' ;
end;
procedure TformLogin.sbSairClick(Sender: TObject);
begin
Close;
end;
procedure TformLogin.UniFSButton1Click(Sender: TObject);
begin
dmDados.FDUsuario.Open;
if dmDados.FDUsuario.Locate('LOGIN', edUsuario.Text, []) then
begin
if dmDados.FDUsuarioSENHA.Value <> edSenhaLogin.Text then
begin
// ShowMessage('ATENÇÃO: USUARIO ou SENHA INVÁLIDA.');
UniSweetAlert1.InputType := ItNone;
UniSweetAlert1.AlertType := atWarning;
UniSweetAlert1.ShowCancelButton := False;
UniSweetAlert1.ShowConfirmButton := True;
UniSweetAlert1.Width := 300;
UniSweetAlert1.Title := 'ATENÇÃO';
UniSweetAlert1.Show('Usuario / Senha Incorreta');
exit;
end;
end
else
begin
// ShowMessage('ATENÇÃO: USUARIO ou SENHA INVÁLIDA.');
UniSweetAlert1.InputType := ItNone;
UniSweetAlert1.AlertType := atWarning;
UniSweetAlert1.ShowCancelButton := False;
UniSweetAlert1.ShowConfirmButton := True;
UniSweetAlert1.Width := 300;
UniSweetAlert1.Title := 'ATENÇÃO';
UniSweetAlert1.Show('Usuario / Senha Incorreta');
exit;
end;
ModalResult := mrOk;
MainModule.UniMainModule.xUsuario:= edUsuario.Text; // o edit usuario sempre sera o usuario global
MainModule.UniMainModule.xResponsavel := dmDados.FDUsuarioNOME.Value;
// o edit usuario sempre sera o usuario global ( chama o nome do tecnico/ responsavel)
MainForm.lbOla.Caption := 'Olá, ' + dmDados.FDUsuarioNOME.Value;
// registra o log de entrada
MainForm.RegistraLog('LOGIN', 'LOGOU NO SISTEMA');
MainModule.UniMainModule.vADMIN := False;
if dmDados.FDUsuarioPERFIL.Value = 'ADMINISTRADOR' then
MainModule.UniMainModule.vADMIN := True;
Toast.Success('Sucesso', 'Usuário autorizado ', topCenter);
end;
procedure TformLogin.UniLoginFormCreate(Sender: TObject);
begin
edUsuario.SetFocus;
end;
procedure TformLogin.UniLoginFormScreenResize(Sender: TObject; AWidth,
AHeight: Integer);
begin
// resposividade na tela
Self.Left := Round((AWidth / 2) - (Self.Width / 2));
Self.Top := Round((AHeight / 2) - (Self.Height / 2));
end;
initialization
RegisterAppFormClass(TformLogin);
end.