grid部分字段实时显示新录入记录,当录入第二条时卡死,重新连接数据源方式返回所有字段,数据全串了……
表单中带有grid,选了必要的几个字段实时更新grid显示,grid在添加新记录之前通过几层set filter to 筛选小范围的记录共浏览,添加一条新的记录后根据序号通过索引排序到正确的位置,以筛选条件及新增记录一同显示,添加第一条记录速度还可以,【确认】后当添加第二条记录时慢的几乎卡死,代码如下:请大师指点……第一个文本框的两个事件主要是过滤筛选
第一个文本框text1(事件1:gotfocus)
sele b_dagl
set filter to
set order to dahpxmlh
go top
第一个文本框text1(事件2:losFocus)
public wm_xm,wm_dah
wm_dah=this.value
mll="dah='"+wm_dah+"'"
sele b_dagl
set order to ptdah &&普通索引档案号
seek wm_dah
if found()
store dah to thisform.c1.txtdah.value
store sfzh to thisform.c1.txtsfzh.value
store xm to thisform.c1.txtxm.value
wm_xm=xm
store xb to thisform.c1.txtxb.value
store csrq to thisform.c1.txtcsrq.value
store jg to thisform.c1.Txtjg.value
store mz to thisform.c1.Txtmz.value
store zb to thisform.c1.Txtzb.value
store zt to thisform.c1.Txtzt.value
store dwmc to thisform.c1.Txtdwmc.value
store zxbz to thisform.c1.Txtzxbz.value
set filter to &mll
set order to dahpxmlh
count to clfs
sum ys to clys
store "姓名:"+wm_xm+" "+ "材料份数:"+allt(str(clfs))+" " +"材料页数:"+allt(str(clys)) to thisform.caption
go top
thisform.
else
messagebox('该档案信息未录入,不能补充材料',0+16,"错误信息")
("enabled",.f.)
retu
endif
THISFORM.REFRESH
【确认】(事件:click)
thisform.grid1.recordsource =null
SELE b_dagl
do case
case wbsw=1 &&添加按钮赋值wbsw=1
count to jls &&统计筛选类别后记录数
go bott &&指向记录尾
jsq=len(rtrim(pxmlh)) &&删除了字符表达式后续空格后,返回结果字符串长度
mlh_zdfs=val(subs(pxmlh,jsq-2,3)) &&取出最大份
set order to dahpxmlh
seek alltrim(thisform.c1.txtdah.value)+thisform.c1.txtpxmlh.value
if found()
if jls = mlh_zdfs &&判断最大份数是否与该类别记录数相等
blpxmlh1=subs(pxmlh,1,jsq-3) &&取出需要补录的大类别,带空格排序目录号pxmlh
blyjmlh = alltrim(subs(blpxmlh1,1,3))+alltrim(subs(blpxmlh1,4,7)) &&取出移交大类别,不带空格正常目录号zcmlh
mlh_fs=val(subs(pxmlh,jsq-2,3)) &&取出当前记录取出第几份 取表单第几份也可以
go bott
do while .not. bof() .and. thisform.c1.txtdah.value = dah .and. blpxmlh1=subs(pxmlh,1,jsq-3) .and. val(subs(pxmlh,jsq-2,3))>=mlh_fs
blpxmlh2=str(val(subs(pxmlh,jsq-2,3))+1,3) &&目录末位 第几份资料顺序加1
repl next 1 yjmlh with blyjmlh+alltrim(blpxmlh2),pxmlh with blpxmlh1+blpxmlh2,gjsy with alltrim(dah)+"-"+blyjmlh+alltrim(blpxmlh2)+'-'+alltrim(str(ys))
skip -1
enddo
insert into b_dagl (dah,xm,xb,mz,csrq,sfzh,zb,jg,dwmc,zt,pxmlh,yjmlh,clmc,clrq,ys,bz,gjsy,lry,lrrq);
values (thisform.c1.txtdah.value,THISFORM.C1.txtxm.VALUE,THISFORM.C1.txtxb.VALUE,THISFORM.C1.Txtmz.VALUE,THISFORM.C1.txtcsrq.VALUE,;
THISFORM.C1.txtsfzh.VALUE,thisform.c1.Txtzb.value,thisform.c1.Txtjg.value,thisform.c1.Txtdwmc.value,thisform.c1.Txtzt.value,;
THISFORM.C1.txtpxmlh.VALUE,THISFORM.C1.txtyjmlh.VALUE,THISFORM.C1.txtclmc.value,THISFORM.C1.txtclrq.VALUE,val(THISFORM.C1.txtys.VALUE),;
THISFORM.C1.txtbz.VALUE,THISFORM.C1.txtgjsy.VALUE,THISFORM.C1.txtlry.VALUE,;THISFORM.C1.txtlrrq.VALUE)
else
=messagebox('该档案目录未录入完整,不能补充目录,请到档案目录管理中[添加]补充完整!',0+64,'提示信息')
("enabled",.f.)
retu
endif
else
if jls+1=val(thisform.c1.txtdnf.value)
insert into b_dagl (dah,xm,xb,mz,csrq,sfzh,zb,jg,dwmc,zt,pxmlh,yjmlh,clmc,clrq,ys,bz,gjsy,lry,lrrq);
values (thisform.c1.txtdah.value,THISFORM.C1.txtxm.VALUE,THISFORM.C1.txtxb.VALUE,THISFORM.C1.Txtmz.VALUE,THISFORM.C1.txtcsrq.VALUE,;
THISFORM.C1.txtsfzh.VALUE,thisform.c1.Txtzb.value,thisform.c1.Txtjg.value,thisform.c1.Txtdwmc.value,thisform.c1.Txtzt.value,;
THISFORM.C1.txtpxmlh.VALUE,THISFORM.C1.txtyjmlh.VALUE,THISFORM.C1.txtclmc.value,;THISFORM.C1.txtclrq.VALUE,;
val(THISFORM.C1.txtys.VALUE),THISFORM.C1.txtbz.VALUE,THISFORM.C1.txtgjsy.VALUE,THISFORM.C1.txtlry.VALUE,THISFORM.C1.txtlrrq.VALUE)
else
=messagebox('该档案目录无需补充,请确认“整理”后到档案目录管理中[添加]!',0+64,'提示信息')
("enabled",.f.)
retu
endif
endif
count to clfs
sum ys to clys
store "姓名:"+wm_xm+" "+"材料份数:"+allt(str(clfs))+" "+"材料页数:"+allt(str(clys)) to thisform.caption
go top
thisform.grid1.recordsource = "b_dagl" &&返回所有的字段,与标题不对应,原本grid只是选了几个字段供浏览,无法返回与标题对应的字段值。
THISFORM.GRID1.Refresh()
=messagebox("档案信息补充成功",0+64,"系统提示")
endcase
[此贴子已经被作者于2022-5-24 14:36编辑过]