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;
問題是這樣的:
我輸入正確的用戶和密碼可進去系統,但是我輸入不正確的用戶,它就立即退出系統,不知為什麼?
,請各位幫我幫看一下是什麼原因,謝謝
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;
問題是這樣的:
我輸入正確的用戶和密碼可進去系統,但是我輸入不正確的用戶,它就立即退出系統,不知為什麼?
,請各位幫我幫看一下是什麼原因,謝謝