下面这种方法好像不行,在我这里总是提示下面这具有错误:if EntryFrm.ShowModal=mrOK then⑴让登录窗体在主窗体运行前打开,
⑵根据登录窗体返回值判断主窗体是否应该运行。
详细代码如下://project.dpr文件program project;
... ...
... ...begin
Application.Initialize;
EntryFrm:=TEntryFrm.Create(application); //登录窗口
if EntryFrm.ShowModal=mrOK then //登录窗体关闭时返回了mrOK值,说明登录成功
begin
Application.CreateForm(TMainFrm, MainFrm);
//其它auto-create forms
end;
EntryFrm.Free;
application.Terminate
Application.Title := '某某管理系统';
Application.Run;
end. //entry.pas 登录窗体文件
var
count:short; //登录次数{$R *.dfm}procedure TEntryFrm.BitBtn2Click(Sender: TObject);//取消登录
begin
application.Terminate;
end;procedure TEntryFrm.BitBtn1Click(Sender: TObject);//确定登录
begin
Inc(count);
ID:=edit1.Text; //帐号
Pas:=edit2.Text; //密码;ID,Pas是全局变量
//※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※//
IDInfo.Open;
if IDInfo.Locate('ID',ID,[]) then
begin
if StrEncry(IDInfo.FieldByName('Pas').AsString)=Pas then //密码解密,登录成功
begin
Pop:=IDInfo.fieldbyname('Pop').AsString; //取得权限
writelog(ID,'登录'); //写入日志
self.ModalResult:=mrOK; //关闭窗口并返回mrOK值
end;
end;
if count>=3 then self.ModalResult:=mrabort; //只允许登录3次
IDInfo.Close;
//※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※//
edit1.Text:='';
edit2.Text:='';
edit1.SetFocus;
end;
⑵根据登录窗体返回值判断主窗体是否应该运行。
详细代码如下://project.dpr文件program project;
... ...
... ...begin
Application.Initialize;
EntryFrm:=TEntryFrm.Create(application); //登录窗口
if EntryFrm.ShowModal=mrOK then //登录窗体关闭时返回了mrOK值,说明登录成功
begin
Application.CreateForm(TMainFrm, MainFrm);
//其它auto-create forms
end;
EntryFrm.Free;
application.Terminate
Application.Title := '某某管理系统';
Application.Run;
end. //entry.pas 登录窗体文件
var
count:short; //登录次数{$R *.dfm}procedure TEntryFrm.BitBtn2Click(Sender: TObject);//取消登录
begin
application.Terminate;
end;procedure TEntryFrm.BitBtn1Click(Sender: TObject);//确定登录
begin
Inc(count);
ID:=edit1.Text; //帐号
Pas:=edit2.Text; //密码;ID,Pas是全局变量
//※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※//
IDInfo.Open;
if IDInfo.Locate('ID',ID,[]) then
begin
if StrEncry(IDInfo.FieldByName('Pas').AsString)=Pas then //密码解密,登录成功
begin
Pop:=IDInfo.fieldbyname('Pop').AsString; //取得权限
writelog(ID,'登录'); //写入日志
self.ModalResult:=mrOK; //关闭窗口并返回mrOK值
end;
end;
if count>=3 then self.ModalResult:=mrabort; //只允许登录3次
IDInfo.Close;
//※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※//
edit1.Text:='';
edit2.Text:='';
edit1.SetFocus;
end;
解决方案 »
- 如何将MDI子窗体置于上层
- 我现在知道,一个窗口有句柄,与标题名,我想实现软件里,当这个窗口显示之前,能否把它屏蔽了.
- 拖放操作问题
- 最后sos,我的treeview生成结点时有错,请帮助修改一下
- 这个算法怎么做?(建筑)
- 请问关于D7里面重新安装正式版的INTRAWEB为什么会有问题??
- 如何把Access数据库集成一个exe文件?
- 在MDI主窗体中改变(动态创建)子窗体的控件属性出错
- 来者有分帮我看一下吧!所有程序我都己写好运行也对,运行后当我在EDIT中输入相应中文字段名后,在点增加按钮就下面这种情况谢谢帮忙!
- TDatetime为Float型,谁知道年、月、日、时、分、秒在Float中是如何表示的?
- 如何在Delphi中实现连续打印。
- InstallShield Professional 6.22安装密码是什么?
var
pw,edtpasswd:String;
begin
if Trim(edtuse.Text)='' then
begin
showmessage('用戶名不能為空﹗');
exit;
end;if Trim(edtpw.Text)='' then
begin
showmessage('密碼不能為空﹗');
exit;
end;useid:=Trim(edtuse.Text);dm.adoc.connected:=false;
dm.aqquery.Close;
dm.aqquery.SQL.Clear;
dm.aqquery.SQL.Add(' select count(*) as num ,useid,passwd,useqx from useinfor where useid='''+Trim(edtuse.Text)+''' group by useid,passwd,useqx ');
dm.aqquery.Open;if (dm.aqquery.FieldValues['num']<=0) then
begin
showMessage('系統中沒用該用戶﹗');
exit;
end;
pw:= Trim(dm.aqquery.FieldValues['passwd']);
edtpasswd:=Trim(edtpw.Text);
useqx:= Trim(dm.aqquery.FieldValues['useqx']);if not (edtpasswd=pw) then
begin
showmessage('密碼不正確﹗');
exit;
end;fmlogin.Visible:=false;
Application.CreateForm(Tfmmain, fmmain) ;
fmmain.ShowModal;
fmmain.Release;
BitBtn1.Enabled:=false;end;
begin
Application.CreateForm(Tfrmmain, frmmain);
Application.Run;
end
else begin
application.run;
application.Terminate;
end;
---------------------------------------------
以上写在工程文件内
____________________________________
procedure Tfrmlogin.qdClick(Sender: TObject);/////////////确定登陆按钮单击事件
begin
with dm.cxq2 do
begin
close;
sql.Clear;
sql.Add('select * from PSWord where PSW_NAME='''+nl.Text+'''');
open;
if recordcount=1 then
begin
czy:=nl.Text;
qx:=fieldbyname('psw_qx').AsString;
if trim(fieldbyname('PSW_PSword').asstring)=trim(pass.Text) then
begin
ModalResult := IdOk;
end;
end;
end;
end;
if Show_FormLogin then
begin
Application.CreateForm(Tfrmmain, frmmain);
Application.Run;
end
else begin
application.run;
application.Terminate;
end;