📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ADODB;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
Label3: TLabel;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
UserType: string;
UserName: string;
DataFile: string;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
ADOQuery1: TADOQuery;
begin
{数据库操作:判断用户和密码是否正确}
if (edit1.Text<>'') and (edit2.Text<>'') then
begin
ADOQuery1:= TADOQuery.Create(self);
ADOQuery1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\zhang\data\zl.mdb;Persist Security Info=False';
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from master where mname="'+edit1.Text+'" and password="'+edit2.Text+'" ');
ADOQuery1.Open;
if (edit1.Text=ADOQuery1.FieldByName('mname').AsString) and (edit2.Text=ADOQuery1.FieldByName('password').AsString) then
begin
{用户和密码正确,登录成功,并获取用户的权限类型}
UserType := ADOQuery1.FieldByName('type').AsString;
UserName := ADOQuery1.FieldByName('mname').AsString;
ADOQuery1.Free;
Form1.Hide;
form2.ShowModal;
end
else
application.MessageBox('用户名或者密码错误,登录失败!','提示');
edit1.Text:='';
edit2.Text:='';
edit1.SetFocus;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit1.SetFocus;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
application.Terminate;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -