重新登录窗体怎么做啊?
解决方案 »
- Delphi类库中可有像JAVA中的Collection,Set,List, Map 这样的类,是否需要自己实现?谢谢!
- 如何将查询到的记录按任意字段排序?
- 誰把我的貼子刪除了而且還把我信譽分給扣了?怎麼回事?
- 学习delphi
- 做一个返回数组的函数?
- 报表中计算字段的问题?
- 关于打印状态的问题(在线等待啊)
- 怎样可以实时传输图像和声音?(在internet和局域中)?
- 三层结构,执行客户端程序时出现接口不支持错误,这是怎么回事?
- 大虾留步---为什么在Delphi5中使用dsgnintf单元总提示:File not found 'dsgnintf.dcu'?(全部分数奉上)
- 如何在Delphi中使用WIN200自带的WINFAX组件?
- 怎样制做试用版程序
//write by minidog
interfaceUses 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.
program Project1;
uses
Forms,
Controls,
Dialogs,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {PasswordDlg};{$R *.RES}begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.ShowMainForm:=false;
Application.CreateForm(TPasswordDlg, PasswordDlg);
PasswordDlg.ShowModal;
while PasswordDlg.ispass=False do
begin
if (MessageDlg('please input the password',MtInformation,[mbYes,mbNo],0)=mryes) then
Passworddlg.ShowModal
else exit;
end;
if PasswordDlg.ispass then
begin
application.ShowMainForm:=true;
Application.Run;
PasswordDlg.Free;
PasswordDlg:=nil;
end
//application.Terminate;
end.
其中ispass:boolean定义在密码登陆窗口的public里,是确定登陆密码是否正确。
在密码登陆窗口的确定按钮的click事件中确定密码,如下:
procedure TPasswordDlg.OKBtnClick(Sender: TObject);
begin
if (passworddlg.Password.Text='1') then //密码为1
ispass:=true
else ispass:=false;
end;