| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 | 
							- unit tpGatherGcl;
 
- interface
 
- uses
 
-   Classes, tpGatherTree;
 
- type
 
-   TtpGatherGclRela = class
 
-   private
 
-     FRelaGcl: TtpGatherTreeNode;
 
-     FRelaPegXmj: TtpGatherTreeNode;
 
-   public
 
-     constructor Create(AGcl, APegXmj: TtpGatherTreeNode);
 
-     property RelaGcl: TtpGatherTreeNode read FRelaGcl;
 
-     property RelaPegXmj: TtpGatherTreeNode read FRelaPegXmj;
 
-   end;
 
-   TtpGatherGcl = class
 
-   private
 
-     FID: Integer;
 
-     FRelas: TList;
 
-     FIndexCode: string;
 
-     FB_Code: string;
 
-     FName: string;
 
-     FUnits: string;
 
-     FPrice: Double;
 
-     FQuantity: Double;
 
-     FTotalPrice: Double;
 
-     function GetRela(AIndex: Integer): TtpGatherGclRela;
 
-     function GetRelaCount: Integer;
 
-   public
 
-     constructor Create(AID: Integer; AGcl, APegXmj: TtpGatherTreeNode);
 
-     destructor Destroy; override;
 
-     procedure GatherNode(AGcl, APegXmj: TtpGatherTreeNode);
 
-     property ID: Integer read FID;
 
-     property IndexCode: string read FIndexCode;
 
-     property B_Code: string read FB_Code;
 
-     property Name: string read FName;
 
-     property Units: string read FUnits;
 
-     property Price: Double read FPrice;
 
-     property Quantity: Double read FQuantity;
 
-     property TotalPrice: Double read FTotalPrice;
 
-     property RelaCount: Integer read GetRelaCount;
 
-     property Rela[AIndex: Integer]: TtpGatherGclRela read GetRela;
 
-   end;
 
-   TtpGatherGclList = class
 
-   private
 
-     FGcls: TList;
 
-     FNewID: Integer;
 
-     function FindGatherGcl(ANode: TtpGatherTreeNode): TtpGatherGcl;
 
-     function NewGatherGcl(AGcl, APegXmj: TtpGatherTreeNode): TtpGatherGcl;
 
-     function GetGcl(AIndex: Integer): TtpGatherGcl;
 
-     function GetGclCount: Integer;
 
-   public
 
-     constructor Create;
 
-     destructor Destroy; override;
 
-     procedure GatherNode(AGcl, APegXmj: TtpGatherTreeNode);
 
-     property GclCount: Integer read GetGclCount;
 
-     property Gcl[AIndex: Integer]: TtpGatherGcl read GetGcl;
 
-   end;
 
- implementation
 
- uses
 
-   UtilMethods, SysUtils, ZhAPI;
 
- { TtpGatherGcl }
 
- constructor TtpGatherGcl.Create(AID: Integer; AGcl, APegXmj: TtpGatherTreeNode);
 
- var
 
-   vRela: TtpGatherGclRela;
 
- begin
 
-   FID := AID;
 
-   FRelas := TList.Create;
 
-   vRela := TtpGatherGclRela.Create(AGcl, APegXmj);
 
-   FRelas.Add(vRela);
 
-   FB_Code := AGcl.B_Code;
 
-   FIndexCode := B_CodeToIndexCode(FB_Code);
 
-   FName := AGcl.Name;
 
-   FUnits := AGcl.Units;
 
-   FPrice := AGcl.Price;
 
-   FQuantity := AGcl.Quantity;
 
-   FTotalPrice := AGcl.TotalPrice;
 
- end;
 
- destructor TtpGatherGcl.Destroy;
 
- begin
 
-   ClearObjects(FRelas);
 
-   FRelas.Free;
 
-   inherited;
 
- end;
 
- procedure TtpGatherGcl.GatherNode(AGcl, APegXmj: TtpGatherTreeNode);
 
- var
 
-   vRela: TtpGatherGclRela;
 
- begin
 
-   vRela := TtpGatherGclRela.Create(AGcl, APegXmj);
 
-   FRelas.Add(vRela);
 
-   FQuantity := FQuantity + AGcl.Quantity;
 
-   FTotalPrice := FTotalPrice + AGcl.TotalPrice;
 
- end;
 
- function TtpGatherGcl.GetRela(AIndex: Integer): TtpGatherGclRela;
 
- begin
 
-   Result := TtpGatherGclRela(FRelas.Items[AIndex]);
 
- end;
 
- function TtpGatherGcl.GetRelaCount: Integer;
 
- begin
 
-   Result := FRelas.Count;
 
- end;
 
- { TtpGatherGclList }
 
- constructor TtpGatherGclList.Create;
 
- begin
 
-   FGcls := TList.Create;
 
-   FNewID := 0;
 
- end;
 
- destructor TtpGatherGclList.Destroy;
 
- begin
 
-   ClearObjects(FGcls);
 
-   FGcls.Free;
 
-   inherited;
 
- end;
 
- function TtpGatherGclList.FindGatherGcl(
 
-   ANode: TtpGatherTreeNode): TtpGatherGcl;
 
- var
 
-   iGcl: Integer;
 
-   vGcl: TtpGatherGcl;
 
- begin
 
-   Result := nil;
 
-   for iGcl := 0 to FGcls.Count - 1 do
 
-   begin
 
-     vGcl := TtpGatherGcl(FGcls.Items[iGcl]);
 
-     if SameText(vGcl.B_Code, ANode.B_Code) and
 
-         SameText(vGcl.Name, ANode.Name) and
 
-         SameText(vGcl.Units, ANode.Units) and
 
-         (vGcl.Price - ANode.Price < 0.0001) then
 
-     begin
 
-       Result := vGcl;
 
-       Break;
 
-     end;
 
-   end;
 
- end;
 
- procedure TtpGatherGclList.GatherNode(AGcl, APegXmj: TtpGatherTreeNode);
 
- var
 
-   vGcl: TtpGatherGcl;
 
- begin
 
-   vGcl := FindGatherGcl(AGcl);
 
-   if Assigned(vGcl) then
 
-     vGcl.GatherNode(AGcl, APegXmj)
 
-   else
 
-     vGcl := NewGatherGcl(AGcl, APegXmj);
 
- end;
 
- function TtpGatherGclList.GetGcl(AIndex: Integer): TtpGatherGcl;
 
- begin
 
-   Result := TtpGatherGcl(FGcls.Items[AIndex]);
 
- end;
 
- function TtpGatherGclList.GetGclCount: Integer;
 
- begin
 
-   Result := FGcls.Count;
 
- end;
 
- function TtpGatherGclList.NewGatherGcl(
 
-   AGcl, APegXmj: TtpGatherTreeNode): TtpGatherGcl;
 
- begin
 
-   Result := TtpGatherGcl.Create(FNewID, AGcl, APegXmj);
 
-   FGcls.Add(Result);
 
-   Inc(FNewID);
 
- end;
 
- { TtpGatherGclRela }
 
- constructor TtpGatherGclRela.Create(AGcl, APegXmj: TtpGatherTreeNode);
 
- begin
 
-   FRelaGcl := AGcl;
 
-   FRelaPegXmj := APegXmj;
 
- end;
 
- end.
 
 
  |