一、生成treeview
C# code
this.setredraw( false)
nvo_datastore mydtx,mydtx2
nvo_loginqx myqx
datastore mydt,mydt2
long tvlever1,tvlever2
mydt = mydtx.f_getdatastore( "select menuname,menutext from menuright where len(menuname) = 3" )
mydt.settransobject(sqlca)
mydt.retrieve( )
int i,m
treeviewitem tvitem,tvitem2
for i = 1 to mydt.rowcount( )
tvitem.label = mydt.getitemstring(i,"menutext")
tvitem.data = mydt.getitemstring(i,"menuname")
tvitem.statepictureindex = 2
tvlever1 = this.insertitemlast( 0,tvitem)
mydt2 = mydtx.f_getdatastore( "select menutext,menutag from menuright where len(menuname)>3 and left(menuname,3) ='"+ tvitem.data+"'")
mydt2.settransobject(sqlca)
mydt2.retrieve( )
for m = 1 to mydt2.rowcount()
tvitem2.label = mydt2.getitemstring(m,"menutext")
tvitem2.data = mydt2.getitemstring(m,"menutag")
tvitem2.statepictureindex = 1
this.insertitemlast(tvlever1,tvitem2)
next
this.expandall( tvlever1)
next
mydtx.f_destroydatastore( )
mydtx2.f_destroydatastore( )
this.setredraw( true)
二、点击权限组时,选择相对应的权限
1、无清空权限
C# codetreeviewitem tvi
long ll_tvi,ll_tvi2
ll_tvi = this.FindItem(RootTreeItem!, 0)
do while ll_tvi >0
ll_tvi2 = this.finditem(childtreeitem!,ll_tvi)
do while ll_tvi2>0
this.getitem(ll_tvi2,tvi)
tvi.statepictureindex = 1
this.setitem(ll_tvi2,tvi)
ll_tvi2 = this.finditem(nexttreeitem!,ll_tvi2)
loop
ll_tvi = this.finditem(nexttreeitem!,ll_tvi)
loop
2、生成权限
C# code
nvo_loginqx myqx
rightcode = myqx.f_pub_transdata_to_code( rightcode)
treeviewitem tvi
long ll_tvi,ll_tvi2
ll_tvi = this.FindItem(RootTreeItem!, 0)
do while ll_tvi >0
ll_tvi2 = this.finditem(childtreeitem!,ll_tvi)
do while ll_tvi2>0
this.getitem(ll_tvi2,tvi)
if myqx.f_pub_checkqx( tvi.data,rightcode) then
tvi.statepictureindex = 2
this.setitem(ll_tvi2,tvi)
end if
ll_tvi2 = this.finditem(nexttreeitem!,ll_tvi2)
loop
ll_tvi = this.finditem(nexttreeitem!,ll_tvi)
loop
三、保存权限
C# code
nvo_loginqx myqx
string rightcode
rightcode = fill('0',80)
treeviewitem tvi
long ll_tvi,ll_tvi2
ll_tvi = this.FindItem(RootTreeItem!, 0)
do while ll_tvi >0
ll_tvi2 = this.finditem(childtreeitem!,ll_tvi)
do while ll_tvi2>0
this.getitem(ll_tvi2,tvi)
if tvi.statepictureindex = 2 then rightcode = replace(rightcode,integer(tvi.data),1,'1')
ll_tvi2 = this.finditem(nexttreeitem!,ll_tvi2)
loop
ll_tvi = this.finditem(nexttreeitem!,ll_tvi)
loop
return myqx.f_pub_transdata_to_string( rightcode)
|