Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共10 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:多层结构BOM的算法

1楼
RandyBoy 发表于:2011/11/28 11:29:00

如何用函数循环遍历某一产品的单层bom生成多层结构BOM

2楼
狐狸爸爸 发表于:2011/11/28 15:17:00
这个用具体数据表来说明问题比较好。
3楼
RandyBoy 发表于:2011/11/29 10:17:00

procedure TImportMainF.GenProcductPackDetail(ParentID:Integer;IncludeRoot:Boolean;
  bomlevel:Integer;pmtotal:Double;RootId:Integer;FatherId:Integer;SingleTotal:Double);
  procedure InsBomDataTable(rootid,bomlevel,ord,parent,comgoid,xh:Integer;singletotal,total:Double);
  begin
    with BomDataDS do begin
      Last;
      Insert;
      FieldByName('goid').AsInteger:=RootId;
      FieldByName('bomlevel').AsInteger:=bomlevel;
      FieldByName('total').AsFloat :=total;
      FieldByName('ord').AsInteger:=ord;
      FieldByName('parent').AsInteger:=parent;
      FieldByName('comgoid').AsInteger:=comgoid;
      FieldByName('singletotal').AsFloat:=singletotal;
      FieldByName('xh').AsInteger:=xh;
      post;
    end;
  end;
var
  i,k,j,TempStr,pmord:Integer;
   CurGoid:Integer;
   CurTotal:Double;
   Cursf_nonstock:Boolean;
   curSf_Last:Boolean;
   CurBomLevel:Integer;
   CurOrd:integer;
   CurSingleTotal:Double;
begin
   SimpleDataSet3.Close;
   SimpleDataSet3.DataSet.CommandText:='Select a.goid,a.comgoid,a.total,b.sf_nonstock from cp_singlebom as a inner join cp_good as b on a.comgoid=b.goid where a.goid=:curgoid'
                        + ' Order by a.ord desc';
   SimpleDataSet3.Params.ParamByName('curgoid').AsInteger:=ParentID;
   SimpleDataSet3.Open;
   k:=SimpleDataSet3.RecordCount;
   if IncludeRoot then begin
     //根结点
      Inc(BomOrd);
       pmord:=BomOrd;
       inc(xh);
       //if SimpleDataSet3.RecordCount > 0 then begin
        InsBomDataTable(RootId,bomlevel,BomOrd,FatherId,ParentID,xh,SingleTotal,pmtotal);
       //end;
   end;
   if SimpleDataSet3.RecordCount > 0 then begin
      SimpleDataSet3.First;
      BomTempDS.First;
     while Not SimpleDataSet3.Eof do begin
       with BomTempDS do begin
         Insert;
         FieldByName('goid').AsInteger:=SimpleDataSet3.FieldByName('comgoid').AsInteger;
         FieldByName('level').AsInteger:=BomLevel + 1;
         FieldByName('singletotal').AsFloat:=SimpleDataSet3.FieldByName('total').AsFloat;
         FieldByName('total').AsFloat :=SimpleDataSet3.FieldByName('total').AsFloat*PmTotal;
         FieldByName('ord').AsInteger:=BomOrd;
         FieldByName('parent').AsInteger:=PmOrd;
         FieldByName('sf_nonstock').AsBoolean:=SimpleDataSet3.FieldByName('sf_nonstock').AsBoolean;
         FieldByName('sf_last').AsBoolean:=False;
         post;
         First;
       end;
       SimpleDataSet3.Next;
     end;
   end;
   BomTempDS.First;
   while Not BomTempDS.Eof do begin
     SimpleDataSet4.Close;
     SimpleDataSet4.DataSet.CommandText:='select a.goid,a.comgoid,b.sf_nonstock from cp_singlebom as a '
             + ' inner join cp_good as b on a.comgoid=b.goid where a.goid=:curgoid' + ' Order by a.ord';
     SimpleDataSet4.Params.ParamByName('curgoid').AsInteger:=BomTempDS.FieldByName('goid').AsInteger;
     SimpleDataSet4.Open;
     SimpleDataSet4.First;
     Cursf_nonstock:=BomTempDS.FieldByName('sf_nonstock').AsBoolean;
     CurTotal:=BomTempDS.FieldByName('total').AsFloat;
     CurGoid:=BomTempDS.FieldByName('goid').AsInteger;
     CurBomLevel:=BomTempDS.FieldByName('level').AsInteger;
     CurOrd:=BomTempDS.FieldByName('parent').AsInteger;
     curSf_Last:=BomTempDS.FieldByName('sf_last').AsBoolean;
     CurSingleTotal:=BomTempDS.FieldByName('singletotal').AsFloat;
     BomTempDS.Delete;
     BomTempDS.First;
     if Cursf_nonstock then begin
      if SimpleDataSet4.FieldByName('goid').AsInteger > 0 then begin
        GenProcductPackDetail(CurGoid,True,CurBomLevel,CurTotal,RootId,CurOrd,CurSingleTotal);
      end else begin
        Inc(BomOrd);
        pmord:=BomOrd;
        Inc(xh);
        InsBomDataTable(RootId,CurBomLevel,BomOrd,CurOrd,CurGoid,xh,CurSingleTotal,CurTotal);
      end;
     end else begin
       Inc(BomOrd);
       pmord:=BomOrd;
       Inc(xh);
       InsBomDataTable(RootId,CurBomLevel,BomOrd,CurOrd,CurGoid,xh,CurSingleTotal,CurTotal);
     end;
   end;
end;

4楼
RandyBoy 发表于:2011/11/29 10:19:00
以前写的DELPHI 代码,用于遍历给定产品的所有单层BOM的物料明细并存储在临时数据表中
5楼
RandyBoy 发表于:2011/11/29 10:25:00

在数据表的当前记录后插入行,其余行往后移,FOXTABLE应该如何处理呢。

6楼
狐狸爸爸 发表于:2011/11/29 11:16:00

foxtable有插入行和移动行的功能:

 

http://www.foxtable.com/help/topics/1846.htm

 

7楼
贰零伍號行星 发表于:2011/11/29 13:29:00
移动后他的 _Identify  会发生改变吗?假如 关联表于其对应 也会变不
8楼
lyq 发表于:2011/11/29 15:23:00
_Identify是主键,自动增量型,肯定会变的
9楼
狐狸爸爸 发表于:2011/11/29 15:41:00
以下是引用贰零伍號行星在2011-11-29 13:29:00的发言:
移动后他的 _Identify  会发生改变吗?假如 关联表于其对应 也会变不

 

不会变的

10楼
hanxuntx 发表于:2011/11/29 16:15:00
移动后是_SortKey 改变
共10 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02148 s, 2 queries.