?? unitloginform.~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 + -