📄 p_login.pas
字号:
unit p_login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB, jpeg, ExtCtrls;
type
TF_login = class(TForm)
userlogin: TADOQuery;
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
login: TButton;
bclose: TButton;
procedure loginClick(Sender: TObject);
procedure bcloseClick(Sender: TObject);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure plogin;
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
q:integer;
czy:string;
{ Public declarations }
end;
var
F_login: TF_login;
m:integer = 0;
s:boolean = false;
iStyle:Longint;
implementation
uses p_main;
{$R *.dfm}
procedure Tf_login.plogin;
begin
with userlogin do
begin
close;
sql.Clear;
sql.Add('select * from 管理员表 where 简称 = :a and 密码 = :b');
parameters.ParamByName('a').Value:=trim(edit1.Text);
parameters.ParamByName('b').Value:=trim(edit2.Text);
open;
end;
if userlogin.RecordCount>0 then
begin
czy:=userlogin.FieldByName('姓名').Value;
q:=userlogin.FieldByName('权限').Value;
s:=true;
f_main.StatusBar1.Panels[1].Text:=czy;
f_main.statusbar1.Panels[3].Text:=datetostr(date());
f_main.statusbar1.Panels[5].Text:=timetostr(time());
close;
end
else
if m<3 then
begin
application.MessageBox('用户名或密码错误,请重新输入!','提示',64);
edit1.Clear;
edit2.Clear;
edit1.SetFocus;
end
else
begin
application.MessageBox('您无权使用本系统!','提示',64);
Application.Terminate;
end;
end;
procedure TF_login.loginClick(Sender: TObject);
begin
m:=m+1;
if edit1.Text='' then
application.MessageBox('请输入用户名','提示',64)
else
if edit2.Text='' then
application.MessageBox('请输入密码','提示',64)
else
plogin;
end;
procedure TF_login.bcloseClick(Sender: TObject);
begin
if s=false then
application.Terminate
else
close;
end;
procedure TF_login.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if (Key=#13) and (Edit1.Text<>'') and (Edit2.Text<>'') then
login.Click;
end;
procedure TF_login.FormShow(Sender: TObject);
begin
iStyle:=setwindowlong(handle,gwl_style,getwindowlong(handle,gwl_style) and not ws_minimizebox and not ws_maximizebox and not ws_sysmenu);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -