-- 作者: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;
|