在表单的 Load 事件中添加以下代码:
sele 1
use database\车辆档案 exclusive
sele 2
use database\驾驶员档案
sele 3
use database\车辆类型表
public nof,l
store .f. to nof,l
set delete on
在表单的Unload 事件中添加以下代码:
close all
use database\车辆档案 exclusive &&以独占方式打开数据表
set exact off
delete from车辆档案 where 车牌号码="NoNumber"
set exact on
close all
在“备注”编辑框的KeyPress 事件中添加以下代码:
if nkeycode=24
thisform.commandgroup1.command5.setfocus &&Command5获得焦点
endif
if nkeycode=5
thisform.container1.text11.setfocus
endif
在“购置日期”文本框的KeyPress事件中添加以下代码:
IF NKEYCODE=18 or NKEYCODE=3
thisform.datalist.visible=.T. &&显示Datalist控件
thisform.datalist.setfocus
ENDIF
在“购置日期”文本框后面“6”按钮的Click 事件中添加以下代码:
thisform.datalist.visible=.t.
在“首记录”按钮的Click 事件中添加以下代码:
if bof()=.f.
go top &&记录指针移动到第一条记录
thisform.commandgroup1.command3.enabled=.T.
thisform.commandgroup1.command4.enabled=.T.
thisform.Container1.label16.caption= alltrim(str(recno()))
thisform.init &&调用表单的Init事件
endif
thisform.commandgroup1.command1.enabled=.f.
thisform.commandgroup1.command2.enabled=.f.
thisform.refresh
在“上一条”按钮的Click 事件中添加以下代码:
if bof()=.f.
skip -1 &&记录指针向上移动一条记录
thisform.commandgroup1.command3.enabled=.T.
thisform.commandgroup1.command4.enabled=.T.
thisform.Container1.label16.caption= alltrim(str(recno()))
thisform.init &&执行表单的Init事件
else
thisform.commandgroup1.command1.enabled=.f.
thisform.commandgroup1.command2.enabled=.f.
endif
thisform.refresh
在“下一条”按钮的Click 事件中添加以下代码:
skip 1 &&记录本指针向下移动一条记录
if eof()=.f.
thisform.commandgroup1.command1.enabled=.t.
thisform.commandgroup1.command2.enabled=.t.
thisform.Container1.label16.caption= alltrim(str(recno()))
thisform.init &&执行表单的Init事件
else
skip -1
thisform.commandgroup1.command3.enabled=.f.
thisform.commandgroup1.command4.enabled=.f.
endif
thisform.refresh
在“末记录”按钮的Click事件中添加以下代码:
if eof()=.f.
go bottom &&记录指针移动到最后一条记录
thisform.commandgroup1.command1.enabled=.T.
thisform.commandgroup1.command2.enabled=.T.
thisform.Container1.label16.caption= alltrim(str(recno()))
thisform.init &&执行表单的Init事件
endif
thisform.commandgroup1.command3.enabled=.f.
thisform.commandgroup1.command4.enabled=.f.
thisform.refresh
单击“添加”按钮,如果按钮上的标题文本为“添加”,则在“车辆档案”表中追加一条新记录,并将 “NoNumber” 赋于 “车牌号码”字段用来避免出现两条空记录使索引字段出错。然后清空表单上所有相关控件的内容,做好接收用户输入信息的准备,并设置按钮的标题文本为“保存”;如果为“保存”,则将用户输入的信息保存到“车辆档案”表中,并设置按钮的标题文本为“添加”。具体代码如下:
在“添加”按钮的Click 事件中添加以下代码:
sele 1
if thisform.commandgroup1.command5.caption="添加"
append blank &&追加空记录
repl 车辆档案.车牌号码 with "NoNumber"+alltrim(str(reccount()))
thisform.refresh &&刷新表单
thisform.Commandgroup1.command5.caption="保存" &&赋值给Command5的标题文本
thisform.Commandgroup1.command5.tooltiptext="保存记录" &&显示工具提示文本
l=.t.
thisform.resize &&执行表单的Resize事件
thisform.container1.container2.command1.enabled=.t.
store .f. to thisform.commandgroup1.command1.enabled,thisform.commandgroup1.;
command2.enabled,thisform.commandgroup1.command3.enabled,thisform.;
commandgroup1.command4.enabled,thisform.commandgroup1.command6.enabled,;
thisform.commandgroup1.command7.enabled &&设置控件无效
thisform.commandgroup1.command8.enabled=.T.
store '' to thisform.Container1.textcph.value,thisform.Container1.textlx.value,;
thisform.Container1.text3.value,thisform.Container1.text4.value,;
thisform.Container1.text5.value,thisform.Container1.text6.value,;
若图片无法显示请联系QQ752018766,本论文免费,转发请注明源于www.751com.cn
else
if empty(alltrim(thisform.container1.textcph.value)) or empty(alltrim(thisform.;
container1.text3.value)) or empty(alltrim(thisform.container1.text10.value))
a=messagebox ("车牌号、驾驶员、使用单位或个人 不允许为空!" ,16,"错误")
else
nof=.f.
thisform.Commandgroup1.command5.caption="添加" &&赋值给Command5的标题文本
thisform.Commandgroup1.command5.tooltiptext="添加记录"
l=.f.
thisform.resize &&执行表单的Resize事件
thisform.container1.container2.command1.enabled=.f.
store .t. to thisform.commandgroup1.command1.enabled,thisform.commandgroup1.;
command2.enabled,thisform.commandgroup1.command3.enabled,thisform.;
commandgroup1.command4.enabled,thisform.commandgroup1.command7.enabled
store .f. to thisform.commandgroup1.command6.enabled,;
thisform.commandgroup1.command8.enabled
repl 车辆档案.车牌号码 with alltrim(thisform.Container1.textcph.value),车辆类型with ;
alltrim(thisform.Container1.textlx.value),驾驶员 with alltrim(thisform.Container1.;
text3.value),购置日期 with ctod(thisform.Container1.text4.value),发动机号 with ;
val(thisform.Container1.text5.value),车架号 with val(thisform.Container1.text6.value),;
厂牌型号 with trim(thisform.Container1.text7.value),载重 with val(thisform.;
container1.text8.value),坐位 with val(thisform.container1.text9.value),使用人或单位;
with trim(thisform.Container1.text10.value),车辆所在单位 with ;
trim(thisform.Container1.text11.value)
if thisform.Container1.check1.value=1
repl 车辆档案.年检审 with .t.
else
repl 车辆档案.年检审 with .f.
若图片无法显示请联系QQ752018766,本论文免费,转发请注明源于www.751com.cn
endif
endif
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] 下一页