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

📄 unitloginform.~pas

📁 此代码是关于mapgis的在
💻 ~PAS
字号:
unit UnitLoginForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, bsSkinData, BusinessSkinForm, bsSkinCtrls, StdCtrls, Mask,
  bsSkinBoxCtrls, DB, ADODB;

type
  TPasswordEdit=class(TbsSkinEdit);
  
  TForm_Login = class(TForm)
    bsBusinessSkinForm1: TbsBusinessSkinForm;
    bsSkinData1: TbsSkinData;
    bsCompressedStoredSkin1: TbsCompressedStoredSkin;
    bsSkinButton2: TbsSkinButton;
    bsSkinButton4: TbsSkinButton;
    bsSkinPanel1: TbsSkinPanel;
    Label17: TLabel;
    Label18: TLabel;
    bsSkinEdit_Password: TbsSkinEdit;
    bsSkinComboBox_UserName: TbsSkinComboBox;
    procedure bsSkinButton4Click(Sender: TObject);
    procedure bsSkinButton2Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    FIsOk: Boolean;
    FConnection: TADOConnection;
    FResPersonID: Integer;
    { Private declarations }
    function CheckPassword(var ResPersonID:Integer):Boolean;
    procedure Init;
    procedure SetConnection(const Value: TADOConnection);
  public
    { Public declarations }
    property IsOk:Boolean read FIsOk;
    property Connection:TADOConnection read FConnection write SetConnection;
    property ResPersonID:Integer read FResPersonID;
  end;

var
  Form_Login: TForm_Login;

function ConnectToAccount(AccountConnection:TADOConnection;var PersonID:Integer;
  var UserName,Password:string):Boolean;

implementation

uses BusinessDialogs;

{$R *.dfm}

function ConnectToAccount(AccountConnection:TADOConnection;var PersonID:Integer;
  var UserName,Password:string):Boolean;
begin
  with TForm_Login.Create(Application) do
  begin
    try
      Connection:=AccountConnection;
      ShowModal;
      Result:=IsOk;
      if Result then
      begin
        UserName:=bsSkinComboBox_UserName.Text;
        Password:=bsSkinEdit_Password.Text;
        PersonID:=ResPersonID;
      end;
    finally
      Free;
    end;
  end;
end;

procedure TForm_Login.bsSkinButton4Click(Sender: TObject);
begin
  Close;
end;

procedure TForm_Login.bsSkinButton2Click(Sender: TObject);
begin
  if CheckPassword(FResPersonID)=False then
  begin
    MyInformation('提示信息','口令不正确!');
    Exit;
  end;
  FIsOk:=True;
  Close;
end;

procedure TForm_Login.FormShow(Sender: TObject);
begin
  FIsOk:=False;
end;

function TForm_Login.CheckPassword(var ResPersonID:Integer): Boolean;
begin
  with TADOQuery.Create(nil) do
  begin
    try
      Connection:=Self.FConnection;
      Close;
      SQL.Text:='select * from 用户表 where 用户名=:UserName and 密码=:Password';
      Parameters.ParamByName('UserName').Value:=bsSkinComboBox_UserName.Text;
      Parameters.ParamByName('Password').Value:=bsSkinEdit_Password.Text;
      Open;
      Result:=not Eof;
      ResPersonID:=FieldByName('员工号').AsInteger;
      Close;
    finally
      Free;
    end;
  end;
end;

procedure TForm_Login.Init;
begin
  bsSkinComboBox_UserName.Items.Clear;
  with TADOQuery.Create(nil) do
  begin
    try
      Connection:=Self.FConnection;
      Close;
      SQL.Text:='select * from 用户表';
      Open;
      while not Eof do
      begin
        bsSkinComboBox_UserName.Items.Add(FieldByName('用户名').Value);
        Next;
      end;
      Close;
    finally
      Free;
    end;
  end;
end;

procedure TForm_Login.SetConnection(const Value: TADOConnection);
begin
  FConnection := Value;
  if (FConnection<>nil)and(FConnection.Connected) then
  begin
    Init;
  end;
end;

procedure TForm_Login.FormCreate(Sender: TObject);
begin
  TPasswordEdit(bsSkinEdit_Password).PasswordChar:='*';
end;

end.

⌨️ 快捷键说明

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