Delphi中,登陆之后怎样显示主界面?
代码如下unitUnit1;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Contro...
代码如下
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, Buttons, jpeg, ExtCtrls;
type
Tlogin = class(TForm)
Image1: TImage;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
Edit1: TEdit;
Edit2: TEdit;
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure plogin;
private
{ Private declarations }
public
{ Public declarations }
end;
var
login: Tlogin;
m:integer = 0;
s:boolean = false;
czy:string;
implementation
{$R *.dfm}
procedure Tlogin.SpeedButton2Click(Sender: TObject);
begin
if messagebox(self.Handle,'真的要退出系统吗?','学生缴费管理系统',mb_yesno+mb_iconquestion)=idyes then
application.Terminate;
end;
procedure Tlogin.plogin;
begin
with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select * from 登录信息 where username = :a and password = :b');
parameters.ParamByName('a').Value:=trim(edit1.Text);
parameters.ParamByName('b').Value:=trim(edit2.Text);
open;
end;
if ADOQuery1.RecordCount>0 then
begin
czy:=ADOQuery1.FieldByName('username').Value;
s:=true;
close;
end
else
if m<3 then
begin
application.MessageBox('用户名或密码错误,请重新输入!','提示',64);
edit1.Clear;
edit2.Clear;
edit1.SetFocus;
end
else
begin
application.MessageBox('您无权使用本系统!','提示',64);
Application.Terminate;
end
end;
procedure Tlogin.SpeedButton1Click(Sender: TObject);
begin
m:=m+1;
if edit1.Text='' then
application.MessageBox('请输入用户名','提示',64)
else
if edit2.Text='' then
application.MessageBox('请输入密码','提示',64)
else
plogin;
end;
end.
现在代码实现的是,输入用户名密码,关闭登陆界面,不显示主界面。有没有高手指点一下 展开
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, Buttons, jpeg, ExtCtrls;
type
Tlogin = class(TForm)
Image1: TImage;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
Edit1: TEdit;
Edit2: TEdit;
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure plogin;
private
{ Private declarations }
public
{ Public declarations }
end;
var
login: Tlogin;
m:integer = 0;
s:boolean = false;
czy:string;
implementation
{$R *.dfm}
procedure Tlogin.SpeedButton2Click(Sender: TObject);
begin
if messagebox(self.Handle,'真的要退出系统吗?','学生缴费管理系统',mb_yesno+mb_iconquestion)=idyes then
application.Terminate;
end;
procedure Tlogin.plogin;
begin
with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select * from 登录信息 where username = :a and password = :b');
parameters.ParamByName('a').Value:=trim(edit1.Text);
parameters.ParamByName('b').Value:=trim(edit2.Text);
open;
end;
if ADOQuery1.RecordCount>0 then
begin
czy:=ADOQuery1.FieldByName('username').Value;
s:=true;
close;
end
else
if m<3 then
begin
application.MessageBox('用户名或密码错误,请重新输入!','提示',64);
edit1.Clear;
edit2.Clear;
edit1.SetFocus;
end
else
begin
application.MessageBox('您无权使用本系统!','提示',64);
Application.Terminate;
end
end;
procedure Tlogin.SpeedButton1Click(Sender: TObject);
begin
m:=m+1;
if edit1.Text='' then
application.MessageBox('请输入用户名','提示',64)
else
if edit2.Text='' then
application.MessageBox('请输入密码','提示',64)
else
plogin;
end;
end.
现在代码实现的是,输入用户名密码,关闭登陆界面,不显示主界面。有没有高手指点一下 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询