登陆的时候密码正确则正常进入系统,否则就死在这里了.
但是在进入系统之后再打开这个窗体,却可以正确提示密码错误了.不解!!登陆单元的源码如下:
var
fm_login: Tfm_login;
quitstr:string;implementation
uses un_data,un_main,un_change;
{$R *.dfm}procedure Tfm_login.BitBtn2Click(Sender: TObject);
begin
application.Terminate;
end;procedure Tfm_login.FormShow(Sender: TObject);
begin
quitstr:='0';
with hhhc_data.hhhc_user do
begin
Active :=false;
CommandText :='select * from hhhc_user';
Active :=true;
name_list.Clear;
pass_edit.Text :='';
while not eof do
begin
name_list.Items.Add(trim(fieldbyname('user').AsString));
next;
end;
end;
name_list.SetFocus;
end;procedure Tfm_login.BitBtn1Click(Sender: TObject);
begin
if hhhc_data.hhhc_user.Locate('user;password',VarArrayOf([name_list.text,pass_edit.text]),[]) then
begin
fm_main.admin_lab.Caption :=name_list.Text ;
fm_change.admin_lab2.Caption:=name_list.Text;
quitstr:='1';
close;
end
else
begin
quitstr:='0';
application.MessageBox('ÃÜÂë´íÎó£¬ÇëÖØÐÂÊäÈë','ÌáʾÐÅÏ¢',64+mb_ok);
pass_edit.Text :='';
end;
end;procedure Tfm_login.pass_editKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
BitBtn1click(self);
end;procedure Tfm_login.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if quitstr<>'1' then
canclose:=false;
end;end.
但是在进入系统之后再打开这个窗体,却可以正确提示密码错误了.不解!!登陆单元的源码如下:
var
fm_login: Tfm_login;
quitstr:string;implementation
uses un_data,un_main,un_change;
{$R *.dfm}procedure Tfm_login.BitBtn2Click(Sender: TObject);
begin
application.Terminate;
end;procedure Tfm_login.FormShow(Sender: TObject);
begin
quitstr:='0';
with hhhc_data.hhhc_user do
begin
Active :=false;
CommandText :='select * from hhhc_user';
Active :=true;
name_list.Clear;
pass_edit.Text :='';
while not eof do
begin
name_list.Items.Add(trim(fieldbyname('user').AsString));
next;
end;
end;
name_list.SetFocus;
end;procedure Tfm_login.BitBtn1Click(Sender: TObject);
begin
if hhhc_data.hhhc_user.Locate('user;password',VarArrayOf([name_list.text,pass_edit.text]),[]) then
begin
fm_main.admin_lab.Caption :=name_list.Text ;
fm_change.admin_lab2.Caption:=name_list.Text;
quitstr:='1';
close;
end
else
begin
quitstr:='0';
application.MessageBox('ÃÜÂë´íÎó£¬ÇëÖØÐÂÊäÈë','ÌáʾÐÅÏ¢',64+mb_ok);
pass_edit.Text :='';
end;
end;procedure Tfm_login.pass_editKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
BitBtn1click(self);
end;procedure Tfm_login.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if quitstr<>'1' then
canclose:=false;
end;end.
解决方案 »
- 购方名称如何解密??
- 请问如何在TChart中使用曲线趋势图(Fast Line)?
- 请教一条SELECT语句!!!
- DELPHI6.0+SQLSERVER用什么做报表的啊?
- 装入Hook后能截获Keyboard但是,不能把Key值写入文件,这是怎么会事???急!急!急!
- 怎样调用form窗体?
- TreeView控件的问题
- 请教各位同盟一个问题!!!!!
- timer的简单问题!
- 如何在listview中判断checked改变?
- 关于三层中如何实现动态设定中间层ADOConnection控件的ConnectionString,以连接不同数据库的问题?
- 如何编程实现把WebBrowser存储为mht格式
begin
application.Terminate;
end;
你是要退出登录窗体还是要退出这个系统?????
begin
quitstr:='0';
with hhhc_data.hhhc_user do
begin
Active :=false;
CommandText :='select * from hhhc_user';
Active :=true;
name_list.Clear;
pass_edit.Text :='';
First; // 添加这行再试试 如果没有就死循环啦
while not eof do
begin
name_list.Items.Add(trim(fieldbyname('user').AsString));
next;
end;
end;
name_list.SetFocus;
end;
那是退出按钮,当然是退出系统了.Tfm_login.BitBtn1Click是登陆按钮.习惯不好,没有取名字...lzy6204(为了忘却的记忆), 加上first还是不行,哪里有死循环?密码正确就可以正常进入啊.
断点跟踪一下这里
else
begin
quitstr:='0';
application.MessageBox('ÃÜÂë´íÎó£¬ÇëÖØÐÂÊäÈë','ÌáʾÐÅÏ¢',64+mb_ok);
pass_edit.Text :='';
end;看出现了什么问题
原来是个低级错误,我把登陆窗体的FormStyle属性设为fsStayOnTop了..晕..