关于关闭登陆检查的问题 |
答題得分者是:timhuang
|
leqan
一般會員 ![]() ![]() 發表:19 回覆:15 積分:6 註冊:2003-05-30 發送簡訊給我 |
有个朋友帮我修改的代码如下: unit Unit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, abcpanel, abcbar; type
Tmain = class(TForm)
abcButtonBar1: TabcButtonBar;
abcButtonPage1: TabcButtonPage;
abcButtonPage2: TabcButtonPage;
abcButtonPage3: TabcButtonPage;
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
main: Tmain; implementation uses Unit2; {$R *.dfm} procedure Tmain.FormShow(Sender: TObject);
begin
login.ShowModal;
end; end. unit Unit2; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls; type
Tlogin = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
login: Tlogin; implementation uses Unit1, Unit3; {$R *.dfm} procedure Tlogin.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Close;
DM.SQLDataSet1.CommandText:='select * from user where no=''' Edit1.Text ''' and pass=''' Edit2.Text '''';
DM.SQLDataSet1.ExecSQL;
if DM.SQLDataSet1.RecordCount<>1 then
main.Close
end; 在关闭登陆窗口的时候为什么要这样?有其他办法吗? procedure Tlogin.Button2Click(Sender: TObject);
begin
close;
main.Close;
end; procedure Tlogin.Button1Click(Sender: TObject);
begin
DM.SQLDataSet1.CommandText:='select * from user where no=''' Edit1.Text ''' and pass=''' Edit2.Text '''';
DM.SQLDataSet1.ExecSQL;
if DM.SQLDataSet1.RecordCount=1 then
Close
else
ShowMessage('无法通过验证,请检查号码和密码...');
end; end. unit Unit3; interface uses
SysUtils, Classes, DBXpress, FMTBcd, DBClient, Provider, DB, SqlExpr; type
TDM = class(TDataModule)
SQLConnection1: TSQLConnection;
SQLDataSet1: TSQLDataSet;
private
{ Private declarations }
public
{ Public declarations }
end; var
DM: TDM; implementation {$R *.dfm} end. 發表人 - leqan 於 2003/07/19 14:43:54 發表人 - leqan 於 2003/07/19 14:45:22 發表人 - leqan 於 2003/07/19 14:46:28
|
timhuang
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:78 回覆:1815 積分:1608 註冊:2002-07-15 發送簡訊給我 |
在 login 的 form 在 close 檢查登入是否完成是為了避免使用者自行關閉 login 的 form 而避開了登入檢查. 所以他在 login 的 form 中的 onclose 再行檢查一次! 但要注意的地方是這個程式中使用了 select 的 sql command, 該 dataset 必須使用 dataset.open 而不是 dataset.execsql , 記得要改一下, 否則會有問題的!!
|
leqan
一般會員 ![]() ![]() 發表:19 回覆:15 積分:6 註冊:2003-05-30 發送簡訊給我 |
引言: 在 login 的 form 在 close 檢查登入是否完成是為了避免使用者自行關閉 login 的 form 而避開了登入檢查. 所以他在 login 的 form 中的 onclose 再行檢查一次! 但要注意的地方是這個程式中使用了 select 的 sql command, 該 dataset 必須使用 dataset.open 而不是 dataset.execsql , 記得要改一下, 否則會有問題的!! |
timhuang
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:78 回覆:1815 積分:1608 註冊:2002-07-15 發送簡訊給我 |
|
leqan
一般會員 ![]() ![]() 發表:19 回覆:15 積分:6 註冊:2003-05-30 發送簡訊給我 |
|
timhuang
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:78 回覆:1815 積分:1608 註冊:2002-07-15 發送簡訊給我 |
|
leqan
一般會員 ![]() ![]() 發表:19 回覆:15 積分:6 註冊:2003-05-30 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |