procedure TForm4.suiButton1Click(Sender: TObject); var adologin:TADODataSet; i:integer; s:string; mm:tstringlist; begin if suiComboBox1.Text='' then begin application.MessageBox('请输入用户名','提示',64); exit; end; mm:=tstringlist.Create; for i:=1 to length(suiEdit2.Text) do mm.Add(copy(suiEdit2.Text,length(suiEdit2.Text)-i+1,1)); for i:=0 to mm.Count-1 do s:=s+mm[i]; adologin:=TADODataSet.Create(application); adologin.ConnectionString:=' Provider=SQLOLEDB.1;'+'Persist Security Info=False;User ID='+GetRegInfo(3)+';Password='+GetRegInfo(4)+';'+ 'Initial Catalog='+GetRegInfo(2)+';Data Source='+GetRegInfo(1); adologin.CommandText:='select * from PassView where 用户名='''+trim(suiComboBox1.Text)+''''+' and '+'密码='''+s+''''; mm.Free; adologin.Open; if adologin.RecordCount<>0 then begin username:=adologin.FieldValues['用户名']; power:=adologin.FieldValues['权限']; if power=0 then //权限处理 begin form1.Notebook1.Align:=alcustom; form1.p3.Align:=albottom; form1.p1.Align:=albottom; form1.p2.Align:=albottom; form1.Notebook1.PageIndex:=0; form1.Notebook2.PageIndex:=0; form1.Notebook1.Align:=alclient; end; adologin.Free; form1.show; form4.Hide; end else//密码错误处理 begin adologin.Free; application.MessageBox('用户名和密码有误!请查证后再输!','提示',64); exit; end;//end elseend;
很多可以剪掉的,你看看吧,主要是这句 adologin.CommandText:='select * from PassView where 用户名='''+trim(suiComboBox1.Text)+''''+' and '+'密码='''+s+'''';
ADOQuery1.SQL.Text:='Select * From UserLog Where ID='+QuotedStr(edtID.Text)+' and UserName='+QuotedStr(edtUserName.Text)+' and UserPass='+QuotedStr(edtUserPass.Text); ADOQuery1.Open; if not ADOQuery1.Isempty then begin ShowMessage('登录成功!'); . . . end;
var adologin:TADODataSet; i:integer;
s:string;
mm:tstringlist;
begin
if suiComboBox1.Text='' then
begin
application.MessageBox('请输入用户名','提示',64);
exit;
end;
mm:=tstringlist.Create;
for i:=1 to length(suiEdit2.Text) do
mm.Add(copy(suiEdit2.Text,length(suiEdit2.Text)-i+1,1));
for i:=0 to mm.Count-1 do
s:=s+mm[i];
adologin:=TADODataSet.Create(application);
adologin.ConnectionString:=' Provider=SQLOLEDB.1;'+'Persist Security Info=False;User ID='+GetRegInfo(3)+';Password='+GetRegInfo(4)+';'+
'Initial Catalog='+GetRegInfo(2)+';Data Source='+GetRegInfo(1);
adologin.CommandText:='select * from PassView where 用户名='''+trim(suiComboBox1.Text)+''''+' and '+'密码='''+s+'''';
mm.Free;
adologin.Open;
if adologin.RecordCount<>0 then
begin
username:=adologin.FieldValues['用户名'];
power:=adologin.FieldValues['权限'];
if power=0 then //权限处理
begin
form1.Notebook1.Align:=alcustom;
form1.p3.Align:=albottom;
form1.p1.Align:=albottom;
form1.p2.Align:=albottom;
form1.Notebook1.PageIndex:=0;
form1.Notebook2.PageIndex:=0;
form1.Notebook1.Align:=alclient;
end;
adologin.Free;
form1.show;
form4.Hide;
end else//密码错误处理
begin
adologin.Free;
application.MessageBox('用户名和密码有误!请查证后再输!','提示',64);
exit;
end;//end elseend;
adologin.CommandText:='select * from PassView where 用户名='''+trim(suiComboBox1.Text)+''''+' and '+'密码='''+s+'''';
ADOQuery1.SQL.Text:='Select * From UserLog Where ID='+QuotedStr(edtID.Text)+' and UserName='+QuotedStr(edtUserName.Text)+' and UserPass='+QuotedStr(edtUserPass.Text);
ADOQuery1.Open;
if not ADOQuery1.Isempty then
begin
ShowMessage('登录成功!');
.
.
.
end;