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

📄 login.pas

📁 销售帐目管理
💻 PAS
字号:
unit Login;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, SUIForm, SUIButton, StdCtrls, SUIEdit, StdActns, ActnList,
  SUIDlg;

type
  TFrmLogin = class(TForm)
    suiForm1: TsuiForm;
    Image1: TImage;
    Label1: TLabel;
    suiEdit1: TsuiEdit;
    Label2: TLabel;
    suiEdit2: TsuiEdit;
    suiButton1: TsuiButton;
    suiButton2: TsuiButton;
    suiMessageDialog1: TsuiMessageDialog;
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure suiButton1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure suiButton2Click(Sender: TObject);
    procedure suiEdit2KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FrmLogin: TFrmLogin;
  PwdErrCs : integer;

implementation

uses pubunit, DataModule, Main;

{$R *.dfm}

procedure TFrmLogin.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then begin
     Key := #0;
     Perform(WM_NEXTDLGCTL,0,0);
  end;
end;

procedure TFrmLogin.suiButton1Click(Sender: TObject);
var username,password,PowerOptions,tmpstr : String;
    Count,i : integer;
    Label L_Exit;
begin
  username := Trim(suiEdit1.Text);
  Password := Trim(suiEdit2.Text);
  P_LoginUserName := UserName ;
  P_LoginPwd := password ;
  PowerOptions := '';
  with DataModule1.tbl_Power do begin
    if not Active then Active := true;
    First;
    while not Eof do begin
      if ((Trim(UpperCase(FieldByName('用户名').AsString))=username) and
          (Trim(UpperCase(FieldByName('密码').AsString))=password)) then begin
          PowerOptions := FieldByName('用户权限').AsString;
          LoginUser := FieldByName('用户名').AsString;
          Super := FieldByName('用户级别').AsInteger;
          break;
      end;
      Next;
    end;
  end;
  if PowerOptions = '' then
     if ((UpperCase(username)='ANGEL') and (UpperCase(Password)='HUNTER')) then
     begin
        LoginUser := 'SUPER';
        Super := 1;
     end
     else
     begin
        LoginUser := '';
        Inc(PwdErrCs);
        suiMessageDialog1.ButtonCount := 1;
        suiMessageDialog1.Button1Caption := '确定(&S)';
        suiMessageDialog1.Button1ModalResult := mrOK;
        suiMessageDialog1.Caption := '输入错误'+IntToStr(PwdErrCs)+'次(3次取消登录)!' ;
        suiMessageDialog1.IconType := suiStop;
        suiMessageDialog1.Text := '无效的用户名或密码!';
        suiMessageDialog1.ShowModal ;
        if PwdErrCs >= 3 then
           Goto L_Exit
        else
           Exit;
     end;

  //==========设置功能是否可用
  Count := FrmMain.ComponentCount ;
  for i := 0 to Count - 1 do begin
    if (FrmMain.Components[i] is TAction) then
       if (((FrmMain.Components[i] as TAction).Caption <> '用户注册') and
           ((FrmMain.Components[i] as TAction).Caption <> '退出系统')) then
          (FrmMain.Components[i] as TAction).Enabled := false;
  end;
  if PowerOptions = '' then
     for i := 0 to Count - 1 do begin
       if (FrmMain.Components[i] is TAction) then
          (FrmMain.Components[i] as TAction).Enabled := true;
     end
  else
     for i := 0 to Count - 1 do begin
       if (FrmMain.Components[i] is TAction) then
          if AnsiPos('['+(FrmMain.Components[i] as TAction).Caption+']',PowerOptions) > 0 then
             (FrmMain.Components[i] as TAction).Enabled := true;
     end;

L_Exit:
  Close;
end;

procedure TFrmLogin.FormShow(Sender: TObject);
begin
  PwdErrCs := 0;
  suiEdit1.SetFocus ;
end;

procedure TFrmLogin.suiButton2Click(Sender: TObject);
begin
  Close;
end;

procedure TFrmLogin.suiEdit2KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_RETURN then begin
     Key := $0;
     suiButton1.OnClick(self);
  end;
end;

procedure TFrmLogin.FormCreate(Sender: TObject);
begin
  ChangeInterface(Self,suiForm1);
end;

end.

⌨️ 快捷键说明

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