?? login.~pas
字號:
unit login;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,Inifiles;
type
TF_login = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
i_server_add: TComboBox;
i_user: TEdit;
i_passwd: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
F_login: TF_login;
Inifile:TInifile;
implementation
uses DataModule, crypt, mainwin;
{$R *.DFM}
procedure TF_login.Button1Click(Sender: TObject);
var
passwd, passwrd:String;
begin
application.CreateForm(TDataModule1,DataModule1);
With DataModule1 do
begin
Database.Connected:=False;
Database.AliasName:=i_server_add.Text;
Database.Connected:=True;
T_user.Filter:='ID='''+i_user.Text+'''';
T_user.Filtered:=True;
T_user.Open;
if T_user.RecordCount=1 then
begin
passwd:=i_passwd.Text;
if length(passwd)>5 then
begin
passwd:=Copy(passwd+passwd,1,10);//統一密碼長度
passwd:=Encrypt(passwd,123);//加密
end;
passwrd:=T_user['PASSWD'];
if (passwrd=passwd) and (T_user['AUTHORITY']='3') then
begin
F_main.login:=True;
end
else
Application.MessageBox('請重新輸入密碼。'+#13+'注意大小寫!','密碼錯誤',MB_OK);
end
else
Application.MessageBox('請確認用戶名大小寫是否正確!','無此用戶',MB_OK);
T_user.Close;
end;
if F_main.login then F_login.Close
else DataModule1.Free;
end;
procedure TF_login.FormShow(Sender: TObject);
begin
self.i_server_add.SetFocus;
end;
procedure TF_login.FormCreate(Sender: TObject);
begin
Inifile:=TInifile.Create(extractfilepath(paramstr(0))+'SERVER.ini') ;
if fileexists(extractfilepath(paramstr(0))+'SERVER.ini') then
begin
i_server_add.Text:=inifile.ReadString('SERVER','SERVER NAME','');
i_user.Text:=inifile.ReadString('SERVER','USER NAME','');
end;
end;
procedure TF_login.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if not fileexists(extractfilepath(paramstr(0))+'SERVER.ini') then
Inifile:=TInifile.Create(extractfilepath(paramstr(0))+'SERVER.ini') ;
inifile.WriteString('SERVER','SERVER NAME',i_server_add.Text);
inifile.WriteString('SERVER','USER NAME',i_user.Text);
inifile.Free;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -