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

📄 login.~pas

📁 人事管理系统 具备了很强的功能 你看了就知道!
💻 ~PAS
字号:
unit login;

interface

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

type
  TF_login = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    i_server_add: TComboBox;
    i_user: TEdit;
    i_passwd: TEdit;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  F_login: TF_login;
  Inifile:TInifile;
implementation

uses DataModule, crypt, mainwin;

{$R *.DFM}

procedure TF_login.Button1Click(Sender: TObject);
var
  passwd, passwrd:String;
begin
  application.CreateForm(TDataModule1,DataModule1);
  With DataModule1 do
  begin
    Database.Connected:=False;
    Database.AliasName:=i_server_add.Text;
    Database.Connected:=True;
    T_user.Filter:='ID='''+i_user.Text+'''';
    T_user.Filtered:=True;
    T_user.Open;
    if T_user.RecordCount=1 then
    begin
      passwd:=i_passwd.Text;
      if length(passwd)>5 then
      begin
        passwd:=Copy(passwd+passwd,1,10);//统一密码长度
        passwd:=Encrypt(passwd,123);//加密
      end;
      passwrd:=T_user['PASSWD'];
      if (passwrd=passwd) and (T_user['AUTHORITY']='3') then
        begin
          F_main.login:=True;
        end
      else
       Application.MessageBox('请重新输入密码。'+#13+'注意大小写!','密码错误',MB_OK);
    end
    else
      Application.MessageBox('请确认用户名大小写是否正确!','无此用户',MB_OK);
    T_user.Close;
  end;
  if F_main.login then F_login.Close
   else DataModule1.Free;
end;

procedure TF_login.FormShow(Sender: TObject);
begin
    self.i_server_add.SetFocus;
end;

procedure TF_login.FormCreate(Sender: TObject);
begin
  Inifile:=TInifile.Create(extractfilepath(paramstr(0))+'SERVER.ini') ;
  if fileexists(extractfilepath(paramstr(0))+'SERVER.ini') then
     begin
     i_server_add.Text:=inifile.ReadString('SERVER','SERVER NAME','');
     i_user.Text:=inifile.ReadString('SERVER','USER NAME','');
     end;
end;

procedure TF_login.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if not fileexists(extractfilepath(paramstr(0))+'SERVER.ini') then
    Inifile:=TInifile.Create(extractfilepath(paramstr(0))+'SERVER.ini') ;
    inifile.WriteString('SERVER','SERVER NAME',i_server_add.Text);
    inifile.WriteString('SERVER','USER NAME',i_user.Text);
    inifile.Free;
end;

end.

⌨️ 快捷键说明

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