-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLozinka.pas
101 lines (88 loc) · 2.35 KB
/
Lozinka.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
unit Lozinka;
interface
uses WinTypes, WinProcs, Classes, Graphics, Forms, Dialogs, Controls, StdCtrls,
Buttons, Mask, ExtCtrls, jpeg, Db, DBTables;
type
TPasswordDlg = class(TForm)
Label1: TLabel;
EdLozinka: TEdit;
OKBtn: TBitBtn;
CancelBtn: TBitBtn;
Label3: TLabel;
Image1: TImage;
Korisnici: TTable;
Label2: TLabel;
EdName: TEdit;
KorisniciSifra: TAutoIncField;
KorisniciLoginName: TStringField;
KorisniciLozinka: TStringField;
procedure FormCreate(Sender: TObject);
procedure Kpress(Sender: TObject; var Key: Char);
procedure OKBtnClick(Sender: TObject);
procedure CancelBtnClick(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
private
BrojPokusaja:integer;
public
{ Public declarations }
end;
var
PasswordDlg: TPasswordDlg;
implementation
uses BazeModul, SysUtils;
{$R *.DFM}
procedure TPasswordDlg.FormCreate(Sender: TObject);
begin
BrojPokusaja:=1;
end;
procedure TPasswordDlg.Kpress(Sender: TObject; var Key: Char);
begin
if key =#13 then
begin
selectnext(sender as twincontrol,true,true);key:=#0;
end;
end;
procedure TPasswordDlg.OKBtnClick(Sender: TObject);
begin
SifraKorisnika:=0;
Korisnici.Active:=True;
if Korisnici.Locate('LoginName',EdName.Text,[]) then
begin
if KorisniciLozinka.Value=EdLozinka.Text then
begin
ModalResult:=MrOk;
SifraKorisnika:=KorisniciSifra.AsInteger;
end
else
begin
ShowMessage('Krivo korisnièko ime ili lozinka.');
BrojPokusaja:=BrojPokusaja+1;
if BrojPokusaja>3 then CancelBtnClick(Sender)
else
begin
EdLozinka.Text:='';
EdName.SetFocus;
end;
end
end
else
begin
ShowMessage('Krivo korisnièko ime ili lozinka.');
BrojPokusaja:=BrojPokusaja+1;
if BrojPokusaja>3 then CancelBtnClick(Sender)
else
begin
EdLozinka.Text:='';
EdName.SetFocus;
end;
end;
end;
procedure TPasswordDlg.CancelBtnClick(Sender: TObject);
begin
ModalResult:=MrCancel;
end;
procedure TPasswordDlg.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key =#27 then CancelBtnClick(Sender);
end;
end.