-
Notifications
You must be signed in to change notification settings - Fork 0
/
ULogowanie.pas
128 lines (106 loc) · 2.75 KB
/
ULogowanie.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
unit ULogowanie;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms,
Controls, Graphics, Dialogs, Buttons, StdCtrls, ExtCtrls, Windows;
type
{ TLogowanie }
TLogowanie = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Edit1: TEdit;
Edit2: TEdit;
Image1: TImage;
Image2: TImage;
Image3: TImage;
Image4: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Panel1: TPanel;
Timer1: TTimer;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
Function fGetUserName: string;
Procedure Logowanie;
end;
var
Logowanie: TLogowanie;
implementation
uses datamodule;
{$R *.frm}
procedure TLogowanie.FormCreate(Sender: TObject);
begin
DM.ZConnection1.Disconnect;
Label3.Caption:= 'Wersja: '+ wersja;
if DM.autologin then
begin
if ParamCount = 2 then // dwa parametry login i hasło
begin // logowanie automatyczne
Edit1.Text:= ParamStr(1);
Edit2.Text:= ParamStr(2);
Timer1.Enabled:= true; // uruchamiam logowanie z opuznieniem
end
else
begin // normalne logowanie
if ParamCount = 1 then Edit1.Text:= ParamStr(1) // w jednym parametrze można przemycić login
else Edit1.Text:= fGetUserName; // login
Edit2.Text:=''; // hasło
end;
end
else
begin // autologin is false dla Reconnect
Edit1.Text:= DM.ZConnection1.User;
Edit2.Text:= DM.ZConnection1.Password;
end;
end;
procedure TLogowanie.BitBtn2Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TLogowanie.BitBtn1Click(Sender: TObject);
begin
Logowanie;
end;
procedure TLogowanie.FormShow(Sender: TObject);
begin
Edit2.SetFocus;
end;
procedure TLogowanie.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled:= False;
Logowanie;
end;
function TLogowanie.fGetUserName: string;
var SLogin : string='';
buffsize: dword;
begin
buffsize:=128;
SetLength(SLogin, buffsize);
GetUserName(PChar(SLogin), buffsize);
Result:= SLogin;
end;
Procedure TLogowanie.Logowanie;
begin
DM.ZConnection1.User := Edit1.Text;
DM.ZConnection1.Password := Edit2.Text;
DM.login := Edit1.Text;
DM.haslo := Edit2.Text;
try
DM.ZConnection1.Connect;
except
ShowMessage('Brak połączenia z serwerem lub Błędny login, hasło.');
exit;
end;
if DM.Aktualizacja then ModalResult:= mrCancel
else ModalResult:= mrOK;
end;
end.