📄 userlog.~pas
字号:
unit UserLog;
interface
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,Messages,
Buttons,Registry, ExtCtrls, Db, DBTables, jpeg, Grids, DBGrids, ADODB;
type
TFrmUserLog = class(TForm)
Label1: TLabel;
edtPassword: TEdit;
Label2: TLabel;
BitOK: TBitBtn;
BitCancel: TBitBtn;
Bevel1: TBevel;
CombUserName: TComboBox;
Image1: TImage;
Image2: TImage;
Query1: TADOQuery;
Label3: TLabel;
procedure BitOKClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure BitCancelClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure edtPasswordKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure CombUserNameKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
iInputPass:integer;
// qx_SiteDir,qx_SiteOpt,qx_JinkuDir,qx_JinkuOpt,qx_DengJi,qx_BoxGL,qx_DataComm,qx_UsersOpt:String[2];
// qx_JinkuDir,qx_JinkuOpt,qx_BoxGL,qx_DataComm:String[2];
public
{ Public declarations }
PassOK:Boolean;
end;
var
FrmUserLog: TFrmUserLog;
implementation
//uses fsDE_DataModule;
//uses uEditClose;
{$R *.DFM}
procedure TFrmUserLog.BitOKClick(Sender: TObject);
var
Str1,StrKL:string;
i:integer;
begin
if (trim(CombUserName.text) = '') and (trim(edtPassword.text) = '') then
begin
iInputPass:=0;
ModalResult := mrCancel;
close;
end;
if ((trim(CombUserName.text) = '123') and (trim(edtPassword.text) = '123')) then
begin
PassOK:=true;
modalresult:=mrOK;
// qx_UsersOpt:=true;
// FrmKuContrl.LabUser.Caption:='超级用户';
exit;
end;
if iInputPass >= 3 then
begin
application.MessageBox('对不起,口令输入超过三次,无权进入!','提 示 信 息 ',MB_OKCANCEL);
iInputPass:=0;
ModalResult := mrCancel;
close;
end;
{
with Query1 do
begin
close;
SQL.Clear;
SQL.add('select UserName,XingMing,UserPass ,LastTime from UsersB where UserName='''+CombUserName.Text+''' '); // and DW='''+strDW+'''
Open;
end;
if Query1.RecordCount > 0 then
begin
Str1:=Query1.FieldByName('UserPass').AsString;
StrKL:=Str1 ;
for i:=1 to Length(Str1) do
StrKL[i]:=Chr(Ord(Str1[i]) xor Ord('Y') xor ord('X') xor ord('M') );
end
else
begin
application.MessageBox('对不起,无其操作用户!','提 示 信 息 ',MB_OK);
exit;
end;
if (Str1 = '1111') then
begin
PassOK:=true;
UserName:=Query1.FieldByName('UserName').AsString;
// qx_SiteDir:='0';
// qx_SiteOpt:='0';
qx_JinkuDir:=false;
qx_JinKuDir:=false;
// qx_DengJi:=false;
// qx_BoxGL:=false;
qx_DataComm:=false;
// qx_UsersOpt:='0';
application.MessageBox('请登录后立即修改个人密码,然后重新登录!','提 示 信 息 ',MB_OK);
modalresult:=mrOK;
exit;
end;
if trim(edtPassword.text) <> StrKL then
begin
Beep;
application.MessageBox('对不起,口令输入错误,请重新输入!','提 示 信 息 ',MB_OKCANCEL);
edtPassword.Text:='';
edtPassword.SetFocus;
iInputPass:=iInputPass + 1;
end
else
begin
with query1 do
begin
XingMing:=FieldByName('XingMing').AsString;
// qx_SiteDir:=FieldByName('qx_SiteDir').AsString;
// qx_SiteOpt:=FieldByName('qx_SiteOpt').AsString;
// qx_JinkuDir:=FieldByName('qx_JinkuDir').AsBoolean;//.AsString;
// qx_JinKuDir:=FieldByName('qx_JinkuDir').AsBoolean;
qx_DengJi:=true;//FieldByName('qx_DengJi').AsString;
// qx_BoxGL:=FieldByName('qx_BoxGL').AsBoolean;
// qx_DataComm:=FieldByName('qx_DataComm').AsBoolean;
qx_UsersOpt:=true;//FieldByName('qx_UsersOpt').AsString;
Edit;
FieldByName('LastTime').AsDateTime:=now;
post;
Close;
end;
UserName:=CombUserName.Text;
// FrmKuContrl.LabUser.Caption:=UserName;
// FrmKuContrl.LabXingMing.Caption:=XingMing;
// FrmKuContrl.LabLastTime.Caption:=DateTimeToStr(now);
iInputPass:=0;
PassOK:=true;
modalresult:=mrOK;
end;
}
end;
procedure TFrmUserLog.FormActivate(Sender: TObject);
begin
PassOK:=false;
iInPutPass:= 0;
edtPassword.text:='';
CombUserName.SetFocus;
end;
procedure TFrmUserLog.BitCancelClick(Sender: TObject);
begin
iInputPass:=0;
ModalResult := mrCancel;
close;
end;
procedure TFrmUserLog.FormDestroy(Sender: TObject);
begin
Query1.Close;
end;
procedure TFrmUserLog.FormShow(Sender: TObject);
begin
{ with Query1 do
begin
Close;
SQL.Clear;
SQL.Add('select UserBH,Pass from UsersB where DW='''+strDW+'''');
Open;
end;
if Query1.RecordCount > 0 then
begin
Query1.First;
while not Query1.Eof do
begin
CombUserName.Items.Add(Query1.FieldByName('UserName').asstring);
Query1.Next;
end;
end
else
PassOK:=true;
}
end;
procedure TFrmUserLog.edtPasswordKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (edtPassword.Text <> '') and (Key=13) then
BitOK.SetFocus;
end;
procedure TFrmUserLog.CombUserNameKeyPress(Sender: TObject; var Key: Char);
begin
if (Key=#13) and (CombUserName.Text <> '') then
// edtPassword.SetFocus;
begin
Key:=#0;
perform(WM_NEXTDLGCTL,0,0);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -