| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 | 
							- unit tpPegGclGatherDm;
 
- interface
 
- uses
 
-   SysUtils, Classes, tpGatherGcl, sdDB, sdProvider;
 
- type
 
-   TtpPegGclGatherData = class(TDataModule)
 
-     smpGclGather: TsdMemoryProvider;
 
-     sddGclGather: TsdDataSet;
 
-     sdvGclGather: TsdDataView;
 
-     smpGclRela: TsdMemoryProvider;
 
-     sddGclRela: TsdDataSet;
 
-     sdvGclRela: TsdDataView;
 
-     procedure sdvGclGatherCurrentChanged(ARecord: TsdDataRecord);
 
-     procedure sdvGclRelaFilterRecord(ARecord: TsdDataRecord;
 
-       var Allow: Boolean);
 
-   private
 
-   public
 
-     procedure LoadGclGatherData(AGcls: TtpGatherGclList);
 
-   end;
 
- implementation
 
- uses tpGatherTree;
 
- {$R *.dfm}
 
- { TtpPegGclGatherData }
 
- procedure TtpPegGclGatherData.LoadGclGatherData(AGcls: TtpGatherGclList);
 
-   procedure BeforeLoad;
 
-   begin
 
-     sddGclGather.Active := True;
 
-     sddGclGather.DisableControls;
 
-     sddGclGather.BeginUpdate;
 
-     sddGclGather.DeleteAll;
 
-     sddGclRela.Active := True;
 
-     sddGclRela.DisableControls;
 
-     sddGclRela.BeginUpdate;
 
-     sddGclRela.DeleteAll;
 
-     sdvGclRela.Filtered := False;
 
-   end;
 
-   procedure AfterLoad;
 
-   begin
 
-     sddGclGather.EndUpdate;
 
-     sddGclGather.EnableControls;
 
-     sddGclRela.EndUpdate;
 
-     sddGclRela.EnableControls;
 
-     sdvGclGather.LocateInControl(sdvGclGather.Records[0]);
 
-     sdvGclRela.Filtered := True;
 
-   end;
 
-   procedure LoadGclRela(AGcl: TtpGatherGcl);
 
-   var
 
-     iRela: Integer;
 
-     vRela: TtpGatherGclRela;
 
-     Rec: TsdDataRecord;
 
-   begin
 
-     for iRela := 0 to AGcl.RelaCount - 1 do
 
-     begin
 
-       vRela := AGcl.Rela[iRela];
 
-       Rec := sddGclRela.Add;
 
-       Rec.ValueByName('DetailGclID').AsInteger := vRela.RelaGcl.ID;
 
-       Rec.ValueByName('GclID').AsInteger := AGcl.ID;
 
-       Rec.ValueByName('PegXmjID').AsInteger := vRela.RelaPegXmj.ID;
 
-       Rec.ValueByName('PegXmjCode').AsString := vRela.RelaPegXmj.Code;
 
-       Rec.ValueByName('PegXmjName').AsString := vRela.RelaPegXmj.Name;
 
-       Rec.ValueByName('PegXmjUnits').AsString := vRela.RelaPegXmj.Units;
 
-       Rec.ValueByName('Quantity').AsFloat := vRela.RelaGcl.Quantity;
 
-       Rec.ValueByName('TotalPrice').AsFloat := vRela.RelaPegXmj.TotalPrice;
 
-       Rec.ValueByName('DrawingCode').AsString := vRela.RelaPegXmj.DrawingCode;
 
-     end;
 
-   end;
 
-   procedure LoadGclNode(AGcl: TtpGatherGcl);
 
-   var
 
-     Rec: TsdDataRecord;
 
-   begin
 
-     Rec := sddGclGather.Add;
 
-     Rec.ValueByName('ID').AsInteger := AGcl.ID;
 
-     Rec.ValueByname('IndexCode').AsString := AGcl.IndexCode;
 
-     Rec.ValueByname('B_Code').AsString := AGcl.B_Code;
 
-     Rec.ValueByName('Name').AsString := AGcl.Name;
 
-     Rec.ValueByName('Units').AsString := AGcl.Units;
 
-     Rec.ValueByName('Price').AsFloat := AGcl.Price;
 
-     Rec.ValueByName('Quantity').AsFloat := AGcl.Quantity;
 
-     Rec.ValueByName('TotalPrice').AsFloat := AGcl.TotalPrice;
 
-     LoadGclRela(AGcl);
 
-   end;
 
- var
 
-   iGcl: Integer;
 
- begin
 
-   BeforeLoad;
 
-   try
 
-     for iGcl := 0 to AGcls.GclCount - 1 do
 
-       LoadGclNode(AGcls.Gcl[iGcl]);
 
-   finally
 
-     AfterLoad;
 
-   end;
 
- end;
 
- procedure TtpPegGclGatherData.sdvGclGatherCurrentChanged(
 
-   ARecord: TsdDataRecord);
 
- begin
 
-   sdvGclRela.RefreshFilter;
 
- end;
 
- procedure TtpPegGclGatherData.sdvGclRelaFilterRecord(
 
-   ARecord: TsdDataRecord; var Allow: Boolean);
 
- begin
 
-   if Assigned(sdvGclGather.Current) then
 
-     Allow := ARecord.ValueByName('GclID').AsInteger = sdvGclGather.Current.ValueByName('ID').AsInteger
 
-   else
 
-     Allow := False;
 
- end;
 
- end.
 
 
  |