login.pas

来自「学生信息管理系统是一个集中了学生各种信息的系统」· PAS 代码 · 共 98 行

PAS
98
字号
unit Login;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons;

type
  TLoginFrm = class(TForm)
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Label1: TLabel;
    Edit1: TEdit;
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  LoginFrm: TLoginFrm;
  Times:Integer;

implementation

uses Student;

{$R *.dfm}

procedure TLoginFrm.BitBtn2Click(Sender: TObject);
begin
 close;
end;

procedure TLoginFrm.BitBtn1Click(Sender: TObject);
var pwdfile:textfile;
    PwdStr:string;
begin
    if RadioButton1.checked=True then
        assignfile(pwdfile,'.\Admini.cfg');
    if RadioButton2.checked=True then
        assignfile(pwdfile,'.\student.cfg');
    reset(pwdfile);
    readln(pwdfile,PwdStr);
    closefile(pwdfile);
    Times:=Times+1;
    if edit1.Text=PwdStr then
        begin
          close;
          StuMainFrm.Enabled:=True;
          StuMainFrm.PageControl1.ActivePage:=StuMainFrm.Tabsheet6;
          StuMainFrm.PageControl1.Visible:=True;
          if RadioButton1.checked=True then
             begin
              StuMainFrm.ToolButton2.Enabled:=True;
              StuMainFrm.ToolButton3.Enabled:=True;
              StuMainFrm.ToolButton4.Enabled:=True;
              StuMainFrm.ToolButton5.Enabled:=True;
              StuMainFrm.ToolButton8.Enabled:=True;
              StuMainFrm.ToolButton6.Enabled:=True;
             end;
          if RadioButton2.checked=True then
             begin
              StuMainFrm.ToolButton6.Enabled:=True;
             end;
        end
    else
       begin
         if MessageDlg('密码输入错误,是否退出?',mtConfirmation,[mbYes,mbNo],0)=mrYes  then
            begin
              close;
              StuMainFrm.Enabled:=True;
            end
         else
           begin
             if times<3 then edit1.SetFocus
             else
              begin
               MessageDlg('对不起,密码输入严重错误,请退出!',mtInformation,[mbOk],0);
               Application.Terminate;
              end;
           end;
       end;
end;

procedure TLoginFrm.FormShow(Sender: TObject);
begin
  Times:=0;
end;

end.

⌨️ 快捷键说明

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