⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 这是本人网络数据库实习的程序,编程语言选择DELPHI7.0,完全个人编写.本程序一些界面还不够完善,功能不大,还有很多地方需要改进,望有兴趣的朋友一起探讨或通过电子邮箱与我联系!
💻 PAS
字号:
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:=true;
  qx:=false;
//判断用户名是否为空
  if username<>'' then
    begin
    adotable1.First;
    while not adotable1.Eof do
      begin
      if adotable1.FieldByName('用户名').AsString =username then
        begin
        right:=false;
        if adotable1.FieldByName('密码').AsString=pass then
          begin
            password:=pass;
            if adotable1.FieldByName('权限').AsString='系统管理员' then
            begin
            qx:=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 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.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -