有關登錄問題??(30分)

  • 主题发起人 jesse.zhou
  • 开始时间
J

jesse.zhou

Unregistered / Unconfirmed
GUEST, unregistred user!
工程文件:
Application.Initialize;
Application.CreateForm(TM_data, M_data); //數據model
Face_form:=Tface_form.Create(application); //建立封面
face_form.Show;
face_form.Update;
T1:=GetTickcount;
while (GettickCount-T1)<2000 do;
face_form.Close;
face_form.Free;
Pass_form:=TPass_form.Create(application);//建立登錄窗口
Pass_form.ShowModal;
if loged then
begin

Application.CreateForm(TMail_Form, Mail_Form);
Application.CreateForm(Tfrmfin, frmfin);
Application.CreateForm(Tfrm_fout, frm_fout);
Application.CreateForm(Tfrm_fwuname, frm_fwuname);
Application.CreateForm(Tfrmin, frmin);
Application.CreateForm(Tfrmwuname, frmwuname);
Application.CreateForm(Tfrmout, frmout);
Application.CreateForm(Tfrmstore, frmstore);
Application.CreateForm(Tfrmwu, frmwu);
Pass_form.Close;
Pass_form.Free;
Application.Run;
end
else
begin
Pass_form.Close;
Application.Run;
end;
登錄窗口代碼如下:
var
Pass_Form: TPass_Form;
loged:boolean;
vcount:integer;
implementation

uses Data_Unit, Main_Unit;

{$R *.dfm}

procedure TPass_Form.FormCreate(Sender: TObject);
begin
vcount:=0;
end;

procedure TPass_Form.SeSkinButton1Click(Sender: TObject);
var i:integer;
begin
inc(vcount);
try
with M_data.adopass do
begin
close;
sql.Clear;
sql.Add('select userno,username,userlever from useid where userno=:userno and username=:username');
parameters.ParamByName('userno').Value:=edit1.Text;
parameters.ParamByName('username').Value:=edit2.Text;
prepared;
open;
end;
if M_data.adopass.RecordCount<1 then
begin
if vcount>=3 then
begin
messagedlg('對不起,閣下無權使用本系統,請退出!',mterror,[mbok],0);
application.Terminate;
end
else
begin
messagedlg('輸入用戶名或密碼錯誤,請重輸入!',mterror,[mbok],0);
edit1.SetFocus;

end;
end
else
begin
loged:=true;
for i:=1 to 15 do //設置權限
// vlist:=copy(trim(data.adopass.fieldbyname('userlever').asstring),i,1);
end;
except
ON E:exception do
begin
messagedlg('連接錯誤,與管理員聯系.'+#13#10+'錯誤提示:'+e.Message,mterror,[mbok],0);
abort;
end;
end;
問題是這樣的:
我輸入正確的用戶和密碼可進去系統,但是我輸入不正確的用戶,它就立即退出系統,不知為什麼?
,請各位幫我幫看一下是什麼原因,謝謝


 
messagedlg('對不起,閣下無權使用本系統,請退出!',mterror,[mbok],0);
application.Terminate;

你使用了application.Terminate;系统当然会退出了。你可以将application.Terminate;换成
exit;试试
 
我程序設置想三次輸入錯誤就退出系統,可是程序第一次輸入錯誤用戶就退出系統,不知為什麼?
希望各位能幫我???,我很急??
 
跟踪到那一句出去的,看看
 
if vcount>=3 then
begin
messagedlg('對不起,閣下無權使用本系統,請退出!',mterror,[mbok],0);
application.Terminate;
end
把下面那句
application.Terminate; 取掉就可以了。
 
你的SeSkinButton1按钮是否为TBitBtn类,如果是的话,把它的
Kind属性设置成 bkCustom,千万不能为 bkOK 这样窗口就直接关闭了
 
其实你可以在主form的onpaint属性时才运行logon窗口
 
你們的方法我都試過 cztwf你好:SeSkinButton1按钮是为TBitBtn类,Kind属性设置成 bkCustom
如果把resultmodel不設置為mrok則輸入正確的用戶都不能進去.
nathnalee:你好,在主form的onpaint中才運行logon,請問怎樣調用?
 
你的问题在这里:
project1的

Pass_form.ShowModal;
应该是
while vcount<=3 do
pass_form.showmodal;

然后在你的pass_form的这里
loged:=true;
之前加上vcount:=100
方法笨点可是解决问题

问题是你的okbtn点了一会以后都会结束showmodle
所以就会退出了。
发分吧

 
另外
application.Terminate;
这一局确实可以去掉!
 
顶部