unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, ExtCtrls;
type
Tlogin = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
ADOConnection1: TADOConnection;
Button3: TButton;
ADOTable1: TADOTable;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
login: Tlogin;
username,password:string;
number:integer;
qx:boolean;
implementation
uses unit2,unit3;
{$R *.dfm}
procedure Tlogin.Button1Click(Sender: TObject);
var
pass:string;
right:Boolean;
begin
username:=edit1.Text;
pass:=edit2.Text;
right:=false;
qx:=false;
adotable1.Open;
//判断用户名是否为空
if username<>'' then
begin
adotable1.First;
while not adotable1.Eof do
begin
if adotable1.FieldByName('用户名').AsString =username then
begin
right:=true;
if adotable1.FieldByName('密码').AsString=pass then
begin
password:=pass;
right:=true;
if adotable1.FieldByName('权限').AsString='系统管理员' then
begin
qx:=true;
right:=true;
main.gly.Visible:=true;
main.dy.Visible:=false;
main.tj.Visible:=true;
main.Label6.Caption:='管理员';
main.Label1.Visible:=false;
main.Show;
login.Hide;
end
else
begin
main.gly.Visible:=false;
main.dy.Visible:=true;
main.tj.Visible:=true;
main.Label6.Caption:='客户';
main.Label1.Visible:=false;
number:=adotable1.FieldByName('用户编号').AsInteger;
main.Show;
login.Hide;
end;
end
else
begin
application.MessageBox('密码输入错误,请重新输入!','密码错误',0);
edit2.Text:='';
edit2.SetFocus;
end;
end;
adotable1.Next;
end;
if right=false then
begin
if application.MessageBox('该用户名不存在,是否以此身份登录?','登录提示',1)=1 then
begin
main.gly.Visible:=false;
main.dy.Visible:=false;
main.tj.Visible:=false;
main.Label6.Caption:='游客';
main.Label1.Visible:=true;
main.Show;
login.Hide;
end;
end;
end
else
begin
application.MessageBox('用户名不能为空!','提示',0);
edit1.SetFocus;
end;
end;
procedure Tlogin.Button2Click(Sender: TObject);
begin
showmessage('谢谢使用本报刊订阅系统!');
close;
end;
procedure Tlogin.FormCreate(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
end;
procedure Tlogin.Button3Click(Sender: TObject);
begin
login.Hide;
regester.Show;
end;
end.