unit mDataRecord;

interface

uses
  Classes, sdDB;

type
  TMeasureBaseRecord = class(TsdDataRecord)
  public
    procedure SetFloatValue(AValue: TsdValue; AFloat: Double);
    procedure SetIntValue(AValue: TsdValue; AInt: Integer);
    procedure SetBoolValue(AValue: TsdValue; ABool: Boolean);
    procedure SetStrValue(AValue: TsdValue; AStr: string);

    procedure AddDifferValue(AValue: TsdValue; ADiffer: Double);
  end;

  TBillsRecord = class(TMeasureBaseRecord)
  private
    // 树结构
    FID: TsdValue;
    FParentID: TsdValue;
    FNextSiblingID: TsdValue;
    // 报表专用
    FSerialNo: TsdValue;
    FIsLeaf: TsdValue;
    FLeafXmjParentID: TsdValue;
    FXiangCode: TsdValue;
    FMuCode: TsdValue;
    FJieCode: TsdValue;
    FXimuCode: TsdValue;
    FIndexCode: TsdValue;
    FChapterParentID: TsdValue;
    FNodeLevel: TsdValue;
    FB_CodeChapter: TsdValue;
    // 基础数据
    FCode: TsdValue;
    FB_Code: TsdValue;
    FName: TsdValue;
    FUnits: TsdValue;
    FAlias: TsdValue;
    // 单价
    FPrice: TsdValue;
    FNewPrice: TsdValue;
    // 0号台账计算相关
    FOrgQuantity: TsdValue;
    FOrgTotalPrice: TsdValue;
    FMisQuantity: TsdValue;
    FMisTotalPrice: TsdValue;
    FOthQuantity: TsdValue;
    FOthTotalPrice: TsdValue;
    FQuantity: TsdValue;
    FTotalPrice: TsdValue;
    // 计算模式标记
    FCalcType: TsdValue;
    // 累计
    FAddDealQuantity: TsdValue;
    FAddDealTotalPrice: TsdValue;

    FAddQcQuantity: TsdValue;
    FAddQcTotalPrice: TsdValue;
    FAddQcBGLCode: TsdValue;
    FAddQcBGLNum: TsdValue;

    FAddPcQuantity: TsdValue;
    FAddPcTotalPrice: TsdValue;
    FAddPcBGLCode: TsdValue;
    FAddPcBGLNum: TsdValue;

    FAddGatherQuantity: TsdValue;
    FAddGatherTotalPrice: TsdValue;

    FLockedLevel: TsdValue;
    FLockedInfo: TsdValue;
    FLockedNewPrice: TsdValue;
    FCreatePhaseID: TsdValue;
    FIsMeasureAdd: TsdValue;
    FIsGatherZJJL: TsdValue;

    FPeg: TsdValue;
    FDrawingCode: TsdValue;
    FMemoStr: TsdValue;
    FApprovalCode: TsdValue;

    FDgnQuantity1: TsdValue;
    FDgnQuantity2: TsdValue;
    FDgnPrice: TsdValue;

    FDealDgnQuantity1: TsdValue;
    FDealDgnQuantity2: TsdValue;
    FCDgnQuantity1: TsdValue;
    FCDgnQuantity2: TsdValue;
    FAddDgnPrice: TsdValue;

    FHasBookMark: TsdValue;
    FMarkMemo: TsdValue;

    FDealCode: TsdValue;
    FDealCompany: TsdValue;
    FDealType: TsdValue;
    FAddCutTotalPrice: TsdValue;
    FAddPayTotalPrice: TsdValue;

    FAddCompleteRate: TsdValue;

    FCacheMisTP: Double;
    FCacheOrgTP: Double;
    FCacheOthTP: Double;

    FPM_AddTotalPrice: TsdValue;
  protected
    procedure DoAfterAddFields; override;
  public
    property ID: TsdValue read FID;
    property ParentID: TsdValue read FParentID;
    property NextSiblingID: TsdValue read FNextSiblingID;

    property SerialNo: TsdValue read FSerialNo;
    property IsLeaf: TsdValue read FIsLeaf;
    property LeafXmjParentID: TsdValue read FLeafXmjParentID;
    property XiangCode: TsdValue read FXiangCode;
    property MuCode: TsdValue read FMuCode;
    property JieCode: TsdValue read FJieCode;
    property XimuCode: TsdValue read FXimuCode;
    property IndexCode: TsdValue read FIndexCode;
    property ChapterParentID: TsdValue read FChapterParentID;
    property NodeLevel: TsdValue read FNodeLevel;
    property B_CodeChapter: TsdValue read FB_CodeChapter;

    property Code: TsdValue read FCode;
    property B_Code: TsdValue read FB_Code;
    property Name: TsdValue read FName;
    property Units: TsdValue read FUnits;
    property Alias: TsdValue read FAlias;

    property Price: TsdValue read FPrice;
    property NewPrice: TsdValue read FNewPrice;

    property OrgQuantity: TsdValue read FOrgQuantity;
    property OrgTotalPrice: TsdValue read FOrgTotalPrice;
    property MisQuantity: TsdValue read FMisQuantity;
    property MisTotalPrice: TsdValue read FMisTotalPrice;
    property OthQuantity: TsdValue read FOthQuantity;
    property OthTotalPrice: TsdValue read FOthTotalPrice;
    property Quantity: TsdValue read FQuantity;
    property TotalPrice: TsdValue read FTotalPrice;
    property CalcType: TsdValue read FCalcType;

    property AddDealQuantity: TsdValue read FAddDealQuantity;
    property AddDealTotalPrice: TsdValue read FAddDealTotalPrice;

    property AddQcQuantity: TsdValue read FAddQcQuantity;
    property AddQcTotalPrice: TsdValue read FAddQcTotalPrice;
    property AddQcBGLCode: TsdValue read FAddQcBGLCode;
    property AddQcBGLNum: TsdValue read FAddQcBGLNum;

    property AddPcQuantity: TsdValue read FAddPcQuantity;
    property AddPcTotalPrice: TsdValue read FAddPcTotalPrice;
    property AddPcBGLCode: TsdValue read FAddPcBGLCode;
    property AddPcBGLNum: TsdValue read FAddPcBGLNum;

    property AddGatherQuantity: TsdValue read FAddGatherQuantity;
    property AddGatherTotalPrice: TsdValue read FAddGatherTotalPrice;

    property LockedLevel: TsdValue read FLockedLevel;
    property LockedInfo: TsdValue read FLockedInfo;
    property LockedNewPrice: TsdValue read FLockedNewPrice;
    property CreatePhaseID: TsdValue read FCreatePhaseID;
    property IsMeasureAdd: TsdValue read FIsMeasureAdd;
    property IsGatherZJJL: TsdValue read FIsGatherZJJL;

    property Peg: TsdValue read FPeg;
    property DrawingCode: TsdValue read FDrawingCode;
    property MemoStr: TsdValue read FMemoStr;
    property ApprovalCode: TsdValue read FApprovalCode;

    property DgnQuantity1: TsdValue read FDgnQuantity1;
    property DgnQuantity2: TsdValue read FDgnQuantity2;
    property DgnPrice: TsdValue read FDgnPrice;

    property DealDgnQuantity1: TsdValue read FDealDgnQuantity1;
    property DealDgnQuantity2: TsdValue read FDealDgnQuantity2;
    property CDgnQuantity1: TsdValue read FCDgnQuantity1;
    property CDgnQuantity2: TsdValue read FCDgnQuantity2;
    property AddDgnPrice: TsdValue read FAddDgnPrice;

    property HasBookMark: TsdValue read FHasBookMark;
    property MarkMemo: TsdValue read FMarkMemo;

    property DealCode: TsdValue read FDealCode;
    property DealCompany: TsdValue read FDealCompany;
    property DealType: TsdValue read FDealType;
    property AddCutTotalPrice: TsdValue read FAddCutTotalPrice;
    property AddPayTotalPrice: TsdValue read FAddPayTotalPrice;

    property AddCompleteRate: TsdValue read FAddCompleteRate;

    // Cache Data 用于增量计算，记录原始值
    property CacheOrgTP: Double read FCacheOrgTP write FCacheOrgTP;
    property CacheMisTP: Double read FCacheMisTP write FCacheMisTP;
    property CacheOthTP: Double read FCacheOthTP write FCacheOthTP;
    
    property PM_AddTotalPrice: TsdValue read FPM_AddTotalPrice;
  end;

  TStageRecord = class(TMeasureBaseRecord)
  private
    FBillsID: TsdValue;

    FDealQuantity: TsdValue;
    FDealTotalPrice: TsdValue;
    FDealFlag: TsdValue;
    FDealFormula: TsdValue;

    FQcQuantity: TsdValue;
    FQcTotalPrice: TsdValue;
    FQcFlag: TsdValue;
    FQcFormula: TsdValue;
    FQcBGLCode: TsdValue;
    FQcBGLNum: TsdValue;

    FPcQuantity: TsdValue;
    FPcTotalPrice: TsdValue;
    FPcFlag: TsdValue;
    FPcFormula: TsdValue;
    FPcBGLCode: TsdValue;
    FPcBGLNum: TsdValue;

    FGatherQuantity: TsdValue;
    FGatherTotalPrice: TsdValue;

    FEndDealQuantity: TsdValue;
    FEndDealTotalPrice: TsdValue;
    FEndQcQuantity: TsdValue;
    FEndQcTotalPrice: TsdValue;
    FEndQcBGLCode: TsdValue;
    FEndQcBGLNum: TsdValue;
    FEndPcQuantity: TsdValue;
    FEndPcTotalPrice: TsdValue;
    FEndPcBGLCode: TsdValue;
    FEndPcBGLNum: TsdValue;
    FEndGatherQuantity: TsdValue;
    FEndGatherTotalPrice: TsdValue;

    FPreDealQuantity: TsdValue;
    FPreDealTotalPrice: TsdValue;
    FPreQcQuantity: TsdValue;
    FPreQcTotalPrice: TsdValue;
    FPreQcBGLCode: TsdValue;
    FPreQcBGLNum: TsdValue;
    FPrePcQuantity: TsdValue;
    FPrePcTotalPrice: TsdValue;
    FPrePcBGLCode: TsdValue;
    FPrePcBGLNum: TsdValue;
    FPreGatherQuantity: TsdValue;
    FPreGatherTotalPrice: TsdValue;

    FHasBookMark: TsdValue;
    FMarkMemo: TsdValue;

    FCacheDealTP: Double;

    FPM_PreTotalPrice: TsdValue;
    FPM_TotalPrice: TsdValue;
  protected
    procedure DoAfterAddFields; override;
  public
    property BillsID: TsdValue read FBillsID;

    property DealQuantity: TsdValue read FDealQuantity;
    property DealTotalPrice: TsdValue read FDealTotalPrice;
    property DealFlag: TsdValue read FDealFlag;
    property DealFormula: TsdValue read FDealFormula;

    property QcQuantity: TsdValue read FQcQuantity;
    property QcTotalPrice: TsdValue read FQcTotalPrice;
    property QcFlag: TsdValue read FQcFlag;
    property QcFormula: TsdValue read FQcFormula;
    property QcBGLCode: TsdValue read FQcBGLCode;
    property QcBGLNum: TsdValue read FQcBGLNum;

    property PcQuantity: TsdValue read FPcQuantity;
    property PcTotalPrice: TsdValue read FPcTotalPrice;
    property PcFlag: TsdValue read FPcFlag;
    property PcFormula: TsdValue read FPcFormula;
    property PcBGLCode: TsdValue read FPcBGLCode;
    property PcBGLNum: TsdValue read FPcBGLNum;

    property GatherQuantity: TsdValue read FGatherQuantity;
    property GatherTotalPrice: TsdValue read FGatherTotalPrice;

    property EndDealQuantity: TsdValue read FEndDealQuantity;
    property EndDealTotalPrice: TsdValue read FEndDealTotalPrice;
    property EndQcQuantity: TsdValue read FEndQcQuantity;
    property EndQcTotalPrice: TsdValue read FEndQcTotalPrice;
    property EndQcBGLCode: TsdValue read FEndQcBGLCode;
    property EndQcBGLNum: TsdValue read FEndQcBGLNum;
    property EndPcQuantity: TsdValue read FEndPcQuantity;
    property EndPcTotalPrice: TsdValue read FEndPcTotalPrice;
    property EndPcBGLCode: TsdValue read FEndPcBGLCode;
    property EndPcBGLNum: TsdValue read FEndPcBGLNum;
    property EndGatherQuantity: TsdValue read FEndGatherQuantity;
    property EndGatherTotalPrice: TsdValue read FEndGatherTotalPrice;

    property PreDealQuantity: TsdValue read FPreDealQuantity;
    property PreDealTotalPrice: TsdValue read FPreDealTotalPrice;
    property PreQcQuantity: TsdValue read FPreQcQuantity;
    property PreQcTotalPrice: TsdValue read FPreQcTotalPrice;
    property PreQcBGLCode: TsdValue read FPreQcBGLCode;
    property PreQcBGLNum: TsdValue read FPreQcBGLNum;
    property PrePcQuantity: TsdValue read FPrePcQuantity;
    property PrePcTotalPrice: TsdValue read FPrePcTotalPrice;
    property PrePcBGLCode: TsdValue read FPrePcBGLCode;
    property PrePcBGLNum: TsdValue read FPrePcBGLNum;
    property PreGatherQuantity: TsdValue read FPreGatherQuantity;
    property PreGatherTotalPrice: TsdValue read FPreGatherTotalPrice;

    property HasBookMark: TsdValue read FHasBookMark;
    property MarkMemo: TsdValue read FMarkMemo;


    property CacheDealTP: Double read FCacheDealTP write FCacheDealTP;

    property PM_PreTotalPrice: TsdValue read FPM_PreTotalPrice;
    property PM_TotalPrice: TsdValue read FPM_TotalPrice;
  end;

  TProjectGLRecord = class(TMeasureBaseRecord)
  private
    FID: TsdValue;
    FCode: TsdValue;
    FName: TsdValue;
    FUnits: TsdValue;
    FSpecs: TsdValue;
    FBasePrice: TsdValue;
    FRiskRange: TsdValue;
    FLockedPhaseID: TsdValue;
    FCreatePhaseID: TsdValue;

    FInfoPrice: TsdValue;
    FInfoDate: TsdValue;
    FDeltaPrice: TsdValue;
    FValidDeltaPrice: TsdValue;

    FPM_PreQuantity: TsdValue;
    FPM_PreTotalPrice: TsdValue;
    FPM_Quantity: TsdValue;
    FPM_TotalPrice: TsdValue;

    FPreUsedQuantity: TsdValue;
    FPreUsedTotalPrice: TsdValue;
    FUsedQuantity: TsdValue;
    FUsedTotalPrice: TsdValue;

    FPrePAL_UsedQuantity: TsdValue;
    FPrePAL_UsedTotalPrice: TsdValue;
    FPrePAL_DeltaPrice: TsdValue;
    FPrePAL_Total: TsdValue;
    FPAL_UsedQuantity: TsdValue;
    FPAL_UsedTotalPrice: TsdValue;
    FPAL_DeltaPrice: TsdValue;
    FPAL_Total: TsdValue;
  protected
    procedure DoAfterAddFields; override;
  public
    property ID: TsdValue read FID;
    property Code: TsdValue read FCode;
    property Name: TsdValue read FName;
    property Units: TsdValue read FUnits;
    property Specs: TsdValue read FSpecs;
    property BasePrice: TsdValue read FBasePrice;
    property RiskRange: TsdValue read FRiskRange;
    property LockedPhaseID: TsdValue read FLockedPhaseID;
    property CreatePhaseID: TsdValue read FCreatePhaseID;

    property InfoPrice: TsdValue read FInfoPrice;
    property InfoDate: TsdValue read FInfoDate;
    property DeltaPrice: TsdValue read FDeltaPrice;
    property ValidDeltaPrice: TsdValue read FValidDeltaPrice;

    property PM_PreQuantity: TsdValue read FPM_PreQuantity;
    property PM_PreTotalPrice: TsdValue read FPM_PreTotalPrice;
    property PM_Quantity: TsdValue read FPM_Quantity;
    property PM_TotalPrice: TsdValue read FPM_TotalPrice;

    property PreUsedQuantity: TsdValue read FPreUsedQuantity;
    property PreUsedTotalPrice: TsdValue read FPreUsedTotalPrice;
    property UsedQuantity: TsdValue read FUsedQuantity;
    property UsedTotalPrice: TsdValue read FUsedTotalPrice;

    property PrePAL_UsedQuantity: TsdValue read FPrePAL_UsedQuantity;
    property PrePAL_UsedTotalPrice: TsdValue read FPrePAL_UsedTotalPrice;
    property PrePAL_DeltaPrice: TsdValue read FPrePAL_DeltaPrice;
    property PrePAL_Total: TsdValue read FPrePAL_Total;
    property PAL_UsedQuantity: TsdValue read FPAL_UsedQuantity;
    property PAL_UsedTotalPrice: TsdValue read FPAL_UsedTotalPrice;
    property PAL_DeltaPrice: TsdValue read FPAL_DeltaPrice;
    property PAL_Total: TsdValue read FPAL_Total;
  end;

  TDetailGLRecord = class(TMeasureBaseRecord)
  private
    FID: TsdValue;
    FBillsID: TsdValue;
    FGLID: TsdValue;

    FCode: TsdValue;
    FQuantity: TsdValue;

    FCreatePhaseID: TsdValue;

    FLastBillsQuantity: TsdValue;
    FLockedPhaseID: TsdValue;

    FRelaProjectGL: TProjectGLRecord;
  protected
    procedure DoAfterAddFields; override;
  public
    property ID: TsdValue read FID;
    property BillsID: TsdValue read FBillsID;
    property GLID: TsdValue read FGLID;

    property Code: TsdValue read FCode;
    property Quantity: TsdValue read FQuantity;

    property CreatePhaseID: TsdValue read FCreatePhaseID;

    property LastBillsQuantity: TsdValue read FLastBillsQuantity;
    property LockedPhaseID: TsdValue read FLockedPhaseID;

    property RelaProjectGL: TProjectGLRecord read FRelaProjectGL write FRelaProjectGL;
  end;

  TStageCompareRecord = class(TMeasureBaseRecord)
  private
    FID: TsdValue;
    FQuantity0: TsdValue;
    FTotalPrice0: TsdValue;
    FQuantity1: TsdValue;
    FTotalPrice1: TsdValue;
    FQuantity2: TsdValue;
    FTotalPrice2: TsdValue;
    FQuantity3: TsdValue;
    FTotalPrice3: TsdValue;
    FQuantity4: TsdValue;
    FTotalPrice4: TsdValue;
    FQuantity5: TsdValue;
    FTotalPrice5: TsdValue;
    FQuantity6: TsdValue;
    FTotalPrice6: TsdValue;
    FQuantity7: TsdValue;
    FTotalPrice7: TsdValue;
    FQuantity8: TsdValue;
    FTotalPrice8: TsdValue;
    FQuantity9: TsdValue;
    FTotalPrice9: TsdValue;
    FQuantity10: TsdValue;
    FTotalPrice10: TsdValue;
    FQuantity11: TsdValue;
    FTotalPrice11: TsdValue;
    FQuantity12: TsdValue;
    FTotalPrice12: TsdValue;
    FQuantity13: TsdValue;
    FTotalPrice13: TsdValue;
    FQuantity14: TsdValue;
    FTotalPrice14: TsdValue;
  protected
    procedure DoAfterAddFields; override;
  public
    property ID: TsdValue read FID;
    property Quantity0: TsdValue read FQuantity0;
    property TotalPrice0 : TsdValue read FTotalPrice0;
    property Quantity1: TsdValue read FQuantity0;
    property TotalPrice1 : TsdValue read FTotalPrice0;
    property Quantity2: TsdValue read FQuantity0;
    property TotalPrice2 : TsdValue read FTotalPrice0;
    property Quantity3: TsdValue read FQuantity0;
    property TotalPrice3: TsdValue read FTotalPrice0;
    property Quantity4: TsdValue read FQuantity0;
    property TotalPrice4 : TsdValue read FTotalPrice0;
    property Quantity5: TsdValue read FQuantity0;
    property TotalPrice5 : TsdValue read FTotalPrice0;
    property Quantity6: TsdValue read FQuantity0;
    property TotalPrice6 : TsdValue read FTotalPrice0;
    property Quantity7: TsdValue read FQuantity0;
    property TotalPrice7 : TsdValue read FTotalPrice0;
    property Quantity8: TsdValue read FQuantity0;
    property TotalPrice8 : TsdValue read FTotalPrice0;
    property Quantity9: TsdValue read FQuantity0;
    property TotalPrice9 : TsdValue read FTotalPrice0;
    property Quantity10: TsdValue read FQuantity0;
    property TotalPrice10 : TsdValue read FTotalPrice0;
    property Quantity11: TsdValue read FQuantity0;
    property TotalPrice11 : TsdValue read FTotalPrice0;
    property Quantity12: TsdValue read FQuantity0;
    property TotalPrice12 : TsdValue read FTotalPrice0;
    property Quantity13: TsdValue read FQuantity0;
    property TotalPrice13 : TsdValue read FTotalPrice0;
    property Quantity14: TsdValue read FQuantity0;
    property TotalPrice14 : TsdValue read FTotalPrice0;
  end;

implementation

{ TBillsRecord }

procedure TBillsRecord.DoAfterAddFields;
begin
  inherited;
  FID := ValueByName('ID');
  FParentID := ValueByName('ParentID');
  FNextSiblingID := ValueByName('NextSiblingID');

  FSerialNo := ValueByName('SerialNo');
  FIsLeaf := ValueByName('IsLeaf');
  FLeafXmjParentID := ValueByName('LeafXmjParentID');
  FXiangCode := ValueByName('XiangCode');
  FMuCode := ValueByName('MuCode');
  FJieCode := ValueByName('JieCode');
  FXimuCode := ValueByName('XimuCode');
  FIndexCode := ValueByName('IndexCode');
  FChapterParentID := ValueByName('ChapterParentID');
  FNodeLevel := ValueByName('NodeLevel');
  FB_CodeChapter := ValueByName('B_CodeChapter');

  FCode := ValueByName('Code');
  FB_Code := ValueByName('B_Code');
  FName := ValueByName('Name');
  FUnits := ValueByName('Units');
  FAlias := ValueByName('Alias');

  FPrice := ValueByName('Price');
  FNewPrice := ValueByName('NewPrice');

  FOrgQuantity := ValueByName('OrgQuantity');
  FOrgTotalPrice := ValueByName('OrgTotalPrice');
  FMisQuantity := ValueByName('MisQuantity');
  FMisTotalPrice := ValueByName('MisTotalPrice');
  FOthQuantity := ValueByName('OthQuantity');
  FOthTotalPrice := ValueByName('OthTotalPrice');
  FQuantity := ValueByName('Quantity');
  FTotalPrice := ValueByName('TotalPrice');
  FCalcType := ValueByName('CalcType');

  FAddDealQuantity := ValueByName('AddDealQuantity');
  FAddDealTotalPrice := ValueByName('AddDealTotalPrice');

  FAddQcQuantity := ValueByName('AddQcQuantity');
  FAddQcTotalPrice := ValueByName('AddQcTotalPrice');
  FAddQcBGLCode := ValueByName('AddQcBGLCode');
  FAddQcBGLNum := ValueByName('AddQcBGLNum');

  FAddPcQuantity := ValueByName('AddPcQuantity');
  FAddPcTotalPrice := ValueByName('AddPcTotalPrice');
  FAddPcBGLCode := ValueByName('AddPcBGLCode');
  FAddPcBGLNum := ValueByName('AddPcBGLNum');

  FAddGatherQuantity := ValueByName('AddGatherQuantity');
  FAddGatherTotalPrice := ValueByName('AddGatherTotalPrice');

  FLockedLevel := ValueByName('LockedLevel');
  FLockedInfo := ValueByName('LockedInfo');
  FLockedNewPrice := ValueByName('LockedNewPrice');
  FCreatePhaseID := ValueByName('CreatePhaseID');
  FIsMeasureAdd := ValueByName('IsMeasureAdd');
  FIsGatherZJJL := ValueByName('IsGatherZJJL');

  FPeg := ValueByName('Peg');
  FDrawingCode := ValueByName('DrawingCode');
  FMemoStr := ValueByName('MemoStr');
  FApprovalCode := ValueByName('ApprovalCode');

  FDgnQuantity1 := ValueByName('DgnQuantity1');
  FDgnQuantity2 := ValueByName('DgnQuantity2');
  FDgnPrice := ValueByName('DgnPrice');

  FDealDgnQuantity1 := ValueByName('DealDgnQuantity1');
  FDealDgnQuantity2 := ValueByName('DealDgnQuantity2');
  FCDgnQuantity1 := ValueByName('CDgnQuantity1');
  FCDgnQuantity2 := ValueByName('CDgnQuantity2');
  FAddDgnPrice := ValueByName('AddDgnPrice');

  FHasBookMark := ValueByName('HasBookMark');
  FMarkMemo := ValueByName('MarkMemo');

  FDealCode := ValueByName('DealCode');
  FDealCompany := ValueByName('DealCompany');
  FDealType := ValueByName('DealType');
  FAddCutTotalPrice := ValueByName('AddCutTotalPrice');
  FAddPayTotalPrice := ValueByName('AddPayTotalPrice');

  FAddCompleteRate := ValueByName('AddCompleteRate');
  
  FPM_AddTotalPrice := ValueByName('PM_AddTotalPrice');
end;

{ TStageRecord }

procedure TStageRecord.DoAfterAddFields;
begin
  inherited;
  FBillsID := ValueByName('BillsID');

  FDealQuantity := ValueByName('DealQuantity');
  FDealTotalPrice := ValueByName('DealTotalPrice');
  FDealFlag := ValueByName('DealFlag');
  FDealFormula := ValueByName('DealFormula');

  FQcQuantity := ValueByName('QcQuantity');
  FQcTotalPrice := ValueByName('QcTotalPrice');
  FQcFlag := ValueByName('QcFlag');
  FQcFormula := ValueByName('QcFormula');
  FQcBGLCode := ValueByName('QcBGLCode');
  FQcBGLNum := ValueByName('QcBGLNum');

  FPcQuantity := ValueByName('PcQuantity');
  FPcTotalPrice := ValueByName('PcTotalPrice');
  FPcFlag := ValueByName('PcFlag');
  FPcFormula := ValueByName('PcFormula');
  FPcBGLCode := ValueByName('PcBGLCode');
  FPcBGLNum := ValueByName('PcBGLNum');

  FGatherQuantity := ValueByName('GatherQuantity');
  FGatherTotalPrice := ValueByName('GatherTotalPrice');

  FEndDealQuantity := ValueByName('EndDealQuantity');
  FEndDealTotalPrice := ValueByName('EndDealTotalPrice');
  FEndQcQuantity := ValueByName('EndQcQuantity');
  FEndQcTotalPrice := ValueByName('EndQcTotalPrice');
  FEndQcBGLCode := ValueByName('EndQcBGLCode');
  FEndQcBGLNum := ValueByName('EndQcBGLNum');
  FEndPcQuantity := ValueByName('EndPcQuantity');
  FEndPcTotalPrice := ValueByName('EndPcTotalPrice');
  FEndPcBGLCode := ValueByName('EndPcBGLCode');
  FEndPcBGLNum := ValueByName('EndPcBGLNum');
  FEndGatherQuantity := ValueByName('EndGatherQuantity');
  FEndGatherTotalPrice := ValueByName('EndGatherTotalPrice');

  FPreDealQuantity := ValueByName('PreDealQuantity');
  FPreDealTotalPrice := ValueByName('PreDealTotalPrice');
  FPreQcQuantity := ValueByName('PreQcQuantity');
  FPreQcTotalPrice := ValueByName('PreQcTotalPrice');
  FPreQcBGLCode := ValueByName('PreQcBGLCode');
  FPreQcBGLNum := ValueByName('PreQcBGLNum');
  FPrePcQuantity := ValueByName('PrePcQuantity');
  FPrePcTotalPrice := ValueByName('PrePcTotalPrice');
  FPrePcBGLCode := ValueByName('PrePcBGLCode');
  FPrePcBGLNum := ValueByName('PrePcBGLNum');
  FPreGatherQuantity := ValueByName('PreGatherQuantity');
  FPreGatherTotalPrice := ValueByName('PreGatherTotalPrice');

  FHasBookMark := ValueByName('HasBookMark');
  FMarkMemo := ValueByName('MarkMemo');

  FPM_PreTotalPrice := ValueByName('PM_PreTotalPrice');
  FPM_TotalPrice := ValueByName('PM_TotalPrice');
end;

{ TProjectGLRecord }

procedure TProjectGLRecord.DoAfterAddFields;
begin
  inherited;
  FID := ValueByName('ID');
  FCode := ValueByName('Code');
  FName := ValueByName('Name');
  FUnits := ValueByName('Units');
  FSpecs := ValueByName('Specs');
  FBasePrice := ValueByName('BasePrice');
  FRiskRange := ValueByName('RiskRange');
  FLockedPhaseID := ValueByName('LockedPhaseID');
  FCreatePhaseID := ValueByName('CreatePhaseID');

  FInfoPrice := ValueByName('InfoPrice');
  FInfoDate := ValueByName('InfoDate');
  FDeltaPrice := ValueByName('DeltaPrice');
  FValidDeltaPrice := ValueByName('ValidDeltaPrice');

  FPM_PreQuantity := ValueByName('PM_PreQuantity');
  FPM_PreTotalPrice := ValueByName('PM_PreTotalPrice');
  FPM_Quantity := ValueByName('PM_Quantity');
  FPM_TotalPrice := ValueByName('PM_TotalPrice');

  FUsedQuantity := ValueByName('UsedQuantity');
  FUsedTotalPrice := ValueByName('UsedTotalPrice');
  FPreUsedQuantity := ValueByName('PreUsedQuantity');
  FPreUsedTotalPrice := ValueByName('PreUsedTotalPrice');

  FPAL_UsedQuantity := ValueByName('PAL_UsedQuantity');
  FPAL_UsedTotalPrice := ValueByName('PAL_UsedTotalPrice');
  FPAL_DeltaPrice := ValueByName('PAL_DeltaPrice');
  FPAL_Total := ValueByName('PAL_Total');
  FPrePAL_UsedQuantity := ValueByName('PrePAL_UsedQuantity');
  FPrePAL_UsedTotalPrice := ValueByName('PrePAL_UsedTotalPrice');
  FPrePAL_DeltaPrice := ValueByName('PrePAL_DeltaPrice');
  FPrePAL_Total := ValueByName('PrePAL_Total');
end;

{ TDetailGLRecord }

procedure TDetailGLRecord.DoAfterAddFields;
begin
  inherited;
  FID := ValueByName('ID');
  FBillsID := ValueByName('BillsID');
  FGLID := ValueByName('GLID');

  FCode := ValueByName('Code');
  FQuantity := ValueByName('Quantity');

  FCreatePhaseID := ValueByName('CreatePhaseID');

  FLastBillsQuantity := ValueByName('LastBillsQuantity');
  FLockedPhaseID := ValueByName('LockedPhaseID');
end;

{ TMeasureBaseRecord }

procedure TMeasureBaseRecord.AddDifferValue(AValue: TsdValue;
  ADiffer: Double);
begin
  if ADiffer <> 0 then
    AValue.AsFloat := AValue.AsFloat + ADiffer;
end;

procedure TMeasureBaseRecord.SetBoolValue(AValue: TsdValue;
  ABool: Boolean);
begin
  if AValue.AsBoolean <> ABool then
    AValue.AsBoolean := ABool;
end;

procedure TMeasureBaseRecord.SetFloatValue(AValue: TsdValue;
  AFloat: Double);
begin
  if AValue.AsFloat <> AFloat then
    AValue.AsFloat := AFloat;
end;

procedure TMeasureBaseRecord.SetIntValue(AValue: TsdValue; AInt: Integer);
begin
  if AValue.AsInteger <> AInt then
    AValue.AsInteger := AInt;
end;

procedure TMeasureBaseRecord.SetStrValue(AValue: TsdValue; AStr: string);
begin
  if AValue.AsString <> AStr then
    AValue.AsString := AStr;
end;

{ TStageCompareRecord }

procedure TStageCompareRecord.DoAfterAddFields;
begin
  inherited;
  FID := ValueByName('ID');
  FQuantity0 := ValueByName('Quantity0');
  FTotalPrice0 := ValueByName('TotalPrice0');
  FQuantity1 := ValueByName('Quantity1');
  FTotalPrice1 := ValueByName('TotalPrice1');
  FQuantity2 := ValueByName('Quantity2');
  FTotalPrice2 := ValueByName('TotalPrice2');
  FQuantity3 := ValueByName('Quantity3');
  FTotalPrice3 := ValueByName('TotalPrice3');
  FQuantity4 := ValueByName('Quantity4');
  FTotalPrice4 := ValueByName('TotalPrice4');
  FQuantity5 := ValueByName('Quantity5');
  FTotalPrice5 := ValueByName('TotalPrice5');
  FQuantity6 := ValueByName('Quantity6');
  FTotalPrice6 := ValueByName('TotalPrice6');
  FQuantity7 := ValueByName('Quantity7');
  FTotalPrice7 := ValueByName('TotalPrice7');
  FQuantity8 := ValueByName('Quantity8');
  FTotalPrice8 := ValueByName('TotalPrice8');
  FQuantity9 := ValueByName('Quantity9');
  FTotalPrice9 := ValueByName('TotalPrice9');
  FQuantity10 := ValueByName('Quantity10');
  FTotalPrice10 := ValueByName('TotalPrice10');
  FQuantity11 := ValueByName('Quantity11');
  FTotalPrice11 := ValueByName('TotalPrice11');
  FQuantity12 := ValueByName('Quantity12');
  FTotalPrice12 := ValueByName('TotalPrice12');
  FQuantity13 := ValueByName('Quantity13');
  FTotalPrice13 := ValueByName('TotalPrice13');
  FQuantity14 := ValueByName('Quantity14');
  FTotalPrice14 := ValueByName('TotalPrice14');
end;

end.
