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

📄 unitlogin.pas

📁 远程抄表系统的客户端程序 安徽六安项目-客户端程序 0 开发环境 Delphi 7.0 所需控件 mxOutlookBar 数 据 库 Sybase 11.5 1 04-12-
💻 PAS
字号:
unit UnitLogin;

interface

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

type
  TFormLogin = class(TForm)
    LabelName: TLabel;
    Image: TImage;
    LabelPass: TLabel;
    MaskEdit_Pwd: TMaskEdit;
    BtnOK: TButton;
    BtnCancel: TButton;
    Combo_Name: TComboBox;
    LabelInfo: TLabel;
    LabelWarning: TLabel;
    procedure BtnOKClick(Sender: TObject);
    procedure BtnCancelClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    MyTitle : string;
    // 初始密码
    MyPwd   : string;
    //函数返回值
    //0 取消登录
    //1 Guest登录成功
    //2 管理员登录成功
    //3 程序员级别的权限 固定密码: ADMIN@JZTX
    //4 密码输入错误超过三次
    MyValue: short;

  end;
const
  MAX_INPUT_TIMES = 3;
var
  FormLogin: TFormLogin;

  //登录次数
  Count : short;

implementation

{$R *.dfm}

procedure TFormLogin.BtnOKClick(Sender: TObject);
begin
  Inc(Count, 1);
  if Count >=  MAX_INPUT_TIMES then
  begin
    MyValue := 4;
    Close;
  end;

  if  (Combo_Name.Text = 'Guest') then
    begin
      MyValue := 1;
      Close;
    end;

  if  ( Combo_Name.Text   = '管理员' ) and
           ( MaskEdit_Pwd.Text = MyPwd  ) then
    begin
      MyValue := 2;
      Close;
    end
  else
  if  ( Combo_Name.Text   = '管理员' ) and
           ( MaskEdit_Pwd.Text = 'ADMIN@JZTX'  ) then
    begin
      MyValue := 3;
      Close;
    end
  else begin
      MaskEdit_Pwd.Text := '';

      LabelWarning.Caption := '密码输入错误:' + IntToStr(Count) + '次';
    end;
end;

procedure TFormLogin.BtnCancelClick(Sender: TObject);
begin
  MyValue := 0;
  Close;
end;

procedure TFormLogin.FormShow(Sender: TObject);
begin
  self.Caption := MyTitle;
  MaskEdit_Pwd.Text := '';
  Combo_Name.Clear();
  Combo_Name.Items.Add('Guest');
  Combo_Name.Items.Add('管理员');
  Combo_Name.Text := 'Guest';

  LabelWarning.Caption := '请输入用户名和密码(Guest没有密码)';

  Count := 0;
end;

procedure TFormLogin.FormCreate(Sender: TObject);
begin
  MyTitle := '用户登录';
end;

end.

⌨️ 快捷键说明

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