📄 login.pas
字号:
unit login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ADODB, DB, ExtCtrls, JPEG;
type
Tloginform = class(TForm)
Button1: TButton;
Button2: TButton;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
int_login:integer;
r1,r2,r3:boolean;
operator:string;
end;
var
loginform: Tloginform;
implementation
uses
main;
{$R *.dfm}
procedure Tloginform.Button1Click(Sender: TObject);
var
ADOQuery1:TADOQuery;
begin
if (edit1.Text='') or (edit2.Text='') then
begin
MessageDlg('用户名或密码不能为空!!', mtInformation, [mbYes],0);
exit;
end;
ADOQuery1:=TADOQuery.Create(self);
ADOQuery1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+
extractfilepath(application.ExeName)+
'train.mdb;Persist Security Info=False';
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from users where name=:A and password=:B');
ADOQuery1.Parameters.ParamByName('A').Value:=Edit1.Text;
ADOQuery1.Parameters.ParamByName('B').Value:=edit2.Text;
ADOQuery1.Open;
if ADOQuery1.RecordCount > 0 then
begin
operator:=ADOQuery1.FieldValues['name'];
r1:=ADOQuery1.FieldValues['r1'];
r2:=ADOQuery1.FieldValues['r2'];
r3:=ADOQuery1.FieldValues['r3'];
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
loginform.Hide;
mainform.Show;
end
else
begin
MessageDlg('用户名或密码错误'+#13+'请重新输入!',mtWarning,[mbOK],0);
edit1.Text:='';
edit2.Text:='';
int_login:=int_login + 1;
if int_login=1 then
begin
messagedlg('你只有三次机会登录系统'+#13+'现在你还有两次机会!!',mtWarning,[mbOK],0);
end;
IF int_login=2 then
begin
MessageDlg('您还有最后一次机会'+#13+'如用户名或密码错误'+#13+'本系统将被锁定!!',mtWarning,[mbOK],0);
end;
if int_login=3 then
begin
MessageDlg('由于您登陆次数太多'+#13+'系统己被锁定!!',mtWarning,[mbOK],0);
application.Terminate; //超过次数退出程序
end;
end;
ADOQuery1.Free;
end;
procedure Tloginform.Button2Click(Sender: TObject);
begin
application.Terminate;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -