在vfp中,我们只要使用“表缓冲”,就可以将用户改得“面目全非”的表记录恢复至该表打开时的样子。详细用法见下:
设有一个名为liushu.dbf的表,将其添加到表单的数据环境中,并把buffermodeoverride设置为5(开放式表缓冲,可用命令实现:=CURSORSETPROP('Buffering',5,'liushu')&&启用表缓冲),然后在表单中添加一个grid控件,name=“grid1”,在表单的load事件中输入以下代码:
thisform.grid1.recordsource="liushu" &&将表的名称赋值给grid1的数据源
set multilocks on && 对于表缓冲必须为 on
在“关闭”按钮的click事件中输入以下代码:
select liushu &&选择liushu表
if getnextmodified(0) > 0 &&判断是否有记录被修改
lnchoice = messagebox("数据被修改,是否保存当前修改?", 3+32, "保存")
if lnchoice = 2 && 取消
return
endif
if lnchoice = 6 && 确定保存
=tableupdate(.t.) &&保存修改
else
=tablerevert(.t.) &&放弃修改
endif
endif
rele thisform
联系客服