注册 登录
编程论坛 Delphi论坛

[求助]登陆界面的程序,始终找不出来问题,请教!

wanfangliang 发布于 2006-04-05 19:06, 966 次点击

var
LoginForm: TLoginForm;
i: integer;
username: string;
//password: integer;

implementation
uses unit1, Unit13;
{$R *.dfm}

procedure TLoginForm.FormActivate(Sender: TObject);
begin
i:=4;
Edit1.text:='';
Edit2.text:='';
Edit1.setFocus;
end;

procedure TLoginForm.BitBtn1Click(Sender: TObject);
begin
with Datamoduleunit do
begin
i := i - 1;
if i = 0 then
begin
Application.MessageBox('非法用户,系统将退出!', '提示', Mb_Ok or Mb_IconStop);
Application.Terminate;
end;
if userquery1.Locate('用户名称', Trim(edit1.text), []) then
begin
if Edit2.Text = Userquery1.FieldByName('用户密码').AsString then
begin
Close;
UserName := edit1.Text;
Mainform.StatusBar1.Panels.Items[2].Text := UserName;
end
else
begin
Application.MessageBox('密码错误!', '提示', Mb_Ok or Mb_IconStop);
Edit1.SetFocus;
Edit1.SelectAll;
end;
end;
end;
end;

procedure TLoginForm.BitBtn2Click(Sender: TObject);
begin
application.messagebox('您确定要退出吗?','提示信息',mb_ok);
close;
end;

以及主程序的调用

procedure TMainForm.FormActivate(Sender: TObject);
var
Path: string;
begin
Path := ExtractFilePath(Application.ExeName);
//i:= 3;
with DatamoduleUnit do
begin
adoconnection1.LoginPrompt :=false;
ADOConnection1.Connected := False;
ADOConnection1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + Path + '\CRMDB.mdb;Persist Security Info=False';
ADOConnection1.Connected := True;
with userquery1 do
begin
Close;
SQL.Clear;
Sql.Add('select * from 用户信息表');
try
Open;
except
end;
if IsEmpty then
begin
Close;
SQL.Clear;
SQL.Add('Insert into 用户信息表 values (''001'',''系统管理员'',''001'',''网络部'','''','''','''','''','''')');
try
ExecSql;
except
end;
end;
end;
if not Assigned(LoginForm) then
begin
LoginForm := TLoginForm.Create(Self);
end;
LoginForm.ShowModal;
LoginForm.Free;
end;
end;

3 回复
#2
ensr20062006-04-05 20:55

这样看不出来!~~~为什么你要把一个登陆做的这么复杂?本来很简单的东西呀

#3
yaotian20082006-04-05 21:43
"始终找不出来问题"你是有问题找不出来吗?还是程序做的太完美,"始终找不出来问题"?把程序打包上传来看看!
#4
ysp_19842006-04-06 10:08
procedure TLoginForm.BitBtn2Click(Sender: TObject);
begin
application.messagebox('您确定要退出吗?','提示信息',mb_ok);
close;
end;
就不对.“您确定要退出吗?”说明你可以不用退出?

procedure TLoginForm.BitBtn2Click(Sender: TObject);
begin
if messagebox(handle,'您确定要退出吗?','提示信息',MB_OKCANCEL+MB_ICONINFORMATION)=IDOK then
close;
end;
最好把你的程序打包传上来/

[此贴子已经被作者于2006-4-6 10:08:32编辑过]

1