W
wjll
Unregistered / Unconfirmed
GUEST, unregistred user!
本人想编写一个人事管理系统,里面加入改变密码模块,可是,调试中,发现不管旧密码
正确与否,它都将新密码写入数据库。请指教。程序如下:
procedure Tfrmchangepassword.Button1Click(Sender: TObject);
begin
with ChangepasswordQuery do
begin
if Edit3.Text<>Edit4.Text
then Application.MessageBox('您输入的密码不匹配。请在两个文本框内输入新密码','警告',mb_ok+mb_iconexclamation)
else
begin
SQL.Clear;
SQL.Add('Select Name From Quanxian Where (name=_a) and (mima=_b)');
ParamByName('p_a').Asstring:=Edit1.Text;
ParamByName('p_b').Asstring:=Edit2.Text;
ChangepasswordQuery.ExecSQL;
if changepasswordquery.IsEmpty
then
begin
SQL.Clear;
SQL.Add('UPDATE QUANXIAN SET MIMA=_c WHERE (NAME=_a)');
ParamByName('p_a').Asstring:=Edit1.Text;
ParamByName('p_c').Asstring:=Edit3.Text;
ChangepasswordQuery.ExecSQL;
end
else
begin
Application.MessageBox('您输入的旧密码不正确,请重新输入。','警告',mb_ok+mb_iconexclamation)
end;
end;
end;
end;
正确与否,它都将新密码写入数据库。请指教。程序如下:
procedure Tfrmchangepassword.Button1Click(Sender: TObject);
begin
with ChangepasswordQuery do
begin
if Edit3.Text<>Edit4.Text
then Application.MessageBox('您输入的密码不匹配。请在两个文本框内输入新密码','警告',mb_ok+mb_iconexclamation)
else
begin
SQL.Clear;
SQL.Add('Select Name From Quanxian Where (name=_a) and (mima=_b)');
ParamByName('p_a').Asstring:=Edit1.Text;
ParamByName('p_b').Asstring:=Edit2.Text;
ChangepasswordQuery.ExecSQL;
if changepasswordquery.IsEmpty
then
begin
SQL.Clear;
SQL.Add('UPDATE QUANXIAN SET MIMA=_c WHERE (NAME=_a)');
ParamByName('p_a').Asstring:=Edit1.Text;
ParamByName('p_c').Asstring:=Edit3.Text;
ChangepasswordQuery.ExecSQL;
end
else
begin
Application.MessageBox('您输入的旧密码不正确,请重新输入。','警告',mb_ok+mb_iconexclamation)
end;
end;
end;
end;