高手帮忙看看我的程序,我一直无法找出错误

 unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, ADODB, StdCtrls, ExtCtrls;

type
  Tlogin = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Button2: TButton;
    ADOConnection1: TADOConnection;
    Button3: TButton;
    ADOTable1: TADOTable;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
     { Public declarations }
  end;


var
  login: Tlogin;
  username,password:string;
  number:integer;
  qx:boolean;
implementation
    uses unit2,unit3;
{$R *.dfm}

procedure Tlogin.Button1Click(Sender: TObject);
var
  pass:string;
  right:Boolean;
begin
  username:=edit1.Text;
  pass:=edit2.Text;
  right:=false;
  qx:=false;
   adotable1.Open;
//判断用户名是否为空
  if username<>'' then
    begin

    adotable1.First;
    while not adotable1.Eof do
      begin
      if adotable1.FieldByName('用户名').AsString =username then
        begin
        right:=true;
        if adotable1.FieldByName('密码').AsString=pass then
          begin
            password:=pass;
               right:=true;
            if adotable1.FieldByName('权限').AsString='系统管理员' then
            begin
            qx:=true;
                right:=true;
            main.gly.Visible:=true;
            main.dy.Visible:=false;
            main.tj.Visible:=true;
            main.Label6.Caption:='管理员';
            main.Label1.Visible:=false;
            main.Show;
            login.Hide;
            end
          else
            begin
            main.gly.Visible:=false;
            main.dy.Visible:=true;
            main.tj.Visible:=true;
            main.Label6.Caption:='客户';
            main.Label1.Visible:=false;
            number:=adotable1.FieldByName('用户编号').AsInteger;
            main.Show;
            login.Hide;
            end;
          end
        else
          begin
          application.MessageBox('密码输入错误,请重新输入!','密码错误',0);
          edit2.Text:='';
          edit2.SetFocus;
          end;
        end;
      adotable1.Next;
      end;
    if right=false then
      begin
      if application.MessageBox('该用户名不存在,是否以此身份登录?','登录提示',1)=1 then
        begin
        main.gly.Visible:=false;
        main.dy.Visible:=false;
        main.tj.Visible:=false;
        main.Label6.Caption:='游客';
        main.Label1.Visible:=true;
        main.Show;
        login.Hide;
        end;
      end;
    end
  else
    begin
    application.MessageBox('用户名不能为空!','提示',0);
    edit1.SetFocus;
    end;
end;

procedure Tlogin.Button2Click(Sender: TObject);
begin
 showmessage('谢谢使用本报刊订阅系统!');
 close;
end;

procedure Tlogin.FormCreate(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
end;

procedure Tlogin.Button3Click(Sender: TObject);
begin
  login.Hide;
  regester.Show;
end;

end.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值