123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- unit BillsPosTree;
- // 清单--部位明细树 (同导入计量Saas相关,不做他用)
- interface
- uses
- Classes, CacheTree, ZhAPI;
- type
- TPosNode = class
- private
- FQuantity: Double;
- FMemoStr: string;
- FName: string;
- FDrawingCode: string;
- public
- property Name: string read FName write FName;
- property Quantity: Double read FQuantity write FQuantity;
- property MemoStr: string read FMemoStr write FMemoStr;
- property DrawingCode: string read FDrawingCode write FDrawingCode;
- end;
- TBillsPosTreeNode = class(TCacheNode)
- private
- FPosList: TList;
- FQuantity: Double;
- FPrice: Double;
- FDgnQty1: Double;
- FDgnQty2: Double;
- FUnits: string;
- FDrawingCode: string;
- FName: string;
- FCode: string;
- FMemoStr: string;
- FB_Code: string;
- FTotalPrice: Double;
- function GetPos(AIndex: Integer): TPosNode;
- function GetPosCount: Integer;
- public
- constructor Create(ACacheTree: TCacheTree; AID: Integer); override;
- destructor Destroy; override;
- function AddPos: TPosNode;
- procedure Calculate;
- property Code: string read FCode write FCode;
- property B_Code: string read FB_Code write FB_Code;
- property Name: string read FName write FName;
- property Units: string read FUnits write FUnits;
- property Price: Double read FPrice write FPrice;
- property Quantity: Double read FQuantity write FQuantity;
- property TotalPrice: Double read FTotalPrice write FTotalPrice;
- property DgnQty1: Double read FDgnQty1 write FDgnQty1;
- property DgnQty2: Double read FDgnQty2 write FDgnQty2;
- property DrawingCode: string read FDrawingCode write FDrawingCode;
- property MemoStr: string read FMemoStr write FMemoStr;
- property PosCount: Integer read GetPosCount;
- property Pos[AIndex: Integer]: TPosNode read GetPos;
- end;
- TBillsPosTree = class(TCacheTree)
- private
- protected
- function GetNewNode: TCacheNode; override;
- public
- procedure CalculateAll;
- end;
- implementation
- { TBillsPosTreeNode }
- function TBillsPosTreeNode.AddPos: TPosNode;
- begin
- Result := TPosNode.Create;
- FPosList.Add(Result);
- end;
- procedure TBillsPosTreeNode.Calculate;
- var
- fQuantity: Double;
- iPos: Integer;
- begin
- fQuantity := 0;
- for iPos := 0 to FPosList.Count - 1 do
- fQuantity := fQuantity + TPosNode(FPosList.Items[iPos]).Quantity;
- Quantity := fQuantity;
- TotalPrice := Quantity * Price;
- end;
- constructor TBillsPosTreeNode.Create(ACacheTree: TCacheTree; AID: Integer);
- begin
- inherited;
- FPosList := TList.Create;
- end;
- destructor TBillsPosTreeNode.Destroy;
- begin
- ClearObjects(FPosList);
- FPosList.Free;
- inherited;
- end;
- function TBillsPosTreeNode.GetPos(AIndex: Integer): TPosNode;
- begin
- Result := TPosNode(FPosList.Items[AIndex]);
- end;
- function TBillsPosTreeNode.GetPosCount: Integer;
- begin
- Result := FPosList.Count;
- end;
- { TBillsPosTree }
- procedure TBillsPosTree.CalculateAll;
- var
- i: Integer;
- vNode: TBillsPosTreeNode;
- begin
- for i := 0 to CacheNodes.Count - 1 do
- begin
- vNode := TBillsPosTreeNode(CacheNodes[i]);
- if (vNode.PosCount > 0) then
- vNode.Calculate;
- end;
- end;
- function TBillsPosTree.GetNewNode: TCacheNode;
- begin
- Result := TBillsPosTreeNode.Create(Self, GetNewNodeID);
- CacheNodes.Add(Result);
- end;
- end.
|