Просмотр исходного кода

恢复代码
【2016/8/10 16:21:14】提交的SHA-1: 14acd1101976c6d3ba566490c0ff8a93e20d263d,因高危操作导致代码混乱。
该代码基于Parent【2016/7/19 14:27:36】,提交代码时,未先Pull,便Commit至本地Git库
致使Git认为,以下第2部分代码应以【2016/8/10 16:21:14】最新记录为准,并替换之
即将第2部分代码自【2016/8/10 16:02:55】替换为【2016/7/19 14:27:36】,导致第2部分代码非正常回滚

现做如下处理:
1. 基于Sha-1:14acd1101976c6d3ba566490c0ff8a93e20d263d,保留
DataModules\PHPWebDm.pas
Forms\FileDownLoadFrm.dfm
Forms\FileDownLoadFrm.pas
Forms\LoginFrm.pas
Dprs\CSL\Measure_Cloud.cfg
Dprs\CSL\Measure_Cloud.dof
Dprs\CSL\Measure_Cloud.dpr
Dprs\CSL\Measure_Cloud.res

2. 基于Sha-1:7bc18746370cd34cadf5c104d3598acedb7951a0,恢复如下单元
DataModules\BGLDm.dfm
DataModules\BGLDm.pas
DataModules\DbTreeDm.dfm
DataModules\DbTreeDm.pas
DataModules\PhasePayDm.dfm
DataModules\PhasePayDm.pas
DataModules\ProjectGLDm.dfm
DataModules\ProjectGLDm.pas
DataModules\ProjectManagerDm.pas
DataModules\StandardBillsDm.dfm
DataModules\ZJJLDm.pas
Dprs\Pro\Measure.dof
Dprs\Pro\Measure.dpr
Dprs\Pro\Measure.res
Dprs\Pro\Measure_Cloud.dof
Dprs\Pro\Measure_Cloud.dpr
Dprs\Pro\Measure_Cloud.res
Dprs\Pro\Measure_GuangDong.dof
Dprs\Pro\Measure_GuangDong.dpr
Dprs\Pro\Measure_GuangDong.res
Dprs\Pro\Measure_GuangDong_Cloud.dof
Dprs\Pro\Measure_GuangDong_Cloud.dpr
Dprs\Pro\Measure_GuangDong_Cloud.res
Dprs\Pro\Measure_GuangDong_TZ.dof
Dprs\Pro\Measure_GuangDong_TZ.dpr
Dprs\Pro\Measure_GuangDong_TZ.res
Dprs\Pro\Measure_TZ.dof
Dprs\Pro\Measure_TZ.dpr
Dprs\Pro\Measure_TZ.res
Forms\MainFrm.dfm
Forms\MainFrm.pas
Forms\ProjectPropertiesFrm.dfm
Forms\ProjectPropertiesFrm.pas
Forms\ReportsFrm.dfm
Forms\ReportsFrm.pas
Frames\CheckerFme.pas
Frames\DealPaymentFme.dfm
Frames\DealPaymentFme.pas
Frames\ProjectGLFme.dfm
Frames\ZJJLFme.dfm
Frames\ZJJLFme.pas
Report\ReportConnection.pas
Units\BillsClipboard.pas
Units\CacheTree.pas
Units\Checker.pas
Units\ConditionalDefines.pas
Units\Connections.pas
Units\DataBaseTables.pas
Units\DbTreeImport.pas
Units\DebugUsers.pas
Units\ExcelImport.pas
Units\ProjectData.pas
Units\ProjectProperty.pas
Units\UpdateDataBase.pas
Units\mDataRecord.pas

MaiXinRong 10 лет назад
Родитель
Сommit
9ac8cacba0
51 измененных файлов с 1004 добавлено и 321 удалено
  1. 0 12
      DataModules/BGLDm.dfm
  2. 0 52
      DataModules/BGLDm.pas
  3. 12 9
      DataModules/PhasePayDm.dfm
  4. 23 18
      DataModules/PhasePayDm.pas
  5. 56 1
      DataModules/ProjectGLDm.dfm
  6. 63 6
      DataModules/ProjectGLDm.pas
  7. 7 3
      DataModules/ProjectManagerDm.pas
  8. 4 1
      DataModules/StandardBillsDm.dfm
  9. 30 12
      DataModules/ZJJLDm.pas
  10. 2 2
      Dprs/Pro/Measure.dof
  11. 3 1
      Dprs/Pro/Measure.dpr
  12. BIN
      Dprs/Pro/Measure.res
  13. 4 3
      Dprs/Pro/Measure_Cloud.dof
  14. 4 1
      Dprs/Pro/Measure_Cloud.dpr
  15. BIN
      Dprs/Pro/Measure_Cloud.res
  16. 2 2
      Dprs/Pro/Measure_GuangDong.dof
  17. 3 1
      Dprs/Pro/Measure_GuangDong.dpr
  18. BIN
      Dprs/Pro/Measure_GuangDong.res
  19. 2 2
      Dprs/Pro/Measure_GuangDong_Cloud.dof
  20. 4 1
      Dprs/Pro/Measure_GuangDong_Cloud.dpr
  21. BIN
      Dprs/Pro/Measure_GuangDong_Cloud.res
  22. 2 2
      Dprs/Pro/Measure_GuangDong_TZ.dof
  23. 3 1
      Dprs/Pro/Measure_GuangDong_TZ.dpr
  24. BIN
      Dprs/Pro/Measure_GuangDong_TZ.res
  25. 2 2
      Dprs/Pro/Measure_TZ.dof
  26. 3 1
      Dprs/Pro/Measure_TZ.dpr
  27. BIN
      Dprs/Pro/Measure_TZ.res
  28. 20 0
      Forms/MainFrm.dfm
  29. 12 0
      Forms/MainFrm.pas
  30. 57 9
      Forms/ProjectPropertiesFrm.dfm
  31. 18 0
      Forms/ProjectPropertiesFrm.pas
  32. 21 10
      Forms/ReportsFrm.dfm
  33. 76 71
      Forms/ReportsFrm.pas
  34. 4 2
      Frames/CheckerFme.pas
  35. 10 0
      Frames/DealPaymentFme.dfm
  36. 53 2
      Frames/DealPaymentFme.pas
  37. 109 1
      Frames/ProjectGLFme.dfm
  38. 8 8
      Frames/ZJJLFme.dfm
  39. 1 1
      Frames/ZJJLFme.pas
  40. 1 0
      Report/ReportConnection.pas
  41. 1 0
      Units/BillsClipboard.pas
  42. 1 1
      Units/CacheTree.pas
  43. 2 0
      Units/Checker.pas
  44. 7 0
      Units/ConditionalDefines.pas
  45. 98 9
      Units/Connections.pas
  46. 131 8
      Units/DataBaseTables.pas
  47. 5 3
      Units/ExcelImport.pas
  48. 75 63
      Units/ProjectData.pas
  49. 22 0
      Units/ProjectProperty.pas
  50. 7 0
      Units/UpdateDataBase.pas
  51. 36 0
      Units/mDataRecord.pas

+ 0 - 12
DataModules/BGLDm.dfm

@@ -47,9 +47,6 @@ object BGLData: TBGLData
       FieldName = 'DrawingCode'
       Size = 50
     end
-    object cdsBGLLocked: TBooleanField
-      FieldName = 'Locked'
-    end
     object cdsBGLApprovalCode: TWideStringField
       FieldName = 'ApprovalCode'
       Size = 50
@@ -96,9 +93,6 @@ object BGLData: TBGLData
       FieldName = 'Direction'
       BlobType = ftMemo
     end
-    object cdsBGLViewLocked: TBooleanField
-      FieldName = 'Locked'
-    end
     object cdsBGLViewDrawingCode: TWideStringField
       FieldName = 'DrawingCode'
       Size = 50
@@ -169,9 +163,6 @@ object BGLData: TBGLData
     object cdsBGBillsUsedQuantity: TFloatField
       FieldName = 'UsedQuantity'
     end
-    object cdsBGBillsLocked: TBooleanField
-      FieldName = 'Locked'
-    end
   end
   object cdsBGBillsView: TClientDataSet
     Aggregates = <>
@@ -219,8 +210,5 @@ object BGLData: TBGLData
     object cdsBGBillsViewUsedQuantity: TFloatField
       FieldName = 'UsedQuantity'
     end
-    object cdsBGBillsViewLocked: TBooleanField
-      FieldName = 'Locked'
-    end
   end
 end

+ 0 - 52
DataModules/BGLDm.pas

@@ -53,7 +53,6 @@ type
     cdsBGLPos_Reason: TMemoField;
     cdsBGLDirection: TMemoField;
     cdsBGLDrawingCode: TWideStringField;
-    cdsBGLLocked: TBooleanField;
     cdsBGLApprovalCode: TWideStringField;
     cdsBGLCreatePhaseID: TIntegerField;
     cdsBGLExecutionRate: TFloatField;
@@ -66,7 +65,6 @@ type
     cdsBGLViewPos_Reason: TMemoField;
     cdsBGLViewDirection: TMemoField;
     cdsBGLViewDrawingCode: TWideStringField;
-    cdsBGLViewLocked: TBooleanField;
     cdsBGLViewApprovalCode: TWideStringField;
     cdsBGLViewCreatePhaseID: TIntegerField;
     cdsBGLViewExecutionRate: TFloatField;
@@ -85,7 +83,6 @@ type
     cdsBGBillsQuantity: TFloatField;
     cdsBGBillsTotalPrice: TFloatField;
     cdsBGBillsUsedQuantity: TFloatField;
-    cdsBGBillsLocked: TBooleanField;
     
     cdsBGBillsView: TClientDataSet;
     cdsBGBillsViewID: TIntegerField;
@@ -97,7 +94,6 @@ type
     cdsBGBillsViewQuantity: TFloatField;
     cdsBGBillsViewTotalPrice: TFloatField;
     cdsBGBillsViewUsedQuantity: TFloatField;
-    cdsBGBillsViewLocked: TBooleanField;
     cdsBGLBGLType: TWideStringField;
     cdsBGLViewBGLType: TWideStringField;
     procedure cdsBGBillsViewAfterInsert(DataSet: TDataSet);
@@ -130,9 +126,6 @@ type
 
     function LocateBGL(const ACode: string): Boolean;
     function LocateBGBills(ABGID: Integer; const AB_Code: string): Boolean;
-
-    procedure LockAllBGL;
-    procedure LockAllBGBills;
   public
     constructor Create(AProjectData: TObject);
     destructor Destroy; override;
@@ -148,8 +141,6 @@ type
 
     procedure BatchWritePos_Reason;
 
-    procedure LockAll;
-
     property ProjectData: TObject read FProjectData;
   end;
 
@@ -412,16 +403,12 @@ begin
       (cdsBGBillsViewUnits.Tag = 1) or
       (cdsBGBillsViewPrice.Tag = 1) then
   begin
-    if cdsBGBillsViewLocked.AsBoolean then
-      DisplayErrorMessage('变更清单已被锁定,不可修改!');
     if cdsBGBillsViewUsedQuantity.AsFloat <> 0 then
       DisplayErrorMessage('变更令已被应用至清单,不可修改!');
   end;
 
   if (cdsBGBillsViewQuantity.Tag = 1) then
   begin
-    if cdsBGBillsViewLocked.AsBoolean then
-      DisplayErrorMessage('变更清单已被锁定,不可修改!');
     if (cdsBGBillsViewUsedQuantity.AsFloat <> 0) and
        (cdsBGBillsViewQuantity.AsFloat < cdsBGBillsViewUsedQuantity.AsFloat) then
       DisplayErrorMessage('变更清单的清单数量应大于已变更数量!');
@@ -451,11 +438,6 @@ begin
   begin
     cdsBGLViewCode.Tag := 0;
 
-    if cdsBGLViewLocked.AsBoolean then
-    begin
-      ErrorMessage('当前变更令已锁定,不可修改!');
-      Abort;
-    end;
     if CheckBGLUsed(cdsBGLViewID.AsInteger) then
     begin
       ErrorMessage('当前变更令下变更清单已被应用到清单,不可修改!');
@@ -499,8 +481,6 @@ end;
 
 procedure TBGLData.cdsBGLViewBeforeDelete(DataSet: TDataSet);
 begin
-  if cdsBGLViewLocked.AsBoolean then
-    raise Exception.Create('变更令已被锁定,不可删除!');
   if CheckBGLUsed(cdsBGLViewID.AsInteger) then
     raise Exception.Create('变更令下变更清单已被应用到清单,不可删除!');
   DeleteBGBills(cdsBGLViewID.AsInteger);
@@ -526,8 +506,6 @@ end;
 
 procedure TBGLData.cdsBGBillsViewBeforeDelete(DataSet: TDataSet);
 begin
-  if cdsBGBillsViewLocked.AsBoolean then
-    raise Exception.Create('变更清单已被锁定,不可删除!');
   if cdsBGBillsViewUsedQuantity.AsFloat <> 0 then
     raise Exception.Create('变更清单已被应用至清单,不可删除!');
 end;
@@ -549,36 +527,6 @@ begin
   end;
 end;
 
-procedure TBGLData.LockAll;
-begin
-  LockAllBGL;
-  LockAllBGBills;
-end;
-
-procedure TBGLData.LockAllBGBills;
-begin
-  cdsBGBills.First;
-  while not cdsBGBills.Eof do
-  begin
-    cdsBGBills.Edit;
-    cdsBGBillsLocked.AsBoolean := True;
-    cdsBGBills.Post;
-    cdsBGBills.Next;
-  end;
-end;
-
-procedure TBGLData.LockAllBGL;
-begin
-  cdsBGL.First;
-  while not cdsBGL.Eof do
-  begin
-    cdsBGL.Edit;
-    cdsBGLLocked.AsBoolean := True;
-    cdsBGL.Post;
-    cdsBGL.Next;
-  end;
-end;
-
 procedure TBGLData.cdsBGBillsViewAfterDelete(DataSet: TDataSet);
 begin
   GatherBGLTotalPrice(cdsBGLViewID.AsInteger);

+ 12 - 9
DataModules/PhasePayDm.dfm

@@ -173,11 +173,11 @@ object PhasePayData: TPhasePayData
       636573734E616D65090001044E616D650609466F726D756C613133094669656C
       644E616D650609466F726D756C61313308446174615479706502180844617461
       53697A6503FF000549734B6579080F4E65656450726F636573734E616D650900
-      01044E616D65060F456E64546F74616C50726963653133094669656C644E616D
-      65060F456E64546F74616C507269636531330844617461547970650206084461
+      01044E616D65060F507265546F74616C50726963653133094669656C644E616D
+      65060F507265546F74616C507269636531330844617461547970650206084461
       746153697A6502080549734B6579080F4E65656450726F636573734E616D6509
-      0001044E616D65060F456E64546F74616C50726963653134094669656C644E61
-      6D65060F456E64546F74616C5072696365313408446174615479706502060844
+      0001044E616D65060F456E64546F74616C50726963653133094669656C644E61
+      6D65060F456E64546F74616C5072696365313308446174615479706502060844
       61746153697A6502080549734B6579080F4E65656450726F636573734E616D65
       090001044E616D65060C546F74616C50726963653134094669656C644E616D65
       060C546F74616C50726963653134084461746154797065020608446174615369
@@ -185,11 +185,14 @@ object PhasePayData: TPhasePayData
       616D650609466F726D756C613134094669656C644E616D650609466F726D756C
       6131340844617461547970650218084461746153697A6503FF000549734B6579
       080F4E65656450726F636573734E616D65090001044E616D65060F507265546F
-      74616C50726963653133094669656C644E616D65060F507265546F74616C5072
-      69636531330844617461547970650206084461746153697A6502080549734B65
-      79080F4E65656450726F636573734E616D65090001044E616D65060F50726554
-      6F74616C50726963653134094669656C644E616D65060F507265546F74616C50
+      74616C50726963653134094669656C644E616D65060F507265546F74616C5072
+      69636531340844617461547970650206084461746153697A6502080549734B65
+      79080F4E65656450726F636573734E616D65090001044E616D65060F456E6454
+      6F74616C50726963653134094669656C644E616D65060F456E64546F74616C50
       7269636531340844617461547970650206084461746153697A6502080549734B
-      6579080F4E65656450726F636573734E616D65090000}
+      6579080F4E65656450726F636573734E616D65090001044E616D65060853746F
+      7043616C63094669656C644E616D65060853746F7043616C6308446174615479
+      70650205084461746153697A6502010549734B6579080F4E65656450726F6365
+      73734E616D65090000}
   end
 end

+ 23 - 18
DataModules/PhasePayDm.pas

@@ -187,28 +187,33 @@ begin
   sFField := 'Formula' + IntToStr(TPhaseData(FPhaseData).StageIndex);
   sPreField := 'PreTotalPrice' + IntToStr(TPhaseData(FPhaseData).StageIndex);
 
-  iID := Rec.ValueByName('ID').AsInteger;
-  with TProjectData(TPhaseData(FPhaseData).ProjectData).DealPaymentData do
+  if not Rec.ValueByName('StopCalc').AsBoolean then
   begin
-    // 获取起扣金额
-    fStartedPrice :=  GetStartedPrice(iID);
-
-    if Rec.ValueByName(sFField).AsString <> '' then
+    iID := Rec.ValueByName('ID').AsInteger;
+    with TProjectData(TPhaseData(FPhaseData).ProjectData).DealPaymentData do
     begin
-      // 初次达到起扣金额时,bqwc基数值取值为累计完成计量-起扣金额
-      if Rec.ValueByName('Pre'+sTPField).AsFloat = 0 then
-        fTotalPrice := FPayFormula.Calculate(Rec.ValueByName(sFField).AsString, fStartedPrice)
+      // 获取起扣金额
+      fStartedPrice :=  GetStartedPrice(iID);
+
+      if Rec.ValueByName(sFField).AsString <> '' then
+      begin
+        // 初次达到起扣金额时,bqwc基数值取值为累计完成计量-起扣金额
+        if Rec.ValueByName('Pre'+sTPField).AsFloat = 0 then
+          fTotalPrice := FPayFormula.Calculate(Rec.ValueByName(sFField).AsString, fStartedPrice)
+        else
+          fTotalPrice := FPayFormula.Calculate(Rec.ValueByName(sFField).AsString);
+      end
       else
-        fTotalPrice := FPayFormula.Calculate(Rec.ValueByName(sFField).AsString);
-    end
-    else
-      fTotalPrice := 0;
+        fTotalPrice := 0;
 
-    if CheckStartedPrice(iID) then
-      Rec.ValueByName(sTPField).AsFloat := GetAllowTotalPrice(iID, fTotalPrice, Rec.ValueByName(sPreField).AsFloat)
-    else
-      Rec.ValueByName(sTPField).AsFloat := 0;
-  end;
+      if CheckStartedPrice(iID) then
+        Rec.ValueByName(sTPField).AsFloat := GetAllowTotalPrice(iID, fTotalPrice, Rec.ValueByName(sPreField).AsFloat)
+      else
+        Rec.ValueByName(sTPField).AsFloat := 0;
+    end;
+  end
+  else
+    Rec.ValueByName(sTPField).AsFloat := 0;
 
   {if Rec.ValueByName(sFField).AsString <> '' then
   begin

+ 56 - 1
DataModules/ProjectGLDm.dfm

@@ -58,7 +58,44 @@ object ProjectGLData: TProjectGLData
       734B6579080F4E65656450726F636573734E616D65090001044E616D65060D50
       4D5F546F74616C5072696365094669656C644E616D65060D504D5F546F74616C
       50726963650844617461547970650206084461746153697A6502080549734B65
-      79080F4E65656450726F636573734E616D65090000}
+      79080F4E65656450726F636573734E616D65090001044E616D65060C55736564
+      5175616E74697479094669656C644E616D65060C557365645175616E74697479
+      0844617461547970650206084461746153697A6502080549734B6579080F4E65
+      656450726F636573734E616D65090001044E616D65060E55736564546F74616C
+      5072696365094669656C644E616D65060E55736564546F74616C507269636508
+      44617461547970650206084461746153697A6502080549734B6579080F4E6565
+      6450726F636573734E616D65090001044E616D65061050414C5F557365645175
+      616E74697479094669656C644E616D65061050414C5F557365645175616E7469
+      74790844617461547970650206084461746153697A6502080549734B6579080F
+      4E65656450726F636573734E616D65090001044E616D65061250414C5F557365
+      64546F74616C5072696365094669656C644E616D65061250414C5F5573656454
+      6F74616C50726963650844617461547970650206084461746153697A65020805
+      49734B6579080F4E65656450726F636573734E616D65090001044E616D65060E
+      50414C5F44656C74615072696365094669656C644E616D65060E50414C5F4465
+      6C746150726963650844617461547970650206084461746153697A6502080549
+      734B6579080F4E65656450726F636573734E616D65090001044E616D65060950
+      414C5F546F74616C094669656C644E616D65060950414C5F546F74616C084461
+      7461547970650206084461746153697A6502080549734B6579080F4E65656450
+      726F636573734E616D65090001044E616D65060F507265557365645175616E74
+      697479094669656C644E616D65060F507265557365645175616E746974790844
+      617461547970650206084461746153697A6502080549734B6579080F4E656564
+      50726F636573734E616D65090001044E616D65061150726555736564546F7461
+      6C5072696365094669656C644E616D65061150726555736564546F74616C5072
+      6963650844617461547970650206084461746153697A6502080549734B657908
+      0F4E65656450726F636573734E616D65090001044E616D65061350726550414C
+      5F557365645175616E74697479094669656C644E616D65061350726550414C5F
+      557365645175616E746974790844617461547970650206084461746153697A65
+      02080549734B6579080F4E65656450726F636573734E616D65090001044E616D
+      65061550726550414C5F55736564546F74616C5072696365094669656C644E61
+      6D65061550726550414C5F55736564546F74616C507269636508446174615479
+      70650206084461746153697A6502080549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D65061150726550414C5F44656C746150726963
+      65094669656C644E616D65061150726550414C5F44656C746150726963650844
+      617461547970650206084461746153697A6502080549734B6579080F4E656564
+      50726F636573734E616D65090001044E616D65060C50726550414C5F546F7461
+      6C094669656C644E616D65060C50726550414C5F546F74616C08446174615479
+      70650206084461746153697A6502080549734B6579080F4E65656450726F6365
+      73734E616D65090000}
   end
   object sdvProjectGL: TsdDataView
     Active = False
@@ -107,6 +144,24 @@ object ProjectGLData: TProjectGLData
       item
         FieldName = 'PM_TotalPrice'
         DisplayFormat = '0.##'
+      end
+      item
+        FieldName = 'UsedQuantity'
+      end
+      item
+        FieldName = 'UsedTotalPrice'
+      end
+      item
+        FieldName = 'PAL_UsedQuantity'
+      end
+      item
+        FieldName = 'PAL_UsedTotalPrice'
+      end
+      item
+        FieldName = 'PAL_DeltaPrice'
+      end
+      item
+        FieldName = 'PAL_Total'
       end>
     OnGetText = sdvProjectGLGetText
     OnSetText = sdvProjectGLSetText

+ 63 - 6
DataModules/ProjectGLDm.pas

@@ -37,6 +37,9 @@ type
 
     procedure CalculateRelaBills(ARec: TProjectGLRecord);
 
+    procedure CalculatePALRela(ARec: TProjectGLRecord);
+    procedure CalculatePALRelas;
+
     procedure ExecuteSql(const ASql: string);
     procedure SaveGLPrice;
     procedure SavePM_CurData;
@@ -122,6 +125,9 @@ var
         Rec.InfoDate.AsString := vQuery.FieldByName('InfoDate').AsString;
         Rec.DeltaPrice.AsFloat := vQuery.FieldByName('DeltaPrice').AsFloat;
         Rec.ValidDeltaPrice.AsFloat := vQuery.FieldByName('ValidDeltaPrice').AsFloat;
+
+        Rec.UsedQuantity.AsFloat := vQuery.FieldByName('UsedQuantity').AsFloat;
+        Rec.UsedTotalPrice.AsFloat := vQuery.FieldByName('UsedTotalPrice').AsFloat;
       end
       else
       begin
@@ -129,6 +135,9 @@ var
         Rec.InfoDate.AsString := '';
         Rec.DeltaPrice.AsFloat := 0;
         Rec.ValidDeltaPrice.AsFloat := 0;
+
+        Rec.UsedQuantity.AsFloat := 0;
+        Rec.UsedTotalPrice.AsFloat := 0;
       end;
     end;
   end;
@@ -176,10 +185,12 @@ procedure TProjectGLData.SaveGLPrice;
 const
   sDeleteSql = 'Delete From GLPrice Where PhaseID = %d';
   sInsertSql = 'Insert Into GLPrice'+
-               '  Select ID As GLID, %d As PhaseID, InfoPrice, InfoDate, DeltaPrice, ValidDeltaPrice' +
+               '  Select ID As GLID, %d As PhaseID, InfoPrice, InfoDate, DeltaPrice, ValidDeltaPrice, UsedQuantity, UsedTotalPrice' +
                '  From ProjectGL';
   sUpdateSql = 'Update GLPrice As G, ProjectGL As P'+
-               '    Set G.PM_PreQuantity = P.PM_PreQuantity, G.PM_PreTotalPrice = P.PM_PreTotalPrice'+
+               '    Set G.PM_PreQuantity = P.PM_PreQuantity, G.PM_PreTotalPrice = P.PM_PreTotalPrice,'+
+               '        G.PrePAL_UsedQuantity = P.PrePAL_UsedQuantity, G.PrePAL_UsedTotalPrice = P.PrePAL_UsedTotalPrice,' +
+               '        G.PrePAL_DeltaPrice = P.PrePAL_DeltaPrice, G.PrePAL_Total = P.PrePAL_Total'+
                '  Where (G.PhaseID = %d) and (G.GLID = P.ID)';
 var
   iPhaseID: Integer;
@@ -212,9 +223,14 @@ begin
     CalculateDeltaPrice(TProjectGLRecord(AValue.Owner));
     CalculatePM_Quantity(TProjectGLRecord(AValue.Owner));
     CalculatePM_TotalPrice(TProjectGLRecord(AValue.Owner));
+    CalculatePALRela(TProjectGLRecord(AValue.Owner));
     CalculateRelaBills(TProjectGLRecord(AValue.Owner));
     TProjectData(FProjectData).PriceMarginBillsData.RefreshAllDetailBills;
   end;
+  if SameText(AValue.FieldName, 'UsedQuantity') then
+  begin
+    CalculatePALRela(TProjectGLRecord(AValue.Owner));
+  end;
 end;
 
 procedure TProjectGLData.CalculateDeltaPrice(ARec: TProjectGLRecord);
@@ -380,7 +396,11 @@ procedure TProjectGLData.SavePM_CurData;
 const
   sUpdateSql = 'Update GLPrice As G, ProjectGL As P'+
                '  Set G.PM_Quantity%d = P.PM_Quantity, G.PM_TotalPrice%d = P.PM_TotalPrice,'+
-               '    G.PM_Quantity_F = P.PM_Quantity, G.PM_TotalPrice_F = P.PM_TotalPrice'+
+               '    G.PAL_UsedQuantity%d = P.PAL_UsedQuantity, G.PAL_UsedTotalPrice%d = P.PAL_UsedTotalPrice,'+
+               '    G.PAL_DeltaPrice%d = P.PAL_DeltaPrice, G.PAL_Total%d = P.PAL_Total,'+
+               '    G.PM_Quantity_F = P.PM_Quantity, G.PM_TotalPrice_F = P.PM_TotalPrice,'+
+               '    G.PAL_UsedQuantity_F = P.PAL_UsedQuantity, G.PAL_UsedTotalPrice_F = P.PAL_UsedTotalPrice,'+
+               '    G.PAL_DeltaPrice_F = P.PAL_DeltaPrice, G.PAL_Total_F = P.PAL_Total'+
                '  Where (G.PhaseID = %d) and (G.GLID = P.ID)';
 var
   iStageIndex: Integer;
@@ -389,7 +409,7 @@ var
 begin
   iStageIndex := TProjectData(FProjectData).PhaseData.StageIndex;
   iPhaseCount := TProjectData(FProjectData).ProjProperties.PhaseCount;
-  sSql := Format(sUpdateSql, [iStageIndex, iStageIndex, iPhaseCount]);
+  sSql := Format(sUpdateSql, [iStageIndex, iStageIndex, iStageIndex, iStageIndex, iStageIndex, iStageIndex, iPhaseCount]);
   ExecuteSql(sSql);
 end;
 
@@ -498,8 +518,12 @@ end;
 procedure TProjectGLData.LoadStagePM_CalcData;
 const
   sSelectSql = 'Select GLID, PhaseID, PM_PreQuantity, PM_PreTotalPrice,'+
-               '    PM_Quantity%d As PM_Quantity, PM_TotalPrice%d As PM_TotalPrice'+
+               '    PrePAL_UsedQuantity, PrePAL_UsedTotalPrice, PrePAL_DeltaPrice, PrePAL_Total,' +
+               '    PM_Quantity%d As PM_Quantity, PM_TotalPrice%d As PM_TotalPrice,'+
+               '    PAL_UsedQuantity%d As PAL_UsedQuantity, PAL_UsedTotalPrice%d As PAL_UsedTotalPrice,' +
+               '    PAL_DeltaPrice%d As PAL_DeltaPrice, PAL_Total%d As PAL_Total' +
                '  From GLPrice Where PhaseID = %d';
+
 var
   sSql: string;
   vQuery: TADOQuery;
@@ -516,11 +540,21 @@ var
       begin
         Rec.PM_Quantity.AsFloat := vQuery.FieldByName('PM_Quantity').AsFloat;
         Rec.PM_TotalPrice.AsFloat := vQuery.FieldByName('PM_TotalPrice').AsFloat;
+
+        Rec.PAL_UsedQuantity.AsFloat := vQuery.FieldByName('PAL_UsedQuantity').AsFloat;
+        Rec.PAL_UsedTotalPrice.AsFloat := vQuery.FieldByName('PAL_UsedTotalPrice').AsFloat;
+        Rec.PAL_DeltaPrice.AsFloat := vQuery.FieldByName('PAL_DeltaPrice').AsFloat;
+        Rec.PAL_Total.AsFloat := vQuery.FieldByName('PAL_Total').AsFloat;
       end
       else
       begin
         Rec.PM_Quantity.AsFloat := 0;
         Rec.PM_TotalPrice.AsFloat := 0;
+
+        Rec.PAL_UsedQuantity.AsFloat := 0;
+        Rec.PAL_UsedTotalPrice.AsFloat := 0;
+        Rec.PAL_DeltaPrice.AsFloat := 0;
+        Rec.PAL_Total.AsFloat := 0;
       end;
     end;
   end;
@@ -531,7 +565,7 @@ begin
   try
     vQuery.Connection := sdpProjectGL.Connection;
     with TProjectData(FProjectData) do
-      sSql := Format(sSelectSql, [StageIndex, StageIndex, PhaseIndex]);
+      sSql := Format(sSelectSql, [StageIndex, StageIndex, StageIndex, StageIndex, StageIndex, StageIndex, PhaseIndex]);
     vQuery.SQL.Clear;
     vQuery.SQL.Add(sSql);
     vQuery.Open;
@@ -575,4 +609,27 @@ begin
   Result := TProjectData(FProjectData).ProjProperties.DecimalManager.PriceMargin;
 end;
 
+procedure TProjectGLData.CalculatePALRela(ARec: TProjectGLRecord);
+begin
+  ARec.UsedTotalPrice.AsFloat := Decimal.TotalPrice.RoundTo(ARec.UsedQuantity.AsFloat * ARec.InfoPrice.AsFloat);
+  ARec.PAL_UsedQuantity.AsFloat := Decimal.Quantity.RoundTo(ARec.PM_Quantity.AsFloat - ARec.UsedQuantity.AsFloat);
+  ARec.PAL_UsedTotalPrice.AsFloat := Decimal.TotalPrice.RoundTo(ARec.PAL_UsedQuantity.AsFloat * ARec.BasePrice.AsFloat);
+  ARec.PAL_DeltaPrice.AsFloat := Decimal.TotalPrice.RoundTo(ARec.UsedQuantity.AsFloat * ARec.ValidDeltaPrice.AsFloat);
+  ARec.PAL_Total.AsFloat := Decimal.TotalPrice.RoundTo(ARec.BasePrice.AsFloat*ARec.PM_Quantity.AsFloat - ARec.InfoPrice.AsFloat*ARec.UsedQuantity.AsFloat);
+end;
+
+procedure TProjectGLData.CalculatePALRelas;
+var
+  iRec: Integer;
+  Rec: TProjectGLRecord;
+begin
+  if TProjectData(FProjectData).PhaseData.StageDataReadOnly then Exit;
+
+  for iRec := 0 to sddProjectGL.RecordCount - 1 do
+  begin
+    Rec := TProjectGLRecord(sddProjectGL.Records[iRec]);
+    CalculatePALRela(Rec);
+  end;
+end;
+
 end.

+ 7 - 3
DataModules/ProjectManagerDm.pas

@@ -25,7 +25,7 @@ type
     procedure sdvProjectsInfoBeforeDeleteRecord(ARecord: TsdDataRecord;
       var Allow: Boolean);
   private
-    FConnection: TEncryptConnection;
+    FConnection: TCommonConnection;
     FProjectsTree: TsdIDTree;
     FBackupManager: TBackupManager;
 
@@ -79,7 +79,7 @@ uses
 constructor TProjectManagerData.Create;
 begin
   inherited Create(nil);
-  FConnection := TEncryptConnection.Create;
+  FConnection := TCommonConnection.Create;
   FProjectsTree := TsdIDTree.Create;
   FProjectsTree.KeyFieldName := 'ID';
   FProjectsTree.ParentFieldName := 'ParentID';
@@ -276,9 +276,13 @@ end;
 
 procedure TProjectManagerData.Open;
 var
+  sFileName: string;
   FQuery: TADOQuery;
 begin
-  FConnection.Open(GetAppFilePath + 'Data\ProjectManager.dat');
+  sFileName := GetAppFilePath + 'Data\ProjectManager.dat';
+  if FileEncrypted(sFileName) then
+    SimpleDecrypt(sFileName, sFileName);
+  FConnection.Open(sFileName);
 
   UpdateManagerDataBase;
   sdpProjectsInfo.Connection := FConnection.Connection;

+ 4 - 1
DataModules/StandardBillsDm.dfm

@@ -30,7 +30,10 @@ object StandardBillsData: TStandardBillsData
       0844617461547970650218084461746153697A6503C8000549734B6579080F4E
       65656450726F636573734E616D65090001044E616D650604556E697409466965
       6C644E616D650604556E69740844617461547970650218084461746153697A65
-      02140549734B6579080F4E65656450726F636573734E616D65090000}
+      02140549734B6579080F4E65656450726F636573734E616D65090001044E616D
+      6506085374617469634944094669656C644E616D650608537461746963494408
+      44617461547970650203084461746153697A6502040549734B6579080F4E6565
+      6450726F636573734E616D65090000}
   end
   object sdvStdBills: TsdDataView
     Active = False

+ 30 - 12
DataModules/ZJJLDm.pas

@@ -5,9 +5,11 @@ interface
 uses
   ZjGrid,
   SysUtils, Classes, DB, DBClient, ADODB, sdIDTree, sdDB, Provider,
-  Windows;
+  Windows, BillsTree;
 
 type
+  TZJJLType = (ztFx, ztGcl);
+
   TZJJLNode = class
   private
     FBillsID: Integer;
@@ -75,6 +77,9 @@ type
       var Allow: Boolean);
     procedure DetailGridCellTextChanged(Sender: TObject; Col, Row: Integer);
 
+    // 向父项检测,直至提取到图册号为止
+    function GetDrawingCode(ANode: TsdIDTreeNode): string;
+
     function GetMainBillsTree: TsdIDTree;
   public
     constructor Create(APhaseData: TObject);
@@ -396,7 +401,7 @@ begin
   Result.PegName := GetPegName(vPeg);
   Result.FBFXName := GetFBFXName(vNode, vPeg);
   Result.UnitName := GetFieldStrDef(vNode, 'Name', '');
-  Result.DrawingCode := GetFieldStrDef(vNode, 'DrawingCode', '');
+  Result.DrawingCode := GetDrawingCode(vNode);
 end;
 
 procedure TZJJLData.DetailGridCellTextChanged(Sender: TObject; Col,
@@ -489,16 +494,15 @@ begin
   cdsZJJLBillsID.AsInteger := ANode.ID;
   cdsZJJLType.AsInteger := AType;
   ZJJLNode := GetOrgZJJLNode(ANode.ID);
-  if not Assigned(ZJJLNode) then
-  begin
-    cdsZJJLCode.AsString := GetNewCode;
-    cdsZJJLBillsCode.AsString := ANode.Rec.ValueByName('Code').AsString;
-  end
-  else
+
+  cdsZJJLCode.AsString := GetNewCode;
+  if AType = Ord(ztFx) then
+    cdsZJJLBillsCode.AsString := ANode.Rec.ValueByName('Code').AsString
+  else if AType = Ord(ztGcl) then
+    cdsZJJLBillsCode.AsString := ANode.Rec.ValueByName('B_Code').AsString;
+  if Assigned(ZJJLNode) then
   begin
-    cdsZJJLCode.AsString := ZJJLNode.FCode;
     cdsZJJLCertificateCode.AsString := ZJJLNode.FCertificateCode;
-    cdsZJJLBillsCode.AsString := ZJJLNode.FBillsCode;
     cdsZJJLFormulaMemo.AsString := ZJJLNode.FFormulaMemo;
     cdsZJJLRelaFile.AsString := ZJJLNode.FRelaFile;
   end;
@@ -522,8 +526,8 @@ begin
   if Assigned(vNode.Parent) then
     Result.PegName := vNode.Parent.Rec.ValueByName('Name').AsString;
   Result.FBFXName := '';
-  Result.UnitName := '';
-  Result.DrawingCode := vNode.Rec.ValueByName('DrawingCode').AsString;
+  Result.UnitName := vNode.Rec.ValueByName('Name').AsString;
+  Result.DrawingCode := GetDrawingCode(vNode);
 end;
 
 function TZJJLData.GetInfoRec(ABillsID, AType: Integer): TZJJLInfoRec;
@@ -545,4 +549,18 @@ begin
   end;
 end;
 
+function TZJJLData.GetDrawingCode(ANode: TsdIDTreeNode): string;
+var
+  vNode: TBillsIDTreeNode;
+begin
+  Result := '';
+  vNode := TBillsIDTreeNode(ANode);
+  while (Result = '') and Assigned(vNode) do
+  begin
+    if Assigned(vNode.Rec) then
+      Result := vNode.Rec.DrawingCode.AsString;
+    vNode := TBillsIDTreeNode(vNode.Parent);
+  end;
+end;
+
 end.

+ 2 - 2
Dprs/Pro/Measure.dof

@@ -115,7 +115,7 @@ AutoIncBuild=1
 MajorVer=3
 MinorVer=1
 Release=6
-Build=1003
+Build=1006
 Debug=0
 PreRelease=0
 Special=0
@@ -126,7 +126,7 @@ CodePage=936
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化专业版
-FileVersion=3.1.6.1003
+FileVersion=3.1.6.1006
 InternalName=
 LegalCopyright=版权所有(C)珠海纵横创新软件有限公司2003-2016
 LegalTrademarks=Measure

+ 3 - 1
Dprs/Pro/Measure.dpr

@@ -195,7 +195,9 @@ uses
   ProjGatherSelectFrm in '..\..\ProjGather\ProjGatherSelectFrm.pas' {ProjGatherSelectForm},
   DealBillsExcelImport in '..\..\Units\DealBillsExcelImport.pas',
   ExcelImport_Bills in '..\..\Units\ExcelImport_Bills.pas',
-  ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas';
+  ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas',
+  DbTreeImport in '..\..\Units\DbTreeImport.pas',
+  DbTreeDm in '..\..\DataModules\DbTreeDm.pas';
 
 {$R *.res}
 

BIN
Dprs/Pro/Measure.res


+ 4 - 3
Dprs/Pro/Measure_Cloud.dof

@@ -115,7 +115,7 @@ AutoIncBuild=1
 MajorVer=3
 MinorVer=1
 Release=6
-Build=1003
+Build=1006
 Debug=0
 PreRelease=0
 Special=0
@@ -126,7 +126,7 @@ CodePage=936
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化云版
-FileVersion=3.1.6.1003
+FileVersion=3.1.6.1006
 InternalName=
 LegalCopyright=版权所有(C)珠海纵横创新软件有限公司2003-2016
 LegalTrademarks=Measure
@@ -137,8 +137,9 @@ ProductVersion=3.1.6.1
 C:\Program Files (x86)\Borland\Delphi7\Lib\3F\Developer Express Inc\ExpressEditors Library 5\Delphi 7\Bin\dclcxEditorsVCLD7.bpl=ExpressEditors Library 5 (VCL Edition) by Developer Express Inc.
 C:\Program Files (x86)\Borland\Delphi7\Lib\3F\Developer Express Inc\ExpressEditors Library 5\Delphi 7\Bin\dclcxExtEditorsVCLD7.bpl=ExpressExtendedEditors Library 5 (VCL Edition) by Developer Express Inc.
 [HistoryLists\hlConditionals]
-Count=1
+Count=2
 Item0=_mCloud;
+Item1=_mCloud;_mDebugView
 [HistoryLists\hlUnitAliases]
 Count=1
 Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;

+ 4 - 1
Dprs/Pro/Measure_Cloud.dpr

@@ -199,7 +199,10 @@ uses
   ProjGatherSelectFrm in '..\..\ProjGather\ProjGatherSelectFrm.pas' {ProjGatherSelectForm},
   DealBillsExcelImport in '..\..\Units\DealBillsExcelImport.pas',
   ExcelImport_Bills in '..\..\Units\ExcelImport_Bills.pas',
-  ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas';
+  ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas',
+  DbTreeImport in '..\..\Units\DbTreeImport.pas',
+  DbTreeDm in '..\..\DataModules\DbTreeDm.pas' {DbTreeData: TDataModule},
+  DebugUsers in '..\..\Units\DebugUsers.pas';
 
 {$R *.res}
 

BIN
Dprs/Pro/Measure_Cloud.res


+ 2 - 2
Dprs/Pro/Measure_GuangDong.dof

@@ -115,7 +115,7 @@ AutoIncBuild=1
 MajorVer=3
 MinorVer=1
 Release=6
-Build=1003
+Build=1006
 Debug=0
 PreRelease=0
 Special=0
@@ -126,7 +126,7 @@ CodePage=936
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化广东专业版
-FileVersion=3.1.6.1003
+FileVersion=3.1.6.1006
 InternalName=
 LegalCopyright=版权所有(C)珠海纵横创新软件有限公司2003-2016
 LegalTrademarks=Measure

+ 3 - 1
Dprs/Pro/Measure_GuangDong.dpr

@@ -195,7 +195,9 @@ uses
   ProjGatherSelectFrm in '..\..\ProjGather\ProjGatherSelectFrm.pas' {ProjGatherSelectForm},
   DealBillsExcelImport in '..\..\Units\DealBillsExcelImport.pas',
   ExcelImport_Bills in '..\..\Units\ExcelImport_Bills.pas',
-  ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas';
+  ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas',
+  DbTreeImport in '..\..\Units\DbTreeImport.pas',
+  DbTreeDm in '..\..\DataModules\DbTreeDm.pas';
 
 {$R *.res}
 

BIN
Dprs/Pro/Measure_GuangDong.res


+ 2 - 2
Dprs/Pro/Measure_GuangDong_Cloud.dof

@@ -115,7 +115,7 @@ AutoIncBuild=1
 MajorVer=3
 MinorVer=1
 Release=6
-Build=1003
+Build=1006
 Debug=0
 PreRelease=0
 Special=0
@@ -126,7 +126,7 @@ CodePage=936
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化广东云版
-FileVersion=3.1.6.1003
+FileVersion=3.1.6.1006
 InternalName=
 LegalCopyright=版权所有(C)珠海纵横创新软件有限公司2003-2016
 LegalTrademarks=Measure

+ 4 - 1
Dprs/Pro/Measure_GuangDong_Cloud.dpr

@@ -199,7 +199,10 @@ uses
   ProjGatherSelectFrm in '..\..\ProjGather\ProjGatherSelectFrm.pas' {ProjGatherSelectForm},
   DealBillsExcelImport in '..\..\Units\DealBillsExcelImport.pas',
   ExcelImport_Bills in '..\..\Units\ExcelImport_Bills.pas',
-  ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas';
+  ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas',
+  DbTreeImport in '..\..\Units\DbTreeImport.pas',
+  DbTreeDm in '..\..\DataModules\DbTreeDm.pas',
+  DebugUsers in '..\..\Units\DebugUsers.pas';
 
 {$R *.res}
 

BIN
Dprs/Pro/Measure_GuangDong_Cloud.res


+ 2 - 2
Dprs/Pro/Measure_GuangDong_TZ.dof

@@ -115,7 +115,7 @@ AutoIncBuild=0
 MajorVer=3
 MinorVer=1
 Release=6
-Build=1001
+Build=1005
 Debug=0
 PreRelease=0
 Special=0
@@ -126,7 +126,7 @@ CodePage=936
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横0号台账广东专业版
-FileVersion=3.1.6.1001
+FileVersion=3.1.6.1005
 InternalName=
 LegalCopyright=版权所有(C)珠海纵横创新软件有限公司2003-2016
 LegalTrademarks=Measure

+ 3 - 1
Dprs/Pro/Measure_GuangDong_TZ.dpr

@@ -195,7 +195,9 @@ uses
   ProjGatherSelectFrm in '..\..\ProjGather\ProjGatherSelectFrm.pas' {ProjGatherSelectForm},
   DealBillsExcelImport in '..\..\Units\DealBillsExcelImport.pas',
   ExcelImport_Bills in '..\..\Units\ExcelImport_Bills.pas',
-  ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas';
+  ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas',
+  DbTreeImport in '..\..\Units\DbTreeImport.pas',
+  DbTreeDm in '..\..\DataModules\DbTreeDm.pas' {DbTreeData: TDataModule};
 
 {$R *.res}
 

BIN
Dprs/Pro/Measure_GuangDong_TZ.res


+ 2 - 2
Dprs/Pro/Measure_TZ.dof

@@ -115,7 +115,7 @@ AutoIncBuild=1
 MajorVer=3
 MinorVer=1
 Release=6
-Build=1003
+Build=1006
 Debug=0
 PreRelease=0
 Special=0
@@ -126,7 +126,7 @@ CodePage=936
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横0号台账专业版
-FileVersion=3.1.6.1003
+FileVersion=3.1.6.1006
 InternalName=
 LegalCopyright=版权所有(C)珠海纵横创新软件有限公司2003-2016
 LegalTrademarks=Measure

+ 3 - 1
Dprs/Pro/Measure_TZ.dpr

@@ -195,7 +195,9 @@ uses
   ProjGatherSelectFrm in '..\..\ProjGather\ProjGatherSelectFrm.pas' {ProjGatherSelectForm},
   DealBillsExcelImport in '..\..\Units\DealBillsExcelImport.pas',
   ExcelImport_Bills in '..\..\Units\ExcelImport_Bills.pas',
-  ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas';
+  ExcelImport_GclBills in '..\..\Units\ExcelImport_GclBills.pas',
+  DbTreeImport in '..\..\Units\DbTreeImport.pas',
+  DbTreeDm in '..\..\DataModules\DbTreeDm.pas' {DbTreeData: TDataModule};
 
 {$R *.res}
 

BIN
Dprs/Pro/Measure_TZ.res


+ 20 - 0
Forms/MainFrm.dfm

@@ -405,6 +405,10 @@ object MainForm: TMainForm
         item
           Item = dxtbnImportCloudTenderFile
           Visible = True
+        end
+        item
+          Item = dxbtnImportDmf
+          Visible = True
         end>
     end
     object dxsiEdit: TdxBarSubItem
@@ -1051,6 +1055,16 @@ object MainForm: TMainForm
       Hint = #21462#28040#38544#34255
       Visible = ivAlways
     end
+    object dxbtnImportDmf: TdxBarButton
+      Action = actnImportDmf
+      Category = 0
+    end
+    object dxbtnCanCalc: TdxBarButton
+      Caption = #20572#29992'/'#21551#29992
+      Category = 0
+      Hint = #20572#29992'/'#21551#29992
+      Visible = ivAlways
+    end
   end
   object Images: TImageList
     DrawingStyle = dsTransparent
@@ -3218,6 +3232,12 @@ object MainForm: TMainForm
       Caption = #25209#37327#25554#20837
       ImageIndex = 2
     end
+    object actnImportDmf: TAction
+      Category = 'File'
+      Caption = #23548#20837#31639#37327#36719#20214'0'#21495#21488#36134#25509#21475#25968#25454
+      OnExecute = actnImportDmfExecute
+      OnUpdate = actnImportCloudTenderFileUpdate
+    end
   end
   object dxpmTabSet: TdxBarPopupMenu
     BarManager = dxBarManager

+ 12 - 0
Forms/MainFrm.pas

@@ -156,6 +156,9 @@ type
     dxbtnInsertCol: TdxBarButton;
     dxbtnHidden: TdxBarButton;
     dxbtnCancelHidden: TdxBarButton;
+    dxbtnImportDmf: TdxBarButton;
+    actnImportDmf: TAction;
+    dxbtnCanCalc: TdxBarButton;
     procedure FormCreate(Sender: TObject);
     procedure FormDestroy(Sender: TObject);
     procedure jtsProjectsChange(Sender: TObject; NewTab: Integer;
@@ -199,6 +202,7 @@ type
       Shift: TShiftState);
     procedure actnReplyUpdate(Sender: TObject);
     procedure dxbtnTenderPartitionClick(Sender: TObject);
+    procedure actnImportDmfExecute(Sender: TObject);
   private
     FProjectManagerFrame: TProjectManagerFrame;
     FProjectFrames: TList;
@@ -835,4 +839,12 @@ begin
   PartTendersModel;
 end;
 
+procedure TMainForm.actnImportDmfExecute(Sender: TObject);
+var
+  sFileName: string;
+begin
+  if SelectFile(sFileName, '.dmf') then
+    CurProjectFrame.ProjectData.ImportDmfFile(sFileName);
+end;
+
 end.

+ 57 - 9
Forms/ProjectPropertiesFrm.dfm

@@ -1,7 +1,7 @@
 object ProjectPropertiesForm: TProjectPropertiesForm
   Left = 663
   Top = 261
-  ActiveControl = leProjectName
+  ActiveControl = cbShowAlias
   BorderIcons = [biSystemMenu]
   BorderStyle = bsSingle
   Caption = #39033#30446#23646#24615
@@ -120,8 +120,8 @@ object ProjectPropertiesForm: TProjectPropertiesForm
     Top = 63
     Width = 530
     Height = 255
-    ActivePage = jpsPropertiesBase
-    ActivePageIndex = 0
+    ActivePage = jpsPropertiesView
+    ActivePageIndex = 2
     Align = alTop
     Caption = 'jpsProperties'
     object jpsPropertiesBase: TJimPage
@@ -934,13 +934,13 @@ object ProjectPropertiesForm: TProjectPropertiesForm
             Left = 52
             Top = 72
             Width = 349
-            Height = 49
+            Height = 73
             Caption = #20215#24046
             TabOrder = 31
             Visible = False
             object lePM_PriceDigit: TLabeledEdit
-              Left = 49
-              Top = 19
+              Left = 51
+              Top = 43
               Width = 87
               Height = 18
               EditLabel.Width = 36
@@ -951,14 +951,24 @@ object ProjectPropertiesForm: TProjectPropertiesForm
               Text = '0'
             end
             object udPM_PriceDigit: TUpDown
-              Left = 136
-              Top = 19
+              Left = 138
+              Top = 43
               Width = 16
               Height = 18
               Associate = lePM_PriceDigit
               Max = 10
               TabOrder = 1
             end
+            object cbDisplayPM: TCheckBox
+              Left = 11
+              Top = 19
+              Width = 166
+              Height = 17
+              Caption = #22635#20889#20215#24046#37329#39069#33267#35745#37327#21488#36134
+              Ctl3D = False
+              ParentCtl3D = False
+              TabOrder = 2
+            end
           end
         end
       end
@@ -1015,6 +1025,19 @@ object ProjectPropertiesForm: TProjectPropertiesForm
         Font.Style = []
         ParentFont = False
       end
+      object leReport: TLabel
+        Left = 7
+        Top = 141
+        Width = 48
+        Height = 12
+        Caption = #25253#34920#24213#32441
+        Font.Charset = ANSI_CHARSET
+        Font.Color = clBlue
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        ParentFont = False
+      end
       object pnlViewBar: TPanel
         Left = 62
         Top = 11
@@ -1027,7 +1050,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
         Left = 8
         Top = 24
         Width = 505
-        Height = 225
+        Height = 113
         BevelOuter = bvNone
         TabOrder = 1
         object pnlAlias: TPanel
@@ -1144,6 +1167,31 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
         end
       end
+      object pnlReport: TPanel
+        Left = 62
+        Top = 147
+        Width = 457
+        Height = 2
+        BevelOuter = bvLowered
+        TabOrder = 2
+      end
+      object cbShowReportShading: TCheckBox
+        Left = 40
+        Top = 160
+        Width = 17
+        Height = 17
+        TabOrder = 3
+        OnClick = cbShowReportShadingClick
+      end
+      object edtReportShading: TEdit
+        Left = 64
+        Top = 160
+        Width = 177
+        Height = 18
+        Ctl3D = False
+        ParentCtl3D = False
+        TabOrder = 4
+      end
     end
   end
   object xpm: TXPMenu

+ 18 - 0
Forms/ProjectPropertiesFrm.pas

@@ -102,6 +102,11 @@ type
     gbPM_Digit: TGroupBox;
     lePM_PriceDigit: TLabeledEdit;
     udPM_PriceDigit: TUpDown;
+    cbDisplayPM: TCheckBox;
+    pnlReport: TPanel;
+    leReport: TLabel;
+    cbShowReportShading: TCheckBox;
+    edtReportShading: TEdit;
     procedure btnOkClick(Sender: TObject);
     procedure leContractPriceClick(Sender: TObject);
     procedure msbBaseMouseWheel(Sender: TObject; Shift: TShiftState;
@@ -124,6 +129,7 @@ type
     procedure leNewUnlockPasswordAgainExit(Sender: TObject);
     procedure leNewUnLockPasswordExit(Sender: TObject);
     procedure leUnlockPasswordExit(Sender: TObject);
+    procedure cbShowReportShadingClick(Sender: TObject);
   private
     FProjectData: TProjectData;
     FStaffData: TStaffData;
@@ -209,6 +215,10 @@ begin
   cbShowBGLCode.Checked := FProjProperties.ShowBGLCode;
   cbShowDesignQuantity.Checked := FProjProperties.ShowDesignQuantity;
   cbShowAlias.Checked := FProjProperties.ShowAlias;
+
+  cbShowReportShading.Checked := FProjProperties.ShowReportShading;
+  edtReportShading.Enabled := cbShowReportShading.Checked;
+  edtReportShading.Text := FProjProperties.ReportShading;
 end;
 
 procedure TProjectPropertiesForm.btnOkClick(Sender: TObject);
@@ -556,6 +566,9 @@ end;
 
 procedure TProjectPropertiesForm.SaveProjectView;
 begin
+  FProjProperties.ShowReportShading := cbShowReportShading.Checked;
+  FProjProperties.ReportShading := edtReportShading.Text;
+
   FProjProperties.ShowPriceChange := cbShowPriceChange.Checked;
   FProjProperties.ShowBGLCode := cbShowBGLCode.Checked;
   FProjProperties.ShowDesignQuantity := cbShowDesignQuantity.Checked;
@@ -564,4 +577,9 @@ begin
   FProjectFrame.RefreshColumnDisplay;
 end;
 
+procedure TProjectPropertiesForm.cbShowReportShadingClick(Sender: TObject);
+begin
+  edtReportShading.Enabled := cbShowReportShading.Checked;
+end;
+
 end.

+ 21 - 10
Forms/ReportsFrm.dfm

@@ -82,23 +82,23 @@ object ReportsForm: TReportsForm
   end
   object pnlReports: TPanel
     Left = 0
-    Top = 76
+    Top = 81
     Width = 1107
-    Height = 430
+    Height = 425
     Align = alClient
     BevelOuter = bvNone
     TabOrder = 6
     object sprReportPreview: TSplitter
       Left = 211
       Top = 0
-      Height = 430
+      Height = 425
       AutoSnap = False
     end
     object pnlReportsList: TPanel
       Left = 0
       Top = 0
       Width = 211
-      Height = 430
+      Height = 425
       Align = alLeft
       BevelOuter = bvNone
       TabOrder = 0
@@ -106,7 +106,7 @@ object ReportsForm: TReportsForm
         Left = 0
         Top = 35
         Width = 211
-        Height = 395
+        Height = 390
         Align = alClient
         Font.Charset = DEFAULT_CHARSET
         Font.Color = clWindowText
@@ -193,7 +193,7 @@ object ReportsForm: TReportsForm
       Left = 214
       Top = 0
       Width = 893
-      Height = 430
+      Height = 425
       HorzScrollBar.Increment = 48
       HorzScrollBar.Tracking = True
       VertScrollBar.Increment = 32
@@ -216,7 +216,7 @@ object ReportsForm: TReportsForm
     Font.Charset = DEFAULT_CHARSET
     Font.Color = clWindowText
     Font.Height = -12
-    Font.Name = #23435#20307
+    Font.Name = 'Microsoft YaHei UI'
     Font.Style = []
     Bars = <
       item
@@ -313,7 +313,7 @@ object ReportsForm: TReportsForm
         Caption = #33539#22260#36755#20986
         DockedDockingStyle = dsTop
         DockedLeft = 0
-        DockedTop = 47
+        DockedTop = 52
         DockingStyle = dsTop
         FloatLeft = 602
         FloatTop = 414
@@ -343,7 +343,7 @@ object ReportsForm: TReportsForm
         Caption = #25253#34920#36873#39033
         DockedDockingStyle = dsTop
         DockedLeft = 308
-        DockedTop = 47
+        DockedTop = 52
         DockingStyle = dsTop
         FloatLeft = 484
         FloatTop = 279
@@ -388,7 +388,7 @@ object ReportsForm: TReportsForm
     DockControlHeights = (
       0
       0
-      76
+      81
       0)
     object xlbPrint: TdxBarLargeButton
       Caption = #25171#21360
@@ -2906,4 +2906,15 @@ object ReportsForm: TReportsForm
       8001800180018001FFFFFFFFFFFFFFFF00000000000000000000000000000000
       000000000000}
   end
+  object BatchPrintXml: TPrintComXML
+    PreviewRows = 1
+    PreviewCols = 1
+    Scaling = 1.000000000000000000
+    OnGetDatasetEvent = PreviewComXMLGetDatasetEvent
+    OnGetDataConnection = PreviewComXMLGetDataConnection
+    OnCrossTabLabelShow = PreviewComXMLCrossTabLabelShow
+    OnContentDisplay = PreviewComXMLContentDisplay
+    Left = 390
+    Top = 89
+  end
 end

+ 76 - 71
Forms/ReportsFrm.pas

@@ -60,6 +60,7 @@ type
     chkExcel2010: TCheckBox;
     dxcciExcelMode: TdxBarControlContainerItem;
     pnlReports: TPanel;
+    BatchPrintXml: TPrintComXML;
     procedure PreviewComXMLGetDataConnection(var ADOCon: TADOConnection);
     procedure xlbRealSizeClick(Sender: TObject);
     procedure xlbOnePageClick(Sender: TObject);
@@ -105,9 +106,9 @@ type
     // 报表数据准备
     FReportDataPrepare: TReportPrepare;
 
-    procedure InitPageSettings;
-    procedure InitFont;
-    procedure InitPaperSettings(ATemplate: TTemplateNode);
+    procedure InitPageSettings(APrintCom: TPrintComXML);
+    procedure InitFont(APrintCom: TPrintComXML);
+    procedure InitPaperSettings(ATemplate: TTemplateNode; APrintCom: TPrintComXML);
 
     function GetHintStr: string;
 
@@ -123,7 +124,7 @@ type
     procedure ResizePreviewBox;
     procedure PreviewReportCurPage;
     procedure RepaintCurPagePreview;
-    procedure LoadTemplet(ATemplate: TTemplateNode);
+    procedure LoadTemplet(ATemplate: TTemplateNode; APrintCom: TPrintComXML);
     procedure LoadTempletAndDisplay;
 
     procedure BeforeExport;
@@ -133,7 +134,7 @@ type
     procedure PrintReport(ATemplateNode: TTemplateNode; isPDF, isExcel: boolean;
       ExcelOutputName, TemplateFileName: string);
 
-    procedure ExportXlsReport(AStartPage, AEndPage: Integer; const AFileName: string);
+    procedure ExportXlsReport(AStartPage, AEndPage: Integer; const AFileName: string; APrintCom: TPrintComXML);
     procedure ExportCurXlsReport;
     procedure ExportAllSelectedXlsReports;
     procedure PrintAllSelectedReports;
@@ -151,7 +152,7 @@ type
     destructor Destroy; override;
 
     procedure InitFormView;
-    procedure InitReportSettings(ATemplate: TTemplateNode = nil);
+    procedure InitReportSettings(APrintCom: TPrintComXML; ATemplate: TTemplateNode = nil);
 
     property ProjectData: TProjectData read FProjectData write SetProjectData;
     // 当前预览的页码
@@ -188,7 +189,7 @@ begin
   {ReportsForm.BorderIcons := ReportsForm.BorderIcons - [biMaximize];
   ReportsForm.WindowState := wsMaximized;}
   ReportsForm.ProjectData := AProjectData;
-  ReportsForm.InitReportSettings;
+  ReportsForm.InitReportSettings(ReportsForm.PreviewComXML);
   ReportsForm.InitFormView;
   try
     ReportsForm.ShowModal;
@@ -297,7 +298,7 @@ begin
 
   Screen.Cursor := crHourGlass;
   try
-    LoadTemplet(vTemplateNode);
+    LoadTemplet(vTemplateNode, PreviewComXML);
     if PreviewComXML.TotalPages > 0 then
       PreviewTemplet
     else
@@ -584,7 +585,7 @@ var
 begin
   sFileName := extvReport.Selected.Text;
   if (PrintStartPage <= PrintEndPage) and SaveFile(sFileName, '.xls') then
-    ExportXlsReport(PrintStartPage, PrintEndPage, sFileName);
+    ExportXlsReport(PrintStartPage, PrintEndPage, sFileName, PreviewComXML);
 end;
 
 procedure TReportsForm.AfterExport;
@@ -762,29 +763,32 @@ begin
     LoadTempletAndDisplay;
 end;
 
-procedure TReportsForm.InitReportSettings(ATemplate: TTemplateNode);
+procedure TReportsForm.InitReportSettings(APrintCom: TPrintComXML; ATemplate: TTemplateNode);
 begin
-  PreviewComXML.FillZero := chkFillZero.Checked;
-  InitPageSettings;
-  InitPaperSettings(ATemplate);
+  APrintCom.FillZero := chkFillZero.Checked;
+  InitPageSettings(APrintCom);
+  InitPaperSettings(ATemplate, APrintCom);
+
+  APrintCom.ShowBackgroundMark := FProjectData.ProjProperties.ShowReportShading;
+  APrintCom.BackgroundMarkStr := FProjectData.ProjProperties.ReportShading;
 end;
 
-procedure TReportsForm.InitPageSettings;
+procedure TReportsForm.InitPageSettings(APrintCom: TPrintComXML);
 begin
   // 设置页面大小
-  PreviewComXML.setPageSize(ReportConfig.PageSize);
+  APrintCom.setPageSize(ReportConfig.PageSize);
   if ReportConfig.PageSize = 'A3' then
-    PreviewComXML.PrintPageSizeIdx := DMPAPER_A3
+    APrintCom.PrintPageSizeIdx := DMPAPER_A3
   else if ReportConfig.PageSize = 'A4' then
-    PreviewComXML.PrintPageSizeIdx := DMPAPER_A4;  
+    APrintCom.PrintPageSizeIdx := DMPAPER_A4;
   // 设置边距
-  PreviewComXML.setEdge(0, '', ReportConfig.LeftEdge/10);
-  PreviewComXML.setEdge(1, '', ReportConfig.RightEdge/10);
-  PreviewComXML.setEdge(2, '', ReportConfig.UpEdge/10);
-  PreviewComXML.setEdge(3, '', ReportConfig.DownEdge/10);
+  APrintCom.setEdge(0, '', ReportConfig.LeftEdge/10);
+  APrintCom.setEdge(1, '', ReportConfig.RightEdge/10);
+  APrintCom.setEdge(2, '', ReportConfig.UpEdge/10);
+  APrintCom.setEdge(3, '', ReportConfig.DownEdge/10);
 end;
 
-procedure TReportsForm.InitPaperSettings(ATemplate: TTemplateNode);
+procedure TReportsForm.InitPaperSettings(ATemplate: TTemplateNode; APrintCom: TPrintComXML);
 
   procedure InitRepBorderLine;
   var
@@ -794,7 +798,7 @@ procedure TReportsForm.InitPaperSettings(ATemplate: TTemplateNode);
   begin
     ObjList := TList.Create;
     try
-      PreviewComXML.getAllShapeObjs(1, ObjList);
+      APrintCom.getAllShapeObjs(1, ObjList);
       for i := 0 to ObjList.Count - 1 do
       begin
         ShapeRec := ObjList[i];
@@ -817,7 +821,7 @@ procedure TReportsForm.InitPaperSettings(ATemplate: TTemplateNode);
           else
              ShapeRec.PenStyle := integer(psSolid)
         end;
-        PreviewComXML.setShapeObj(ShapeRec);
+        APrintCom.setShapeObj(ShapeRec);
       end;
     finally
       ObjList.Free;
@@ -834,25 +838,25 @@ procedure TReportsForm.InitPaperSettings(ATemplate: TTemplateNode);
   begin
     ObjList := TList.Create;
     try
-      PreviewComXML.getAllFlowShowContentObjs(ObjList);
+      APrintCom.getAllFlowShowContentObjs(ObjList);
       // 设置报表表格横线
       for i := 0 to ObjList.Count - 1 do
       begin
         FlowContentRec := ObjList[i];
         FlowContentRec.LineInfo.TopThick := ReportConfig.CellHorLineWidth;
         FlowContentRec.LineInfo.BottomThick := ReportConfig.CellHorLineWidth;
-        PreviewComXML.setFlowContentObj(FlowContentRec);
+        APrintCom.setFlowContentObj(FlowContentRec);
       end;
-      PreviewComXML.getAllCrossContentObjs(ObjList);
+      APrintCom.getAllCrossContentObjs(ObjList);
       for i := 0 to ObjList.Count - 1 do
       begin
         CrossContentRec := ObjList[i];
         CrossContentRec.CrossContent.LineInfo.TopThick := ReportConfig.CellHorLineWidth;
         CrossContentRec.CrossContent.LineInfo.BottomThick := ReportConfig.CellHorLineWidth;
-        PreviewComXML.setCrossContentObj(CrossContentRec);
+        APrintCom.setCrossContentObj(CrossContentRec);
       end;
       // 设置报表表格竖线
-      PreviewComXML.getAllFlowShowContentObjs(ObjList);
+      APrintCom.getAllFlowShowContentObjs(ObjList);
       for i := 0 to ObjList.Count - 1 do
       begin
         FlowContentRec := ObjList[i];
@@ -864,10 +868,10 @@ procedure TReportsForm.InitPaperSettings(ATemplate: TTemplateNode);
             FlowContentRec.LineInfo.LeftThick := 0
           else if (i = ObjList.Count - 1) then
             FlowContentRec.LineInfo.RightThick := 0;
-        PreviewComXML.setFlowContentObj(FlowContentRec);
+        APrintCom.setFlowContentObj(FlowContentRec);
       end;
 
-      PreviewComXML.getAllCrossContentObjs(ObjList);
+      APrintCom.getAllCrossContentObjs(ObjList);
       for i := 0 to ObjList.Count - 1 do
       begin
         CrossContentRec := ObjList[i];
@@ -931,7 +935,7 @@ procedure TReportsForm.InitPaperSettings(ATemplate: TTemplateNode);
             end;
           end;
         end;
-        PreviewComXML.setCrossContentObj(CrossContentRec);
+        APrintCom.setCrossContentObj(CrossContentRec);
       end;
     finally
       ObjList.Free;
@@ -1029,7 +1033,7 @@ procedure TReportsForm.InitPaperSettings(ATemplate: TTemplateNode);
             0..2 : SetPTRBorder(PSR.Data); //文本,参数,字段,表栏
             7 : SetPCRBorder(PSR.Data) //Column
           end;
-          PreviewComXML.setActShowElementObj(PSR);
+          APrintCom.setActShowElementObj(PSR);
         end;
       end;
     finally
@@ -1040,7 +1044,7 @@ procedure TReportsForm.InitPaperSettings(ATemplate: TTemplateNode);
 begin
   if not Assigned(ATemplate) or (ATemplate.SelfFormat = 0) then
   begin
-    InitFont;           // 各类字体
+    InitFont(APrintCom);           // 各类字体
     InitRepBorderLine;  // 报表边框
     InitRepCellLine;    // 报表表格
     InitOtherArea;      // 活动区域
@@ -1094,7 +1098,7 @@ begin
   PreviewReportCurPage;
 end;
 
-procedure TReportsForm.InitFont;
+procedure TReportsForm.InitFont(APrintCom: TPrintComXML);
 
   procedure AssignFontRec(AFontRec: TFontRec; AFont: TFont);
   begin
@@ -1113,7 +1117,7 @@ procedure TReportsForm.InitFont;
     if TitleRec <> nil then
     begin
       AssignFontRec(TitleRec.FontRec, ReportConfig.TitleFont);
-      PreviewComXML.setTitleObj(TitleRec);
+      APrintCom.setTitleObj(TitleRec);
     end;
   end;
 
@@ -1143,23 +1147,23 @@ procedure TReportsForm.InitFont;
   begin
     ObjList := TList.Create;
     try
-      PreviewComXML.getAllColumnHeadObjs(ObjList);
+      APrintCom.getAllColumnHeadObjs(ObjList);
       for i := 0 to ObjList.Count - 1 do
       begin
         ColumnRec := ObjList[i];
         AssignFontRec(ColumnRec.FontRec, ReportConfig.ColumnFont);
         InitColumnThick(ColumnRec);
-        PreviewComXML.setColumnHeadTailObj(0, ColumnRec);
+        APrintCom.setColumnHeadTailObj(0, ColumnRec);
       end;
-      PreviewComXML.getAllColumnTailObjs(ObjList);
+      APrintCom.getAllColumnTailObjs(ObjList);
       for i := 0 to ObjList.Count - 1 do
       begin
         ColumnRec := ObjList[i];
         AssignFontRec(ColumnRec.FontRec, ReportConfig.ColumnFont);
         InitColumnThick(ColumnRec);
-        PreviewComXML.setColumnHeadTailObj(1,ColumnRec);
+        APrintCom.setColumnHeadTailObj(1,ColumnRec);
       end;
-      PreviewComXML.getAllActAreaObjs(ObjList);
+      APrintCom.getAllActAreaObjs(ObjList);
       for i := 0 to ObjList.Count - 1 do
       begin
         AAR := ObjList[i];
@@ -1171,7 +1175,7 @@ procedure TReportsForm.InitFont;
             ColumnRec := SER.Data;
             AssignFontRec(ColumnRec.FontRec, ReportConfig.ColumnFont);
             InitColumnThick(ColumnRec);
-            PreviewComXML.setActShowElementObj(SER);
+            APrintCom.setActShowElementObj(SER);
           end;
         end;
       end;
@@ -1191,45 +1195,45 @@ procedure TReportsForm.InitFont;
     ObjList := TList.Create;
     try
       // 设置表正文
-      PreviewComXML.getAllFlowShowContentObjs(ObjList);
+      APrintCom.getAllFlowShowContentObjs(ObjList);
       for i := 0 to ObjList.Count - 1 do
       begin
         FlowContentRec := ObjList[i];
         if not (FlowContentRec.Fixed) then
         begin
           AssignFontRec(FlowContentRec.FontRec, ReportConfig.ContentFont);
-          PreviewComXML.setFlowContentObj(FlowContentRec);
+          APrintCom.setFlowContentObj(FlowContentRec);
         end;
       end;
-      PreviewComXML.getAllBillShowContentObjs(ObjList);
+      APrintCom.getAllBillShowContentObjs(ObjList);
       for i := 0 to ObjList.Count - 1 do
       begin
         FlowContentRec := ObjList[i];
         if not(FlowContentRec.Fixed) then
         begin
           AssignFontRec(FlowContentRec.FontRec, ReportConfig.ContentFont);
-          PreviewComXML.setBillContentObj(FlowContentRec);
+          APrintCom.setBillContentObj(FlowContentRec);
         end;
       end;
-      PreviewComXML.getAllCrossContentObjs(ObjList);
+      APrintCom.getAllCrossContentObjs(ObjList);
       for i := 0 to ObjList.Count - 1 do
       begin
         CrossContentRec := ObjList[i];
         if not(CrossContentRec.CrossContent.Fixed) then
         begin
           AssignFontRec(CrossContentRec.CrossContent.FontRec, ReportConfig.ContentFont);
-          PreviewComXML.setCrossContentObj(CrossContentRec);
+          APrintCom.setCrossContentObj(CrossContentRec);
         end;
       end;
       // 设置表合计
       for i := 0 to 2 do
       begin
-        PreviewComXML.getAllSumObjs(i,ObjList);
+        APrintCom.getAllSumObjs(i,ObjList);
         for j := 0 to ObjList.Count - 1 do
         begin
           SumRec := ObjList[j];
           AssignFontRec(SumRec.FontRec, ReportConfig.GatherFont);
-          PreviewComXML.setSumObj(SumRec);
+          APrintCom.setSumObj(SumRec);
         end;
       end;
     finally
@@ -1245,19 +1249,19 @@ procedure TReportsForm.InitFont;
   begin
     ObjList := TList.Create;
     try
-      PreviewComXML.getAllHeadObjs(ObjList);
+      APrintCom.getAllHeadObjs(ObjList);
       for i := 0 to ObjList.Count - 1 do
       begin
         HeadTailRec := ObjList[i];
         AssignFontRec(HeadTailRec.FontRec, ReportConfig.GridHeaderFont);
-        PreviewComXML.setHeadTailObj(0, HeadTailRec);
+        APrintCom.setHeadTailObj(0, HeadTailRec);
       end;
-      PreviewComXML.getAllTailObjs(ObjList);
+      APrintCom.getAllTailObjs(ObjList);
       for i := 0 to ObjList.Count - 1 do
       begin
         HeadTailRec := ObjList[i];
         AssignFontRec(HeadTailRec.FontRec, ReportConfig.GridHeaderFont);
-        PreviewComXML.setHeadTailObj(1, HeadTailRec);
+        APrintCom.setHeadTailObj(1, HeadTailRec);
       end;
     finally
       ObjList.Free;
@@ -1335,14 +1339,14 @@ procedure TReportsForm.PrintReport(ATemplateNode: TTemplateNode;
   begin
     if isPDF then
     begin
-      PreviewComXML.PrintPDFAll;
+      BatchPrintXml.PrintPDFAll;
       while not CheckPrinterReady do
         Sleep(1000);
     end
     else if not isExcel then
-      PreviewComXML.PrintAll(1)
+      BatchPrintXml.PrintAll(1)
     else
-      ExportXlsReport(1, PreviewComXML.TotalPages, ExcelOutputName);
+      ExportXlsReport(1, BatchPrintXml.TotalPages, ExcelOutputName, BatchPrintXml);
   end;
 
 var
@@ -1355,8 +1359,8 @@ begin
 
   Screen.Cursor := crHourGlass;
   try
-    LoadTemplet(ATemplateNode);
-    if PreviewComXML.TotalPages > 0 then
+    LoadTemplet(ATemplateNode, BatchPrintXml);
+    if BatchPrintXml.TotalPages > 0 then
       PrintTemplet
     {else if strRptName <> '' then
     begin
@@ -1369,7 +1373,7 @@ begin
 end;
 
 procedure TReportsForm.ExportXlsReport(AStartPage, AEndPage: Integer;
-  const AFileName: string);
+  const AFileName: string; APrintCom: TPrintComXML);
 
   procedure ExportPagesXlsReport(AStartPage, AEndPage: Integer; const AFileName: string);
   var
@@ -1378,10 +1382,10 @@ procedure TReportsForm.ExportXlsReport(AStartPage, AEndPage: Integer;
     LoadExcelBorder(Border);
     if IsExcel2010 then
       // 康博士代码中写批量打印是,用Printer.Canvas,打印当前时,用PreviewBox.Canvas。不懂为什么
-      PreViewComXML.OutputToExcelRangeXMLEx(PreviewBox.Canvas, AStartPage,
+      APrintCom.OutputToExcelRangeXMLEx(PreviewBox.Canvas, AStartPage,
           AEndPage, GetTemplateXlsFileName, AFileName, Border, ExcelMode)
     else
-      PreViewComXML.OutputToExcelFile(PreviewBox.Canvas, AStartPage,
+      APrintCom.OutputToExcelFile(PreviewBox.Canvas, AStartPage,
           AEndPage, GetTemplateXlsFileName, AFileName, ExcelMode, Border);
   end;
 
@@ -1407,13 +1411,13 @@ begin
       until iStartPage > iEndPage;
     end
     else
-      ExportPagesXlsReport(PrintStartPage, PrintEndPage, AFileName);
+      ExportPagesXlsReport(AStartPage, AEndPage, AFileName);
   finally
     AfterExport;
   end;
 end;
 
-procedure TReportsForm.LoadTemplet(ATemplate: TTemplateNode);
+procedure TReportsForm.LoadTemplet(ATemplate: TTemplateNode; APrintCom: TPrintComXML);
 var
   RptArchiverObj: TReportArchiver;
   Mem: TMemoryStream;
@@ -1428,17 +1432,18 @@ begin
     // 以下代码有顺序限制,不可修改,主要保证在不修改报表模板文件的基础上可以用户定制报表格式
     // 私以为,原因在于这些设置修改后,并不能生效,需要保存再读取方可生效
     // 读取报表模板
-    if not PreviewComXML.ReadReportStream(Mem) then Exit;
+    if not APrintCom.ReadReportStream(Mem) then Exit;
     // 将报表设置中的数据覆盖掉原模板的数据
-    InitReportSettings(ATemplate);
+    InitReportSettings(APrintCom, ATemplate);
     // 保存
-    PreviewComXML.SaveToStream(Mem);
+    APrintCom.SaveToStream(Mem);
     // 再次读取,使报表设置中的设置生效
-    PreviewComXML.ReadReportStream(Mem);
+    APrintCom.ReadReportStream(Mem);
     // ReadReportStream之后会将PreviewComXML的FillZero值赋为True,故再赋值一次
-    PreviewComXML.FillZero := chkFillZero.Checked;
-    PreviewComXML.ReadDBData;
-    PreviewComXML.AnalyseData;
+    APrintCom.FillZero := chkFillZero.Checked;
+    InitPageSettings(APrintCom);
+    APrintCom.ReadDBData;
+    APrintCom.AnalyseData;
   finally
     if Mem <> nil then
       Mem.Free;

+ 4 - 2
Frames/CheckerFme.pas

@@ -126,7 +126,7 @@ end;
 
 procedure TCheckerFrame.Init;
 var
-  i: Integer;
+  i, iIndex: Integer;
   vA: TOVArr;
   sURL, sPicPath, sID, sErrors: string;
   vProj: TProjectData;
@@ -185,7 +185,9 @@ begin
           vA[i, 0], vA[i, 2], vA[i, 1], sPicPath, vA[i, 6], vStatus, vA[i, 8], StrToInt(vA[i, 7]));
 
       vCM := TChecker.Create;
-      vProj.Checkers.Add(StrToInt(vA[i, 4]), vA[i, 0], vA[i, 2], vA[i, 6], vA[i, 8]);
+      iIndex := vProj.Checkers.Add(StrToInt(vA[i, 4]), vA[i, 0], vA[i, 2], vA[i, 6], vA[i, 8]);
+      if vStatus in [csFinished, csNotPass] then
+        vProj.Checkers.LastChecker := vProj.Checkers.Item[iIndex];
     end;
     RepairOrder;
   end

+ 10 - 0
Frames/DealPaymentFme.dfm

@@ -310,6 +310,11 @@ object DealPaymentFrame: TDealPaymentFrame
       item
         Item = MainForm.dxbtnSetDealPayPlan
         Visible = True
+      end
+      item
+        BeginGroup = True
+        Item = MainForm.dxbtnCanCalc
+        Visible = True
       end>
     UseOwnFont = False
     OnPopup = dxpmDealPaymentPopup
@@ -332,5 +337,10 @@ object DealPaymentFrame: TDealPaymentFrame
       OnExecute = actnSetDealPayPlanExecute
       OnUpdate = actnSetDealPayPlanUpdate
     end
+    object actnCanCalc: TAction
+      Caption = #20572#29992'/'#21551#29992
+      OnExecute = actnCanCalcExecute
+      OnUpdate = actnCanCalcUpdate
+    end
   end
 end

+ 53 - 2
Frames/DealPaymentFme.pas

@@ -24,6 +24,7 @@ type
     actnDealPayment: TActionList;
     actnCalculatePhasePay: TAction;
     actnSetDealPayPlan: TAction;
+    actnCanCalc: TAction;
     procedure zgParameterCellCanEdit(Sender: TObject; const ACoord: TPoint;
       var Allow: Boolean);
     procedure imgHelpClick(Sender: TObject);
@@ -46,6 +47,8 @@ type
     procedure zgDealPaymentShowHint(var HintStr: String;
       var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint);
     procedure actnSetDealPayPlanUpdate(Sender: TObject);
+    procedure actnCanCalcExecute(Sender: TObject);
+    procedure actnCanCalcUpdate(Sender: TObject);
   private
     FDealPaymentData: TDealPaymentData;
 
@@ -69,7 +72,8 @@ type
 implementation
 
 uses
-  MainFrm, UtilMethods, ProjectData, PhaseData, DealPayPlanFrm;
+  MainFrm, UtilMethods, ProjectData, PhaseData, DealPayPlanFrm, PhasePayDm,
+  Math;
 
 {$R *.dfm}
 
@@ -159,6 +163,7 @@ procedure TDealPaymentFrame.dxpmDealPaymentPopup(Sender: TObject);
 begin
   SetDxBtnAction(actnCalculatePhasePay, MainForm.dxbtnCalculatePhasePay);
   SetDxBtnAction(actnSetDealPayPlan, MainForm.dxbtnSetDealPayPlan);
+  SetDxBtnAction(actnCanCalc, MainForm.dxbtnCanCalc);
 end;
 
 procedure TDealPaymentFrame.actnCalculatePhasePayExecute(Sender: TObject);
@@ -174,7 +179,7 @@ end;
 procedure TDealPaymentFrame.zgDealPaymentCellGetColor(Sender: TObject;
   ACoord: TPoint; var AColor: TColor);
 var
-  Rec: TsdDataRecord;
+  Rec, PhaseRec: TsdDataRecord;
   iCurPhase: Integer;
 begin
   if (ACoord.Y > zgDealPayment.FixedRowCount - 1) and
@@ -196,6 +201,14 @@ begin
     // µ±ÆÚÐÂÔöÏî
     else if Rec.ValueByName('CreatePhaseID').AsInteger = iCurPhase then
       AColor := clInfoBk;
+
+    with TProjectData(FDealPaymentData.ProjectData) do
+      if PhaseData.Active then
+      begin
+        PhaseRec := PhaseData.PhasePayData.PayRecord(Rec.ValueByName('ID').AsInteger);
+        if Assigned(PhaseRec) and PhaseRec.ValueByName('StopCalc').AsBoolean then
+          AColor := clSilver;
+      end;
   end;
 end;
 
@@ -378,4 +391,42 @@ begin
   TAction(Sender).Enabled := Assigned(sdDealPayment.DataView.Current);
 end;
 
+procedure TDealPaymentFrame.actnCanCalcExecute(Sender: TObject);
+var
+  Rec, PhaseRec: TsdDataRecord;
+begin
+  Rec := sdDealPayment.DataView.Current;
+  with TProjectData(FDealPaymentData.ProjectData).PhaseData.PhasePayData do
+    PhaseRec := PayRecord(Rec.ValueByName('ID').AsInteger);
+  PhaseRec.ValueByName('StopCalc').AsBoolean := not PhaseRec.ValueByName('StopCalc').AsBoolean;
+
+  TProjectData(FDealPaymentData.ProjectData).PhaseData.PhasePayData.CalculateAll;
+end;
+
+procedure TDealPaymentFrame.actnCanCalcUpdate(Sender: TObject);
+var
+  Rec, PhaseRec: TsdDataRecord;
+begin
+  Rec := sdDealPayment.DataView.Current;
+  if not Assigned(Rec) or Rec.ValueByName('PreDefined').AsBoolean then
+  begin
+    TAction(Sender).Visible := False;
+    Exit;
+  end; 
+  TAction(Sender).Visible := TProjectData(FDealPaymentData.ProjectData).ValidStageIsRefer;
+
+  with TProjectData(FDealPaymentData.ProjectData) do
+    if PhaseData.Active then
+      PhaseRec := PhaseData.PhasePayData.PayRecord(Rec.ValueByName('ID').AsInteger)
+    else
+      PhaseRec := nil;
+  if Assigned(PhaseRec) then
+  begin
+    if PhaseRec.ValueByName('StopCalc').AsBoolean then
+      TAction(Sender).Caption := 'ÆôÓÃ'
+    else
+      TAction(Sender).Caption := 'Í£ÓÃ';
+  end;
+end;
+
 end.

+ 109 - 1
Frames/ProjectGLFme.dfm

@@ -11,7 +11,7 @@ object ProjectGLFrame: TProjectGLFrame
     Height = 313
     Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
     OptionsEx = []
-    ColCount = 13
+    ColCount = 19
     RowCount = 6
     FixedRowCount = 2
     ShowGridLine = False
@@ -246,6 +246,114 @@ object ProjectGLFrame: TProjectGLFrame
         FieldName = 'PM_TotalPrice'
         Width = 60
         ReadOnly = True
+      end
+      item
+        Title.Caption = #26412#26399#23454#32791'|'#25968#37327
+        Title.CaptionAcrossCols = '2'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taRightJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'UsedQuantity'
+        Width = 60
+        ReadOnly = False
+      end
+      item
+        Title.Caption = '|'#37329#39069
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taRightJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'UsedTotalPrice'
+        Width = 60
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #26412#26399#28040#32791#30408#20111'|'#25968#37327#30408#20111
+        Title.CaptionAcrossCols = '4'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taRightJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'PAL_UsedQuantity'
+        Width = 60
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#25968#37327#30408#20111#37329#39069
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taRightJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'PAL_UsedTotalPrice'
+        Width = 82
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#20215#24046#30408#20111#37329#39069
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taRightJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'PAL_DeltaPrice'
+        Width = 82
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#21512#35745#30408#20111#37329#39069
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'PAL_Total'
+        Width = 82
+        ReadOnly = True
       end>
     Grid = zgProjectGL
     ExtendRowCount = 3

+ 8 - 8
Frames/ZJJLFme.dfm

@@ -214,7 +214,7 @@ object ZJJLFrame: TZJJLFrame
   object zaZJJL: TZjGridDBA
     Columns = <
       item
-        Title.Caption = #20013#38388#35745#37327#34920#21495
+        Title.Caption = #32534#21495
         Title.CaptionAcrossCols = '1'
         Title.Font.Charset = GB2312_CHARSET
         Title.Font.Color = clWindowText
@@ -227,11 +227,11 @@ object ZJJLFrame: TZJJLFrame
         Font.Height = -12
         Font.Name = #23435#20307
         Font.Style = []
-        FieldName = 'Code'
-        ReadOnly = False
+        FieldName = 'BillsCode'
+        ReadOnly = True
       end
       item
-        Title.Caption = #20132#24037#35777#20070'/'#20973#35777#21495
+        Title.Caption = #20013#38388#35745#37327#34920#21495
         Title.CaptionAcrossCols = '1'
         Title.Font.Charset = GB2312_CHARSET
         Title.Font.Color = clWindowText
@@ -244,11 +244,11 @@ object ZJJLFrame: TZJJLFrame
         Font.Height = -12
         Font.Name = #23435#20307
         Font.Style = []
-        FieldName = 'CertificateCode'
+        FieldName = 'Code'
         ReadOnly = False
       end
       item
-        Title.Caption = #39033#30446#33410#32534#21495
+        Title.Caption = #20132#24037#35777#20070'/'#20973#35777#21495
         Title.CaptionAcrossCols = '1'
         Title.Font.Charset = GB2312_CHARSET
         Title.Font.Color = clWindowText
@@ -261,8 +261,8 @@ object ZJJLFrame: TZJJLFrame
         Font.Height = -12
         Font.Name = #23435#20307
         Font.Style = []
-        FieldName = 'BillsCode'
-        ReadOnly = True
+        FieldName = 'CertificateCode'
+        ReadOnly = False
       end>
     Grid = zgZJJL
     ExtendRowCount = 0

+ 1 - 1
Frames/ZJJLFme.pas

@@ -127,7 +127,7 @@ procedure TZJJLFrame.zgZJJLMouseDown(Sender: TObject; Button: TMouseButton;
 begin
   if Button = mbRight then
     dxpmZJJL.PopupFromCursorPos
-  else if (ssDouble in Shift) and (zgZJJL.CurCol = 3) then
+  else if (ssDouble in Shift) and (zgZJJL.CurCol = 1) then
   begin
     if FZJJLData.cdsZJJLView.RecordCount > 0 then
       FZJJLData.LocateBills;

+ 1 - 0
Report/ReportConnection.pas

@@ -28,6 +28,7 @@ constructor TReportConnection.Create(AProjectData: TProjectData);
 begin
   FProjectData := AProjectData;
   FCommonGather := TrpgGatherControl.Create(AProjectData.ProjectID);
+  FConnection := AProjectData.ADOConnection;
 end;
 
 destructor TReportConnection.Destroy;

+ 1 - 0
Units/BillsClipboard.pas

@@ -110,6 +110,7 @@ begin
   Clear;
   CopyData(ANode, ACount);
   SaveToStream;
+  SaveToXmlFile('E:\1.xml');
   SaveToClipboard(CF_BillsBlock);
 end;
 

+ 1 - 1
Units/CacheTree.pas

@@ -230,7 +230,7 @@ end;
 
 function TCacheNode.GetNodeID(ANode: TCacheNode): Integer;
 begin
-  if Assigned(ANode) then
+  if Assigned(ANode) and (ANode <> nil) then
     Result := ANode.ID
   else
     Result := -1;

+ 2 - 0
Units/Checker.pas

@@ -42,6 +42,7 @@ type
   TCheckers = class(TObject)			// ÉóºËÈ˹ÜÀíÀà
   private
     FList: TList;
+    FLastChecker: TChecker;
     function GetItem(Index: Integer): TChecker;
     function GetCount: Integer;
   public
@@ -56,6 +57,7 @@ type
     function FindByID(AID: Integer): TChecker;
     property Item[Index: Integer]: TChecker read GetItem; default;
     property Count: Integer read GetCount;
+    property LastChecker: TChecker read FLastChecker write FLastChecker;
   end;
 
 implementation

+ 7 - 0
Units/ConditionalDefines.pas

@@ -30,6 +30,13 @@ var
     _IsDebugView: Boolean = False;
   {$ENDIF}
 
+  // 使用G_IsCloud变量总是出现编译问题
+  {$IFDEF _mCloud}
+    _IsCloud: Boolean = True;
+  {$ELSE}
+    _IsCloud: Boolean = False;
+  {$ENDIF}
+
 implementation
 
 end.

+ 98 - 9
Units/Connections.pas

@@ -8,7 +8,7 @@ uses
 const
   ProductName = 'Measure';
   EmptyFileVersion = '1.0.0.0';
-  FileVersion = '1.0.1.2';
+  FileVersion = '1.0.1.4';
   EncryptVersion = 'Auto1.0';
   SAdoConnectStr = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;' +
                    'User ID=Admin;Password='''';Persist Security Info=True';
@@ -21,7 +21,7 @@ type
     function GetConnection: TADOConnection; virtual; abstract;
   public
     procedure Open(const AFileName: string); virtual; abstract;
-    procedure Save; virtual;
+    procedure Save; virtual; abstract;
     procedure Close;
     function HasOpened: Boolean; virtual; abstract;
 
@@ -41,6 +41,7 @@ type
     destructor Destroy; override;
 
     procedure Open(const AFileName: string); override;
+    procedure Save; override;
     function HasOpened: Boolean; override;
   end;
 
@@ -61,6 +62,8 @@ type
   TEncryptConnection = class(TCommonConnection)
   private
     FFileHead: TDrawingFileHead;
+    function CheckFileValid(const AFileName: string): Boolean;
+
     procedure Encrypt;
     function Decrypt(const AFileName: string): string;
 
@@ -79,6 +82,7 @@ type
     destructor Destroy; override;
     procedure Open(const AFileName: string); override;
     procedure Save; override;
+    procedure UnEncryptSave;
 
     procedure UpdateFileVersion;
     procedure SaveDebugFile(const AFileName: string);
@@ -88,6 +92,7 @@ type
   end;
 
   procedure SimpleDecrypt(const ASourceFile, AResultFile: string);
+  function FileEncrypted(const AFileName: string): Boolean;
 
 implementation
 
@@ -126,6 +131,31 @@ procedure SimpleDecrypt(const ASourceFile, AResultFile: string);
     end;
   end;
 
+  procedure RecoverFileHead(const AFileName: string);
+  var
+    sTempFile: string;
+    FileStream: TFileStream;
+  begin
+    sTempFile := ExtractFilePath(AFileName) + ExtractSimpleFileName(AFileName) + '.tmp';
+    CopyFile(PChar(AFileName), PChar(sTempFile), False);
+    try
+      if FileExists(sTempFile) then
+      begin
+        FileStream := TFileStream.Create(sTempFile, fmOpenWrite);
+        try
+          FileStream.Seek($00, soFromBeginning);
+          FileStream.Write(MDBOrgHead, SizeOf(MDBOrgHead));
+        finally
+          FileStream.Free;
+        end;
+        CopyFile(PChar(sTempFile), PChar(AFileName), False);
+        DeleteFile(PChar(sTempFile));
+      end;
+    except
+      DeleteFile(PChar(sTempFile));
+    end;
+  end;
+
 var
   sTempFile: string;
 begin
@@ -135,11 +165,26 @@ begin
     CopyFile(PChar(ASourceFile), PChar(sTempFile), False);
     RemoveHead(sTempFile);
     AutoDecryptFile(sTempFile, AResultFile);
+    RecoverFileHead(AResultFile);
   finally
     DeleteFile(PChar(sTempFile));
   end;
 end;
 
+function FileEncrypted(const AFileName: string): Boolean;
+var
+  FileHead: TDrawingFileHead;
+  FileStream: TFileStream;
+begin
+  FileStream := TFileStream.Create(AFileName, fmOpenRead);
+  try
+    FileStream.ReadBuffer(FileHead, SizeOf(TDrawingFileHead));
+    Result := FileHead.ProductName = ProductName;
+  finally
+    FileStream.Free;
+  end;
+end;
+
 procedure EncryptFile(const AFileName: string);
 var
   fileStream: TFileStream;
@@ -181,7 +226,10 @@ begin
       AutoEncryptFile(sTempFile, sEncryptFile);
       RefreshFileHead;
       WriteAndAddHead(sEncryptFile);
-      CopyFile(PChar(sEncryptFile), PChar(FOrgFile), False);
+      if CheckFileValid(sEncryptFile) then
+        CopyFile(PChar(sEncryptFile), PChar(FOrgFile), False)
+      else
+        Abort;
     finally
       DeleteFile(PChar(sTempFile));
       DeleteFile(PChar(sEncryptFile));
@@ -207,6 +255,7 @@ begin
   FFileName := Decrypt(AFileName);
   if FileExists(FFileName) then
   begin
+    RecoverFileHead(FFileName);
     InnerOpen(FFileName);
     DamageFileHead(FFileName);
   end
@@ -411,16 +460,51 @@ begin
   RecoverFileHead(AFileName);
 end;
 
-{ TConnection }
-
-procedure TConnection.Close;
+function TEncryptConnection.CheckFileValid(
+  const AFileName: string): Boolean;
+var
+  sConnectFile, sTempFile: string;
+  vCon: TADOConnection;
 begin
-  Connection.Close;
+  Result := False;
+  vCon := TADOConnection.Create(nil);
+  vCon.LoginPrompt := False;
+  sConnectFile := GetTempFileName;
+  sTempFile := GetTempFileName;
+  try
+    if FileExists(AFileName) then
+    begin
+      CopyFile(PChar(AFileName), PChar(sTempFile), False);
+      if CheckFileEncrypt(sTempFile) then
+      begin
+        ReadAndRemoveHead(sTempFile);
+        AutoDecryptFile(sTempFile, sConnectFile);
+      end
+      else
+        CopyFile(PChar(sTempFile), PChar(sConnectFile), False);
+      RecoverFileHead(sConnectFile);
+      vCon.ConnectionString := Format(SAdoConnectStr, [sConnectFile]);
+      vCon.Open;
+      Result := True;
+    end;
+  finally
+    DeleteFile(PChar(sConnectFile));
+    DeleteFile(PChar(sTempFile));
+    vCon.Free;
+  end;
 end;
 
-procedure TConnection.Save;
+procedure TEncryptConnection.UnEncryptSave;
 begin
+  RecoverFileHead(FFileName);
+  
+end;
 
+{ TConnection }
+
+procedure TConnection.Close;
+begin
+  Connection.Close;
 end;
 
 { TCommonConnection }
@@ -453,7 +537,7 @@ begin
   Close;
   if FileExists(AFileName) then
   begin
-    DecryptFile(AFileName);
+    //DecryptFile(AFileName);
     InnerOpen(AFileName);
   end
   else
@@ -468,4 +552,9 @@ begin
   FConnection.Open;
 end;
 
+procedure TCommonConnection.Save;
+begin
+  inherited;
+end;
+
 end.

+ 131 - 8
Units/DataBaseTables.pas

@@ -343,7 +343,7 @@ const
     (FieldName: 'Pos_Reason'; FieldType: ftMemo; Size: 60535; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 变更工程量说明
     (FieldName: 'Direction'; FieldType: ftMemo; Size: 60535; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
-    // 锁定
+    // 锁定 -- 废弃,不再使用
     (FieldName: 'Locked'; FieldType: ftBoolean; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 变更图号
     (FieldName: 'DrawingCode'; FieldType: ftString; Size: 50; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
@@ -375,7 +375,7 @@ const
     (FieldName: 'TotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 已变更数量
     (FieldName: 'UsedQuantity'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
-    // 锁定
+    // 锁定 -- 废弃,不再使用
     (FieldName: 'Locked'; FieldType: ftBoolean; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
 
@@ -418,7 +418,7 @@ const
 
   {调差工料}
   SProjectGL = 'ProjectGL';
-  tdProjectGL: array [0..16] of TScFieldDef =(
+  tdProjectGL: array [0..28] of TScFieldDef =(
     (FieldName: 'ID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
     // 工料机编号
     (FieldName: 'Code'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
@@ -452,13 +452,39 @@ const
     // 当前阶段 -- 调差数量
     (FieldName: 'PM_Quantity'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 当期阶段 -- 调差金额
-    (FieldName: 'PM_TotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+    (FieldName: 'PM_TotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 截止上期实耗 -- 数量
+    (FieldName: 'PreUsedQuantity'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期实耗 -- 金额
+    (FieldName: 'PreUsedTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期消耗盈亏 -- 数量盈亏       盈亏 -- 工料损耗 -- 数量
+    (FieldName: 'PrePAL_UsedQuantity'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期消耗盈亏 -- 数量盈亏金额   盈亏 -- 工料损耗 -- 金额
+    (FieldName: 'PrePAL_UsedTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期消耗盈亏 -- 价差盈亏       盈亏 -- 价差盈亏
+    (FieldName: 'PrePAL_DeltaPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期消耗盈亏 -- 合计盈亏       盈亏 -- 合计
+    (FieldName: 'PrePAL_Total'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 本期实耗 -- 数量
+    (FieldName: 'UsedQuantity'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期实耗 -- 金额
+    (FieldName: 'UsedTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期消耗盈亏 -- 数量盈亏       本期盈亏 -- 工料损耗 -- 数量
+    (FieldName: 'PAL_UsedQuantity'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期消耗盈亏 -- 数量盈亏金额   本期盈亏 -- 工料损耗 -- 金额
+    (FieldName: 'PAL_UsedTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期消耗盈亏 -- 价差盈亏       本期盈亏 -- 价差盈亏
+    (FieldName: 'PAL_DeltaPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期消耗盈亏 -- 合计盈亏       本期盈亏 -- 合计
+    (FieldName: 'PAL_Total'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
     {--------------------End 当期缓存数据----------------------}
   );
 
   {调差工料--价格信息及计算}
   SGLPrice = 'GLPrice';
-  tdGLPrice: array [0..39] of TScFieldDef =(
+  tdGLPrice: array [0..111] of TScFieldDef =(
     // 工料ID
     (FieldName: 'GLID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
     // 期号
@@ -471,44 +497,139 @@ const
     (FieldName: 'DeltaPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 有效价差
     (FieldName: 'ValidDeltaPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 截止上期 -- 数量
+    (FieldName: 'PreUsedQuantity'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 -- 金额
+    (FieldName: 'PreUsedTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期实耗 -- 数量
+    (FieldName: 'UsedQuantity'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期实耗 -- 金额
+    (FieldName: 'UsedTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
     // 截止上期
     (FieldName: 'PM_PreQuantity'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_PreTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 消耗盈亏 -- 数量盈亏       盈亏 -- 工料损耗 -- 数量
+    (FieldName: 'PrePAL_UsedQuantity'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 消耗盈亏 -- 数量盈亏金额   盈亏 -- 工料损耗 -- 金额
+    (FieldName: 'PrePAL_UsedTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 消耗盈亏 -- 价差盈亏       盈亏 -- 价差盈亏
+    (FieldName: 'PrePAL_DeltaPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 消耗盈亏 -- 合计盈亏       盈亏 -- 合计
+    (FieldName: 'PrePAL_Total'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 本期 -- 原报
     (FieldName: 'PM_Quantity0'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice0'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity0'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice0'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice0'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total0'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 本期 -- 1审~14审
     (FieldName: 'PM_Quantity1'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice1'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity1'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice1'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice1'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total1'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
     (FieldName: 'PM_Quantity2'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice2'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity2'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice2'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice2'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total2'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
     (FieldName: 'PM_Quantity3'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice3'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity3'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice3'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice3'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total3'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
     (FieldName: 'PM_Quantity4'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice4'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity4'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice4'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice4'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total4'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
     (FieldName: 'PM_Quantity5'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice5'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity5'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice5'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice5'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total5'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
     (FieldName: 'PM_Quantity6'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice6'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity6'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice6'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice6'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total6'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
     (FieldName: 'PM_Quantity7'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice7'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity7'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice7'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice7'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total7'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
     (FieldName: 'PM_Quantity8'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice8'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity8'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice8'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice8'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total8'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
     (FieldName: 'PM_Quantity9'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice9'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity9'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice9'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice9'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total9'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
     (FieldName: 'PM_Quantity10'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice10'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity10'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice10'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice10'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total10'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
     (FieldName: 'PM_Quantity11'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice11'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity11'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice11'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice11'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total11'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
     (FieldName: 'PM_Quantity12'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice12'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity12'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice12'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice12'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total12'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
     (FieldName: 'PM_Quantity13'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice13'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity13'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice13'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice13'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total13'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
     (FieldName: 'PM_Quantity14'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PM_TotalPrice14'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity14'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice14'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice14'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total14'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 本期 -- 终审数据(当前文件中最后一人的数据)-- 数据缓存
     (FieldName: 'PM_Quantity_F'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
-    (FieldName: 'PM_TotalPrice_F'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+    (FieldName: 'PM_TotalPrice_F'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedQuantity_F'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_UsedTotalPrice_F'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_DeltaPrice_F'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PAL_Total_F'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
 
   {清单使用的工料}
@@ -690,7 +811,7 @@ const
 
   // 计量期合同支付
   SPhasePay = 'PhasePay';
-  tdPhasePay: array [0..60] of TScFieldDef =(
+  tdPhasePay: array [0..61] of TScFieldDef =(
     // 与DealPayment一一对应
     (FieldName: 'ID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
     // 本期金额 0:原报,1..14:1..14审
@@ -756,7 +877,9 @@ const
     (FieldName: 'TotalPrice14'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'Formula14'; FieldType: ftString; Size: 100; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'EndTotalPrice14'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
-    (FieldName: 'PreTotalPrice14'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+    (FieldName: 'PreTotalPrice14'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 是否停用:0、False--否,-1、True--是
+    (FieldName: 'StopCalc'; FieldType: ftBoolean; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
 
   // 计量期属性表

+ 5 - 3
Units/ExcelImport.pas

@@ -154,9 +154,9 @@ procedure TBillsExcelImport.BeginImport;
 begin
   FCurRow := 0;
   FCacheTree := TBillsCacheTree.Create;
-  FCacheTree.NewNodeID := 101;
-  FCacheTree.SeparateChar := '.';
   FCacheTree.AutoSort := True;
+  FCacheTree.SeparateChar := '.';
+  FCacheTree.NewNodeID := Max(FCacheTree.NewNodeID, 101);
 end;
 
 procedure TBillsExcelImport.EndImport;
@@ -180,6 +180,7 @@ begin
   FCacheTree := ACacheTree;
   sChar := FCacheTree.SeparateChar;
   FCacheTree.SeparateChar := '.';
+  FCacheTree.NewNodeID := Max(FCacheTree.NewNodeID, 101);
 
   MSExcel.LoadFromFile(sFileName);
   LoadColumnsFromHead(FMSExcel.Sheets.Spreadsheet(0));
@@ -193,7 +194,7 @@ var
   iCol: Integer;
   sColName: string;
 begin
-  for iCol := 0 to ASheet.Cells.UsedRowCount do
+  for iCol := 0 to ASheet.Cells.UsedColCount do
   begin
     sColName := VarToStrDef(ASheet.Cells.GetValue(iCol, FCurRow), '');
     if sColName = '²ã´Î±àºÅ' then
@@ -240,6 +241,7 @@ begin
     LoadNode(ASheet);
     Inc(FCurRow);
   end;
+  FCacheTree.SaveTreeToFile('E:\Tree.txt');
 end;
 
 procedure TBillsExcelImport.WriteNode(ADataSet: TsdDataSet;

+ 75 - 63
Units/ProjectData.pas

@@ -76,7 +76,6 @@ type
     // 锁定数据 -- Sql语句方式(使用时注意相应的DataMoudle应处于关闭状态)
     procedure LockBillsBaseData;
     procedure LockDealPaymentData;
-    procedure LockBGLData;
     procedure LockProjectGLData;
     procedure LockDetailGLData;
 
@@ -98,6 +97,7 @@ type
     function GetStageIndex: Integer;
     procedure SetStageIndex(const Value: Integer);
     function GetCanInsertNormalBills: Boolean;
+    function GetValidStageIsRefer: Boolean;
   public
     constructor Create;
     destructor Destroy; override;
@@ -179,6 +179,7 @@ type
     function CheckDataBaseInfo(APhaseCount, AAuditStatus: Integer): Boolean;
 
     procedure ImportCloudTenderFile(const AFileName: string);
+    procedure ImportDmfFile(const AFileName: string);
 
     function CheckPassword: Boolean;
 
@@ -213,6 +214,7 @@ type
     property BaseDataReadOnly: Boolean read GetBaseDataReadOnly;
     property StageDataReadOnly: Boolean read GetStageDataReadOnly;
     property PriceMarginReadOnly: Boolean read GetPriceMarginReadOnly;
+    property ValidStageIsRefer: Boolean read GetValidStageIsRefer;
 
     property CanUnlockInfo: Boolean read FCanUnlockInfo write FCanUnlockInfo;
     property CanInsertNormalBills: Boolean read GetCanInsertNormalBills;
@@ -238,7 +240,7 @@ implementation
 
 uses UtilMethods, Globals, ProjectCommands, sdIDTree, StageDm,
   ZJJLDm, PHPWebDm, XMLDoc, XMLIntf, ConstUnit, PasswordInputFrm,
-  mProgressProFrm, mDataRecord, ConditionalDefines;
+  mProgressProFrm, mDataRecord, ConditionalDefines, DbTreeImport;
 
 { TProjectData }
 
@@ -376,7 +378,6 @@ begin
   FProjProperties.AuditStatus := -1;
   FProjProperties.FinalAuditCount := FProjProperties.PhaseCount;
   FStaffData.LockedDataForReply;
-  LockBGLData;
 end;
 
 procedure TProjectData.LockedDataForSubmit;
@@ -385,7 +386,6 @@ begin
   LockDealPaymentData;
   FProjProperties.AuditCompany := FStaffData.FinalStaffCompany;
   FStaffData.LockedDataForAudit;
-  LockBGLData;
 end;
 
 procedure TProjectData.Open(AProjRec: TsdDataRecord);
@@ -469,42 +469,46 @@ end;
 
 procedure TProjectData.Save;
 begin
-  UpdateSysProgress(5, '正在保存数据');
-  SaveLastestPhaseMainData;
-  UpdateSysProgress(10, '正在保存数据');
-  if FPhaseData.Active then
-    FPhaseData.Save;
-  UpdateSysProgress(40, '正在保存数据');
-  FMainListData.Save;
-  FDealPaymentData.Save;
-  UpdateSysProgress(50, '正在保存数据');
-  FStaffData.Save;
-  UpdateSysProgress(60, '正在保存数据');
-  FBGLData.Save;
-  UpdateSysProgress(70, '正在保存数据');
-  FDealBillsData.Save;
-  UpdateSysProgress(80, '正在保存数据');
-
-  FProjectGLData.Save;
-  FDetailGLData.Save;
-  UpdateSysProgress(100, '正在保存数据');
-
-  FBillsCompileData.ReLockBaseData;
-  UpdateSysProgress(110, '正在保存数据');
-  FBillsData.Save;
-  UpdateSysProgress(170, '正在保存数据');
-
-  FProjProperties.AuditCompany := FStaffData.FinalStaffCompany;
-  FProjProperties.Save;
-  UpdateSysProgress(180, '正在保存数据');
-  FConnection.Save;
-  UpdateSysProgress(190, '正在保存数据');
-
-  ZipFolder(FTempFolder, FileName);
-  SaveInfoToManager;
-  UpdateSysProgress(200, '就绪');
-
-  ProjectManager.AddSaveTenderBackup(FProjectID);
+  try
+    UpdateSysProgress(5, '正在保存数据');
+    SaveLastestPhaseMainData;
+    UpdateSysProgress(10, '正在保存数据');
+    if (FPhaseData.Active) and (FPhaseIndex = ProjProperties.PhaseCount) then
+      FPhaseData.Save;
+    UpdateSysProgress(40, '正在保存数据');
+    FMainListData.Save;
+    FDealPaymentData.Save;
+    UpdateSysProgress(50, '正在保存数据');
+    FStaffData.Save;
+    UpdateSysProgress(60, '正在保存数据');
+    FBGLData.Save;
+    UpdateSysProgress(70, '正在保存数据');
+    FDealBillsData.Save;
+    UpdateSysProgress(80, '正在保存数据');
+
+    FProjectGLData.Save;
+    FDetailGLData.Save;
+    UpdateSysProgress(100, '正在保存数据');
+
+    FBillsCompileData.ReLockBaseData;
+    UpdateSysProgress(110, '正在保存数据');
+    FBillsData.Save;
+    UpdateSysProgress(170, '正在保存数据');
+
+    FProjProperties.AuditCompany := FStaffData.FinalStaffCompany;
+    FProjProperties.Save;
+    UpdateSysProgress(180, '正在保存数据');
+    FConnection.Save;
+    UpdateSysProgress(190, '正在保存数据');
+
+    ZipFolder(FTempFolder, FileName);
+    SaveInfoToManager;
+    UpdateSysProgress(200, '就绪');
+
+    ProjectManager.AddSaveTenderBackup(FProjectID);
+  except
+    ErrorMessage('保存数据出错。请重试,或联系纵横客服:企业QQ:800003850   客服热线:(0756)3850888');
+  end;
 end;
 
 procedure TProjectData.SaveInfoToManager;
@@ -534,20 +538,23 @@ procedure TProjectData.SetPhaseIndex(const Value: Integer);
     Result := Format('%s\Phase%d.dat', [TempPath, FPhaseIndex]);
   end;
 
-  procedure ReCreatePhaseData;
+  procedure ReCreatePhaseData(AOrgPhaseIndex: Integer);
   begin
-    if FPhaseData.Active then
+    if (FPhaseData.Active) and (AOrgPhaseIndex = ProjProperties.PhaseCount) then
       FPhaseData.Save;
     FPhaseData.Free;
     FPhaseData := TPhaseData.Create(Self);
   end;
 
+var
+  iOrgPhaseIndex: Integer;
 begin
   SaveLastestPhaseMainData;
   FProjectGLData.Save;
+  iOrgPhaseIndex := FPhaseIndex;
   FPhaseIndex := Value;
   ProjProperties.PhaseIndex := FPhaseIndex;
-  ReCreatePhaseData;
+  ReCreatePhaseData(iOrgPhaseIndex);
   FPhaseData.Open(GetPhaseFileName);
   ResetPhaseDataLink;
   // 须保存项目工料数据,重新加载当期的项目工料数据
@@ -1058,14 +1065,9 @@ procedure TProjectData.CopyPhaseData;
       ExecuteSql(sSql);
     end;
     // 审核通过的最后一人
-    if ProjProperties.AuditStatus <> 0 then
-    begin
-      if ProjProperties.AuditStatus = -1 then
-        vChecker := Checkers.Item[Checkers.Count -1]
-      else
-        vChecker := Checkers.Item[ProjProperties.AuditStatus-1];
-      sSql := Format(sInsertSql, [vChecker.No, vChecker.Name, vChecker.Role, vChecker.Memo, vChecker.CheckedDateTime, 1]);
-    end
+    vChecker := Checkers.LastChecker;
+    if Assigned(vChecker) then
+      sSql := Format(sInsertSql, [vChecker.No, vChecker.Name, vChecker.Role, vChecker.Memo, vChecker.CheckedDateTime, 1])
     else
       sSql := Format(sInsertSql, [-1, '', '', '', '', 1]);
     ExecuteSql(sSql);
@@ -1084,7 +1086,7 @@ begin
     CopyCurPhaseData;
   FDealPaymentData.UpdateLinkSerialNo;
   //CopyHistoryCompleteData;
-  if G_IsCloud then
+  if _IsCloud then
     SaveCloudInfo;
   if _IsDebugView then
     SaveDebugFile('Report.dat');
@@ -1401,15 +1403,6 @@ begin
   ExecuteSql(sLockFormulaSql);
 end;
 
-procedure TProjectData.LockBGLData;
-const
-  sBGSql = 'Update BGL Set Locked = True';
-  sBGBillsSql = 'Update BGBills Set Locked = True';
-begin
-  ExecuteSql(sBGSql);
-  ExecuteSql(sBGBillsSql);
-end;
-
 procedure TProjectData.OpenForReport(const AFileName: string);
 begin
   FProjectID := -1;
@@ -1822,10 +1815,16 @@ procedure TProjectData.CopyPreData;
   const
     sCopySql = 'Insert Into GLPrice (GLID, PhaseID,' +
                '    InfoPrice, InfoDate, DeltaPrice, ValidDeltaPrice,' +
-               '    PM_PreQuantity, PM_PreTotalPrice)'+
+               '    PreUsedQuantity, PreUsedTotalprice' +
+               '    PM_PreQuantity, PM_PreTotalPrice,'+
+               '    PrePAL_UsedQuantity, PrePAL_UsedTotalPrice,'+
+               '    PrePAL_DeltaPrice, PrePAL_Total)'+
                '  Select GLID, %d,'+
                '    InfoPrice, InfoDate, DeltaPrice, ValidDeltaPrice,'+
-               '    PM_PreQuantity+PM_Quantity_F, PM_PreTotalPrice+PM_TotalPrice_F'+
+               '    PreUsedQuantity+UsedQuantity, PreUsedTotalPrice+UsedTotalPrice,'+
+               '    PM_PreQuantity+PM_Quantity_F, PM_PreTotalPrice+PM_TotalPrice_F,'+
+               '    PrePAL_UsedQuantity+PAL_UsedQuantity_F, PrePAL_UsedTotalPrice+PAL_UsedTotalPrice_F,'+
+               '    PrePAL_DeltaPrice+PAL_DeltaPrice_F, PrePAL_Total+PAL_Total_F'+
                '  From GLPrice Where PhaseID = %d';
   begin
     if FProjProperties.PhaseCount > 1 then
@@ -1907,4 +1906,17 @@ begin
   FConnection.SaveDebugFile(AFileName);
 end;
 
+procedure TProjectData.ImportDmfFile(const AFileName: string);
+begin
+  ImportDbTreeTo(AFileName, Self);
+end;
+
+function TProjectData.GetValidStageIsRefer: Boolean;
+begin
+  if FPhaseData.Active then
+    Result := (FPhaseIndex = FProjProperties.PhaseCount) and (FPhaseData.StageCount = 1) and (FProjProperties.AuditStatus <> -1)
+  else
+    Result := False;
+end;
+
 end.

+ 22 - 0
Units/ProjectProperty.pas

@@ -75,6 +75,8 @@ type
 
     FUpdateFlag: Integer;
     FPriceMarginStartPhaseID: Integer;
+    FShowReportShading: Boolean;
+    FReportShading: string;
 
     function GetBoolPropertyDef(const AName: string; ADef: Boolean): Boolean;
     function GetIntPropertyDef(const AName: string; ADef: Integer): Integer;
@@ -115,6 +117,8 @@ type
     procedure SetQuantityDigit(const Value: Integer);
     procedure SetTotalPriceDigit(const Value: Integer);
     procedure SetUpdateFlag(const Value: Integer);
+    procedure SetReportShading(const Value: string);
+    procedure SetShowReportShading(const Value: Boolean);
   public
     constructor Create(AProjectData: TObject);
     destructor Destroy; override;
@@ -210,6 +214,9 @@ type
     property ShowBGLCode: Boolean read FShowBGLCode write SetShowBGLCode;
     property ShowDesignQuantity: Boolean read FShowDesignQuantity write SetShowDesignQuantity;
     property ShowAlias: Boolean read FShowAlias write SetShowAlias;
+
+    property ShowReportShading: Boolean read FShowReportShading write SetShowReportShading;
+    property ReportShading: string read FReportShading write SetReportShading;
   end;
 
 implementation
@@ -469,6 +476,9 @@ begin
   FShowBGLCode := GetBoolPropertyDef('ShowBGLCode', True);
   FShowDesignQuantity := GetBoolPropertyDef('ShowDesignQuantity', False);
   FShowAlias := GetBoolPropertyDef('ShowAlias', False);
+
+  FShowReportShading := GetBoolPropertyDef('ShowReportShading', False);
+  FReportShading := GetStrPropertyDef('ReportShading', '');
 end;
 
 procedure TProjProperties.Open(AConnection: TADOConnection);
@@ -593,6 +603,12 @@ begin
   FQuantityFormat := GetDisplayFormat(FQuantityDigit);
 end;
 
+procedure TProjProperties.SetReportShading(const Value: string);
+begin
+  FReportShading := Value;
+  FPropertyInqurity.Value['ReportShading'] := Value;
+end;
+
 procedure TProjProperties.SetShowAlias(const Value: Boolean);
 begin
   FShowAlias := Value;
@@ -617,6 +633,12 @@ begin
   FPropertyInqurity.Value['ShowPriceChange'] := Value;
 end;
 
+procedure TProjProperties.SetShowReportShading(const Value: Boolean);
+begin
+  FShowReportShading := Value;
+  FPropertyInqurity.Value['ShowReportShading'] := Value;
+end;
+
 procedure TProjProperties.SetStartedSubsist(const Value: Double);
 begin
   FStartedSubsist := Value;

+ 7 - 0
Units/UpdateDataBase.pas

@@ -18,6 +18,8 @@ type
   TUpdateManagerDB = class(TUpdateDB)
   private
     Procedure UpdateAllTables(AConnection: TADOConnection); override;
+  public
+    procedure Update(AConnection: TConnection); overload;
   end;
 
   TUpdateProjectDB = class(TUpdateDB)
@@ -178,6 +180,11 @@ end;
 
 { TUpdateManagerDB }
 
+procedure TUpdateManagerDB.Update(AConnection: TConnection);
+begin
+  UpdateAllTables(AConnection.Connection);
+end;
+
 procedure TUpdateManagerDB.UpdateAllTables(AConnection: TADOConnection);
 var
   Updater: TScUpdater;

+ 36 - 0
Units/mDataRecord.pas

@@ -339,6 +339,20 @@ type
     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
@@ -361,6 +375,20 @@ type
     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)
@@ -642,6 +670,14 @@ begin
   FPM_PreTotalPrice := ValueByName('PM_PreTotalPrice');
   FPM_Quantity := ValueByName('PM_Quantity');
   FPM_TotalPrice := ValueByName('PM_TotalPrice');
+
+  FUsedQuantity := ValueByName('UsedQuantity');
+  FUsedTotalPrice := ValueByName('UsedTotalPrice');
+
+  FPAL_UsedQuantity := ValueByName('PAL_UsedQuantity');
+  FPAL_UsedTotalPrice := ValueByName('PAL_UsedTotalPrice');
+  FPAL_DeltaPrice := ValueByName('PAL_DeltaPrice');
+  FPAL_Total := ValueByName('PAL_Total');
 end;
 
 { TDetailGLRecord }