by ShumingWang » Fri Apr 27, 2018 2:03 am
/*
myapp.rc
CONTROL "", 201, "SysTreeView32", 0 | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL| TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS, 3, 80, 148, 252
*/
// ....
::oTree :=TTreeView(): REDEFINE( 201, odlg,0,nrgb(255,255,255))
// tree rc 属性 + TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS,
ACTIVATE DIALOG odlg nomodal;
ON INIT (oself1:eng0300()
method eng0300() class eng03class
local odb1,odb2
odb1:=::odb1
odb2:=::odb2
::oTree:bChanged := {|oTree,oItem|eng0303(self) }
// ...
return
FUNCTION eng0303(obl1)
local itemid1,version1
oitem:=obl1:oTree:GetSelected()
itemid1:=LEFT(oitem:cprompt,nitemidlen)
version1:=SUBSTR(oitem:cprompt,nitemidlen+3,10)
obl1:odb1:cquery:="select * from "+obl1:odb1:ctable+" where itemid='"+itemid1+"' and version='"+version1+"'"
obl1:odb1:refresh()
eng0324(obl1)
obl1:obrow:refresh()
obl1:odb4:cquery:="select * from "+obl1:odb4:ctable+" where itemid='"+itemid1+"' and version='"+version1+"' order by csort"
obl1:odb4:refresh()
obl1:obrow4:refresh()
if obl1:odb1:ctable=="bom1"
eng050401(oitem,.f.,"bom1","bom2")
else
eng050401(oitem,.f.,"engbom1","engbom2")
end
obl1:ledit:=.f.
obl1:odlg:UPDATE()
obl1:odlg:obar:AEVALwhen()
return
FUNCTION eng0504(itemid1,version1,ctable1,ctable2)
local oWnd1, oTree, oBmp1, oBmp2, odb1
// private oImageList
if ctable1==nil
ctable1:="bom1"
end
if ctable2==nil
ctable2:="bom2"
end
DEFINE WINDOW oWnd1 FROM 3, 0 TO 30, 120 ;
TITLE citemtitle+" "+ALLTRIM(itemid1) + " 树型BOM展开表"
// COLOR "n/w"
oImageList = TImageList():New()
oBmp1 = TBitmap():Define( "folder",, oWnd )
oBmp2 = TBitmap():Define( "fldMask",, oWnd)
oImageList:Add( oBmp1, oBmp2 )
oTree = TTreeView():New( 3, 0, oWnd1)
oTree:bChanged = { || eng050401( oTree:GetSelected(),,ctable1,ctable2) }
oTree:SetImageList( oImageList )
oItem = oTree:Add(itemid1)
odb1:=oServer:Query("select bom2.itemidc itemidc,cversion,goods2.descrip descrip,goods2.size size,unit.unit unit,substring(bom2.mem,1,25) mem,bom2.qty/bom2.qtydevisor*(1+ifnull(bom2.scraprate,0)/100)+bom2.fixscrap qty,bom1.version version,bom2.position position";
+" from "+ctable1+" bom1,"+ctable2+" bom2,goods2,unit";
+" where bom1.itemid='"+itemid1+"' and bom1.version='"+version1+"' and bom1.startdate<=curdate() and bom1.enddate>=curdate() and bom2.itemid='"+itemid1+"' and bom2.version=bom1.version and goods2.itemid=bom2.itemidc and unit.itemid=bom2.itemidc and unit.unitid=bom2.unitid")
while !odb1:EOF()
oItem:Add(odb1:itemidc+" V"+odb1:cversion+" "+odb1:descrip+if(lsize," "+odb1:SIZE,"")+" "+odb1:unit+" "+padl(cvaltochar(ROUND(odb1:qty,nqtydec+1)),nqtylen," ")+" "+odb1:mem+" "+odb1:position)
odb1:SKIP()
enddo
oWnd1:oClient:=oTree
oTree:Expand()
SET MESSAGE OF oWnd1 TO "BOM树型展开表" FONT ofont14
ACTIVATE WINDOW oWnd1
//VALID (oBmp1:End(),oBmp2:End(),.t.)
odb1:end()
oImageList:End()
oBmp1:End()
oBmp2:End()
return
FUNCTION eng050401(oItem,lcat,ctable1,ctable2)
local odb1
if lcat==nil;lcat:=.t.; end
if LEN(oItem:aItems)==0
odb1:=oserver:Query("select bom2.itemidc itemidc,bom2.cversion cversion,goods2.descrip descrip,goods2.size size,unit.unit unit,substring(bom2.mem,1,25) mem,bom2.qty/bom2.qtydevisor*(1+ifnull(bom2.scraprate,0)/100)+bom2.fixscrap qty,bom1.version version ,bom2.position ";
+" from "+ctable1+" bom1,"+ctable2+" bom2,goods2,unit ";
+" where bom1.itemid='"+LEFT(oitem:cprompt,nitemidlen)+"' and bom1.version='"+SUBSTR(oitem:cprompt,nitemidlen+3,10)+"' and bom1.startdate<=curdate() and bom1.enddate>=curdate() and bom2.itemid='"+LEFT(oitem:cprompt,nitemidlen)+"' and bom2.version=bom1.version and goods2.itemid=bom2.itemidc and unit.itemid=bom2.itemidc and unit.unitid=bom2.unitid")
while !odb1:EOF()
oItem:Add(odb1:itemidc+" V"+odb1:cversion+" "+odb1:descrip+if(lsize," "+odb1:SIZE,"")+" "+odb1:unit+" "+STR(ROUND(odb1:qty*if(lcat,val(strtoken(oitem:cprompt,5+if(lsize,1,0)," ")),1),nqtydec+1))+" "+odb1:mem+" "+odb1:position)
odb1:SKIP()
enddo
oitem:expand()
odb1:end()
endif
return