FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour BOM production
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
BOM production
Posted: Thu Apr 26, 2018 01:24 PM

Hi to All,
Is it possible to represent "BOM production" by Tree object ?

thanks

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 1283
Joined: Fri Feb 10, 2006 02:34 PM
Re: BOM production
Posted: Thu Apr 26, 2018 08:05 PM

damianodec,

You can say that tree like a abstract view of BOM, if you refer a "bill of materials" of couse....If you to know to build a tree example, then you can do a BOM view. You can do a lot of levels like product, subproduct and raw material

Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
HIX -> https://github.com/carles9000/hix
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Re: BOM production
Posted: Fri Apr 27, 2018 02: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(&quot;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 &quot;;
                    +&quot; from &quot;+ctable1+&quot; bom1,&quot;+ctable2+&quot; bom2,goods2,unit &quot;; 
                    +&quot; where bom1.itemid='&quot;+LEFT(oitem:cprompt,nitemidlen)+&quot;' and bom1.version='&quot;+SUBSTR(oitem:cprompt,nitemidlen+3,10)+&quot;' and bom1.startdate&lt;=curdate() and bom1.enddate&gt;=curdate() and bom2.itemid='&quot;+LEFT(oitem:cprompt,nitemidlen)+&quot;' and bom2.version=bom1.version and goods2.itemid=bom2.itemidc  and unit.itemid=bom2.itemidc and unit.unitid=bom2.unitid&quot;)

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

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: BOM production
Posted: Thu May 03, 2018 03:42 PM

thank you!

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)

Continue the discussion