事情很简单,我先定义了这么一个函数:function TFormUseField.IsTimeConflict(timeBegin,timeEnd:TDateTime):boolean;
begin
。
end;
然后调用的时候:beginTime:= DateTimePicker1.DateTime;
endTime:= DateTimePicker1.DateTime+(StrToFloat(Edit2.Text))/24.0; ///////////
if IsTimeConflict(beginTime,endTime)=true then
begin
ShowMessage('你启用的场地与预订有冲突!');
exit;
end;当我在Edit2中输入小数时,怎么也执行不过去!有如下几点不解:
1。当我在Edit2中输入整数的时候可以执行,但输入小数的时候就不行了。
2。我把加注释的那一句改为
endTime:= DateTimePicker1.DateTime+(StrToFloat('0.5'))/24.0;
这样却又可以执行!
3.我不改上面那一行,但不调用下面那个函数,也可以执行!我高不清楚怎么回事,写程序也几年了,只是没有用Delphi.
begin
。
end;
然后调用的时候:beginTime:= DateTimePicker1.DateTime;
endTime:= DateTimePicker1.DateTime+(StrToFloat(Edit2.Text))/24.0; ///////////
if IsTimeConflict(beginTime,endTime)=true then
begin
ShowMessage('你启用的场地与预订有冲突!');
exit;
end;当我在Edit2中输入小数时,怎么也执行不过去!有如下几点不解:
1。当我在Edit2中输入整数的时候可以执行,但输入小数的时候就不行了。
2。我把加注释的那一句改为
endTime:= DateTimePicker1.DateTime+(StrToFloat('0.5'))/24.0;
这样却又可以执行!
3.我不改上面那一行,但不调用下面那个函数,也可以执行!我高不清楚怎么回事,写程序也几年了,只是没有用Delphi.
解决方案 »
- delphi客户端如果显示服务器端的图片
- 招聘程序员,诚招
- 请问TreeView中如何根据路径打开指定节点
- 点form最大化按钮,然后再恢复,panel上的组件和StatusBar就看不到了,请教如何解决
- 谁有《运筹学算法与编程实践——Delphi实现》的源码?
- Delphi的帮助文档很不好用,不知各位有何好方法?
- 如何实时监控ie地址栏中的地址变化?大家给出个主意
- 有谁知道怎么让 RichEdit 里面的内容实现滚屏?
- 已经有80分了,我该怎么办 ,为什么我的专家分加不上
- 高分相送!关于ActiveX的事件问题??
- 怎么改变代码编辑器的'覆盖'状态?
- 关于BusinessSkinForm控件的问题~~~
var
Tmp:Extended;
begin
TMp:=StrToFloatDef(edit2.text,0);
if Tmp=0 then
showmessage('输入数据有误,请检查');
end;
function TFormUseField.IsTimeConflict(timeBegin,timeEnd:TDateTime):boolean;
begin
adoquery1.Close;
adoQuery1.sql.Clear;
//选出项目号和场地号相同并且开始时间比当前时间晚的记录
adoquery1.SQL.Add('select beginTime,endTime FROM fieldRecord where projectID=:ProjectID and fieldNum=:fieldNum and beginTime>:curTime');
ADOQuery1.Parameters.ParamByName('ProjectID').Value := ProjectID;
ADOQuery1.Parameters.ParamByName('fieldNum').Value := StrToInt(Edit2.Text);
ADOQuery1.Parameters.ParamByName('curTime').Value := Now;
adoQuery1.open;
while not adoQuery1.Eof do
begin
//如果 beginTime落在某个预订区间内
if (timeBegin>adoQuery1.FieldByName('beginTime').AsDateTime) and (timeBegin<adoQuery1.FieldByName('endTime').AsDateTime) then
begin
IsTimeConflict:=true;
exit;
end;
//如果 endTime落在某个预订区间内
if (timeEnd>adoQuery1.FieldByName('beginTime').Value) and (timeEnd<adoQuery1.FieldByName('endTime').Value) then
begin
IsTimeConflict:=true;
exit;
end;
end;
IsTimeConflict:=false;
end;
function TFormUseField.IsTimeConflict(timeBegin,timeEnd:TDateTime):boolean;
begin
adoquery1.Close;
adoQuery1.sql.Clear;
//选出项目号和场地号相同并且开始时间比当前时间晚的记录
adoquery1.SQL.Add('select beginTime,endTime FROM fieldRecord where projectID=:ProjectID and fieldNum=:fieldNum and beginTime>:curTime');
ADOQuery1.Parameters.ParamByName('ProjectID').Value := ProjectID;///看看清楚下面这一行
ADOQuery1.Parameters.ParamByName('fieldNum').Value := StrToInt(Edit2.Text);
///// ADOQuery1.Parameters.ParamByName('curTime').Value := Now;
adoQuery1.open;
while not adoQuery1.Eof do
begin
//如果 beginTime落在某个预订区间内
if (timeBegin>adoQuery1.FieldByName('beginTime').AsDateTime) and (timeBegin<adoQuery1.FieldByName('endTime').AsDateTime) then
begin
IsTimeConflict:=true;
exit;
end;
//如果 endTime落在某个预订区间内
if (timeEnd>adoQuery1.FieldByName('beginTime').Value) and (timeEnd<adoQuery1.FieldByName('endTime').Value) then
begin
IsTimeConflict:=true;
exit;
end;
end;
IsTimeConflict:=false;
end;