by ShumingWang » Wed Jul 31, 2019 1:41 am
obrow2:setTree(otree)
ocol:=obrow2:aCols[ 1 ]
ocol:cheader:="科目代码"
ocol:AddBitmap( { "tree1", "tree2", "treevh" } )
// ocol:cFooter := "GRAND TOTAL"
ocol:nEditType := {||if(::ledit,1,0)}
ocol:bEditValue := {||odb2:cquery:="select * from ac where acid='"+obrow2:oTreeItem:cPrompt+"'",odb2:refresh(),obrow2:oTreeItem:cPrompt}
// on chang ,to refresh other columns datas
oCol:bOnPostEdit := {|o, v, n|if( n != VK_ESCAPE ,obrow2:oTreeItem:cPrompt := padr(v,nacidlen," ") ,)}
ocol:bpopup:={||acc0501(,,obrow2)}
// right click call popu menu
// insert sub grade tree item, insert new tree item, delete tree item
ocol:bLDClickData:={||acc0502(obrow2:otreeitem),obrow2:otreeitem:Toggle(),obrow2:refresh()}
//ldbl click tree
// dynamic expand sub trees
oCol := obrow2:AddCol()
oCol:bStrData := {||odb2:descrip}
oCol:cHeader := "科目名称"
oCol:bEditValue:= {||odb2:descrip}
oCol:nEditType:={||if(::ledit.and.!odb2:EOF(),1,0)}
oCol:bOnPostEdit := {|o, v, n| if( n != VK_ESCAPE .and. v != odb2:descrip,(odb2:descrip:=v,odb2:save()) , ) }
oCol := obrow2:AddCol()
oCol:bStrData := {||odb2:currency}
oCol:cHeader := "货币"
oCol:bEditValue:= {||odb2:currency}
ocol:nedittype:= {||if(::ledit.and.!odb2:EOF(),EDIT_GET_BUTTON,0)}
oCol:bEditBlock := {||currencybrw(odb2:currency)}
oCol:bOnPostEdit := {|o, v, n| if( n != VK_ESCAPE .and. v != odb2:currency,(v:=currencybrw(v,.t.),odb2:currency:=v,odb2:SAVE()) , ) }
oCol:nWidth := 60
....
// insert sub grade tree item, insert new tree item, delete tree item
FUNCTION acc0501(nrow,ncol,obrow2)
local itemid1,omenu2,acid1
MENU oMenu2 popup
MENUITEM "增加本阶" ACTION (acid1:=padr(obrow2:otreeitem:cprompt,nacidlen," "),msgget("新编码","",@acid1),;
oserver:query("insert into ac (acid,currency) select '"+acid1+"',currency from currency limit 1 on duplicate key update descrip=descrip"),;
if(MYSQL_AFFECTED_ROWS(oserver:nSocket)>0,(obrow2:otreeitem:add(acid1),obrow2:refresh()),))
MENUITEM "增加下阶 " ACTION (acid1:=padr(obrow2:otreeitem:cprompt,nacidlen," "),msgget("新编码","",@acid1),;
oserver:query("insert into ac (acid,facid,currency) select '"+acid1+"','"+obrow2:otreeitem:cprompt+"',currency from currency limit 1 on duplicate key update descrip=descrip"),;
if(MYSQL_AFFECTED_ROWS(oserver:nSocket)>0,(obrow2:otreeitem:addchild(acid1),obrow2:refresh()),))
MENUITEM "删除本阶" ACTION (if(msgyesno("删除当前代码","请确认"),(obrow2:odbf:DELETE(),if(!oserver:lerror,(obrow2:otreeitem:DELETE(),obrow2:refresh()),msgstop("该科目在凭证中已经使用,需要先在凭证里修改或者删除","停止"))),))
ENDMENU
return oMenu2
// dynamic expand sub trees
FUNCTION acc0502(otreeitem)
local odb1,otreeitem2
if otreeitem:otree==nil
odb1:=oserver:query("select acid from ac where facid='"+otreeitem:cprompt+"'")
while !odb1:EOF()
otreeitem2:=otreeitem:addchild(odb1:acid)
acc0502(otreeitem2)
otreeitem2:Toggle()
odb1:SKIP()
end
odb1:end()
end
return