procedure Tfrm_login.BitBtn1Click(Sender: TObject);
begin
if xm.ItemIndex <0 then
begin
messagebox(Handle,'请选择一个正确的用户名!','系统提示',MB_OK+MB_ICONINFORMATION);
Exit;
end; if dm.at1.Locate('u_name',xm.Text,[loCaseInsensitive]) then
begin
if mima.Text=trim(dm.at1.fieldbyname('u_password').AsString) then
begin
frm_main.AdminII:=dm.AT1.fieldbyname('u_id').AsString;
frm_main.AdminName:=dm.AT1.fieldbyname('u_name').AsString;
if dm.at1.fieldbyname('u_name').asstring='书记' then
begin
Frm_Main.N3.Visible:=true ;
end else
begin
frm_main.N3.Visible:=false;
end;
close; end else // 密码不正确
begin
//application.MessageBox('密码错误,请重新输入','提示',mb_ok+mb_iconerror);
//showmessage('密码错误,请重新输入!');
if messagedlg('您输入的密码不正确,请检查!',mtinformation,[mbok,mbcancel],0)=mrok then
begin
mima.Text:='';
mima.SetFocus;
exit;
end else
close;
end;
end;
end;
登录代码如上:
begin
if xm.ItemIndex <0 then
begin
messagebox(Handle,'请选择一个正确的用户名!','系统提示',MB_OK+MB_ICONINFORMATION);
Exit;
end; if dm.at1.Locate('u_name',xm.Text,[loCaseInsensitive]) then
begin
if mima.Text=trim(dm.at1.fieldbyname('u_password').AsString) then
begin
frm_main.AdminII:=dm.AT1.fieldbyname('u_id').AsString;
frm_main.AdminName:=dm.AT1.fieldbyname('u_name').AsString;
if dm.at1.fieldbyname('u_name').asstring='书记' then
begin
Frm_Main.N3.Visible:=true ;
end else
begin
frm_main.N3.Visible:=false;
end;
close; end else // 密码不正确
begin
//application.MessageBox('密码错误,请重新输入','提示',mb_ok+mb_iconerror);
//showmessage('密码错误,请重新输入!');
if messagedlg('您输入的密码不正确,请检查!',mtinformation,[mbok,mbcancel],0)=mrok then
begin
mima.Text:='';
mima.SetFocus;
exit;
end else
close;
end;
end;
end;
登录代码如上:
如果是,只要登录窗口关闭,就会进入主界面,不论密码是否正确
要判断成功与否标准
不成功则 {主form.}close
要判断成功与否标准
不成功则 {主form.}close
application.Terminate;
1,如果MainForm创建了,你可以MainForm.close
2,无论何时,你都可以用application.Terminate来关闭程序