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

📄 login.pas

📁 大二时做的
💻 PAS
字号:
unit login;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Mask, DB, DBTables, ADODB;

type
  TF_login = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    CmbLimit: TComboBox;
    EdLogin: TEdit;
    MEdPwd: TMaskEdit;
    BtnLogin: TBitBtn;
    BtnExit: TBitBtn;
    ADOQuery1: TADOQuery;
    procedure BtnExitClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CmbLimitChange(Sender: TObject);
    procedure BtnLoginClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  F_login: TF_login;
  
implementation

uses main;

{$R *.dfm}

procedure TF_login.BtnExitClick(Sender: TObject);
begin
     application.Terminate ; 
end;

procedure TF_login.FormShow(Sender: TObject);
begin
     CmbLimit.ItemIndex :=0;
end;

procedure TF_login.CmbLimitChange(Sender: TObject);
begin
    case CmbLimit.ItemIndex  of
      1: label2.Caption := '教师证号:';
      2: label2.Caption := '学生证号:';
    else
        label2.Caption := '帐号:';
    end;
end;

procedure TF_login.BtnLoginClick(Sender: TObject);
begin

    adoquery1.sql.Clear ;
    case CmbLimit.ItemIndex  of
      1: begin
         adoquery1.SQL.Add('select * from teacher where teacherno='''+edlogin.Text +''' and password='''+medpwd.Text+'''');
         vloginstatus:='教师';
         end;
      2: begin
         adoquery1.SQL.Add('select * from student where studentno='''+edlogin.Text +''' and password='''+medpwd.Text+'''');
         vloginstatus:='学生';
         end;
    else begin
        adoquery1.SQL.Add('select * from admin where login='''+edlogin.Text +''' and password='''+medpwd.Text+'''');
        vloginstatus:='管理员';
         end;
    end;
    adoquery1.open;

    if adoquery1.recordcount=0 then
    begin
        showmessage('登陆失败,请检查您的帐号和密码!');

    end
    else
    begin
        vlogin:= edlogin.Text;
        vloginname:= adoquery1.fieldbyname('name').asstring;
        mainform.statusbar1.panels[0].text:='你的身份:'+vloginstatus;
        mainform.statusbar1.panels[1].text:='姓名:'+vloginname;
        mainform.statusbar1.panels[2].text:='登录时间:'+datetostr(date())+'  '+timetostr(time());

        f_login.Close ;
    end;
end;

end.

⌨️ 快捷键说明

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