📄 login.~pas
字号:
unit Login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, DB, ADODB;
type
TLoginFrm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
ComboBox1: TComboBox;
Edit1: TEdit;
ComboBox2: TComboBox;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
ADOTable1: TADOTable;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
UserName,UserPassWd,UserPower: String;
var
LoginFrm: TLoginFrm;
implementation
uses MainDinner, MainRoom, MainSail, Admin, MainCheck;
{$R *.dfm}
procedure TLoginFrm.BitBtn2Click(Sender: TObject);
begin
ComboBox1.Text:= '';
Edit1.Text:= '';
ComboBox2.Text:= '';
ComboBox1.SetFocus;
end;
procedure TLoginFrm.BitBtn1Click(Sender: TObject);
begin
if (ComboBox1.Text = '') or (Edit1.Text = '') or (ComboBox2.Text = '') then
begin
ShowMessage('数据不能为空,请重新输入!');
ComboBox1.Text:= '';
Edit1.Text:= '';
ComboBox2.Text:= '';
ComboBox1.SetFocus;
end
else
begin
ADOTable1.First;
while not ADOTable1.Eof do
begin
if ADOTable1.FindField('用户名').AsString <> ComboBox1.Text then
ADOTable1.Next
else
begin
//密码正确的情况
if ADOTable1.FieldValues['密码'] = Edit1.Text then
begin
//权限正确的情况,不同权限进入不同界面
if ADOTable1.FieldValues['权限'] = ComboBox2.Text then
begin
//记录登陆的用户名,密码,权限
UserName:= ComboBox1.Text;
UserPassWd:= Edit1.Text;
UserPower:= ComboBox2.Text;
//验证语句
//ShowMessage(UserName);
//ShowMessage(UserPassWd);
//ShowMessage(UserPower);
if UserPower = '管理员' then
//进入管理员界面
begin
AdminFrm.Show;
end;
if UserPower = '餐饮员工' then
MainDinnerFrm.Show;
if UserPower = '客房员工' then
MainRoomFrm.Show;
if UserPower = '销售分析员工' then
MainSailFrm.Show;
if UserPower = '收银员工' then
MainCheckFrm.Show;
ShowMessage('欢迎进入本系统!');
Exit;
ComboBox1.Text:= '';
Edit1.Text:= '';
ComboBox2.Text:= '';
ComboBox1.SetFocus;
end
else
//权限错误的情况
begin
ShowMessage('输入权限错误,请重新输入!');
ComboBox2.Text:= '';
ComboBox2.SetFocus;
end;
end
else
//密码错误的情况
// begin
//判断输入3次的情况
// n: =0;
// n:= n+1;
// While n >= 3 do //
// begin //
// ShowMessage('您已经3次输入密码!'); //
// Close; //
// end; //
ShowMessage('输入密码错误!请重新输入');
Edit1.Text:= '';
ComboBox2.Text:= '';
Edit1.SetFocus;
Exit;
end;
end;
end;
//如果到了记录尾,表明不存在此纪录
if ADOTable1.Eof then
begin
ShowMessage('用户名不存在!请重新输入!');
ComboBox1.Text:= '';
Edit1.Text:= '';
ComboBox2.Text:= '';
ComboBox1.SetFocus;
end;
end;
procedure TLoginFrm.FormShow(Sender: TObject);
//var
//n: Integer;
begin
//n:= 0;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -