procedure TFlogOn.btnLoginClick(Sender: TObject); begin if edtID.Text='' then begin Application.MessageBox('请输入用户ID','提示',MB_Ok+MB_IconInformation); edtID.SetFocus; edtPassWord.Text:=''; exit; end; if CanLogOn(edtID.Text,edtPassword.Text,mainform.conn) then begin ModalResult:=mryes end else begin LogNumber:=LogNumber+1; if LogNumber=3 then begin Application.MessageBox('对不起,你已经3次登陆失败,退出系统','提示',MB_Ok+MB_IconInformation); Application.Terminate; end; Application.MessageBox('用户不存在或密码错误.','提示',MB_Ok+MB_IconInformation); edtID.SelectAll; edtID.SetFocus; edtPassWord.Text:=''; end;end;
//限制用户使用时间。例:20秒
RunDateTime := now;
Form1.Caption := DateTimeToStr(now) + FloatToStr(RunDateTime - StartDateTime);
if (RunDateTime - StartDateTime) > 20.0 / (60 * 60 * 24){50.0 / (60 * 24) 50分钟} then
begin
Timer1.Enabled := false;
showmessage('time is over');
end StartDateTime := now;//得到起始时间
//*******************************************************************//
//设置截止时间
DateSeparator := '-';
ShortDateFormat := 'yyyy/mm/dd';
NowDate := Date;
EndDate := StrToDate('2001-08-07');
if NowDate > EndDate then
showmessage('date is over')
日期同理。
方法很多,这个最简单
begin
if edtID.Text='' then
begin
Application.MessageBox('请输入用户ID','提示',MB_Ok+MB_IconInformation);
edtID.SetFocus;
edtPassWord.Text:='';
exit;
end;
if CanLogOn(edtID.Text,edtPassword.Text,mainform.conn) then
begin
ModalResult:=mryes
end
else begin
LogNumber:=LogNumber+1;
if LogNumber=3 then
begin
Application.MessageBox('对不起,你已经3次登陆失败,退出系统','提示',MB_Ok+MB_IconInformation);
Application.Terminate;
end;
Application.MessageBox('用户不存在或密码错误.','提示',MB_Ok+MB_IconInformation);
edtID.SelectAll;
edtID.SetFocus;
edtPassWord.Text:='';
end;end;
呵呵。放到INI,保密行差,啊