| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 999 人关注过本帖
标题:登陆界面参考代码
只看楼主 加入收藏
ensr2006
Rank: 2
等 级:新手上路
威 望:3
帖 子:97
专家分:0
注 册:2006-3-28
收藏
 问题点数:0 回复次数:0 
登陆界面参考代码

unit UserCtl;

interface

Uses Classes, Forms ,Windows ,SysUtils ,ADODB, IniFiles;

Type

TAppUser = Class(Tobject)
Private
UserID :String;
Public
UserName :String;
UserType :Integer;
Connection :TAdoConnection;
constructor Create();
destructor Destroy();override;
Function Login():Boolean;
Procedure SetPower();
Procedure RelasePower();
end;

Var AppUser:TAppUser;

implementation
uses Logon ,Main;

Const IniName ='AppInfo.ini';
U_SQL ='Select * From Operator Where ID=:UID and Pwd=:UPwd';
ErrTitle = '错误提示';

{ UserInfo }

constructor TAppUser.Create;
Var Ini:TIniFile;
begin
inherited;
Ini :=TIniFile.Create(ExtractFilePath(Application.ExeName)+IniName);
try
UserID:=Ini.ReadString('Init','DefaultUser','');
finally
Ini.Free;
end;
end;

destructor TAppUser.Destroy;
begin
inherited;

end;
//============================用户登录模块==============================
function TAppUser.Login(): Boolean;
Var Q_User:TAdoQuery;
Password :String;
LogTimes :Integer;
Loged :Boolean;
Ini:TIniFile;
begin
LogTimes :=0;
Loged :=False;
LoginForm :=TLoginForm.Create(Application);
LoginForm.Again :=False;
Q_User :=TAdoQuery.Create(nil);
Try
Q_User.Connection :=Connection;
Q_User.SQL.Text :=U_SQL;
LoginForm.Caption :='请登录系统';
Repeat
if LogTimes=3 then Break;
LoginForm.IdEdit.Text := UserID;
LoginForm.PwdEdit.Clear;
if LoginForm.ShowModal =2 then break;
LoginForm.Again :=True;
Inc(LogTimes);
UserID:=LoginForm.IdEdit.Text;
Password :=LoginForm.PwdEdit.Text;
Q_User.Close;
Q_User.Parameters.ParamByName('UID').Value :=UserID;
Q_User.Parameters.ParamByName('UPwd').Value :=Password;
Q_User.Open;
if Q_User.RecordCount<>0 then
Begin
UserName :=Q_User.FieldByName('Name').AsString;
UserType :=Q_User.FieldByName('Type').AsInteger;
Loged :=True;
Ini :=TIniFile.Create(ExtractFilePath(Application.ExeName)+IniName);
try
Ini.WriteString('Init','DefaultUser',UserID);
finally
Ini.Free;
end;
end
Else Application.MessageBox('用户名或密码错误',ErrTitle,MB_OK OR MB_ICONERROR);
Until Loged;
Result :=Loged;
finally
LoginForm.Free;
Q_User.Free;
end;
end;

procedure TAppUser.SetPower();
begin
With MainForm do
Begin

end;
end;

procedure TAppUser.RelasePower();
begin
//
end;


initialization
AppUser:=TAppUser.Create();

finalization
AppUser.Free;

end.

搜索更多相关主题的帖子: 界面 代码 登陆 
2006-04-09 14:57
快速回复:登陆界面参考代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018629 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved