-
Notifications
You must be signed in to change notification settings - Fork 2
/
LoginUnit.pas
executable file
·152 lines (128 loc) · 3.8 KB
/
LoginUnit.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
unit LoginUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Controls, Forms,
Dialogs, DBCtrls, StdCtrls, Buttons,DB,Math, TntStdCtrls, GlobalProcedures, TntForms,
TntButtons;
type
TLoginForm = class(TTntForm)
Label1: TTntLabel;
Label2: TTntLabel;
BitBtn1: TTntBitBtn;
Edit2: TEdit;
Edit1: TEdit;
BitBtn2: TTntBitBtn;
Label3: TTntLabel;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure TntFormShow(Sender: TObject);
procedure TntFormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
login_valid:boolean;
{ Public declarations }
end;
var
LoginForm: TLoginForm;
implementation
uses
DataUnit, MainUnit, SplashScrUnit;
{$R *.dfm}
//______________________________________________________________________________
procedure TLoginForm.BitBtn1Click(Sender: TObject);
var UserNick: Widestring;
begin
username := '';
UserNick := Edit2.Text;
if (Edit2.Text <> '') and (Edit1.Text <> '') then
begin
with Data.Users do
begin
if ControlAdminUser(Edit2.Text,Edit1.Text) then
begin
usercode := 0;
username := Edit2.Text;
CurrentUserName := 'admin';
login_valid:=true;
LoginForm.Close;
end
else
if Locate('username',UserNick,[loCaseInsensitive]) then
if VerifyPass(FieldByName('userpassword').AsString, Edit1.Text) then
begin
usercode := FieldByName('usercode').AsInteger;
current_user_access := FieldByName('useraccess').AsInteger;
username := Edit2.Text;
if not Data.users.FieldByName('userfirstname').IsNull Then
CurrentUserName := Data.users.FieldByName('userfirstname').Value;
if not Data.users.FieldByName('userlastname').IsNull Then
CurrentUserName := CurrentUserName + ' ' + Data.users.FieldByName('userlastname').AsVariant;
login_valid:=true;
LoginForm.Close;
end
else
begin
MessOK('The user name or password does not match!');
end
else
MessOK('The user name or password doesn''t match!');
edit1.SelectAll;
edit1.SetFocus;
end;
end;
end;
//______________________________________________________________________________
procedure TLoginForm.BitBtn2Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TLoginForm.TntFormShow(Sender: TObject);
begin
LoginForm.Top:=SplashScrForm.Top + SplashScrForm.Height;
LoginForm.Left:=(Screen.Width - LoginForm.Width) div 2;
LoginForm.Caption := 'Login - '+data.MyConnection1.Database;
edit1.Text:='';
edit2.Text:='';
edit2.SetFocus;
login_valid:=false;
end;
{
procedure TLoginForm.TntFormCreate(Sender: TObject);
begin
databases :='';
end;
procedure TLoginForm.TntFormActivate(Sender: TObject);
var db: string;
p:integer;
begin
databases := trim(databases)+',';
// showmessage(databases);
if databases <> ',' then
begin
tntcombobox1.Items.clear;
p:=pos(',',databases);
while p > 0 do
begin
db := copy(databases,1,p-1);
if db <> '' then
tntcombobox1.Items.Add(db);
databases := copy(databases,p+1,length(databases));
p:=pos(',',databases);
end;
tntlabel1.Visible:=true;
tntcombobox1.Visible:=true;
end;
end;
procedure TLoginForm.TntComboBox1Select(Sender: TObject);
begin
// LoginForm.Caption := 'Login - '+data.MyConnection1.Database;
LoginForm.Caption := tntcombobox1.Text;
end;
}
procedure TLoginForm.TntFormClose(Sender: TObject;
var Action: TCloseAction);
begin
if login_valid = false then Application.Terminate;
end;
end.