?? unitlogin.~pas
字號:
unit Unitlogin;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ADOConEd,StrUtils,Registry,ADODB,Unitcomm,
ExtCtrls, SUIForm, SUIEdit, SUIButton, DB;
type
TFormlogin = class(TForm)
suiForm1: TsuiForm;
uname: TsuiEdit;
mm: TsuiEdit;
suiButton1: TsuiButton;
suiButton2: TsuiButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure suiButton2Click(Sender: TObject);
procedure suiButton1Click(Sender: TObject);
procedure Formcreat(Sender: TObject);
procedure Formshow(Sender: TObject);
procedure formclose(Sender: TObject; var Action: TCloseAction);
private
myDataSet:TADODataSet;
{ Private declarations }
public
{ Public declarations }
end;
var
Formlogin: TFormlogin;
implementation
{$R *.dfm}
uses Unitmain;
procedure TFormlogin.suiButton2Click(Sender: TObject);
begin
tag:=0;
close;
end;
procedure TFormlogin.suiButton1Click(Sender: TObject);
var
frmain:Tfrmain;
reg:TRegistry; //UDataSet:TADODataSet;
begin
myDataSet:=TADODataSet.Create(self);
myDataSet.Connection:=ADOConn;
myDataSet.CommandText:='select mm from yh where yh_name='''+Uname.Text+'''';
myDataSet.Active:=true;
if not myDataSet.Eof then
begin
if mm.Text=myDataSet.Fields[0].AsString then
begin
self.Tag:=1;
UserName:=Uname.Text;
reg:=TRegistry.Create;
try
reg.RootKey:=HKEY_LOCAL_MACHINE;
if reg.OpenKey('\Software\質量標準檔案管理系統',true) then
begin
reg.WriteString('uid',UserName);
end;
except
showmessage('讀取用戶信息錯誤!');
application.Terminate;
end;
reg.Free;
frmain:=Tfrmain.Create(nil);
self.Hide;
frmain.ShowModal;
frmain.Free;
self.Close;
end
else
begin
showmessage('密碼錯誤!無法登陸系統!');
mm.SetFocus;
mm.SetFocus;
end;
end
else
begin
showmessage('密碼錯誤!無法登陸系統!');
mm.SelectAll;
mm.SetFocus;
end;
end;
procedure TFormlogin.Formcreat(Sender: TObject);
var
reg:TRegistry;
connstr:string;
tmpstr:string;
begin
reg:=TRegistry.Create;
ADOConn:=TADOConnection.Create(self);
try
reg.RootKey:=HKEY_LOCAL_MACHINE;
if reg.OpenKey('\Software\質量標準檔案管理系統',true)then
begin
if reg.ValueExists('connstr') then
connstr:=reg.ReadString('connstr')
else
begin
if EditConnectionString(ADOConn) then
begin
connstr:=ADOConn.ConnectionString;
reg.WriteString('connstr',connstr);
end
else
begin
showmessage('無法建立與數據庫的連接,程序終止!');
application.Terminate;
end;
end;
try //******
if reg.ValueExists('uid') then
tmpstr:=reg.ReadString('uid')
else
begin
reg.WriteString('uid','');
end;
except
showmessage('讀取用戶信息錯誤!');
application.Terminate;
end;//******
end;
except
showmessage('初始化錯誤!');
application.Terminate;
end;//######
reg.Free;
Uname.Text:=tmpstr;
if connstr <> '' then
begin
try
ADOConn.ConnectionString:=connstr;
ADOConn.LoginPrompt:=false;
ADOConn.Connected:=true;
except
showmessage('連接數據庫錯誤!');
application.Terminate;
end;
end;
end;
procedure TFormlogin.Formshow(Sender: TObject);
begin
if Uname.Text <> '' then
mm.Clear
else
Uname.SetFocus;
end;
procedure TFormlogin.formclose(Sender: TObject; var Action: TCloseAction);
begin
myDataSet:=TADODataSet.Create(self);
myDataSet.Close;
myDataSet.Free;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -