我今天做了一个信息管理系统,可是每当程序运行到登陆界面时,我输入用户名和密码点确定后酒会提示程序访问地址出错,但是并不影响程序接下来的运行(不论输入的口令是对还是错,都是出现这个问题)
一下是登陆截面的代码:
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, StdCtrls, Buttons;
type
TForm7 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Table_U: TTable;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
username,password:string;
qx1,qx2,qx3:boolean;
i:Integer;
implementation
{$R *.dfm}
procedure TForm7.BitBtn1Click(Sender: TObject);
var
Table_U:TTable;
begin
Table_U.Open;
if (Table_U.FieldByName('name').AsString=edit1.text) and (Table_U.FieldByName('password').AsString=edit2.text) then
begin
username:=edit1.text;
password:=edit2.text;
qx1:=Table_U.fieldByName('right_1').asboolean;
qx2:=Table_U.fieldByName('right_2').asboolean;
qx3:=Table_U.fieldByName('right_3').asboolean;
Table_U.Close;
close;
end
else
begin
Table_U.Close;
Application.MessageBox('用户名或密码输入错误,请检查再重试!','提示信息',mb_ok);
edit1.text:='';
edit2.Text:='';
edit1.SetFocus;
i:=i-1;
if i=0 then
close;
end
end;
procedure TForm7.BitBtn2Click(Sender: TObject);
begin
close;
end;
procedure TForm7.FormActivate(Sender: TObject);
begin
i:=3;
Edit1.text:='';
Edit2.text:='';
end;
end.
一下是登陆截面的代码:
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, StdCtrls, Buttons;
type
TForm7 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Table_U: TTable;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
username,password:string;
qx1,qx2,qx3:boolean;
i:Integer;
implementation
{$R *.dfm}
procedure TForm7.BitBtn1Click(Sender: TObject);
var
Table_U:TTable;
begin
Table_U.Open;
if (Table_U.FieldByName('name').AsString=edit1.text) and (Table_U.FieldByName('password').AsString=edit2.text) then
begin
username:=edit1.text;
password:=edit2.text;
qx1:=Table_U.fieldByName('right_1').asboolean;
qx2:=Table_U.fieldByName('right_2').asboolean;
qx3:=Table_U.fieldByName('right_3').asboolean;
Table_U.Close;
close;
end
else
begin
Table_U.Close;
Application.MessageBox('用户名或密码输入错误,请检查再重试!','提示信息',mb_ok);
edit1.text:='';
edit2.Text:='';
edit1.SetFocus;
i:=i-1;
if i=0 then
close;
end
end;
procedure TForm7.BitBtn2Click(Sender: TObject);
begin
close;
end;
procedure TForm7.FormActivate(Sender: TObject);
begin
i:=3;
Edit1.text:='';
Edit2.text:='';
end;
end.