📄 login.pas
字号:
unit login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
Tfrmlogin = class(TForm)
Label1: TLabel;
Label2: TLabel;
ComboBox1: TComboBox;
Edit1: TEdit;
btnyes: TBitBtn;
btnno: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure btnyesClick(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
//procedure btnnoClick(Sender: TObject);
private
times:integer;
{ Private declarations }
public
{ Public declarations }
end;
var
frmlogin: Tfrmlogin;
implementation
uses datarsgl, mainform;
{$R *.dfm}
procedure Tfrmlogin.FormCreate(Sender: TObject);
begin
times:=1;
with dmrsgl.userqry do
begin
if not active then //判断是否为活动连接
active:=true;
first;
while not eof do
begin
combobox1.Items.Add(fieldbyname('name').AsString);
next; //下移动符值
end;
end;
end;
procedure Tfrmlogin.btnyesClick(Sender: TObject);
var findstring:string;
begin
with dmrsgl.userqry do
begin
close;
sql.Clear;
findstring:='select * from usertb where name='+quotedstr(combobox1.Text)+'and password='+quotedstr(edit1.Text);
sql.Add(findstring);
open;
if recordcount<>0 then
begin //符值给其它变量
identify:=fieldbyname('identify').AsString;
pubuser:=fieldbyname('name').AsString;
modalresult:=mrok;
end
else if times<3 then
begin
application.MessageBox('密码错误,请重试!','错误',mb_ok+mb_iconerror);
edit1.Text:='';
edit1.SetFocus;
times:=times+1;
end
else //QUIT SYSTEM
begin
application.MessageBox('密码重试次数过多,请与管理员联系!','错误',mb_ok+mb_iconerror);
application.Terminate;
end
end;
end;
procedure Tfrmlogin.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
selectnext(activecontrol,true,true);
key:=#0;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -