📄 unitlogin.pas
字号:
unit UnitLogin;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, dbtables,db, RXCtrls;
type
TfrmLogin = class(TForm)
Panel1: TPanel;
Bevel1: TBevel;
Image1: TImage;
Label4: TLabel;
lblRy: TLabel;
lblKl: TLabel;
Label3: TLabel;
edtry: TEdit;
edtkl: TEdit;
BitBtnOk: TBitBtn;
BitBtnCancel: TBitBtn;
RxLabel1: TRxLabel;
procedure BitBtnOkClick(Sender: TObject);
procedure BitBtnCancelClick(Sender: TObject);
procedure edtryKeyPress(Sender: TObject; var Key: Char);
procedure edtklKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmLogin: TfrmLogin;
y_total:integer;
implementation
uses UnitMain, UnitDm;
{$R *.dfm}
procedure TfrmLogin.BitBtnOkClick(Sender: TObject);
var
pwd:string;
begin
if edtry.text='' then //操作员不能为空
begin
application.MessageBox('注意:库管员不能为空!','提示',mb_ok+mb_iconinformation);
edtry.SetFocus;
exit;
end;
if edtkl.text='' then //口令不能为空
begin
application.MessageBox('注意:系统口令不能为空!','提示',mb_ok+mb_iconinformation);
edtkl.SetFocus;
exit;
end;
if edtry.text='onion' then //超级用户登录; onion
begin //pw=月*10+日*3+9+年
pwd:=inttostr(strtoint(formatdatetime('mm',now))+10)+inttostr(strtoint(formatdatetime('dd',now))*3)
+'9'+copy(formatdatetime('yyyy',now),4,1);
if edtkl.text<>pwd then
begin
if y_total=3 then
begin
showMessage('对不起,您不能使用本系统!');
bitbtnCancel.OnClick(Sender);
exit;
end;
showMessage('对不起,系统口令错误,请重新输入!');
edtkl.Text:='';
y_total:=y_total+1;
edtkl.setfocus;
exit;
end else
begin
self.Close;
if not Assigned(frmMain) then
begin
Application.CreateForm(TfrmMain, frmMain);
end;
frmMain.StatusBar1.Panels[3].Text:='操作员:'+edtry.text;//人员
end;
end else //如果不是onion时
begin
with dm.qry_StockUser do
begin
Close;
SQL.Clear;
SQL.Add('select * from StockUser ');
open;
end;
if not dm.qry_StockUser.Locate('Oper_name;Oper_pw',vararrayof([edtry.Text,edtkl.text]),[loPartialKey]) then
begin
if y_total=3 then
begin
application.MessageBox('对不起,您不能使用本系统!','警告',mb_ok+mb_iconwarning);
bitbtnCancel.OnClick(Sender);
application.Terminate;
end;
if dm.qry_StockUser.Locate('Oper_name',edtry.Text,[loPartialKey]) then
begin
application.MessageBox('对不起,系统口令错误,请重新输入!','警告',mb_ok+mb_iconwarning);
edtkl.Text:='';
edtkl.setfocus;
end else
begin
application.MessageBox('对不起,库管员错误,请重新输入!','警告',mb_ok+mb_iconwarning);
edtry.setfocus;
end;
y_total:=y_total+1;
exit;
end else
begin
self.Close;
if not Assigned(frmMain) then
begin
Application.CreateForm(TfrmMain, frmMain);
frmmain.StrOperat:=edtry.text;//人员
frmmain.statusbar1.Panels[3].text:='操作员:'+edtry.text;
end;
// frmMain.StatusBar1.Panels[1].Text:='目前库管员:'+query1.FieldByName('库管员').asstring+' '+sfyxm;//人员
end;
end;
end;
procedure TfrmLogin.BitBtnCancelClick(Sender: TObject);
begin
close;
end;
procedure TfrmLogin.edtryKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
key:=#0;
perform(cm_dialogkey,vk_tab,0);
end;
end;
procedure TfrmLogin.edtklKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
key:=#0;
bitbtnOk.SetFocus;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -