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

📄 login.~pas

📁 用delphi编的企业人事管理系统
💻 ~PAS
字号:
unit login;

interface

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

type
  TLoginForm = class(TForm)
    Bevel1: TBevel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edit1: TEdit;
    Button1: TButton;
    Button2: TButton;
    Image1: TImage;
    MaskEdit1: TMaskEdit;
    MaskEdit2: TMaskEdit;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  LoginForm: TLoginForm;

implementation

uses main;

{$R *.dfm}

procedure TLoginForm.FormCreate(Sender: TObject);
var
sUser:string;
sPass:string;
Reg:TRegistry;
begin
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_LOCAL_MACHINE;
Reg.OpenKey('SOFTWARE\Reg\',true);
sUser:=Reg.ReadString('user');
sPass:=Reg.ReadString('pass');
if ((length(sUser)<=0) and (length(sPass)<=0)) then
begin
loginForm.Caption:='您第一次使用,请输入用户名和密码';
button2.Visible:=false;
end
else
begin
label3.Visible:=false;
maskedit2.Visible:=false;
button1.Visible:=false;
end;

end;

procedure TLoginForm.Button1Click(Sender: TObject);
var Reg:TRegistry;
begin
if length(edit1.Text)=0 then
begin
application.MessageBox('请输入用户名','输入用户信息',0);
edit1.SetFocus;
end
else
begin
  if maskedit1.Text<>maskedit2.Text then
  begin
  application.MessageBox('您输入的密码和确认密码不一致','输入用户信息',0);
   end
  else
  begin
  Reg:=TRegistry.Create;
  Reg.RootKey:=HKEY_LOCAL_MACHINE;
  Reg.OpenKey('SOFTWARE\Reg\',true);
  Reg.WriteString('user',edit1.Text);
  Reg.WriteString('pass',maskedit1.Text);
  application.MessageBox('用户名与密码已保存','用户提示信息',0);
  close();
  end;
end;

end;

procedure TLoginForm.Button2Click(Sender: TObject);
var
sUser:string;
sPass:string;
Reg:TRegistry;
begin
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_LOCAL_MACHINE;
Reg.OpenKey('SOFTWARE\Reg\',true);
sUser:=Reg.ReadString('user');
sPass:=Reg.ReadString('pass');
if sUser<>Edit1.Text then
begin
application.MessageBox('用户名错误','用户审核',0);
edit1.SetFocus;
end
  else
  begin
  if sPass<>Maskedit1.Text then
  begin
  application.MessageBox('密码错误','用户审核',0);
  maskedit1.SetFocus;
  end
  else
  begin
  close();
  Frmmain.update;
  end;
  end;
end;

procedure TLoginForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
application.Terminate;
end;

end.

⌨️ 快捷键说明

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