📄 unit2.pas
字号:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, StdCtrls, ExtCtrls;
type
Tloginform = class(TForm)
Image1: TImage;
GroupBox1: TGroupBox;
LabelTishi: TLabel;
Labelyonghu: TLabel;
Edituser: TEdit;
Labelpassword: TLabel;
Editpassword: TEdit;
Buttonok: TButton;
ButtonCancel: TButton;
Tableyonghu: TTable;
procedure ButtonokClick(Sender: TObject);
procedure ButtonCancelClick(Sender: TObject);
procedure TableyonghuBeforeOpen(DataSet: TDataSet);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
loginform: Tloginform;
TimeID:integer;
quanxian:string;
implementation
uses Unit3;
{$R *.dfm}
procedure Tloginform.ButtonokClick(Sender: TObject);
begin
TimeID:=TimeID+1;
tableyonghu.Open;
tableyonghu.SetKey;
tableyonghu.FieldByName('yonghu').AsString:=edituser.Text;
tableyonghu.GotoKey;
if(edituser.Text=tableyonghu.FieldByName('yonghu').AsString)and
(editpassword.Text=tableyonghu.FieldByName('kouling').AsString)
then
begin
Modalresult:=mrok;
quanxian:=tableyonghu.fieldbyname('quanxian').AsString;
end
else
begin
if TimeID>3 then
begin
application.Terminate;
end
else if edituser.Text<>tableyonghu.FieldByName('yonghu').AsString
then
begin
application.MessageBox('非法用户,请你输入正确的用户名!','用户名',
MB_ok+MB_ICONEXCLAMATION);
edituser.SetFocus;
end
else
begin
application.MessageBox('输入密码错误,请你再输入一次','密码',
MB_ok+MB_ICONEXCLAMATION);
editpassword.SetFocus;
end;
end;
if quanxian='administra' then
{};
if quanxian='student' then
begin
frmmain.N2.Enabled:=false;
frmmain.d21.Enabled:=false;
frmmain.N6.Enabled:=false;
frmmain.N7.Enabled:=false;
frmmain.N8.Enabled:=false;
frmmain.xi1.Enabled:=false;
end;
end;
procedure Tloginform.ButtonCancelClick(Sender: TObject);
begin
application.Terminate;
end;
procedure Tloginform.TableyonghuBeforeOpen(DataSet: TDataSet);
begin
Session.AddPassword('1234');
end;
procedure Tloginform.FormShow(Sender: TObject);
begin
timeid:=0;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -