【文件属性】:
文件名称:PB 刷新datawindow当前行的数据
文件大小:8KB
文件格式:SRF
更新时间:2013-09-08 07:37:56
PB 刷新 datawindow 当前行的数据
当数据存在主次表时,当更新了次表数据后,主表数据在后台有更变时。可利用刷新主表当前行的方法重显主表数据。
/************************************************************
函数名称: f_refresh_currentrow(adw)
功 能: 刷新DW当前行数据,不可刷新NO update or 带arguments的DW
参数说明: adw 目标DW
返 回 值: integer 成功返回1,失败返回-1
作 者: sean
创建时间: 2010年8月18日
************************************************************/
string ls_dataobject
string ls_keys[] //key Column Name
string ls_dbname[] //key field Name
string ls_coltype[] //field style
string ls_tablenm //table name
string ls_condition //sql Condition
long ll_currentrow //Current Row numeric
long ll_column //Column count
integer i
datawindow ldw
datastore ldatastore
ldw=adw
if ldw.rowcount( )=0 then
return -1
elseif trim(ldw.describe( "datawindow.table.arguments"))<>'?' then
messagebox('','刷新数据窗口当前行失败!,数据窗口需要参数',exclamation!)
return -1
else
ll_currentrow=ldw.getrow( )
FOR ll_column = 1 TO long(ldw.object.datawindow.column.count)//key names
If ldw.Describe("#"+string(ll_column)+".key") ='yes' Then
i++
ls_keys[i]=ldw.Describe("#"+string(ll_column)+".name")
ls_dbname[i]=ldw.Describe("#"+string(ll_column)+".dbname")
ls_coltype[i]=ldw.Describe("#"+string(ll_column)+".coltype")
End If
NEXT
if upperbound(ls_keys[])=0 then
messagebox('','刷新数据窗口当前行失败!,没有主键',exclamation!)
return -1
else
ls_tablenm=left(ls_dbname[1],pos(ls_dbname[1],'.') -1) //table name
for i=1 to upperbound(ls_keys[])
if pos('numb,deci,long,',LeftA(ls_coltype[i],4) +',')>0 then
ls_condition+="and "+ls_dbname[i]+"="+string(f_getitem(ldw,ll_currentrow,ls_keys[i]))
else
ls_condition+="and "+ls_dbname[i]+"='"+string(f_getitem(ldw,ll_currentrow,ls_keys[i]))+"'"
end if
next
ls_condition=mid(ls_condition,4) //sql Condition
ldatastore=create datastore
ldatastore.dataobject=ldw.dataobject
ldatastore.settransobject( sqlca)
if f_addwhere_retrieve(ldatastore,ls_condition)=1 then
if ldatastore.rowcount( )=1 then
ldw.object.data[ll_currentrow]=ldatastore.object.data[1]
ldw.setitemstatus( ll_currentrow, 0, primary!, NotModified!)
//if ldw.getrow( )<>ll_currentrow then ldw.scrolltorow( ll_currentrow)
end if
else
messagebox('','刷新数据窗口当前行失败!,条件语法错误',exclamation!)
return -1
end if
destroy ldatastore
end if
end if