login.pas

来自「仲裁委仲裁案件计酬程序.有基础资料设置、分级设置」· PAS 代码 · 共 159 行

PAS
159
字号
unit Login;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, PropFilerEh, DB, ADODB, PropStorageEh, StdCtrls, Buttons,
  ExtCtrls,IniFiles, jpeg, Mask, TFlatButtonUnit, TFlatEditUnit;

Type
  TLoginFrm = class(TForm)
    Props: TPropStorageEh;
    PropIni: TIniPropStorageManEh;
    UserQry: TADOQuery;
    Image1: TImage;
    EUser: TEdit;
    BOK: TFlatButton;
    BQuit: TFlatButton;
    Label1: TLabel;
    Label2: TLabel;
    EPWD: TFlatEdit;
    procedure EUserKeyPress(Sender: TObject; var Key: Char);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure BOKClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure EPWDKeyPress(Sender: TObject; var Key: Char);
    procedure BQuitClick(Sender: TObject);
    procedure edtPasswordKeyPress(Sender: TObject; var Key: Char);
  private
  Function Login:Boolean;
    { Private declarations }
  public

    { Public declarations }
  end;

var
  LoginFrm: TLoginFrm;

implementation

{$R *.dfm}
Uses PubData,Link, MAIN,Pub,InterfaceDLLLoader, MyInterface;
Function TLoginFrm.Login:Boolean;
var
  dllInterface: IMyInterface;
Begin

Login:=True;
UserQry.Active:=False;
UserQry.Parameters.ParamValues['@Account']:=EUser.Text;
with TInterfaceDLLLoader.Create() do
begin
dllInterface := GetInterface();
UserQry.Parameters.ParamValues['@PWD']:=dllInterface.TransPassword(EPWD.Text);

DllInterface := nil;
Free(); //
end;

UserQry.Active:=True;
//PubData.SysUser:=EUser.Text;
//exit;
If UserQry.IsEmpty Then
Begin
  Login:=False;
  Application.MessageBox('请确认帐号和密码正确!','错误',MB_ICONINFORMATION);
  EPWD.SetFocus;
  EPWD.SelectAll
End
Else
Begin

PubData.SysUser:=EUser.Text;
End;
End;

procedure TLoginFrm.EUserKeyPress(Sender: TObject; var Key: Char);
begin
If key=#13 Then EPWD.SetFocus;
end;

procedure TLoginFrm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=CaFree;
end;

procedure TLoginFrm.FormShow(Sender: TObject);
begin
If FileExists(ExtractFilePath(Application.ExeName)+'\Login.ini') Then
Begin
PropIni.IniFileName:=ExtractFilePath(Application.ExeName)+'\Login.ini';
Props.Active:=True;
Props.LoadProperties;
End;
end;

procedure TLoginFrm.BOKClick(Sender: TObject);

begin
If Trim(EUser.Text)='' Then
Begin

  EUser.SetFocus;
  Exit;
End;
If Login=False Then
Exit
Else
Begin

  Self.ModalResult := mrOk;
  If Props.Active=false Then
  Begin
    Props.Active:=True;
    PropIni.IniFileName:=ExtractFilePath(Application.ExeName)+'\Login.ini';
  End;

  Props.SaveProperties;
  Props.Active:=false ;

End;
end;

procedure TLoginFrm.FormCreate(Sender: TObject);
begin

Pub.ShowBalloonTip(EUser, 1, '提示','请输入您的账号代码!', $00E8FFFF, clred);
Pub.ShowBalloonTip(EPWD, 1, '提示','请输入您的账号密码!', $00E8FFFF, clred);

end;

procedure TLoginFrm.EPWDKeyPress(Sender: TObject; var Key: Char);
begin
    if Key=#13 then begin
        Key := #0;
        BOK.Click;
    end;
end;

procedure TLoginFrm.BQuitClick(Sender: TObject);
begin
if Assigned(MainFrm) then
Close
Else
Application.Terminate;
end;

procedure TLoginFrm.edtPasswordKeyPress(Sender: TObject; var Key: Char);
begin
    if Key=#13 then begin
        Key := #0;
        BOK.Click;
    end;
end;

end.

⌨️ 快捷键说明

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