一窗口却换不到另一个窗口中,不报错, Delphi / Windows SDK/APIhttp://www.delphi2007.net/DelphiDB/html/delphi_20061219141750218.html
unit z_login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
Tf_login = class(TForm)
Edit1: TEdit;
edit2: TEdit;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
f_login: Tf_login;
implementation
uses z_data,z_main;
{$R *.dfm}
procedure Tf_login.Button1Click(Sender: TObject);
begin
if edit1.Text='' then
application.MessageBox('请输入用户名','提示',64)
else
if edit2.Text='' then
application.MessageBox('请输入密码','提示',64)
else
with Data1.q_login do
begin
close;
sql.Clear;
sql.Add('select * from t_user where user_no = :a and passwd = :b');
parameters.ParamByName('a').Value:=trim(edit1.Text);
parameters.ParamByName('b').Value:=trim(edit2.Text);
open;
end;
if Data1.q_login.RecordCount>0 then
begin
application.MessageBox('用户名或密码错误,请重新输入!','提示',64);
edit1.Clear;
edit2.Clear;
edit1.SetFocus;
end;
end;
procedure Tf_login.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;
end.
1. 里面好像没写换哪个窗口.
2. 当Data1.q_login.RecordCount = 0 时才报为用户名或密码错误
我这个登录窗口是从z_main主窗口中
procedure Tf_main.FormShow(Sender: TObject);
begin
application.CreateForm(Tf_login,f_login);
f_login.ShowModal;
f_login.free;
end;
这样新建出来的
顶上去
当查询成功后close登录框就OK了
if Data1.q_login.RecordCount>0 then
begin
application.MessageBox('用户名或密码错误,请重新输入!','提示',64);
edit1.Clear;
edit2.Clear;
edit1.SetFocus;
end;
Data1.q_login.RecordCount>0应该是查询成功吧
查询成功还用重新输入密码和用户名吗?
if Data1.q_login.RecordCount>0 then
begin
f_login.close;
end;
问题以搞定