首页 技术 正文
技术 2022年11月16日
0 收藏 863 点赞 3,772 浏览 2320 个字

这个是我在2002年做的一个VFP程序中实现的方法, 现在看来功能和VFP8,9中的CursorAdapter非常相似, 因为属性设置有许多相同的地方,我甚至怀疑CA就是就是在这样的基础上再包装出来的类.

以下是程序:

与数据库的连接:

nConnectHandle = sqlstringconnect(“DRIVER=SQL Server;SERVER=” + cDbServer + ;
  “;UID=” + cUserName + ;
  “;PWD=” + cPassword + ;
  “;DATABASE=” + cDatabaseName)
 if nConnectHandle > 0 && 与服务器连接成功

endif

表单的init中:

local cSQLcommand

this.lockscreen = .f.

cSQLcommand = “select department.bmdm, department.bmmc, company.dwmc, department.dwxtbh, department.xtbh ” + ;
 “from department, company where department.dwxtbh = company.xtbh order by company.dwdm, department.bmdm”
do while sqlexec(nConnectHandle, cSQLcommand, ‘department’) = 0 && 远程操作
enddo
= cursorsetprop(‘SendUpdates’, .t., ‘department’)
= cursorsetprop(‘Tables’, ‘dbo.department’, ‘department’)
= cursorsetprop(‘UpdatableFieldList’, ‘bmdm, bmmc, dwxtbh’, ‘department’)
= cursorsetprop(‘UpdateNameList’, ‘bmdm dbo.department.bmdm, bmmc dbo.department.bmmc, dwxtbh dbo.department.dwxtbh, xtbh dbo.department.xtbh’, ‘department’)
= cursorsetprop(‘KeyFieldList’, ‘xtbh’, ‘department’)
with this.grid1
 .columncount = -1
 .recordsource = ‘department’
 .recordsourcetype = 1
 .columns(1).header1.caption = ‘部门代码’
 .columns(2).header1.caption = ‘部门名称’
 .columns(3).header1.caption = ‘单位名称’
 .columns(4).header1.caption = ‘单位系统编号’
 .columns(5).header1.caption = ‘系统编号’
 .SetAll(“DynamicBackColor”,”IIF(MOD(RECNO(‘department’),2)=0,RGB(255,255,255),RGB(230,230,255))”,”Column”) &&交替显示白色和蓝色的记录
endwith

this.lockscreen = .f.

添加click:

local lResult, cBmmc

insert into department(bmdm, bmmc, dwxtbh) values(”, ”, 0)
do form d_bmkp to lResult
select department
if lResult
 if tableupdate(.t., .f., ‘department’)
  cBmmc = department.bmmc
  wait ‘添加成功’ window nowait
  thisform.opentable()
  select department
  locate all for bmmc = cBmmc
  thisform.grid1.refresh
 else
  = tablerevert(.t., ‘department’)
  wait ‘添加失败’ window nowait
 endif
else
 = tablerevert(.t., ‘department’)
endif

编辑click:

local lResult, cBmmc

do form d_bmkp to lResult
select department
if lResult
 if tableupdate(.t., .f., ‘department’)
  cBmmc = department.bmmc
  wait ‘编辑成功’ window nowait
  thisform.opentable()
  select department
  locate all for bmmc = cBmmc
  thisform.grid1.refresh
 else
  = tablerevert(.t., ‘department’)
  wait ‘编辑失败’ window nowait
 endif
else
 = tablerevert(.t., ‘department’)
endif

删除click:

if messagebox(‘你确认要删除吗?’, 4 + 32 + 256, ‘信息’) = 6 && YES
 delete in department
 if tableupdate(.t., .f., ‘department’)
  thisform.grid1.refresh
  wait ‘删除成功’ window nowait
 else
  = tablerevert(.t., ‘department’)
  wait ‘删除失败’ window nowait
 endif
endif

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,580
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918