-
Notifications
You must be signed in to change notification settings - Fork 0
/
f03_LogonForm.~pas
162 lines (146 loc) · 4.04 KB
/
f03_LogonForm.~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
153
154
155
156
157
158
159
160
161
162
unit f03_LogonForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Db, DBTables, ExtCtrls, jpeg, Buttons;
type
Tf03_fLogonForm = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Edit2: TEdit;
PX: TPanel;
Label3: TLabel;
Label4: TLabel;
Image1: TImage;
OkButon: TBitBtn;
BitBtn2: TBitBtn;
Image2: TImage;
procedure Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure OKButonClick(Sender: TObject);
procedure ExitButonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
userDB : TTable;
tryCount : Byte;
{ Private declarations }
public
{ Public declarations }
Kullanan,Sifresi : string;
procedure GetUserPass(var Kullanan :string; var Sifresi: string);
end;
var
f03_fLogonForm: Tf03_fLogonForm;
implementation
{$R *.DFM}
uses MainDef,Registry;
procedure Tf03_fLogonForm.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = vk_return then Edit2.SetFocus;
end;
procedure Tf03_fLogonForm.Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = vk_return then OKButon.SetFocus;
end;
procedure Tf03_fLogonForm.GetUserPass(var Kullanan :string; var Sifresi: string);
var
Reg : TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if not Reg.KeyExists('\Software\ARI\User') then
begin
if Reg.CreateKey('\Software\ARI\User') then
begin
Reg.OpenKey('\Software\ARI\User',False);
Reg.WriteString('Kullanan','ARI');
Reg.WriteString('Sifre','ARI');
Kullanan := 'ARI';
Sifresi := 'ARI';
end else
begin
Showmessage('Kullanici tanimlanamadi manuel degisiklik yapiniz...');
end;
end else
begin
Reg.OpenKey('\Software\ARI\user',False);
Kullanan := Reg.ReadString('Kullanan');
Sifresi := Reg.ReadString('Sifre');
end;
finally
Reg.Free;
end;
end;
procedure Tf03_fLogonForm.OKButonClick(Sender: TObject);
var
Reg : TRegistry;
begin
GetUserPass(Kullanan,Sifresi);
if (Edit1.Text = Kullanan) and (Edit2.Text = Sifresi) then
begin
ModalResult := mrOK;
end else
begin
Inc(TryCount);
ModalResult := 0;
if TryCount >= 5 then
begin
ShowMessage('Bes kez yanlis Kullanici/sifre girdiniz... Program kapatilacaktir. ');
ModalResult := mrCancel;
end;
end;
if (Edit1.Text = 'SISTEM') and (Edit2.Text = 'SISTEM') then
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if not Reg.KeyExists('\Software\ARI\User') then
begin
if Reg.CreateKey('\Software\ARI\User') then
begin
Reg.OpenKey('\Software\ARI\User',False);
Reg.WriteString('Kullanan','ARI');
Reg.WriteString('Sifre','ARI');
ShowMessage('Programdan cikarak'+crlf
+' Kullanici = ARI ve sifresi = ARI'+CRLF
+'olarak tekrar calistiriniz..');
end else
begin
Showmessage('Kullanici tanimlanamadi manuel degisiklik yapiniz... Hata: 5004x');
end;
end else
begin
Reg.DeleteKey('\Software\ARI\user');
Showmessage('Kullanýcý Tanýmlarý silindi...');
end;
finally
Reg.Free;
end;
ModalResult := mrOK;
end;
end;
procedure Tf03_fLogonForm.ExitButonClick(Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure Tf03_fLogonForm.FormCreate(Sender: TObject);
begin
TryCount := 0;
Edit1.Text := '';
Edit2.Text := '';
GetUserPass(Kullanan,Sifresi);
end;
procedure Tf03_fLogonForm.FormShow(Sender: TObject);
var V : variant;
begin
tryCount := 0;
Edit2.Text := '';
end;
end.