📄 gmlogin.pas
字号:
unit GMlogin;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, Db, DBTables;
type
TLogin = class(TForm)
security: TTable;
Label1: TLabel;
Label2: TLabel;
mUserName: TEdit;
mPassword: TEdit;
OKButton: TBitBtn;
CancelButton: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
procedure OKButtonClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Login: TLogin;
digit:Integer;
Flag:integer;
implementation
uses GMMSmain;
{$R *.DFM}
procedure TLogin.FormCreate(Sender: TObject);
begin
digit:=1; {次数初值为1,标志位初值为0}
Flag:=0;
end;
procedure TLogin.CancelButtonClick(Sender: TObject);
begin
ModalResult:=mrAll;
Close;
MainForm.Close;
end;
procedure TLogin.OKButtonClick(Sender: TObject);
var
cmUserName,cmPassword:String[10];
tmpPassword:String[10];
tmpUnRight:String[200];
tmpComment:String[2];
begin
cmUserName:=mUserName.Text;
cmPassword:=mPassword.Text;
security.Open;
security.SetKey;
security.FieldByName('UserName').AsString:=cmUserName;
if security.GotoKey then
begin
tmpPassword:=security.FieldByName('Password').AsString;
tmpUnRight:=security.FieldByName('UnRight').AsString;
tmpComment:=security.FieldByName('Comment').AsString;
if (tmpPassword=cmPassword) and (length(tmpPassword)=length(cmPassWord)) then
begin
gmUserName:=cmUserName;
gmPassword:=tmpPassword;
gmUnRight:=tmpUnRight;
gmComment:=tmpComment;
security.Close;
ModalResult:=mrAll;
Flag:=1; {标志位置1为有效用户}
Close;
end
else
begin
Application.MessageBox('密码不对!','系统登录',mb_OK+mb_ICONQUESTION);
digit:=digit+1;
if digit>3 then
begin
ModalResult:=mrAll;
security.Close;
Close;
MainForm.Close;
end;
security.Close;
ModalResult:=0;
end;
end
else
begin
Application.MessageBox('没有这个用户!','系统登录',mb_OK+mb_ICONQUESTION);
digit:=digit+1;
if digit>3 then
begin
ModalResult:=mrAll;
security.Close;
Close;
MainForm.Close;
end;
security.Close;
ModalResult:=0;
end;
end;
procedure TLogin.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if flag=0 then mainform.Close ;{标志位为0时,则关闭主窗体}
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -