📄 login.pas
字号:
unit Login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls;
type
TLoginForm = class(TForm)
Image1: TImage;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
ComboBox1: TComboBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
LoginForm: TLoginForm;
UseId,Types,Passwd:String;
BackPasswd,BackTypes:String;
implementation
uses Data, Main;
{$R *.dfm}
procedure TLoginForm.Button1Click(Sender: TObject);
begin
UseId := Edit1.Text;
Passwd := Edit2.Text;
Types := ComboBox1.Text;
if UseId='' then //登录证号为空
begin
Application.MessageBox('请输入登录证号','登录错误信息',MB_OK+MB_ICONEXCLAMATION);
end
else
begin
with Data.DataModule.LoginSelect do
if Types='管理员' then
begin
Close;
SQL.Clear;
SQL.Add('select 工作编号,密码,管理员类型 from 管理员');
SQL.Add('where 工作编号 = ''' + UseId + ''' and 密码 = ''' + Passwd +'''');
Open;
BackPasswd := FieldByName('密码').AsString;
BackTypes := FieldByName('管理员类型').AsString;
if BackTypes='' then //未在数据库中找到对应记录
begin
Application.MessageBox('无效的登录证号或密码!请确认无误后再输入','登录错误信息',MB_OK+MB_ICONEXCLAMATION);
end
else
begin
MainForm.Show;
LoginForm.Hide;
end
end
else if Types='借阅者' then
begin
Close;
SQL.Clear;
SQL.Add('select 读者证号,密码,读者类型 from 读者');
SQL.Add('where 读者证号 = ''' + UseId + ''' and 密码 = ''' + Passwd +'''');
Open;
BackPasswd := FieldByName('密码').AsString;
BackTypes := FieldByName('读者类型').AsString;
if BackTypes='' then //未在数据库中找到对应记录
begin
Application.MessageBox('无效的登录证号或密码!请确认无误后再输入','登录错误信息',MB_OK+MB_ICONEXCLAMATION);
end
else
begin
BackTypes := '110';
MainForm.Show;
LoginForm.Hide;
end
end
end;
LoginForm.Edit1.Clear;
LoginForm.Edit2.Clear;
end;
procedure TLoginForm.Button2Click(Sender: TObject);
begin
LoginForm.Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -