第2个回答 2011-01-14
if trim(edtCode.Text) = '' then
begin
showMsg('请输入用户代码');
if edtCode.CanFocus then edtCode.SetFocus;
edtCode.SelectAll;
exit;
end;
if trim(edtPassword.Text) = '' then
begin
showMsg('请输入用户密码');
if edtPassword.CanFocus then edtPassword.SetFocus;
edtPassword.SelectAll;
exit;
end;
with qryUser do
begin
close;
SQL.Text := 'select * from s_userInfo where isUse=1 and code=:code';
Parameters.ParamByName('code').Value := edtCode.Text;
try
Open;
except
qryErrorMsg;
Exit;
end;
if isEmpty then
Begin
edtName.Text := '';
showMsg('用户代码不存在或用户没有权限');
if edtCode.CanFocus then edtCode.SetFocus;
edtCode.SelectAll;
exit;
End;
edtName.Text := FieldByName('name').AsString;
if FieldByName('password').AsString <> trim(edtPassword.Text) then
Begin
showMsg('密码错误');
edtPassword.SetFocus;
edtPassword.SelectAll;
exit;
End;
end;