ソースを参照

Merge branch '3.1.3.3'

Conflicts:
	DataModules/BillsDm.dfm
	DataModules/StageDm.pas
	Dprs/Pro/Measure.dof
	Dprs/Pro/Measure.dpr
	Dprs/Pro/Measure_Cloud.dof
	Dprs/Pro/Measure_Cloud.dpr
	Dprs/Pro/Measure_GuangDong.dof
	Dprs/Pro/Measure_GuangDong.dpr
	Dprs/Pro/Measure_GuangDong_Cloud.dof
	Dprs/Pro/Measure_GuangDong_Cloud.dpr
	Dprs/Pro/Measure_GuangDong_TZ.dof
	Dprs/Pro/Measure_GuangDong_TZ.dpr
	Dprs/Pro/Measure_TZ.dof
	Dprs/Pro/Measure_TZ.dpr
	Dprs/Trail/Measure.dof
	Dprs/Trail/Measure.dpr
	Dprs/Trail/Measure_GuangDong.dof
	Dprs/Trail/Measure_GuangDong.dpr
	Units/DataBaseTables.pas
	Units/ProjectData.pas
	Units/mDataRecord.pas
MaiXinRong 9 年 前
コミット
c39eb5ed2d
68 ファイル変更7623 行追加1733 行削除
  1. 3 0
      DataModules/BillsCompileDm.pas
  2. 7 0
      DataModules/BillsDm.dfm
  3. 446 368
      DataModules/BillsGatherDm.dfm
  4. 246 431
      DataModules/BillsGatherDm.pas
  5. 15 0
      DataModules/BillsMeasureDm.dfm
  6. 79 6
      DataModules/BillsMeasureDm.pas
  7. 44 0
      DataModules/DetailGLDm.dfm
  8. 368 0
      DataModules/DetailGLDm.pas
  9. 1 0
      DataModules/PhasePayDm.pas
  10. 223 0
      DataModules/PriceMarginBillsDm.dfm
  11. 377 0
      DataModules/PriceMarginBillsDm.pas
  12. 117 0
      DataModules/ProjectGLDm.dfm
  13. 575 0
      DataModules/ProjectGLDm.pas
  14. 102 444
      DataModules/ReportMemoryDm/rmGcl_XmjBillsDm.pas
  15. 6 0
      DataModules/StageDm.dfm
  16. 224 22
      DataModules/StageDm.pas
  17. 14 0
      Dprs/Pro/Measure.dof
  18. 20 0
      Dprs/Pro/Measure.dpr
  19. 14 0
      Dprs/Pro/Measure_Cloud.dof
  20. 20 0
      Dprs/Pro/Measure_Cloud.dpr
  21. 14 0
      Dprs/Pro/Measure_GuangDong.dof
  22. 16 0
      Dprs/Pro/Measure_GuangDong.dpr
  23. 14 0
      Dprs/Pro/Measure_GuangDong_Cloud.dof
  24. 16 0
      Dprs/Pro/Measure_GuangDong_Cloud.dpr
  25. 17 2
      Dprs/Pro/Measure_GuangDong_TZ.dof
  26. 16 0
      Dprs/Pro/Measure_GuangDong_TZ.dpr
  27. 14 0
      Dprs/Pro/Measure_TZ.dof
  28. 16 0
      Dprs/Pro/Measure_TZ.dpr
  29. 14 0
      Dprs/Trail/Measure.dof
  30. 16 0
      Dprs/Trail/Measure.dpr
  31. 14 0
      Dprs/Trail/Measure_GuangDong.dof
  32. 16 0
      Dprs/Trail/Measure_GuangDong.dpr
  33. 6 0
      Forms/BatchInsertBillsFrm.dfm
  34. 1 0
      Forms/BatchInsertBillsFrm.pas
  35. 3 3
      Forms/BatchReplaceBillsFrm.dfm
  36. 26 0
      Forms/MainFrm.dfm
  37. 4 0
      Forms/MainFrm.pas
  38. 1 1
      Forms/ReportsFrm.dfm
  39. 1 0
      Forms/ReportsFrm.pas
  40. 269 0
      Forms/SelectDetailGLsFrm.dfm
  41. 158 0
      Forms/SelectDetailGLsFrm.pas
  42. 1 1
      Frames/BGLFme.dfm
  43. 1 1
      Frames/BillsCompileFme.dfm
  44. 549 236
      Frames/BillsGatherFme.dfm
  45. 51 26
      Frames/BillsGatherFme.pas
  46. 58 1
      Frames/BillsMeasureFme.dfm
  47. 20 3
      Frames/BillsMeasureFme.pas
  48. 3 1
      Frames/DealBillsFme.dfm
  49. 1 1
      Frames/PhaseCompareFme.dfm
  50. 745 0
      Frames/PriceMarginBillsFme.dfm
  51. 190 0
      Frames/PriceMarginBillsFme.pas
  52. 115 0
      Frames/PriceMarginFme.dfm
  53. 82 0
      Frames/PriceMarginFme.pas
  54. 35 8
      Frames/ProjectFme.dfm
  55. 43 13
      Frames/ProjectFme.pas
  56. 291 0
      Frames/ProjectGLFme.dfm
  57. 94 0
      Frames/ProjectGLFme.pas
  58. 3 1
      Frames/SearchFme.dfm
  59. 3 1
      Frames/StandardBillsFme.dfm
  60. 159 0
      Units/BaseClipboard.pas
  61. 16 121
      Units/BillsClipboard.pas
  62. 3 0
      Units/ConstUnit.pas
  63. 127 3
      Units/DataBaseTables.pas
  64. 1081 0
      Units/GclBillsGatherModel.pas
  65. 190 37
      Units/ProjectData.pas
  66. 3 0
      Units/UpdateDataBase.pas
  67. 21 0
      Units/UtilMethods.pas
  68. 185 2
      Units/mDataRecord.pas

+ 3 - 0
DataModules/BillsCompileDm.pas

@@ -633,6 +633,9 @@ procedure TBillsCompileData.sdvBillsCompileSetText(var Text: String;
     vNode := TBillsIDTreeNode(BillsCompileTree.FindNode(ARecord.ValueByName('ID').AsInteger));
     iCreatePhase := vNode.Rec.ValueByName('CreatePhaseID').AsInteger;
 
+    if vNode.ID = iPriceMarginID then
+      SetTextErrorHint(sBills_PMHint);
+
     if vNode.HasChildren then
     begin
       if Text = '' then

+ 7 - 0
DataModules/BillsDm.dfm

@@ -198,6 +198,7 @@ object BillsData: TBillsData
       02080549734B6579080F4E65656450726F636573734E616D65090001044E616D
       65060D4861734174746163686D656E74094669656C644E616D65060D48617341
       74746163686D656E740844617461547970650205084461746153697A65020105
+<<<<<<< HEAD
       49734B6579080F4E65656450726F636573734E616D65090001044E616D650608
       43616C6354797065094669656C644E616D65060843616C635479706508446174
       61547970650203084461746153697A6502040549734B6579080F4E6565645072
@@ -210,5 +211,11 @@ object BillsData: TBillsData
       65060A4F7468466F726D756C61094669656C644E616D65060A4F7468466F726D
       756C610844617461547970650218084461746153697A6503C8000549734B6579
       080F4E65656450726F636573734E616D65090000}
+=======
+      49734B6579080F4E65656450726F636573734E616D65090001044E616D650610
+      504D5F416464546F74616C5072696365094669656C644E616D650610504D5F41
+      6464546F74616C50726963650844617461547970650206084461746153697A65
+      02080549734B6579080F4E65656450726F636573734E616D65090000}
+>>>>>>> 3.1.3.3
   end
 end

+ 446 - 368
DataModules/BillsGatherDm.dfm

@@ -1,471 +1,549 @@
 object BillsGatherData: TBillsGatherData
   OldCreateOrder = False
-  Left = 571
-  Top = 314
-  Height = 207
-  Width = 215
-  object cdsBillsGather: TClientDataSet
-    Active = True
-    Aggregates = <>
-    FieldDefs = <
+  Left = 975
+  Top = 520
+  Height = 405
+  Width = 326
+  object smpGclBills: TsdMemoryProvider
+    Left = 40
+    Top = 16
+  end
+  object sddGclBills: TsdDataSet
+    Active = False
+    Provider = smpGclBills
+    Left = 40
+    Top = 72
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D650609496E646578436F6465094669656C644E
+      616D650609496E646578436F6465084461746154797065020108446174615369
+      7A6502640549734B6579080F4E65656450726F636573734E616D65090001044E
+      616D650606425F436F6465094669656C644E616D650606425F436F6465084461
+      7461547970650201084461746153697A6502320549734B6579080F4E65656450
+      726F636573734E616D65090001044E616D6506044E616D65094669656C644E61
+      6D6506044E616D650844617461547970650218084461746153697A6503C80005
+      49734B6579080F4E65656450726F636573734E616D65090001044E616D650605
+      556E697473094669656C644E616D650605556E69747308446174615479706502
+      18084461746153697A6502140549734B6579080F4E65656450726F636573734E
+      616D65090001044E616D6506055072696365094669656C644E616D6506055072
+      6963650844617461547970650206084461746153697A6502080549734B657908
+      0F4E65656450726F636573734E616D65090001044E616D6506084E6577507269
+      6365094669656C644E616D6506084E6577507269636508446174615479706502
+      06084461746153697A6502080549734B6579080F4E65656450726F636573734E
+      616D65090001044E616D65060C4465616C5175616E74697479094669656C644E
+      616D65060C4465616C5175616E74697479084461746154797065020608446174
+      6153697A6502080549734B6579080F4E65656450726F636573734E616D650900
+      01044E616D65060E4465616C546F74616C5072696365094669656C644E616D65
+      060E4465616C546F74616C507269636508446174615479706502060844617461
+      53697A6502080549734B6579080F4E65656450726F636573734E616D65090001
+      044E616D65060B42474C5175616E74697479094669656C644E616D65060B4247
+      4C5175616E746974790844617461547970650206084461746153697A65020805
+      49734B6579080F4E65656450726F636573734E616D65090001044E616D65060D
+      42474C546F74616C5072696365094669656C644E616D65060D42474C546F7461
+      6C50726963650844617461547970650206084461746153697A6502080549734B
+      6579080F4E65656450726F636573734E616D65090001044E616D650608517561
+      6E74697479094669656C644E616D6506085175616E7469747908446174615479
+      70650206084461746153697A6502080549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D65060A546F74616C5072696365094669656C64
+      4E616D65060A546F74616C507269636508446174615479706502060844617461
+      53697A6502080549734B6579080F4E65656450726F636573734E616D65090001
+      044E616D65060F4375724465616C5175616E74697479094669656C644E616D65
+      060F4375724465616C5175616E74697479084461746154797065020608446174
+      6153697A6502080549734B6579080F4E65656450726F636573734E616D650900
+      01044E616D6506114375724465616C546F74616C5072696365094669656C644E
+      616D6506114375724465616C546F74616C507269636508446174615479706502
+      06084461746153697A6502080549734B6579080F4E65656450726F636573734E
+      616D65090001044E616D65060D43757251635175616E74697479094669656C64
+      4E616D65060D43757251635175616E7469747908446174615479706502060844
+      61746153697A6502080549734B6579080F4E65656450726F636573734E616D65
+      090001044E616D65060F4375725163546F74616C5072696365094669656C644E
+      616D65060F4375725163546F74616C5072696365084461746154797065020608
+      4461746153697A6502080549734B6579080F4E65656450726F636573734E616D
+      65090001044E616D6506114375724761746865725175616E7469747909466965
+      6C644E616D6506114375724761746865725175616E7469747908446174615479
+      70650206084461746153697A6502080549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D650613437572476174686572546F74616C5072
+      696365094669656C644E616D650613437572476174686572546F74616C507269
+      63650844617461547970650206084461746153697A6502080549734B6579080F
+      4E65656450726F636573734E616D65090001044E616D65060F5072654465616C
+      5175616E74697479094669656C644E616D65060F5072654465616C5175616E74
+      6974790844617461547970650206084461746153697A6502080549734B657908
+      0F4E65656450726F636573734E616D65090001044E616D650611507265446561
+      6C546F74616C5072696365094669656C644E616D6506115072654465616C546F
+      74616C50726963650844617461547970650206084461746153697A6502080549
+      734B6579080F4E65656450726F636573734E616D65090001044E616D65060D50
+      726551635175616E74697479094669656C644E616D65060D5072655163517561
+      6E746974790844617461547970650206084461746153697A6502080549734B65
+      79080F4E65656450726F636573734E616D65090001044E616D65060F50726551
+      63546F74616C5072696365094669656C644E616D65060F5072655163546F7461
+      6C50726963650844617461547970650206084461746153697A6502080549734B
+      6579080F4E65656450726F636573734E616D65090001044E616D650611507265
+      4761746865725175616E74697479094669656C644E616D650611507265476174
+      6865725175616E746974790844617461547970650206084461746153697A6502
+      080549734B6579080F4E65656450726F636573734E616D65090001044E616D65
+      0613507265476174686572546F74616C5072696365094669656C644E616D6506
+      13507265476174686572546F74616C5072696365084461746154797065020608
+      4461746153697A6502080549734B6579080F4E65656450726F636573734E616D
+      65090001044E616D65060F4164644465616C5175616E74697479094669656C64
+      4E616D65060F4164644465616C5175616E746974790844617461547970650206
+      084461746153697A6502080549734B6579080F4E65656450726F636573734E61
+      6D65090001044E616D6506114164644465616C546F74616C5072696365094669
+      656C644E616D6506114164644465616C546F74616C5072696365084461746154
+      7970650206084461746153697A6502080549734B6579080F4E65656450726F63
+      6573734E616D65090001044E616D65060D41646451635175616E746974790946
+      69656C644E616D65060D41646451635175616E74697479084461746154797065
+      0206084461746153697A6502080549734B6579080F4E65656450726F63657373
+      4E616D65090001044E616D65060F4164645163546F74616C5072696365094669
+      656C644E616D65060F4164645163546F74616C50726963650844617461547970
+      650206084461746153697A6502080549734B6579080F4E65656450726F636573
+      734E616D65090001044E616D6506114164644761746865725175616E74697479
+      094669656C644E616D6506114164644761746865725175616E74697479084461
+      7461547970650206084461746153697A6502080549734B6579080F4E65656450
+      726F636573734E616D65090001044E616D650613416464476174686572546F74
+      616C5072696365094669656C644E616D650613416464476174686572546F7461
+      6C50726963650844617461547970650206084461746153697A6502080549734B
+      6579080F4E65656450726F636573734E616D65090001044E616D65060F456E64
+      4465616C5175616E74697479094669656C644E616D65060F456E644465616C51
+      75616E746974790844617461547970650206084461746153697A650208054973
+      4B6579080F4E65656450726F636573734E616D65090001044E616D650611456E
+      644465616C546F74616C5072696365094669656C644E616D650611456E644465
+      616C546F74616C50726963650844617461547970650206084461746153697A65
+      02080549734B6579080F4E65656450726F636573734E616D65090001044E616D
+      65060D456E6451635175616E74697479094669656C644E616D65060D456E6451
+      635175616E746974790844617461547970650206084461746153697A65020805
+      49734B6579080F4E65656450726F636573734E616D65090001044E616D65060F
+      456E645163546F74616C5072696365094669656C644E616D65060F456E645163
+      546F74616C50726963650844617461547970650206084461746153697A650208
+      0549734B6579080F4E65656450726F636573734E616D65090001044E616D6506
+      11456E644761746865725175616E74697479094669656C644E616D650611456E
+      644761746865725175616E746974790844617461547970650206084461746153
+      697A6502080549734B6579080F4E65656450726F636573734E616D6509000104
+      4E616D650613456E64476174686572546F74616C5072696365094669656C644E
+      616D650613456E64476174686572546F74616C50726963650844617461547970
+      650206084461746153697A6502080549734B6579080F4E65656450726F636573
+      734E616D65090001044E616D6506104465616C5F42474C5175616E7469747909
+      4669656C644E616D6506104465616C5F42474C5175616E746974790844617461
+      547970650206084461746153697A6502080549734B6579080F4E65656450726F
+      636573734E616D65090001044E616D6506124465616C5F42474C546F74616C50
+      72696365094669656C644E616D6506124465616C5F42474C546F74616C507269
+      63650844617461547970650206084461746153697A6502080549734B6579080F
+      4E65656450726F636573734E616D65090001044E616D65060F4465616C5F4247
+      4C50657263656E74094669656C644E616D65060F4465616C5F42474C50657263
+      656E740844617461547970650206084461746153697A6502080549734B657908
+      0F4E65656450726F636573734E616D65090000}
+  end
+  object sdvGclBills: TsdDataView
+    Active = False
+    DataSet = sddGclBills
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'IndexCode'
+      end
+      item
+        FieldName = 'B_Code'
+      end
+      item
+        FieldName = 'Name'
+      end
+      item
+        FieldName = 'Units'
+      end
+      item
+        FieldName = 'Price'
+      end
+      item
+        FieldName = 'DealQuantity'
+      end
+      item
+        FieldName = 'DealTotalPrice'
+      end
       item
-        Name = 'B_Code'
-        DataType = ftString
-        Size = 50
+        FieldName = 'BGLQuantity'
       end
       item
-        Name = 'IndexCode'
-        DataType = ftString
-        Size = 50
+        FieldName = 'BGLTotalPrice'
       end
       item
-        Name = 'Name'
-        DataType = ftWideString
-        Size = 200
+        FieldName = 'Quantity'
       end
       item
-        Name = 'Units'
-        DataType = ftWideString
-        Size = 20
+        FieldName = 'TotalPrice'
       end
       item
-        Name = 'Price'
-        DataType = ftFloat
+        FieldName = 'CurDealQuantity'
       end
       item
-        Name = 'NewPrice'
-        DataType = ftFloat
+        FieldName = 'CurDealTotalPrice'
       end
       item
-        Name = 'DealQuantity'
-        DataType = ftFloat
+        FieldName = 'CurQcQuantity'
       end
       item
-        Name = 'DealTotalPrice'
-        DataType = ftFloat
+        FieldName = 'CurQcTotalPrice'
       end
       item
-        Name = 'Quantity'
-        DataType = ftFloat
+        FieldName = 'CurGatherQuantity'
       end
       item
-        Name = 'TotalPrice'
-        DataType = ftFloat
+        FieldName = 'CurGatherTotalPrice'
       end
       item
-        Name = 'CurDealQuantity'
-        DataType = ftFloat
+        FieldName = 'PreDealQuantity'
       end
       item
-        Name = 'CurDealTotalPrice'
-        DataType = ftFloat
+        FieldName = 'PreDealTotalPrice'
       end
       item
-        Name = 'CurQcQuantity'
-        DataType = ftFloat
+        FieldName = 'PreQcQuantity'
       end
       item
-        Name = 'CurQcTotalPrice'
-        DataType = ftFloat
+        FieldName = 'PreQcTotalPrice'
       end
       item
-        Name = 'CurPcQuantity'
-        DataType = ftFloat
+        FieldName = 'PreGatherQuantity'
       end
       item
-        Name = 'CurPcTotalPrice'
-        DataType = ftFloat
+        FieldName = 'PreGatherTotalPrice'
       end
       item
-        Name = 'CurGatherQuantity'
-        DataType = ftFloat
+        FieldName = 'AddDealQuantity'
       end
       item
-        Name = 'CurGatherTotalPrice'
-        DataType = ftFloat
+        FieldName = 'AddDealTotalPrice'
       end
       item
-        Name = 'AddDealQuantity'
-        DataType = ftFloat
+        FieldName = 'AddQcQuantity'
       end
       item
-        Name = 'AddDealTotalPrice'
-        DataType = ftFloat
+        FieldName = 'AddQcTotalPrice'
       end
       item
-        Name = 'AddQcQuantity'
-        DataType = ftFloat
+        FieldName = 'AddGatherQuantity'
       end
       item
-        Name = 'AddQcTotalPrice'
-        DataType = ftFloat
+        FieldName = 'AddGatherTotalPrice'
       end
       item
-        Name = 'AddPcQuantity'
-        DataType = ftFloat
+        FieldName = 'EndDealQuantity'
       end
       item
-        Name = 'AddPcTotalPrice'
-        DataType = ftFloat
+        FieldName = 'EndDealTotalPrice'
       end
       item
-        Name = 'AddGatherQuantity'
-        DataType = ftFloat
+        FieldName = 'EndQcQuantity'
       end
       item
-        Name = 'AddGatherTotalPrice'
-        DataType = ftFloat
+        FieldName = 'EndQcTotalPrice'
       end
       item
-        Name = 'EndDealQuantity'
-        DataType = ftFloat
+        FieldName = 'EndGatherQuantity'
       end
       item
-        Name = 'EndDealTotalPrice'
-        DataType = ftFloat
+        FieldName = 'EndGatherTotalPrice'
       end
       item
-        Name = 'EndQcQuantity'
-        DataType = ftFloat
+        FieldName = 'Deal_BGLQuantity'
       end
       item
-        Name = 'EndQcTotalPrice'
-        DataType = ftFloat
+        FieldName = 'Deal_BGLTotalPrice'
       end
       item
-        Name = 'EndPcQuantity'
-        DataType = ftFloat
+        FieldName = 'Deal_BGLPercent'
+      end>
+    OnCurrentChanged = sdvGclBillsCurrentChanged
+    Left = 40
+    Top = 136
+  end
+  object smpDetailGclBills: TsdMemoryProvider
+    Left = 40
+    Top = 192
+  end
+  object sddDetailGclBills: TsdDataSet
+    Active = False
+    Provider = smpDetailGclBills
+    Left = 40
+    Top = 248
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D65060742696C6C734944094669656C644E616D
+      65060742696C6C7349440844617461547970650203084461746153697A650204
+      0549734B6579080F4E65656450726F636573734E616D65090001044E616D6506
+      0C5472656553657269616C4E6F094669656C644E616D65060C54726565536572
+      69616C4E6F0844617461547970650203084461746153697A6502040549734B65
+      79080F4E65656450726F636573734E616D65090001044E616D65060B52656C61
+      42696C6C734944094669656C644E616D65060B52656C6142696C6C7349440844
+      617461547970650203084461746153697A6502040549734B6579080F4E656564
+      50726F636573734E616D65090001044E616D6506094C656166586D6A49440946
+      69656C644E616D6506094C656166586D6A494408446174615479706502030844
+      61746153697A6502040549734B6579080F4E65656450726F636573734E616D65
+      090001044E616D650607586D6A436F6465094669656C644E616D650607586D6A
+      436F64650844617461547970650201084461746153697A6502320549734B6579
+      080F4E65656450726F636573734E616D65090001044E616D650607586D6A4E61
+      6D65094669656C644E616D650607586D6A4E616D650844617461547970650218
+      084461746153697A6503C8000549734B6579080F4E65656450726F636573734E
+      616D65090001044E616D650608586D6A556E697473094669656C644E616D6506
+      08586D6A556E6974730844617461547970650218084461746153697A65021405
+      49734B6579080F4E65656450726F636573734E616D65090001044E616D65060A
+      4E616D6544616E576569094669656C644E616D65060A4E616D6544616E576569
+      0844617461547970650218084461746153697A6503C8000549734B6579080F4E
+      65656450726F636573734E616D65090001044E616D6506094E616D6546656E42
+      75094669656C644E616D6506094E616D6546656E427508446174615479706502
+      18084461746153697A6503C8000549734B6579080F4E65656450726F63657373
+      4E616D65090001044E616D65060C4E616D6546656E5869616E67094669656C64
+      4E616D65060C4E616D6546656E5869616E670844617461547970650218084461
+      746153697A6503C8000549734B6579080F4E65656450726F636573734E616D65
+      090001044E616D6506084E616D65556E6974094669656C644E616D6506084E61
+      6D65556E69740844617461547970650218084461746153697A6503C800054973
+      4B6579080F4E65656450726F636573734E616D65090001044E616D6506035065
+      67094669656C644E616D65060350656708446174615479706502180844617461
+      53697A6503C8000549734B6579080F4E65656450726F636573734E616D650900
+      01044E616D650608506F736974696F6E094669656C644E616D650608506F7369
+      74696F6E0844617461547970650218084461746153697A6503C8000549734B65
+      79080F4E65656450726F636573734E616D65090001044E616D65060B44726177
+      696E67436F6465094669656C644E616D65060B44726177696E67436F64650844
+      617461547970650218084461746153697A6502320549734B6579080F4E656564
+      50726F636573734E616D65090001044E616D65060F4375724465616C5175616E
+      74697479094669656C644E616D65060F4375724465616C5175616E7469747908
+      44617461547970650206084461746153697A6502080549734B6579080F4E6565
+      6450726F636573734E616D65090001044E616D6506114375724465616C546F74
+      616C5072696365094669656C644E616D6506114375724465616C546F74616C50
+      726963650844617461547970650206084461746153697A6502080549734B6579
+      080F4E65656450726F636573734E616D65090001044E616D65060D4375725163
+      5175616E74697479094669656C644E616D65060D43757251635175616E746974
+      790844617461547970650206084461746153697A6502080549734B6579080F4E
+      65656450726F636573734E616D65090001044E616D65060F4375725163546F74
+      616C5072696365094669656C644E616D65060F4375725163546F74616C507269
+      63650844617461547970650206084461746153697A6502080549734B6579080F
+      4E65656450726F636573734E616D65090001044E616D65061143757247617468
+      65725175616E74697479094669656C644E616D65061143757247617468657251
+      75616E746974790844617461547970650206084461746153697A650208054973
+      4B6579080F4E65656450726F636573734E616D65090001044E616D6506134375
+      72476174686572546F74616C5072696365094669656C644E616D650613437572
+      476174686572546F74616C507269636508446174615479706502060844617461
+      53697A6502080549734B6579080F4E65656450726F636573734E616D65090001
+      044E616D65060F5072654465616C5175616E74697479094669656C644E616D65
+      060F5072654465616C5175616E74697479084461746154797065020608446174
+      6153697A6502080549734B6579080F4E65656450726F636573734E616D650900
+      01044E616D6506115072654465616C546F74616C5072696365094669656C644E
+      616D6506115072654465616C546F74616C507269636508446174615479706502
+      06084461746153697A6502080549734B6579080F4E65656450726F636573734E
+      616D65090001044E616D65060D50726551635175616E74697479094669656C64
+      4E616D65060D50726551635175616E7469747908446174615479706502060844
+      61746153697A6502080549734B6579080F4E65656450726F636573734E616D65
+      090001044E616D65060F5072655163546F74616C5072696365094669656C644E
+      616D65060F5072655163546F74616C5072696365084461746154797065020608
+      4461746153697A6502080549734B6579080F4E65656450726F636573734E616D
+      65090001044E616D6506115072654761746865725175616E7469747909466965
+      6C644E616D6506115072654761746865725175616E7469747908446174615479
+      70650206084461746153697A6502080549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D650613507265476174686572546F74616C5072
+      696365094669656C644E616D650613507265476174686572546F74616C507269
+      63650844617461547970650206084461746153697A6502080549734B6579080F
+      4E65656450726F636573734E616D65090001044E616D65060F4164644465616C
+      5175616E74697479094669656C644E616D65060F4164644465616C5175616E74
+      6974790844617461547970650206084461746153697A6502080549734B657908
+      0F4E65656450726F636573734E616D65090001044E616D650611416464446561
+      6C546F74616C5072696365094669656C644E616D6506114164644465616C546F
+      74616C50726963650844617461547970650206084461746153697A6502080549
+      734B6579080F4E65656450726F636573734E616D65090001044E616D65060D41
+      646451635175616E74697479094669656C644E616D65060D4164645163517561
+      6E746974790844617461547970650206084461746153697A6502080549734B65
+      79080F4E65656450726F636573734E616D65090001044E616D65060F41646451
+      63546F74616C5072696365094669656C644E616D65060F4164645163546F7461
+      6C50726963650844617461547970650206084461746153697A6502080549734B
+      6579080F4E65656450726F636573734E616D65090001044E616D650611416464
+      4761746865725175616E74697479094669656C644E616D650611416464476174
+      6865725175616E746974790844617461547970650206084461746153697A6502
+      080549734B6579080F4E65656450726F636573734E616D65090001044E616D65
+      0613416464476174686572546F74616C5072696365094669656C644E616D6506
+      13416464476174686572546F74616C5072696365084461746154797065020608
+      4461746153697A6502080549734B6579080F4E65656450726F636573734E616D
+      65090001044E616D65060F456E644465616C5175616E74697479094669656C64
+      4E616D65060F456E644465616C5175616E746974790844617461547970650206
+      084461746153697A6502080549734B6579080F4E65656450726F636573734E61
+      6D65090001044E616D650611456E644465616C546F74616C5072696365094669
+      656C644E616D650611456E644465616C546F74616C5072696365084461746154
+      7970650206084461746153697A6502080549734B6579080F4E65656450726F63
+      6573734E616D65090001044E616D65060D456E6451635175616E746974790946
+      69656C644E616D65060D456E6451635175616E74697479084461746154797065
+      0206084461746153697A6502080549734B6579080F4E65656450726F63657373
+      4E616D65090001044E616D65060F456E645163546F74616C5072696365094669
+      656C644E616D65060F456E645163546F74616C50726963650844617461547970
+      650206084461746153697A6502080549734B6579080F4E65656450726F636573
+      734E616D65090001044E616D650611456E644761746865725175616E74697479
+      094669656C644E616D650611456E644761746865725175616E74697479084461
+      7461547970650206084461746153697A6502080549734B6579080F4E65656450
+      726F636573734E616D65090001044E616D650613456E64476174686572546F74
+      616C5072696365094669656C644E616D650613456E64476174686572546F7461
+      6C50726963650844617461547970650206084461746153697A6502080549734B
+      6579080F4E65656450726F636573734E616D65090000}
+  end
+  object sdvDetailGclBills: TsdDataView
+    Active = False
+    DataSet = sddDetailGclBills
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'XmjCode'
       end
       item
-        Name = 'EndPcTotalPrice'
-        DataType = ftFloat
+        FieldName = 'XmjName'
       end
       item
-        Name = 'EndGatherQuantity'
-        DataType = ftFloat
+        FieldName = 'XmjUnits'
       end
       item
-        Name = 'EndGatherTotalPrice'
-        DataType = ftFloat
+        FieldName = 'NameDanWei'
       end
       item
-        Name = 'BGLQuantity'
-        DataType = ftFloat
+        FieldName = 'NameFenXiang'
       end
       item
-        Name = 'BGLTotalPrice'
-        DataType = ftFloat
+        FieldName = 'NameFenBu'
       end
       item
-        Name = 'Deal_BGLQuantity'
-        DataType = ftFloat
+        FieldName = 'NameUnit'
       end
       item
-        Name = 'Deal_BGLTotalPrice'
-        DataType = ftFloat
+        FieldName = 'Peg'
       end
       item
-        Name = 'CompletionRate'
-        DataType = ftFloat
+        FieldName = 'Position'
+      end
+      item
+        FieldName = 'DrawingCode'
       end>
-    IndexDefs = <>
-    Params = <>
-    StoreDefs = True
-    AfterScroll = cdsBillsGatherAfterScroll
-    Left = 64
-    Top = 16
-    Data = {
-      B60300009619E0BD010000001800000027000000000003000000B60306425F43
-      6F6465010049000000010005574944544802000200320009496E646578436F64
-      650100490000000100055749445448020002003200044E616D6502004A000000
-      010005574944544802000200900105556E69747301004A000000010005574944
-      54480200020028000550726963650800040000000000084E6577507269636508
-      000400000000000C4465616C5175616E7469747908000400000000000E446561
-      6C546F74616C50726963650800040000000000085175616E7469747908000400
-      000000000A546F74616C507269636508000400000000000F4375724465616C51
-      75616E746974790800040000000000114375724465616C546F74616C50726963
-      6508000400000000000D43757251635175616E7469747908000400000000000F
-      4375725163546F74616C507269636508000400000000000D4375725063517561
-      6E7469747908000400000000000F4375725063546F74616C5072696365080004
-      0000000000114375724761746865725175616E74697479080004000000000013
-      437572476174686572546F74616C507269636508000400000000000F41646444
-      65616C5175616E746974790800040000000000114164644465616C546F74616C
-      507269636508000400000000000D41646451635175616E746974790800040000
-      0000000F4164645163546F74616C507269636508000400000000000D41646450
-      635175616E7469747908000400000000000F4164645063546F74616C50726963
-      650800040000000000114164644761746865725175616E746974790800040000
-      00000013416464476174686572546F74616C507269636508000400000000000F
-      456E644465616C5175616E74697479080004000000000011456E644465616C54
-      6F74616C507269636508000400000000000D456E6451635175616E7469747908
-      000400000000000F456E645163546F74616C507269636508000400000000000D
-      456E6450635175616E7469747908000400000000000F456E645063546F74616C
-      5072696365080004000000000011456E644761746865725175616E7469747908
-      0004000000000013456E64476174686572546F74616C50726963650800040000
-      0000000B42474C5175616E7469747908000400000000000D42474C546F74616C
-      50726963650800040000000000104465616C5F42474C5175616E746974790800
-      040000000000124465616C5F42474C546F74616C507269636508000400000000
-      000E436F6D706C6574696F6E5261746508000400000000000000}
-    object cdsBillsGatherB_Code: TStringField
-      FieldName = 'B_Code'
-      Size = 50
-    end
-    object cdsBillsGatherIndexCode: TStringField
-      DisplayWidth = 50
-      FieldName = 'IndexCode'
-      Size = 50
-    end
-    object cdsBillsGatherName: TWideStringField
-      FieldName = 'Name'
-      Size = 200
-    end
-    object cdsBillsGatherUnits: TWideStringField
-      FieldName = 'Units'
-    end
-    object cdsBillsGatherPrice: TFloatField
-      FieldName = 'Price'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherNewPrice: TFloatField
-      FieldName = 'NewPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherDealQuantity: TFloatField
-      FieldName = 'DealQuantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherDealTotalPrice: TFloatField
-      FieldName = 'DealTotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherQuantity: TFloatField
-      FieldName = 'Quantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherTotalPrice: TFloatField
-      FieldName = 'TotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherCurDealQuantity: TFloatField
-      FieldName = 'CurDealQuantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherCurDealTotalPrice: TFloatField
-      FieldName = 'CurDealTotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherCurQcQuantity: TFloatField
-      FieldName = 'CurQcQuantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherCurQcTotalPrice: TFloatField
-      FieldName = 'CurQcTotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherCurPcQuantity: TFloatField
-      FieldName = 'CurPcQuantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherCurPcTotalPrice: TFloatField
-      FieldName = 'CurPcTotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherCurGatherQuantity: TFloatField
-      FieldName = 'CurGatherQuantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherCurGatherTotalPrice: TFloatField
-      FieldName = 'CurGatherTotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherAddDealQuantity: TFloatField
-      FieldName = 'AddDealQuantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherAddDealTotalPrice: TFloatField
-      FieldName = 'AddDealTotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherAddQcQuantity: TFloatField
-      FieldName = 'AddQcQuantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherAddQcTotalPrice: TFloatField
-      FieldName = 'AddQcTotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherAddPcQuantity: TFloatField
-      FieldName = 'AddPcQuantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherAddPcTotalPrice: TFloatField
-      FieldName = 'AddPcTotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherAddGatherQuantity: TFloatField
-      FieldName = 'AddGatherQuantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherAddGatherTotalPrice: TFloatField
-      FieldName = 'AddGatherTotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherEndDealQuantity: TFloatField
-      FieldName = 'EndDealQuantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherEndDealTotalPrice: TFloatField
-      FieldName = 'EndDealTotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherEndQcQuantity: TFloatField
-      FieldName = 'EndQcQuantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherEndQcTotalPrice: TFloatField
-      FieldName = 'EndQcTotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherEndPcQuantity: TFloatField
-      FieldName = 'EndPcQuantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherEndPcTotalPrice: TFloatField
-      FieldName = 'EndPcTotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherEndGatherQuantity: TFloatField
-      FieldName = 'EndGatherQuantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherEndGatherTotalPrice: TFloatField
-      FieldName = 'EndGatherTotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherBGLQuantity: TFloatField
-      FieldName = 'BGLQuantity'
-    end
-    object cdsBillsGatherBGLTotalPrice: TFloatField
-      FieldName = 'BGLTotalPrice'
-    end
-    object cdsBillsGatherDeal_BGLQuantity: TFloatField
-      FieldName = 'Deal_BGLQuantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherDeal_BGLTotalPrice: TFloatField
-      FieldName = 'Deal_BGLTotalPrice'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsBillsGatherCompletionRate: TFloatField
-      FieldName = 'CompletionRate'
-    end
+    OnFilterRecord = sdvDetailGclBillsFilterRecord
+    Left = 40
+    Top = 312
+  end
+  object smpDetailDealBills: TsdMemoryProvider
+    Left = 136
+    Top = 192
   end
-  object cdsRelaXmj: TClientDataSet
-    Active = True
-    Aggregates = <>
-    FieldDefs = <
+  object sddDetailDealBills: TsdDataSet
+    Active = False
+    Provider = smpDetailDealBills
+    Left = 136
+    Top = 248
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D65060742696C6C734944094669656C644E616D
+      65060742696C6C7349440844617461547970650203084461746153697A650204
+      0549734B6579080F4E65656450726F636573734E616D65090001044E616D6506
+      064465616C4944094669656C644E616D6506064465616C494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D650606425F436F6465094669656C644E616D65
+      0606425F436F64650844617461547970650201084461746153697A6502320549
+      734B6579080F4E65656450726F636573734E616D65090001044E616D6506044E
+      616D65094669656C644E616D6506044E616D6508446174615479706502180844
+      61746153697A6503C8000549734B6579080F4E65656450726F636573734E616D
+      65090001044E616D650605556E697473094669656C644E616D650605556E6974
+      730844617461547970650218084461746153697A6502140549734B6579080F4E
+      65656450726F636573734E616D65090001044E616D6506055072696365094669
+      656C644E616D6506055072696365084461746154797065020608446174615369
+      7A6502080549734B6579080F4E65656450726F636573734E616D65090001044E
+      616D6506085175616E74697479094669656C644E616D6506085175616E746974
+      790844617461547970650206084461746153697A6502080549734B6579080F4E
+      65656450726F636573734E616D65090001044E616D65060A546F74616C507269
+      6365094669656C644E616D65060A546F74616C50726963650844617461547970
+      650206084461746153697A6502080549734B6579080F4E65656450726F636573
+      734E616D65090000}
+  end
+  object sdvDetailDealBills: TsdDataView
+    Active = False
+    DataSet = sddDetailDealBills
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'B_Code'
+      end
       item
-        Name = 'Code'
-        DataType = ftString
-        Size = 50
+        FieldName = 'Name'
       end
       item
-        Name = 'Peg'
-        DataType = ftWideString
-        Size = 200
+        FieldName = 'Units'
       end
       item
-        Name = 'Name'
-        DataType = ftWideString
-        Size = 200
+        FieldName = 'Price'
       end
       item
-        Name = 'Units'
-        DataType = ftWideString
-        Size = 20
+        FieldName = 'Quantity'
       end
       item
-        Name = 'Quantity'
-        DataType = ftFloat
+        FieldName = 'TotalPrice'
+      end>
+    OnFilterRecord = sdvDetailGclBillsFilterRecord
+    Left = 136
+    Top = 312
+  end
+  object smpDetailBGLBills: TsdMemoryProvider
+    Left = 240
+    Top = 192
+  end
+  object sddDetailBGLBills: TsdDataSet
+    Active = False
+    Provider = smpDetailBGLBills
+    Left = 240
+    Top = 248
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D650609424742696C6C734944094669656C644E
+      616D650609424742696C6C734944084461746154797065020308446174615369
+      7A6502040549734B6579080F4E65656450726F636573734E616D65090001044E
+      616D65060542474C4944094669656C644E616D65060542474C49440844617461
+      547970650203084461746153697A6502040549734B6579080F4E65656450726F
+      636573734E616D65090001044E616D65060742474C436F6465094669656C644E
+      616D65060742474C436F64650844617461547970650218084461746153697A65
+      02320549734B6579080F4E65656450726F636573734E616D65090001044E616D
+      65060742474C4E616D65094669656C644E616D65060742474C4E616D65084461
+      7461547970650218084461746153697A6503C8000549734B6579080F4E656564
+      50726F636573734E616D65090001044E616D65060F42474C417070726F76616C
+      436F6465094669656C644E616D65060F42474C417070726F76616C436F646508
+      44617461547970650218084461746153697A6502320549734B6579080F4E6565
+      6450726F636573734E616D65090001044E616D65060E42474C44726177696E67
+      436F6465094669656C644E616D65060E42474C44726177696E67436F64650844
+      617461547970650218084461746153697A6502320549734B6579080F4E656564
+      50726F636573734E616D65090001044E616D6506085175616E74697479094669
+      656C644E616D6506085175616E74697479084461746154797065020608446174
+      6153697A6502080549734B6579080F4E65656450726F636573734E616D650900
+      01044E616D65060A546F74616C5072696365094669656C644E616D65060A546F
+      74616C50726963650844617461547970650206084461746153697A6502080549
+      734B6579080F4E65656450726F636573734E616D65090001044E616D65060742
+      696C6C734944094669656C644E616D65060742696C6C73494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090000}
+  end
+  object sdvDetailBGLBills: TsdDataView
+    Active = False
+    DataSet = sddDetailBGLBills
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'BGLCode'
       end
       item
-        Name = 'NameDanWei'
-        DataType = ftWideString
-        Size = 200
+        FieldName = 'BGLName'
       end
       item
-        Name = 'NameFenBu'
-        DataType = ftWideString
-        Size = 200
+        FieldName = 'BGLApprovalCode'
       end
       item
-        Name = 'NameFenXiang'
-        DataType = ftWideString
-        Size = 200
+        FieldName = 'BGLDrawingCode'
       end
       item
-        Name = 'NameUnit'
-        DataType = ftWideString
-        Size = 200
+        FieldName = 'Quantity'
       end
       item
-        Name = 'DrawingCode'
-        DataType = ftWideString
-        Size = 50
+        FieldName = 'TotalPrice'
       end>
-    IndexDefs = <>
-    Params = <>
-    StoreDefs = True
-    Left = 64
-    Top = 88
-    Data = {
-      2A0100009619E0BD01000000180000000A0000000000030000002A0104436F64
-      6501004900000001000557494454480200020032000350656702004A00000001
-      00055749445448020002009001044E616D6502004A0000000100055749445448
-      02000200900105556E69747301004A0000000100055749445448020002002800
-      085175616E7469747908000400000000000A4E616D6544616E57656902004A00
-      00000100055749445448020002009001094E616D6546656E427502004A000000
-      01000557494454480200020090010C4E616D6546656E5869616E6702004A0000
-      000100055749445448020002009001084E616D65556E697402004A0000000100
-      0557494454480200020090010B44726177696E67436F646501004A0000000100
-      0557494454480200020064000000}
-    object cdsRelaXmjCode: TStringField
-      FieldName = 'Code'
-      Size = 50
-    end
-    object cdsRelaXmjPeg: TWideStringField
-      FieldName = 'Peg'
-      Size = 200
-    end
-    object cdsRelaXmjName: TWideStringField
-      FieldName = 'Name'
-      Size = 200
-    end
-    object cdsRelaXmjUnits: TWideStringField
-      FieldName = 'Units'
-    end
-    object cdsRelaXmjQuantity: TFloatField
-      FieldName = 'Quantity'
-      OnGetText = cdsBillsGatherQuantityGetText
-    end
-    object cdsRelaXmjNameDanWei: TWideStringField
-      FieldName = 'NameDanWei'
-      Size = 200
-    end
-    object cdsRelaXmjNameFenBu: TWideStringField
-      FieldName = 'NameFenBu'
-      Size = 200
-    end
-    object cdsRelaXmjNameFenXiang: TWideStringField
-      FieldName = 'NameFenXiang'
-      Size = 200
-    end
-    object cdsRelaXmjNameUnit: TWideStringField
-      FieldName = 'NameUnit'
-      Size = 200
-    end
-    object cdsRelaXmjDrawingCode: TWideStringField
-      FieldName = 'DrawingCode'
-      Size = 50
-    end
+    OnFilterRecord = sdvDetailGclBillsFilterRecord
+    Left = 240
+    Top = 312
   end
 end

+ 246 - 431
DataModules/BillsGatherDm.pas

@@ -3,119 +3,30 @@ unit BillsGatherDm;
 interface
 
 uses
-  SysUtils, Classes, DB, DBClient, sdIDTree, sdDB;
+  SysUtils, Classes, DB, DBClient, sdIDTree, sdDB, sdProvider,
+  GclBillsGatherModel;
 
 type
-  TGclNode = class
-  private
-    FB_Code: string;
-    FIndexCode: string;
-    FName: string;
-    FUnits: string;
-    FPrice: Double;
-    FNewPrice: Double;
-    FDealQuantity: Double;
-    FDealTotalPrice: Double;
-    FQuantity: Double;
-    FTotalPrice: Double;
-    FBGLQuantity: Double;
-    FBGLTotalPrice: Double;
-    FCurDealQuantity: Double;
-    FCurDealTotalPrice: Double;
-    FCurQcQuantity: Double;
-    FCurQcTotalPrice: Double;
-    FCurPcQuantity: Double;
-    FCurPcTotalPrice: Double;
-    FCurGatherQuantity: Double;
-    FCurGatherTotalPrice: Double;
-    FEndDealQuantity: Double;
-    FEndDealTotalPrice: Double;
-    FEndQcQuantity: Double;
-    FEndQcTotalPrice: Double;
-    FEndPcQuantity: Double;
-    FEndPcTotalPrice: Double;
-    FEndGatherQuantity: Double;
-    FEndGatherTotalPrice: Double;
-    FAddDealQuantity: Double;
-    FAddDealTotalPrice: Double;
-    FAddQcQuantity: Double;
-    FAddQcTotalPrice: Double;
-    FAddPcQuantity: Double;
-    FAddPcTotalPrice: Double;
-    FAddGatherQuantity: Double;
-    FAddGatherTotalPrice: Double;
-  end;
-
   TBillsGatherData = class(TDataModule)
-    cdsBillsGather: TClientDataSet;
-    cdsBillsGatherB_Code: TStringField;
-    cdsBillsGatherName: TWideStringField;
-    cdsBillsGatherUnits: TWideStringField;
-    cdsBillsGatherPrice: TFloatField;
-    cdsBillsGatherNewPrice: TFloatField;
-    cdsBillsGatherQuantity: TFloatField;
-    cdsBillsGatherTotalPrice: TFloatField;
-
-    cdsBillsGatherCurDealQuantity: TFloatField;
-    cdsBillsGatherCurDealTotalPrice: TFloatField;
-    cdsBillsGatherCurQcQuantity: TFloatField;
-    cdsBillsGatherCurQcTotalPrice: TFloatField;
-    cdsBillsGatherCurPcQuantity: TFloatField;
-    cdsBillsGatherCurPcTotalPrice: TFloatField;
-    cdsBillsGatherCurGatherQuantity: TFloatField;
-    cdsBillsGatherCurGatherTotalPrice: TFloatField;
-
-    cdsBillsGatherAddDealQuantity: TFloatField;
-    cdsBillsGatherAddDealTotalPrice: TFloatField;
-    cdsBillsGatherAddQcQuantity: TFloatField;
-    cdsBillsGatherAddQcTotalPrice: TFloatField;
-    cdsBillsGatherAddPcQuantity: TFloatField;
-    cdsBillsGatherAddPcTotalPrice: TFloatField;
-    cdsBillsGatherAddGatherQuantity: TFloatField;
-    cdsBillsGatherAddGatherTotalPrice: TFloatField;
-
-    cdsRelaXmj: TClientDataSet;
-    cdsRelaXmjCode: TStringField;
-    cdsRelaXmjName: TWideStringField;
-    cdsRelaXmjUnits: TWideStringField;
-    cdsRelaXmjQuantity: TFloatField;
-    cdsRelaXmjNameFenBu: TWideStringField;
-    cdsRelaXmjNameFenXiang: TWideStringField;
-    cdsRelaXmjNameDanWei: TWideStringField;
-    cdsRelaXmjPeg: TWideStringField;
-    cdsRelaXmjNameUnit: TWideStringField;
-    cdsRelaXmjDrawingCode: TWideStringField;
-    cdsBillsGatherIndexCode: TStringField;
-    cdsBillsGatherDealQuantity: TFloatField;
-    cdsBillsGatherDealTotalPrice: TFloatField;
-    cdsBillsGatherEndDealQuantity: TFloatField;
-    cdsBillsGatherEndDealTotalPrice: TFloatField;
-    cdsBillsGatherEndQcQuantity: TFloatField;
-    cdsBillsGatherEndQcTotalPrice: TFloatField;
-    cdsBillsGatherEndPcQuantity: TFloatField;
-    cdsBillsGatherEndPcTotalPrice: TFloatField;
-    cdsBillsGatherEndGatherQuantity: TFloatField;
-    cdsBillsGatherEndGatherTotalPrice: TFloatField;
-    cdsBillsGatherBGLQuantity: TFloatField;
-    cdsBillsGatherBGLTotalPrice: TFloatField;
-    cdsBillsGatherCompletionRate: TFloatField;
-    cdsBillsGatherDeal_BGLQuantity: TFloatField;
-    cdsBillsGatherDeal_BGLTotalPrice: TFloatField;
-    procedure cdsBillsGatherQuantityGetText(Sender: TField;
-      var Text: String; DisplayText: Boolean);
-    procedure cdsBillsGatherAfterScroll(DataSet: TDataSet);
+    smpGclBills: TsdMemoryProvider;
+    sddGclBills: TsdDataSet;
+    sdvGclBills: TsdDataView;
+    smpDetailGclBills: TsdMemoryProvider;
+    sddDetailGclBills: TsdDataSet;
+    sdvDetailGclBills: TsdDataView;
+    smpDetailDealBills: TsdMemoryProvider;
+    sddDetailDealBills: TsdDataSet;
+    sdvDetailDealBills: TsdDataView;
+    smpDetailBGLBills: TsdMemoryProvider;
+    sddDetailBGLBills: TsdDataSet;
+    sdvDetailBGLBills: TsdDataView;
+    procedure sdvGclBillsCurrentChanged(ARecord: TsdDataRecord);
+    procedure sdvDetailGclBillsFilterRecord(ARecord: TsdDataRecord;
+      var Allow: Boolean);
   private
     FProjectData: TObject;
-    FGclList: TList;
 
-    function GetGclNode(ARec: TsdDataRecord): TGclNode;
-    procedure FilterGclBills(ANode: TsdIDTreeNode);
-    procedure FilterBills(ANode: TsdIDTreeNode);
-    procedure FilterDealBills;
-    procedure WriteGclBills;
-
-    procedure RefreshRelaXmj;
-    procedure AddRelaXmjs(const AB_Code, AName, AUnits: string; APrice: Double);
+    procedure WriteGatherRecord(AGcls: TList);
 
     function GetMainBillsTree: TsdIDTree;
   public
@@ -137,75 +48,36 @@ uses
 
 { TBillsGatherData }
 
-procedure TBillsGatherData.FilterBills(ANode: TsdIDTreeNode);
-begin
-  if not Assigned(ANode) then Exit;
-  if ANode.HasChildren then
-    FilterBills(ANode.FirstChild)
-  else
-    FilterGclBills(ANode);
-  FilterBills(ANode.NextSibling);
-end;
-
-procedure TBillsGatherData.FilterGclBills(ANode: TsdIDTreeNode);
-
-  procedure LoadPhaseData(AGclNode: TGclNode; AID: Integer);
-  var
-    Rec: TsdDataRecord;
-  begin
-    Rec := TBillsIDTreeNode(ANode).StageRec;
-    if not Assigned(Rec) then Exit;
-    AGclNode.FCurDealQuantity := AGclNode.FCurDealQuantity + Rec.ValueByName('DealQuantity').AsFloat;
-    AGclNode.FCurDealTotalPrice := AGclNode.FCurDealTotalPrice + Rec.ValueByName('DealTotalPrice').AsFloat;
-    AGclNode.FCurQcQuantity := AGclNode.FCurQcQuantity + Rec.ValueByName('QcQuantity').AsFloat;
-    AGclNode.FCurQcTotalPrice := AGclNode.FCurQcTotalPrice + Rec.ValueByName('QcTotalPrice').AsFloat;
-    AGclNode.FCurPcQuantity := AGclNode.FCurPcQuantity + Rec.ValueByName('PcQuantity').AsFloat;
-    AGclNode.FCurPcTotalPrice := AGclNode.FCurPcTotalPrice + Rec.ValueByName('PcTotalPrice').AsFloat;
-    AGclNode.FCurGatherQuantity := AGclNode.FCurGatherQuantity + Rec.ValueByName('GatherQuantity').AsFloat;
-    AGclNode.FCurGatherTotalPrice := AGclNode.FCurGatherTotalPrice + Rec.ValueByName('GatherTotalPrice').AsFloat;
-
-    AGclNode.FEndDealQuantity := AGclNode.FEndDealQuantity + Rec.ValueByName('EndDealQuantity').AsFloat;
-    AGclNode.FEndDealTotalPrice := AGclNode.FEndDealTotalPrice + Rec.ValueByName('EndDealTotalPrice').AsFloat;
-    AGclNode.FEndQcQuantity := AGclNode.FEndQcQuantity + Rec.ValueByName('EndQcQuantity').AsFloat;
-    AGclNode.FEndQcTotalPrice := AGclNode.FEndQcTotalPrice + Rec.ValueByName('EndQcTotalPrice').AsFloat;
-    AGclNode.FEndPcQuantity := AGclNode.FEndPcQuantity + Rec.ValueByName('EndPcQuantity').AsFloat;
-    AGclNode.FEndPcTotalPrice := AGclNode.FEndPcTotalPrice + Rec.ValueByName('EndPcTotalPrice').AsFloat;
-    AGclNode.FEndGatherQuantity := AGclNode.FEndGatherQuantity + Rec.ValueByName('EndGatherQuantity').AsFloat;
-    AGclNode.FEndGatherTotalPrice := AGclNode.FEndGatherTotalPrice + Rec.ValueByName('EndGatherTotalPrice').AsFloat;
-  end;
-
-  procedure LoadMeasureData(AGclNode: TGclNode; ARec: TsdDataRecord);
-  begin
-    AGclNode.FQuantity := AGclNode.FQuantity + ARec.ValueByName('Quantity').AsFloat;
-    AGclNode.FTotalPrice := AGclNode.FTotalPrice + ARec.ValueByName('TotalPrice').AsFloat;
-    if TProjectData(FProjectData).ProjProperties.PhaseCount = 0 then Exit;
-    LoadPhaseData(AGclNode, ARec.ValueByName('ID').AsInteger);
-    AGclNode.FAddDealQuantity := AGclNode.FAddDealQuantity + ARec.ValueByName('AddDealQuantity').AsFloat;
-    AGclNode.FAddDealTotalPrice := AGclNode.FAddDealTotalPrice + ARec.ValueByName('AddDealTotalPrice').AsFloat;
-    AGclNode.FAddQcQuantity := AGclNode.FAddQcQuantity + ARec.ValueByName('AddQcQuantity').AsFloat;
-    AGclNode.FAddQcTotalPrice := AGclNode.FAddQcTotalPrice + ARec.ValueByName('AddQcTotalPrice').AsFloat;
-    AGclNode.FAddPcQuantity := AGclNode.FAddPcQuantity + ARec.ValueByName('AddPcQuantity').AsFloat;
-    AGclNode.FAddPcTotalPrice := AGclNode.FAddPcTotalPrice + ARec.ValueByName('AddPcTotalPrice').AsFloat;
-    AGclNode.FAddGatherQuantity := AGclNode.FAddGatherQuantity + ARec.ValueByName('AddGatherQuantity').AsFloat;
-    AGclNode.FAddGatherTotalPrice := AGclNode.FAddGatherTotalPrice + ARec.ValueByName('AddGatherTotalPrice').AsFloat;
-  end;
-
-var
-  Rec: TsdDataRecord;
-  GclNode: TGclNode;
-begin
-  if not Assigned(ANode) then Exit;
-  Rec := ANode.Rec;
-  if Rec.ValueByName('B_Code').AsString = '' then Exit;
-  GclNode := GetGclNode(Rec);
-  LoadMeasureData(GclNode, Rec);
-end;
-
 constructor TBillsGatherData.Create(AProjectData: TObject);
 begin
   inherited Create(nil);
   FProjectData := AProjectData;
-  cdsBillsGather.IndexFieldNames := 'IndexCode';
+
+  sddGclBills.Open;
+  if not Assigned(sddGclBills.FindIndex('idxIndexCode')) then
+    sddGclBills.AddIndex('idxIndexCode', 'IndexCode');
+  sdvGclBills.Open;
+  sdvGclBills.IndexName := 'idxIndexCode';
+
+  sddDetailGclBills.Open;
+  if not Assigned(sddDetailGclBills.FindIndex('idxSerialNo')) then
+    sddDetailGclBills.AddIndex('idxSerialNo', 'BillsID;TreeSerialNo');
+  if not Assigned(sddDetailGclBills.FindIndex('idxRelaBills')) then
+    sddDetailGclBills.AddIndex('idxRelaBills', 'RelaBillsID');
+  sdvDetailGclBills.Open;
+  sdvDetailGclBills.IndexName := 'idxSerialNo';
+
+  sddDetailDealBills.Open;
+  if not Assigned(sddDetailDealBills.FindIndex('idxDeal')) then
+    sddDetailDealBills.AddIndex('idxDeal', 'DealID');
+  sdvDetailDealBills.Open;
+  sdvDetailDealBills.IndexName := 'idxDeal';
+
+  sddDetailBGLBills.Open;
+  if not Assigned(sddDetailBGLBills.FindIndex('idxBGL')) then
+    sddDetailBGLBills.AddIndex('idxBGL', 'BGLID');
+  sdvDetailBGLBills.Open;
+  sdvDetailBGLBills.IndexName := 'idxBGL';
 end;
 
 destructor TBillsGatherData.Destroy;
@@ -219,314 +91,257 @@ begin
 end;
 
 procedure TBillsGatherData.RefreshBills;
+var
+  vGather: TGclGatherModel;
 begin
-  cdsBillsGather.DisableControls;
-  cdsBillsGather.AfterScroll := nil;
+  vGather := TGclGatherModel.Create(FProjectData);
   try
-    cdsBillsGather.EmptyDataSet;
-    FGclList := TList.Create;
-    FilterBills(MainBillsTree.FirstNode);
-    FilterDealBills;
-    WriteGclBills;
+    vGather.GatherDeal := True;
+    vGather.GatherBGL := True;
+    vGather.WriteGatherData := WriteGatherRecord;
+    vGather.Execute;
   finally
-    ClearObjects(FGclList);
-    FGclList.Free;
-    cdsBillsGather.EnableControls;
-    cdsBillsGather.AfterScroll := cdsBillsGatherAfterScroll;
+    vGather.Free;
   end;
 end;
 
-procedure TBillsGatherData.cdsBillsGatherQuantityGetText(Sender: TField;
-  var Text: String; DisplayText: Boolean);
-begin
-  if Sender.AsFloat <> 0 then
-    Text := FormatFloat('0.###', Sender.AsFloat)
-  else
-    Text := '';
-end;
-
-procedure TBillsGatherData.cdsBillsGatherAfterScroll(DataSet: TDataSet);
-begin
-  RefreshRelaXmj;
-end;
+procedure TBillsGatherData.WriteGatherRecord(AGcls: TList);
 
-procedure TBillsGatherData.RefreshRelaXmj;
-begin
-  cdsRelaXmj.EmptyDataSet;
-  AddRelaXmjs(cdsBillsGatherB_Code.AsString, cdsBillsGatherName.AsString,
-    cdsBillsGatherUnits.AsString, cdsBillsGatherPrice.AsFloat);
-end;
-
-procedure TBillsGatherData.AddRelaXmjs(
-  const AB_Code, AName, AUnits: string; APrice: Double);
-
-  function GetFirstXmjParent(AID: Integer): TsdIDTreeNode;
+  procedure DisableAndClearDataSet(ADataSet: TsdDataSet);
   begin
-    Result := MainBillsTree.FindNode(AID);
-    while Assigned(Result) and (Result.Rec.ValueByName('B_Code').AsString <> '') do
-      Result := Result.Parent;
+    ADataSet.DisableControls;
+    ADataSet.BeginUpdate;
+    ADataSet.DeleteAll;
   end;
 
-  // 取树结构的第ALevel层节点的名称(level从0开始)
-  function GetNameByLevel(ANode: TsdIDTreeNode; ALevel: Integer): string;
+  procedure EnableDataSet(ADataSet: TsdDataSet);
   begin
-    Result := '';
-    if not Assigned(ANode) then Exit;
-    if ANode.Level = ALevel then
-      Result := ANode.Rec.ValueByName('Name').AsString
-    else if ANode.Level > ALevel then
-      Result := GetNameByLevel(ANode.Parent, ALevel);
+    ADataSet.EndUpdate;
+    ADataSet.EnableControls;
   end;
 
-  function GetPegNode(ANode: TsdIDTreeNode): TsdIDTreeNode;
+  procedure BeforeWrite;
   begin
-    Result := nil;
-    if not Assigned(ANode) then Exit;
-    if CheckPeg(ANode.Rec.ValueByName('Name').AsString) then
-      Result := ANode
-    else
-      Result := GetPegNode(ANode.Parent);
+    sdvDetailGclBills.Filtered := False;
+    sdvDetailDealBills.Filtered := False;
+    sdvDetailBGLBills.Filtered := False;
+
+    DisableAndClearDataSet(sddGclBills);
+    DisableAndClearDataSet(sddDetailGclBills);
+    DisableAndClearDataSet(sddDetailDealBills);
+    DisableAndClearDataSet(sddDetailBGLBills);
   end;
 
-  function GetNameDanWei(ANode: TsdIDTreeNode): string;
+  procedure AfterWrite;
   begin
-    // 取树结构的第二层节点的名称
-    Result := GetNameByLevel(ANode, 1);
+    EnableDataSet(sddDetailBGLBills);
+    EnableDataSet(sddDetailDealBills);
+    EnableDataSet(sddDetailGclBills);
+    EnableDataSet(sddGclBills);
+
+    sdvGclBills.LocateInControl(sddGclBills.Records[0]);
+    sdvDetailGclBills.Filtered := True;
+    sdvDetailDealBills.Filtered := True;
+    sdvDetailBGLBills.Filtered := True;
   end;
 
-  // ANode为计量单元节点,APegNode为桩号节点
-  function GetNameFenBu(ANode, APegNode: TsdIDTreeNode): string;
+  procedure WriteDetailDealNode(AGclNode: TGclNode);
   var
-    vCurNode: TsdIDTreeNode;
+    iDeal: Integer;
+    vDeal: TDetailDealNode;
+    Rec: TsdDataRecord;
   begin
-    // 如果计量单元节点的名称为桩号(转化为判断计量单元节点与桩号节点为同一个)
-    if not Assigned(APegNode) or (ANode.ID = APegNode.ID) then
-      // 取树结构的第三层节点的名称
-      Result := GetNameByLevel(ANode, 2)
-    // 否则,取桩号节点的子节点的名称
-    else
+    for iDeal := 0 to AGclNode.DetailDealCount - 1 do
     begin
-      vCurNode := ANode;
-      while vCurNode.Level > APegNode.Level + 1 do
-        vCurNode := vCurNode.Parent;
-      Result := vCurNode.Rec.ValueByName('Name').AsString;
+      vDeal := AGclNode.DetailDeal[iDeal];
+      Rec := sddDetailDealBills.Add;
+      Rec.ValueByName('ID').AsInteger := vDeal.ID;
+      Rec.ValueByName('BillsID').AsInteger := AGclNode.ID;
+      Rec.ValueByName('DealID').AsInteger := vDeal.DealID;
+
+      Rec.ValueByName('B_Code').AsString := AGclNode.B_Code;
+      Rec.ValueByName('Name').AsString := AGclNode.Name;
+      Rec.ValueByName('Units').AsString := AGclNode.Units;
+      Rec.ValueByName('Price').AsFloat := AGclNode.Price;
+
+      Rec.ValueByName('Quantity').AsFloat := vDeal.Quantity;
+      Rec.ValueByName('TotalPrice').AsFloat := vDeal.TotalPrice;
     end;
   end;
 
-  function GetNameFenXiang(ANode, APegNode: TsdIDTreeNode): string;
+  procedure WriteDetailBGLNode(AGclNode: TGclNode);
   var
-    iTopLevel: Integer;
-    vCurNode: TsdIDTreeNode;
+    iBGL: Integer;
+    vBGL: TDetailBGLNode;
+    Rec: TsdDataRecord;
   begin
-    if Assigned(APegNode) then
+    for iBGL := 0 to AGclNode.DetailBGLCount - 1 do
     begin
-      iTopLevel := 3;
-      if APegNode.ID <> ANode.ID then
-        iTopLevel := APegNode.Level + 2;
-      Result := '';
-      vCurNode := ANode.Parent;
-      while vCurNode.Level >= iTopLevel do
-      begin
-        Result := vCurNode.Rec.ValueByName('Name').AsString + ';' + Result;
-        vCurNode := vCurNode.Parent;
-      end;
-    end
-    else
-      Result := GetNameByLevel(ANode, 3);
-  end;
-
-  function GetNameUnit(ANode: TsdIDTreeNode): string;
-  begin
-    Result := ANode.Rec.ValueByName('Name').AsString;
+      vBGL := AGclNode.DetailBGL[iBGL];
+      Rec := sddDetailBGLBills.Add;
+      Rec.ValueByName('ID').AsInteger := vBGL.ID;
+      Rec.ValueByName('BillsID').AsInteger := AGclNode.ID;
+      Rec.ValueByName('BGBillsID').AsInteger := vBGL.BGBillsID;
+      Rec.ValueByName('BGLID').AsInteger := vBGL.BGLID;
+
+      Rec.ValueByName('BGLCode').AsString := vBGL.BGLCode;
+      Rec.ValueByName('BGLName').AsString := vBGL.BGLName;
+      Rec.ValueByName('BGLApprovalCode').AsString := vBGL.BGLApprovalCode;
+      Rec.ValueByName('BGLDrawingCode').AsString := vBGL.BGLDrawingCode;
+
+      Rec.ValueByName('Quantity').AsFloat := vBGL.Quantity;
+      Rec.ValueByName('TotalPrice').AsFloat := vBGL.TotalPrice;
+    end;
   end;
 
-  function GetDrawingCode(ANode: TsdIDTreeNode): string;
+  procedure WriteDetailGclNode(AGclNode: TGclNode);
+  var
+    iDetailGcl: Integer;
+    vDetailGcl: TDetailGclNode;
+    Rec: TsdDataRecord;
   begin
-    Result := '';
-    if not Assigned(ANode) then Exit;
-    Result := ANode.Rec.ValueByName('DrawingCode').AsString;
-    if Result = '' then
-      Result := GetDrawingCode(ANode.Parent);
-  end;
+    for iDetailGcl := 0 to AGclNode.DetailGclCount -1 do
+    begin
+      vDetailGcl := AGclNode.DetailGcl[iDetailGcl];
+      Rec := sddDetailGclBills.Add;
+      Rec.ValueByName('ID').AsInteger := vDetailGcl.ID;
+      Rec.ValueByName('BillsID').AsInteger := AGclNode.ID;
+      Rec.ValueByName('TreeSerialNo').AsInteger := vDetailGcl.TreeSerialNo;
+      Rec.ValueByName('RelaBillsID').AsInteger := vDetailGcl.BillsID;
+
+      if Assigned(vDetailGcl.LeafXmj) then
+      begin
+        Rec.ValueByName('LeafXmjID').AsInteger := vDetailGcl.LeafXmj.ID;
+        Rec.ValueByName('XmjCode').AsString := vDetailGcl.LeafXmj.XmjCode;
+        Rec.ValueByName('XmjName').AsString := vDetailGcl.LeafXmj.XmjName;
+        Rec.ValueByName('XmjUnits').AsString := vDetailGcl.LeafXmj.XmjUnits;
+        Rec.ValueByName('NameDanWei').AsString := vDetailGcl.LeafXmj.NameDanWei;
+        Rec.ValueByName('NameFenXiang').AsString := vDetailGcl.LeafXmj.NameFenXiang;
+        Rec.ValueByName('NameFenBu').AsString := vDetailGcl.LeafXmj.NameFenBu;
+        Rec.ValueByName('NameUnit').AsString := vDetailGcl.LeafXmj.NameUnit;
+        Rec.ValueByName('Peg').AsString := vDetailGcl.LeafXmj.Peg;
+        Rec.ValueByName('Position').AsString := vDetailGcl.LeafXmj.Position;
+        Rec.ValueByName('DrawingCode').AsString := vDetailGcl.LeafXmj.DrawingCode;
+      end;
 
-  function GetPegName(APegNode: TsdIDTreeNode): string;
-  begin
-    if Assigned(APegNode) then
-      Result := APegNode.Rec.ValueByName('Name').AsString
-    else
-      Result := '';
+      Rec.ValueByName('CurDealQuantity').AsFloat := vDetailGcl.CurDealQuantity;
+      Rec.ValueByName('CurDealTotalPrice').AsFloat := vDetailGcl.CurDealTotalPrice;
+      Rec.ValueByName('CurQcQuantity').AsFloat := vDetailGcl.CurQcQuantity;
+      Rec.ValueByName('CurQcTotalPrice').AsFloat := vDetailGcl.CurQcTotalPrice;
+      Rec.ValueByName('CurGatherQuantity').AsFloat := vDetailGcl.CurGatherQuantity;
+      Rec.ValueByName('CurGatherTotalPrice').AsFloat := vDetailGcl.CurGatherTotalPrice;
+
+      Rec.ValueByName('PreDealQuantity').AsFloat := vDetailGcl.PreDealQuantity;
+      Rec.ValueByName('PreDealTotalPrice').AsFloat := vDetailGcl.PreDealTotalPrice;
+      Rec.ValueByName('PreQcQuantity').AsFloat := vDetailGcl.PreQcQuantity;
+      Rec.ValueByName('PreQcTotalPrice').AsFloat := vDetailGcl.PreQcTotalPrice;
+      Rec.ValueByName('PreGatherQuantity').AsFloat := vDetailGcl.PreGatherQuantity;
+      Rec.ValueByName('PreGatherTotalPrice').AsFloat := vDetailGcl.PreGatherTotalPrice;
+
+      Rec.ValueByName('EndDealQuantity').AsFloat := vDetailGcl.EndDealQuantity;
+      Rec.ValueByName('EndDealTotalPrice').AsFloat := vDetailGcl.EndDealTotalPrice;
+      Rec.ValueByName('EndQcQuantity').AsFloat := vDetailGcl.EndQcQuantity;
+      Rec.ValueByName('EndQcTotalPrice').AsFloat := vDetailGcl.EndQcTotalPrice;
+      Rec.ValueByName('EndGatherQuantity').AsFloat := vDetailGcl.EndGatherQuantity;
+      Rec.ValueByName('EndGatherTotalPrice').AsFloat := vDetailGcl.EndGatherTotalPrice;
+
+      Rec.ValueByName('AddDealQuantity').AsFloat := vDetailGcl.AddDealQuantity;
+      Rec.ValueByName('AddDealTotalPrice').AsFloat := vDetailGcl.AddDealTotalPrice;
+      Rec.ValueByName('AddQcQuantity').AsFloat := vDetailGcl.AddQcQuantity;
+      Rec.ValueByName('AddQcTotalPrice').AsFloat := vDetailGcl.AddQcTotalPrice;
+      Rec.ValueByName('AddGatherQuantity').AsFloat := vDetailGcl.AddGatherQuantity;
+      Rec.ValueByName('AddGatherTotalPrice').AsFloat := vDetailGcl.AddGatherTotalPrice;
+    end;
   end;
 
-  procedure AddRelaXmj(ARec: TsdDataRecord);
+  procedure WriteGclNode(AGclNode: TGclNode);
   var
-    vNode, vPeg: TsdIDTreeNode;
+    Rec: TsdDataRecord;
   begin
-    vNode := GetFirstXmjParent(ARec.ValueByName('ID').AsInteger);
-    if not Assigned(vNode) then Exit;
-    cdsRelaXmj.Append;
-    cdsRelaXmjQuantity.AsFloat := ARec.ValueByName('Quantity').AsFloat;
-    cdsRelaXmjCode.AsString := vNode.Rec.ValueByName('Code').AsString;
-    cdsRelaXmjName.AsString := vNode.Rec.ValueByName('Name').AsString;
-    cdsRelaXmjUnits.AsString := vNode.Rec.ValueByName('Units').AsString;
-    vPeg := GetPegNode(vNode);
-    cdsRelaXmjPeg.AsString := GetPegName(vPeg);
-    cdsRelaXmjNameDanWei.AsString := GetNameDanWei(vNode);
-    cdsRelaXmjNameFenBu.AsString := GetNameFenBu(vNode, vPeg);
-    cdsRelaXmjNameFenXiang.AsString := GetNameFenXiang(vNode, vPeg);
-    cdsRelaXmjNameUnit.AsString := GetNameUnit(vNode);
-    cdsRelaXmjDrawingCode.AsString := GetDrawingCode(vNode);
-    cdsRelaXmj.Post;
+    Rec := sddGclBills.Add;
+    Rec.ValueByName('ID').AsInteger := AGclNode.ID;
+
+    Rec.ValueByName('IndexCode').AsString := AGclNode.IndexCode;
+    Rec.ValueByName('B_Code').AsString := AGclNode.B_Code;
+    Rec.ValueByName('Name').AsString := AGclNode.Name;
+    Rec.ValueByName('Units').AsString := AGclNode.Units;
+    Rec.ValueByName('Price').AsFloat := AGclNode.Price;
+
+    Rec.ValueByName('DealQuantity').AsFloat := AGclNode.DealQuantity;
+    Rec.ValueByName('DealTotalPrice').AsFloat := AGclNode.DealTotalPrice;
+    Rec.ValueByName('BGLQuantity').AsFloat := AGclNode.BGLQuantity;
+    Rec.ValueByName('BGLTotalPrice').AsFloat := AGclNode.BGLTotalPrice;
+    Rec.ValueByName('Quantity').AsFloat := AGclNode.Quantity;
+    Rec.ValueByName('TotalPrice').AsFloat := AGclNode.TotalPrice;
+
+    Rec.ValueByName('CurDealQuantity').AsFloat := AGclNode.CurDealQuantity;
+    Rec.ValueByName('CurDealTotalPrice').AsFloat := AGclNode.CurDealTotalPrice;
+    Rec.ValueByName('CurQcQuantity').AsFloat := AGclNode.CurQcQuantity;
+    Rec.ValueByName('CurQcTotalPrice').AsFloat := AGclNode.CurQcTotalPrice;
+    Rec.ValueByName('CurGatherQuantity').AsFloat := AGclNode.CurGatherQuantity;
+    Rec.ValueByName('CurGatherTotalPrice').AsFloat := AGclNode.CurGatherTotalPrice;
+
+    Rec.ValueByName('PreDealQuantity').AsFloat := AGclNode.PreDealQuantity;
+    Rec.ValueByName('PreDealTotalPrice').AsFloat := AGclNode.PreDealTotalPrice;
+    Rec.ValueByName('PreQcQuantity').AsFloat := AGclNode.PreQcQuantity;
+    Rec.ValueByName('PreQcTotalPrice').AsFloat := AGclNode.PreQcTotalPrice;
+    Rec.ValueByName('PreGatherQuantity').AsFloat := AGclNode.PreGatherQuantity;
+    Rec.ValueByName('PreGatherTotalPrice').AsFloat := AGclNode.PreGatherTotalPrice;
+
+    Rec.ValueByName('EndDealQuantity').AsFloat := AGclNode.EndDealQuantity;
+    Rec.ValueByName('EndDealTotalPrice').AsFloat := AGclNode.EndDealTotalPrice;
+    Rec.ValueByName('EndQcQuantity').AsFloat := AGclNode.EndQcQuantity;
+    Rec.ValueByName('EndQcTotalPrice').AsFloat := AGclNode.EndQcTotalPrice;
+    Rec.ValueByName('EndGatherQuantity').AsFloat := AGclNode.EndGatherQuantity;
+    Rec.ValueByName('EndGatherTotalPrice').AsFloat := AGclNode.EndGatherTotalPrice;
+
+    Rec.ValueByName('AddDealQuantity').AsFloat := AGclNode.AddDealQuantity;
+    Rec.ValueByName('AddDealTotalPrice').AsFloat := AGclNode.AddDealTotalPrice;
+    Rec.ValueByName('AddQcQuantity').AsFloat := AGclNode.AddQcQuantity;
+    Rec.ValueByName('AddQcTotalPrice').AsFloat := AGclNode.AddQcTotalPrice;
+    Rec.ValueByName('AddGatherQuantity').AsFloat := AGclNode.AddGatherQuantity;
+    Rec.ValueByName('AddGatherTotalPrice').AsFloat := AGclNode.AddGatherTotalPrice;
+
+    Rec.ValueByName('Deal_BGLQuantity').AsFloat := AGclNode.Deal_BGLQuantity;
+    Rec.ValueByName('Deal_BGLTotalPrice').AsFloat := AGclNode.Deal_BGLTotalPrice;
+    Rec.ValueByName('Deal_BGLPercent').AsFloat := AGclNode.Deal_BGLPercent;
+
+    WriteDetailGclNode(AGclNode);
+    WriteDetailDealNode(AGclNode);
+    WriteDetailBGLNode(AGclNode);
   end;
 
 var
-  I: Integer;
-  Rec: TsdDataRecord;
+  iGcl: Integer;
+  vGclNode: TGclNode;
 begin
-  if AB_Code = '' then Exit;
-  with TProjectData(FProjectData).BillsData do
-    for I := 0 to sddBills.RecordCount - 1 do
+  BeforeWrite;
+  try
+    for iGcl := 0 to AGcls.Count - 1 do
     begin
-      Rec := sddBills.Records[I];
-      if SameText(AB_Code, Rec.ValueByName('B_Code').AsString) and
-          SameText(AName, Trim(Rec.ValueByName('Name').AsString)) and
-          SameText(AUnits, Rec.ValueByName('Units').AsString) and
-          (APrice = Rec.ValueByName('Price').AsFloat) then
-        AddRelaXmj(Rec);
+      vGclNode := TGclNode(AGcls.Items[iGcl]);
+      WriteGclNode(vGclNode);
     end;
-end;
-
-procedure TBillsGatherData.WriteGclBills;
-var
-  I: Integer;
-  GclNode: TGclNode;
-begin
-  for I := 0 to FGclList.Count - 1 do
-  begin
-    GclNode := TGclNode(FGclList.Items[I]);
-    cdsBillsGather.Append;
-    cdsBillsGatherB_Code.AsString := GclNode.FB_Code;
-    cdsBillsGatherIndexCode.AsString := GclNode.FIndexCode;
-    cdsBillsGatherName.AsString := GclNode.FName;
-    cdsBillsGatherUnits.AsString := GclNode.FUnits;
-    cdsBillsGatherPrice.AsFloat := GclNode.FPrice;
-    cdsBillsGatherNewPrice.AsFloat := GclNode.FNewPrice;
-
-    cdsBillsGatherDealQuantity.AsFloat := GclNode.FDealQuantity;
-    cdsBillsGatherDealTotalPrice.AsFloat := GclNode.FDealTotalPrice;
-    cdsBillsGatherQuantity.AsFloat := GclNode.FQuantity;
-    cdsBillsGatherTotalPrice.AsFloat := GclNode.FTotalPrice;
-    cdsBillsGatherBGLQuantity.AsFloat := GclNode.FBGLQuantity;
-    cdsBillsGatherBGLTotalPrice.AsFloat := GclNode.FBGLTotalPrice;
-    cdsBillsGatherDeal_BGLQuantity.AsFloat := GclNode.FQuantity + GclNode.FBGLQuantity;
-    cdsBillsGatherDeal_BGLTotalPrice.AsFloat := GclNode.FTotalPrice + GclNode.FBGLTotalPrice;
-
-    cdsBillsGatherCurDealQuantity.AsFloat := GclNode.FCurDealQuantity;
-    cdsBillsGatherCurDealTotalPrice.AsFloat := GclNode.FCurDealTotalPrice;
-    cdsBillsGatherCurQcQuantity.AsFloat := GclNode.FCurQcQuantity;
-    cdsBillsGatherCurQcTotalPrice.AsFloat := GclNode.FCurQcTotalPrice;
-    cdsBillsGatherCurPcQuantity.AsFloat := GclNode.FCurPcQuantity;
-    cdsBillsGatherCurPcTotalPrice.AsFloat := GclNode.FCurPcTotalPrice;
-    cdsBillsGatherCurGatherQuantity.AsFloat := GclNode.FCurGatherQuantity;
-    cdsBillsGatherCurGatherTotalPrice.AsFloat := GclNode.FCurGatherTotalPrice;
-
-    cdsBillsGatherEndDealQuantity.AsFloat := GclNode.FEndDealQuantity;
-    cdsBillsGatherEndDealTotalPrice.AsFloat := GclNode.FEndDealTotalPrice;
-    cdsBillsGatherEndQcQuantity.AsFloat := GclNode.FEndQcQuantity;
-    cdsBillsGatherEndQcTotalPrice.AsFloat := GclNode.FEndQcTotalPrice;
-    cdsBillsGatherEndPcQuantity.AsFloat := GclNode.FEndPcQuantity;
-    cdsBillsGatherEndPcTotalPrice.AsFloat := GclNode.FEndPcTotalPrice;
-    cdsBillsGatherEndGatherQuantity.AsFloat := GclNode.FEndGatherQuantity;
-    cdsBillsGatherEndGatherTotalPrice.AsFloat := GclNode.FEndGatherTotalPrice;
-
-    cdsBillsGatherAddDealQuantity.AsFloat := GclNode.FAddDealQuantity;
-    cdsBillsGatherAddDealTotalPrice.AsFloat := GclNode.FAddDealTotalPrice;
-    cdsBillsGatherAddQcQuantity.AsFloat := GclNode.FAddQcQuantity;
-    cdsBillsGatherAddQcTotalPrice.AsFloat := GclNode.FAddQcTotalPrice;
-    cdsBillsGatherAddPcQuantity.AsFloat := GclNode.FAddPcQuantity;
-    cdsBillsGatherAddPcTotalPrice.AsFloat := GclNode.FAddPcTotalPrice;
-    cdsBillsGatherAddGatherQuantity.AsFloat := GclNode.FAddGatherQuantity;
-    cdsBillsGatherAddGatherTotalPrice.AsFloat := GclNode.FAddGatherTotalPrice;
-
-    if (GclNode.FTotalPrice + GclNode.FBGLTotalPrice) <> 0 then
-      cdsBillsGatherCompletionRate.AsFloat := AdvRoundTo(
-          GclNode.FEndGatherTotalPrice/(GclNode.FTotalPrice + GclNode.FBGLTotalPrice)*100);
-    cdsBillsGather.Post;
+  finally
+    AfterWrite;
   end;
 end;
 
-procedure TBillsGatherData.FilterDealBills;
-var
-  iIndex: Integer;
-  Rec: TsdDataRecord;
-  GclNode: TGclNode;
+procedure TBillsGatherData.sdvGclBillsCurrentChanged(
+  ARecord: TsdDataRecord);
 begin
-  with TProjectData(FProjectData).DealBillsData do
-    for iIndex := 0 to sddDealBills.RecordCount - 1 do
-    begin
-      Rec := sddDealBills.Records[iIndex];
-      GclNode := GetGclNode(Rec);
-      GclNode.FDealQuantity := GclNode.FDealQuantity + Rec.ValueByName('Quantity').AsFloat;
-      GclNode.FDealTotalPrice := GclNode.FDealTotalPrice + Rec.ValueByName('TotalPrice').AsFloat;
-    end;
+  sdvDetailGclBills.RefreshFilter;
+  sdvDetailDealBills.RefreshFilter;
+  sdvDetailBGLBills.RefreshFilter;
 end;
 
-function TBillsGatherData.GetGclNode(ARec: TsdDataRecord): TGclNode;
-
-  procedure LoadBGLData(AGclNode: TGclNode);
-  begin
-    with TProjectData(FProjectData).BGLData do
-    begin
-      cdsBGBills.First;
-      while not cdsBGBills.Eof do
-      begin
-        if SameText(AGclNode.FB_Code, cdsBGBillsB_Code.AsString) and
-           SameText(AGclNode.FName, Trim(cdsBGBillsName.AsString)) and
-           SameText(AGclNode.FUnits, cdsBGBillsUnits.AsString) and
-           (AGclNode.FPrice = cdsBGBillsPrice.AsFloat) then
-        begin
-          AGclNode.FBGLQuantity := AGclNode.FBGLQuantity + cdsBGBillsQuantity.AsFloat;
-          AGclNode.FBGLTotalPrice := AGclNode.FBGLTotalPrice + cdsBGBillsTotalPrice.AsFloat;
-        end;
-        cdsBGBills.Next;
-      end;
-    end;
-  end;
-
-  function CreateGclNode: TGclNode;
-  begin
-    Result := TGclNode.Create;
-    FGclList.Add(Result);
-    Result.FB_Code := ARec.ValueByName('B_Code').AsString;
-    Result.FIndexCode := B_CodeToIndexCode(ARec.ValueByName('B_Code').AsString);
-    Result.FName := Trim(ARec.ValueByName('Name').AsString);
-    Result.FUnits := ARec.ValueByName('Units').AsString;
-    Result.FPrice := ARec.ValueByName('Price').AsFloat;
-    if Assigned(ARec.ValueByName('NewPrice')) then
-      Result.FNewPrice := ARec.ValueByName('NewPrice').AsFloat
-    else
-      Result.FNewPrice := 0;
-    LoadBGLData(Result);
-  end;
-
-var
-  I: Integer;
-  GclNode: TGclNode;
+procedure TBillsGatherData.sdvDetailGclBillsFilterRecord(
+  ARecord: TsdDataRecord; var Allow: Boolean);
 begin
-  Result := nil;
-  for I := 0 to FGclList.Count - 1 do
-  begin
-    GclNode := TGclNode(FGclList.Items[I]);
-    if SameText(GclNode.FB_Code, ARec.ValueByName('B_Code').AsString) and
-        SameText(GclNode.FName, Trim(ARec.ValueByName('Name').AsString)) and
-        SameText(GclNode.FUnits, ARec.ValueByName('Units').AsString) and
-        (PriceRoundTo(GclNode.FPrice - ARec.ValueByName('Price').AsFloat) = 0) then
-    begin
-      Result := GclNode;
-      Break;
-    end;
-  end;
-  if not Assigned(Result) then
-    Result := CreateGclNode;
+  if Assigned(ARecord) and Assigned(sdvGclBills.Current) then
+    Allow := ARecord.ValueByName('BillsID').AsInteger = sdvGclBills.Current.ValueByName('ID').AsInteger
+  else
+    Allow := False;
 end;
 
 end.

+ 15 - 0
DataModules/BillsMeasureDm.dfm

@@ -205,6 +205,21 @@ object BillsMeasureData: TBillsMeasureData
       end
       item
         FieldName = 'AddCompleteRate'
+      end
+      item
+        FieldName = 'PM_PreTotalPrice'
+        KeyFields = 'ID'
+        LookupKeyFields = 'BillsID'
+        LookupResultField = 'PM_PreTotalPrice'
+      end
+      item
+        FieldName = 'PM_TotalPrice'
+        KeyFields = 'ID'
+        LookupKeyFields = 'BillsID'
+        LookupResultField = 'PM_TotalPrice'
+      end
+      item
+        FieldName = 'PM_AddTotalPrice'
       end>
     AfterAddRecord = sdvBillsMeasureAfterAddRecord
     AfterValueChanged = sdvBillsMeasureAfterValueChanged

+ 79 - 6
DataModules/BillsMeasureDm.pas

@@ -35,11 +35,13 @@ type
 
     procedure CalcAddCompleteRate(ANode: TsdIDTreeNode);
     procedure CalcAddDgnPrice(ANode: TsdIDTreeNode);
-    procedure UpdateRecordGather(ANode: TsdIDTreeNode; AQuantity, ATotalPrice: Double);
 
     function SelectAndUpdateBGL(ABillsID: Integer; ARec: TsdDataRecord;
       ANewValue: Double; const AType: string): Boolean;
 
+    procedure CalculateNode(ANode: TBillsIDTreeNode);            
+    procedure UpdateRecordGather(ANode: TsdIDTreeNode; AQuantity, ATotalPrice: Double);
+
     function GetStageData: TStageData;
     procedure SetOnRecChange(const Value: TRecChangeEvent);
   public
@@ -65,6 +67,8 @@ type
     procedure UpdateRecordDeal(ABillsID: Integer; AQuantity, ATotalPrice: Double);
     procedure UpdateRecordQc(ABillsID: Integer; AQuantity, ATotalPrice: Double);
     procedure UpdateRecordPc(ABillsID: Integer; AQuantity, ATotalPrice: Double);
+    procedure UpdateRecordPM(ABillsID: Integer; ADiffer: Double);
+    procedure UpdateGather(ABillsID: Integer; ADiffer: Double);
     procedure UpdateBGLInfo(ABillsID: Integer; ARec: TsdDataRecord; const AType: string);
 
     property ProjectData: TObject read FProjectData;
@@ -80,7 +84,7 @@ implementation
 
 uses
   ProjectData, PhaseData, Math, ZhAPI, BillsCommand, BGLSelectFrm,
-  BGLDm, UtilMethods, mDataRecord;
+  BGLDm, UtilMethods, mDataRecord, ConstUnit;
 
 {$R *.dfm}
 
@@ -147,6 +151,9 @@ begin
     sdvBillsMeasure.Columns.FindColumn('EndPcTotalPrice').LookupDataSet := StageData.sddStage;
     sdvBillsMeasure.Columns.FindColumn('EndGatherQuantity').LookupDataSet := StageData.sddStage;
     sdvBillsMeasure.Columns.FindColumn('EndGatherTotalPrice').LookupDataSet := StageData.sddStage;
+
+    sdvBillsMeasure.Columns.FindColumn('PM_PreTotalPrice').LookupDataSet := StageData.sddStage;
+    sdvBillsMeasure.Columns.FindColumn('PM_TotalPrice').LookupDataSet := StageData.sddStage;
   end;
 end;
 
@@ -285,6 +292,9 @@ procedure TBillsMeasureData.sdvBillsMeasureSetText(var Text: String;
     vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(GetBillsID));
     iCreatePhase := vNode.Rec.ValueByName('CreatePhaseID').AsInteger;
 
+    if vNode.ID = iPriceMarginID then
+      DataSetErrorMessage(Allow, sBills_PMHint);
+
     if SameText('B_Code', AColumn.FieldName) or
         SameText('Name', AColumn.FieldName) or
         SameText('Units', AColumn.FieldName) then
@@ -528,6 +538,10 @@ procedure TBillsMeasureData.sdvBillsMeasureNeedLookupRecord(
     iCreatePhase: Integer;
   begin
     Result := True;
+
+    if ANode.ID = iPriceMarginID then
+      DataSetErrorMessage(Result, sBills_PMHint);
+
     if ANode.HasChildren then
     begin
       if ANewText = '' then
@@ -577,8 +591,9 @@ begin
       if HasCardinalNum(ANewText) then
         raise Exception.Create('数量列公式不可输入参数');
     NewRec := StageData.AddStageRecord(ARecord.ValueByName('ID').AsInteger);
-    SetNewRecValue(NewRec);
     vNode.StageRec := NewRec;
+
+    SetNewRecValue(NewRec);
   end;
 end;
 
@@ -681,14 +696,20 @@ end;
 
 procedure TBillsMeasureData.CalculateAll;
 var
-  Cacl: TBillsCalculate;
+  //Cacl: TBillsCalculate;
+  i: Integer;
 begin
-  Cacl := TBillsCalculate.Create(Self);
+  if not TProjectData(FProjectData).StageDataReadOnly then
+
+  for i := 0 to BillsMeasureTree.Count - 1 do
+    CalculateNode(TBillsIDTreeNode(BillsMeasureTree.Items[i]));
+
+  {Cacl := TBillsCalculate.Create(Self);
   try
     Cacl.Execute;
   finally
     Cacl.Free;
-  end;
+  end;}
 end;
 
 procedure TBillsMeasureData.UpdateRecordDeal(ABillsID: Integer; AQuantity,
@@ -930,4 +951,56 @@ begin
   end;
 end;
 
+procedure TBillsMeasureData.UpdateRecordPM(ABillsID: Integer;
+  ADiffer: Double);
+var
+  stnNode: TBillsIDTreeNode;
+begin
+  stnNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(ABillsID));
+  if not Assigned(stnNode) then Exit;
+
+  stnNode.Rec.PM_AddTotalPrice.AsFloat := stnNode.Rec.PM_AddTotalPrice.AsFloat + ADiffer;
+  UpdateRecordPM(stnNode.ParentID, ADiffer);
+end;
+
+procedure TBillsMeasureData.CalculateNode(ANode: TBillsIDTreeNode);
+begin
+  if Assigned(ANode.StageRec) then
+  begin
+    if not ANode.HasChildren then
+    begin
+      ANode.Rec.AddDealQuantity.AsFloat := ANode.StageRec.EndDealQuantity.AsFloat;
+
+      ANode.Rec.AddQcQuantity.AsFloat := ANode.StageRec.EndQcQuantity.AsFloat;
+      ANode.Rec.AddQcBGLCode.AsString := ANode.StageRec.EndQcBGLCode.AsString;
+      ANode.Rec.AddQcBGLNum.AsString := ANode.StageRec.EndQcBGLNum.AsString;
+
+      ANode.Rec.AddPcQuantity.AsFloat := ANode.StageRec.EndPcQuantity.AsFloat;
+      ANode.Rec.AddPcBGLCode.AsString := ANode.StageRec.EndPcBGLCode.AsString;
+      ANode.Rec.AddPcBGLNum.AsString := ANode.StageRec.EndPcBGLNum.AsString;
+
+      ANode.Rec.AddGatherQuantity.AsFloat := ANode.StageRec.EndGatherQuantity.AsFloat;
+    end;
+    ANode.Rec.AddDealTotalPrice.AsFloat := ANode.StageRec.EndDealTotalPrice.AsFloat;
+    ANode.Rec.AddQcTotalPrice.AsFloat := ANode.StageRec.EndQcTotalPrice.AsFloat;
+    ANode.Rec.AddPcTotalPrice.AsFloat := ANode.StageRec.EndPcTotalPrice.AsFloat;
+    ANode.Rec.AddGatherTotalPrice.AsFloat := ANode.StageRec.EndGatherTotalPrice.AsFloat;
+
+    ANode.Rec.PM_AddTotalPrice.AsFloat := ANode.StageRec.PM_PreTotalPrice.AsFloat + ANode.StageRec.PM_TotalPrice.AsFloat;
+  end;
+end;
+
+procedure TBillsMeasureData.UpdateGather(ABillsID: Integer;
+  ADiffer: Double);
+var
+  stnNode: TBillsIDTreeNode;
+begin
+  stnNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(ABillsID));
+  if not Assigned(stnNode) then Exit;
+
+  with stnNode.Rec do
+    AddDifferValue(AddGatherTotalPrice, ADiffer);
+  UpdateGather(stnNode.ParentID, ADiffer);
+end;
+
 end.

+ 44 - 0
DataModules/DetailGLDm.dfm

@@ -0,0 +1,44 @@
+object DetailGLData: TDetailGLData
+  OldCreateOrder = False
+  Left = 623
+  Top = 444
+  Height = 237
+  Width = 201
+  object sdpDetailGL: TsdADOProvider
+    TableName = 'DetailGL'
+    Left = 64
+    Top = 24
+  end
+  object sddDetailGL: TsdDataSet
+    Active = False
+    Provider = sdpDetailGL
+    BeforeDeleteRecord = sddDetailGLBeforeDeleteRecord
+    BeforeValueChange = sddDetailGLBeforeValueChange
+    OnGetRecordClass = sddDetailGLGetRecordClass
+    Left = 64
+    Top = 80
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D65060742696C6C734944094669656C644E616D
+      65060742696C6C7349440844617461547970650203084461746153697A650204
+      0549734B6579080F4E65656450726F636573734E616D65090001044E616D6506
+      04474C4944094669656C644E616D650604474C49440844617461547970650203
+      084461746153697A6502040549734B6579080F4E65656450726F636573734E61
+      6D65090001044E616D650604436F6465094669656C644E616D650604436F6465
+      0844617461547970650203084461746153697A6502040549734B6579080F4E65
+      656450726F636573734E616D65090001044E616D6506085175616E7469747909
+      4669656C644E616D6506085175616E7469747908446174615479706502060844
+      61746153697A6502080549734B6579080F4E65656450726F636573734E616D65
+      090001044E616D65060D43726561746550686173654944094669656C644E616D
+      65060D4372656174655068617365494408446174615479706502030844617461
+      53697A6502040549734B6579080F4E65656450726F636573734E616D65090001
+      044E616D65060D4C6F636B656450686173654944094669656C644E616D65060D
+      4C6F636B6564506861736549440844617461547970650203084461746153697A
+      6502040549734B6579080F4E65656450726F636573734E616D65090001044E61
+      6D6506114C61737442696C6C735175616E74697479094669656C644E616D6506
+      114C61737442696C6C735175616E746974790844617461547970650206084461
+      746153697A6502080549734B6579080F4E65656450726F636573734E616D6509
+      0000}
+  end
+end

+ 368 - 0
DataModules/DetailGLDm.pas

@@ -0,0 +1,368 @@
+unit DetailGLDm;
+
+interface
+
+uses
+  SysUtils, Classes, sdDB, sdProvider, ADODB, Variants, mDataRecord;
+
+type
+  TDetailGLData = class(TDataModule)
+    sdpDetailGL: TsdADOProvider;
+    sddDetailGL: TsdDataSet;
+    procedure sddDetailGLGetRecordClass(var ARecordClass: TsdRecordClass);
+    procedure sddDetailGLBeforeDeleteRecord(ARecord: TsdDataRecord;
+      var Allow: Boolean);
+    procedure sddDetailGLBeforeValueChange(AValue: TsdValue;
+      const NewValue: Variant; var Allow: Boolean);
+  private
+    FProjectData: TObject;
+
+    procedure LoadRelaProjectGL;
+
+    function FindDetailGL(ABillsID, AGLID: Integer): TDetailGLRecord;
+    procedure ClearDetailGLs(ABillsID: Integer);
+  public
+    constructor Create(AProjectData: TObject);
+    destructor Destroy; override;
+
+    procedure Open(AConnection: TADOConnection);
+    procedure Close;
+    procedure Save;
+    procedure SaveCacheData;
+
+    function AddDetailGL(ABillsID: Integer; AProjectGLRec: TProjectGLRecord;
+      var sMessage: string): TDetailGLRecord;
+    procedure AddDetailGLs(ABillsID: Integer; AGLs: TList);
+
+    procedure LoadDetailGLs(ABillsID: Integer; AGLs: TList);
+    function HasLockedDetailGL(ABillsID: Integer): Boolean;
+    procedure ResetDetailGLs(ABillsID: Integer; AGLs: TList);
+
+    procedure LoadProjectGL_DetailGLs(AGLID: Integer; AGLs: TList);
+
+    function GetUnitPriceMargin(ABillsID: Integer): Double;
+
+    property ProjectData: TObject read FProjectData write FProjectData;
+  end;
+
+implementation
+
+uses
+  Math, UtilMethods, ProjectData, ProjectProperty, ProjectGLDm,
+  PriceMarginBillsDm, StageDm, PhasePayDm;
+
+{$R *.dfm}
+
+{ TDetailGLData }
+
+function TDetailGLData.AddDetailGL(ABillsID: Integer;
+  AProjectGLRec: TProjectGLRecord;
+  var sMessage: string): TDetailGLRecord;
+begin
+  sMessage := '';
+  Result := FindDetailGL(ABillsID, AProjectGLRec.ID.AsInteger);
+  if not Assigned(Result) then
+  begin
+    Result := TDetailGLRecord(sddDetailGL.Add(True));
+    Result.ID.AsInteger := GetsdDataSetNewID(sddDetailGL, 'idxID');
+    Result.BillsID.AsInteger := ABillsID;
+    Result.GLID.AsInteger := AProjectGLRec.ID.AsInteger;
+    Result.Code.AsString := AProjectGLRec.Code.AsString;
+    Result.CreatePhaseID.AsInteger := TProjectData(FProjectData).ProjProperties.PhaseCount;
+    Result.RelaProjectGL := AProjectGLRec;
+    Result.EndUpdate;
+  end
+  else
+    sMessage := Format('编号:%s 名称:%s', [AProjectGLRec.Code.AsString, AProjectGLRec.Name.AsString]);
+end;
+
+procedure TDetailGLData.AddDetailGLs(ABillsID: Integer; AGLs: TList);
+var
+  i: Integer;
+  sHint, sMessage: string;
+begin
+  sHint := '';
+  for i := 0 to AGLs.Count - 1 do
+  begin
+    AddDetailGL(ABillsID, TProjectGLRecord(AGLs.Items[i]), sMessage);
+    if sMessage <> '' then
+    begin
+      if sHint <> '' then
+        sHint := sHint + #13#10;
+      sHint := sHint + sMessage;
+    end;
+  end;
+  if sHint <> '' then
+    TipMessage('以下工料已添加至该清单,请勿重复添加:' + #13#10 + sHint);
+end;
+
+procedure TDetailGLData.ResetDetailGLs(ABillsID: Integer; AGLs: TList);
+var
+  i, iNewID: Integer;
+  Rec, GLRec: TDetailGLRecord;
+begin
+  if HasLockedDetailGL(ABillsID) then Exit;
+
+  ClearDetailGLs(ABillsID);
+
+  sddDetailGL.BeginUpdate;
+  try
+    iNewID := GetsdDataSetNewID(sddDetailGL, 'idxID');
+    for i := 0 to AGLs.Count - 1 do
+    begin
+      GLRec := TDetailGLRecord(AGLs.Items[i]);
+      Rec := TDetailGLRecord(sddDetailGL.Add);
+      Rec.ID.AsInteger := iNewID + i;
+      Rec.BillsID.AsInteger := ABillsID;
+      Rec.GLID.AsInteger := GLRec.GLID.AsInteger;
+      Rec.Code.AsInteger := GLRec.Code.AsInteger;
+      Rec.Quantity.AsFloat := GLRec.Quantity.AsFloat;
+      Rec.CreatePhaseID.AsInteger := TProjectData(FProjectData).ProjProperties.PhaseCount;
+
+      Rec.RelaProjectGL := GLRec.RelaProjectGL;
+    end;
+  finally
+    sddDetailGL.EndUpdate;
+  end;
+end;
+
+procedure TDetailGLData.ClearDetailGLs(ABillsID: Integer);
+var
+  idx: TsdIndex;
+  iFirst, iLast, iRec: Integer;
+begin
+  sddDetailGL.BeginUpdate;
+  try
+    idx := sddDetailGL.FindIndex('idxBillsID');
+    iFirst := idx.FindKeyIndex(ABillsID);
+    if iFirst <> -1 then
+    begin
+      iLast := idx.FindKeyLastIndex(ABillsID);
+      for iRec := iFirst to iLast do
+        sddDetailGL.Remove(idx.Records[iRec]);
+    end;
+  finally
+    sddDetailGL.EndUpdate;
+  end;
+end;
+
+procedure TDetailGLData.Close;
+begin
+  sddDetailGL.Close;
+end;
+
+constructor TDetailGLData.Create(AProjectData: TObject);
+begin
+  inherited Create(nil);
+  FProjectData := AProjectData;
+  sddDetailGL.AddIndex('idxView', 'BillsID;Code');
+  sddDetailGL.AddIndex('idxFind', 'BillsID;GLID');
+  sddDetailGL.AddIndex('idxBillsID', 'BillsID');
+  sddDetailGL.AddIndex('idxID', 'ID');
+  sddDetailGL.AddIndex('idxGLID', 'GLID');
+end;
+
+destructor TDetailGLData.Destroy;
+begin
+  inherited;
+end;
+
+function TDetailGLData.FindDetailGL(ABillsID,
+  AGLID: Integer): TDetailGLRecord;
+var
+  idx: TsdIndex;
+begin
+  idx := sddDetailGL.FindIndex('idxFind');
+  Result := TDetailGLRecord(idx.FindKey(VarArrayOf([ABillsID, AGLID])));
+end;
+
+procedure TDetailGLData.Open(AConnection: TADOConnection);
+begin
+  sdpDetailGL.Connection := AConnection;
+  sddDetailGL.Open;
+  // 建立与ProjectGL间的链接,以便计算时,快速获取工料的价格信息
+  LoadRelaProjectGL;
+end;
+
+procedure TDetailGLData.Save;
+begin
+  SaveCacheData;
+  sddDetailGL.Save;
+end;
+
+procedure TDetailGLData.LoadDetailGLs(ABillsID: Integer; AGLs: TList);
+var
+  idx: TsdIndex;
+  iRec, iFirst, iLast: Integer;
+begin
+  idx := sddDetailGL.FindIndex('idxBillsID');
+  iFirst := idx.FindKeyIndex(ABillsID);
+  if iFirst <> -1 then
+  begin
+    iLast := idx.FindKeyLastIndex(ABillsID);
+    for iRec := iFirst to iLast do
+      AGLs.Add(idx.Records[iRec]);
+  end;
+end;
+
+function TDetailGLData.GetUnitPriceMargin(ABillsID: Integer): Double;
+var
+  idx: TsdIndex;
+  iRec, iFirst, iLast: Integer;
+  Rec: TsdDataRecord;
+begin
+  Result := 0;
+  idx := sddDetailGL.FindIndex('idxBillsID');
+  iFirst := idx.FindKeyIndex(ABillsID);
+  if iFirst <> -1 then
+  begin
+    iLast := idx.FindKeyLastIndex(ABillsID);
+    for iRec := iFirst to iLast do
+    begin
+      Rec := idx.Records[iRec];
+      with TProjectData(FProjectData).ProjectGLData do
+        Result := Result + Rec.ValueByName('Quantity').AsFloat * ValidDeltaPrice[Rec.ValueByName('GLID').AsInteger];
+    end;
+  end;
+end;
+
+procedure TDetailGLData.LoadProjectGL_DetailGLs(AGLID: Integer;
+  AGLs: TList);
+var
+  idx: TsdIndex;
+  iRec, iFirst, iLast: Integer;
+begin
+  idx := sddDetailGL.FindIndex('idxGLID');
+  iFirst := idx.FindKeyIndex(AGLID);
+  if iFirst <> -1 then
+  begin
+    iLast := idx.FindKeyLastIndex(AGLID);
+    for iRec := iFirst to iLast do
+      AGLs.Add(idx.Records[iRec]);
+  end;
+end;
+
+procedure TDetailGLData.sddDetailGLGetRecordClass(
+  var ARecordClass: TsdRecordClass);
+begin
+  ARecordClass := TDetailGLRecord;
+end;
+
+procedure TDetailGLData.LoadRelaProjectGL;
+
+  procedure LoadRela(AProjectGLRec: TProjectGLRecord);
+  var
+    vDetailGLs: TList;
+    iGL: Integer;
+    DetailGLRec: TDetailGLRecord;
+  begin
+    vDetailGLs := TList.Create;
+    try
+      LoadProjectGL_DetailGLs(AProjectGLRec.ID.AsInteger, vDetailGLs);
+      for iGL := 0 to vDetailGLs.Count - 1 do
+      begin
+        DetailGLRec := TDetailGLRecord(vDetailGLs.Items[iGL]);
+        DetailGLRec.RelaProjectGL := AProjectGLRec;
+      end;
+    finally
+      vDetailGLs.Free;
+    end;
+  end;
+
+var
+  idx: TsdIndex;
+  i: Integer;
+  ProjectGLRec: TProjectGLRecord;
+begin
+  if not TProjectData(FProjectData).ProjectGLData.Active then Exit;
+  
+  idx := sddDetailGL.FindIndex('idxGLID');
+  with TProjectData(FProjectData).ProjectGLData do
+  begin
+    for i := 0 to sddProjectGL.RecordCount - 1 do
+    begin
+      ProjectGLRec := TProjectGLRecord(sddProjectGL.Records[i]);
+      LoadRela(ProjectGLRec);
+    end;
+  end;
+end;
+
+procedure TDetailGLData.SaveCacheData;
+
+  function GetBillsQuantity(ABillsID: Integer): Double;
+  var
+    StageRec: TStageRecord;
+  begin
+    StageRec := TProjectData(FProjectData).PhaseData.StageData.StageRecord(ABillsID);
+    if Assigned(StageRec) then
+      Result := StageRec.GatherQuantity.AsFloat
+    else
+      Result := 0;
+  end;
+
+var
+  idx: TsdIndex;
+  DetailGL: TDetailGLRecord;
+  fBillsQuantity: Double;
+  iBillsID, iRec: Integer;
+begin
+  if TProjectData(FProjectData).PhaseData.StageDataReadOnly then Exit;
+
+  idx := sddDetailGL.FindIndex('idxBillsID');
+  iBillsID := -1;
+  for iRec := 0 to idx.RecordCount - 1 do
+  begin
+    DetailGL := TDetailGLRecord(idx.Records[iRec]);
+    if iBillsID <> DetailGL.BillsID.AsInteger then
+    begin
+      iBillsID := DetailGL.BillsID.AsInteger;
+      fBillsQuantity := GetBillsQuantity(iBillsID);
+    end;
+    if DetailGL.LastBillsQuantity.AsFloat <> fBillsQuantity then
+      DetailGL.LastBillsQuantity.AsFloat := fBillsQuantity;
+  end;
+end;
+
+procedure TDetailGLData.sddDetailGLBeforeDeleteRecord(
+  ARecord: TsdDataRecord; var Allow: Boolean);
+begin
+  Allow := TDetailGLRecord(ARecord).LockedPhaseID.AsInteger = 0;
+  if not Allow then
+    ErrorMessage('当前调差工料已被锁定,不可删除。');
+end;
+
+procedure TDetailGLData.sddDetailGLBeforeValueChange(AValue: TsdValue;
+  const NewValue: Variant; var Allow: Boolean);
+begin
+  if SameText(AValue.FieldName, 'Quantity') then
+  begin
+    if TDetailGLRecord(AValue.Owner).LockedPhaseID.AsInteger > 0 then
+      DataSetErrorMessage(Allow, '当前调差工料已被锁定,不可修改数量。');
+  end;
+end;
+
+function TDetailGLData.HasLockedDetailGL(ABillsID: Integer): Boolean;
+var
+  idx: TsdIndex;
+  iFirst, iLast, iRec: Integer;
+  Rec: TDetailGLRecord;
+begin
+  Result := False;
+  idx := sddDetailGL.FindIndex('idxBillsID');
+  iFirst := idx.FindKeyIndex(ABillsID);
+  if iFirst > -1 then
+  begin
+    iLast := idx.FindKeyLastIndex(ABillsID);
+    for iRec := iFirst to iLast do
+    begin
+      Rec := TDetailGLRecord(idx.Records[iRec]);
+      if Rec.LockedPhaseID.AsInteger > 0 then
+      begin
+        Result := True;
+        Break;
+      end;
+    end;
+  end;
+end;
+
+end.

+ 1 - 0
DataModules/PhasePayDm.pas

@@ -160,6 +160,7 @@ var
   iIndex: Integer;
 begin
   if TPhaseData(FPhaseData).StageDataReadOnly then Exit;
+
   for iIndex := 0 to sddPhasePay.RecordCount - 1 do
     Calculate(sddPhasePay.Records[iIndex].ValueByName('ID').AsInteger);
   CalculateCurPay;

+ 223 - 0
DataModules/PriceMarginBillsDm.dfm

@@ -0,0 +1,223 @@
+object PriceMarginBillsData: TPriceMarginBillsData
+  OldCreateOrder = False
+  Left = 736
+  Top = 541
+  Height = 227
+  Width = 354
+  object sdmpGclBills: TsdMemoryProvider
+    Left = 64
+    Top = 16
+  end
+  object sddGclBills: TsdDataSet
+    Active = False
+    Provider = sdmpGclBills
+    Left = 64
+    Top = 80
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D650606425F436F6465094669656C644E616D65
+      0606425F436F64650844617461547970650218084461746153697A6502320549
+      734B6579080F4E65656450726F636573734E616D65090001044E616D65060949
+      6E646578436F6465094669656C644E616D650609496E646578436F6465084461
+      7461547970650218084461746153697A6502320549734B6579080F4E65656450
+      726F636573734E616D65090001044E616D6506044E616D65094669656C644E61
+      6D6506044E616D650844617461547970650218084461746153697A6503FF0005
+      49734B6579080F4E65656450726F636573734E616D65090001044E616D650605
+      556E697473094669656C644E616D650605556E69747308446174615479706502
+      18084461746153697A6502140549734B6579080F4E65656450726F636573734E
+      616D65090001044E616D6506055072696365094669656C644E616D6506055072
+      6963650844617461547970650206084461746153697A6502080549734B657908
+      0F4E65656450726F636573734E616D65090001044E616D65060F437572446561
+      6C5175616E74697479094669656C644E616D65060F4375724465616C5175616E
+      746974790844617461547970650206084461746153697A6502080549734B6579
+      080F4E65656450726F636573734E616D65090001044E616D65060D4375725163
+      5175616E74697479094669656C644E616D65060D43757251635175616E746974
+      790844617461547970650206084461746153697A6502080549734B6579080F4E
+      65656450726F636573734E616D65090001044E616D6506114375724761746865
+      725175616E74697479094669656C644E616D6506114375724761746865725175
+      616E746974790844617461547970650206084461746153697A6502080549734B
+      6579080F4E65656450726F636573734E616D65090000}
+  end
+  object sdmpDetailGclBills: TsdMemoryProvider
+    Left = 160
+    Top = 16
+  end
+  object sddDetailGclBills: TsdDataSet
+    Active = False
+    Provider = sdmpDetailGclBills
+    Left = 160
+    Top = 80
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D65060742696C6C734944094669656C644E616D
+      65060742696C6C7349440844617461547970650203084461746153697A650204
+      0549734B6579080F4E65656450726F636573734E616D65090001044E616D6506
+      0C5472656553657269616C4E6F094669656C644E616D65060C54726565536572
+      69616C4E6F0844617461547970650203084461746153697A6502040549734B65
+      79080F4E65656450726F636573734E616D65090001044E616D65060B52656C61
+      42696C6C734944094669656C644E616D65060B52656C6142696C6C7349440844
+      617461547970650203084461746153697A6502040549734B6579080F4E656564
+      50726F636573734E616D65090001044E616D6506094C656166586D6A49440946
+      69656C644E616D6506094C656166586D6A494408446174615479706502030844
+      61746153697A6502040549734B6579080F4E65656450726F636573734E616D65
+      090001044E616D650607586D6A436F6465094669656C644E616D650607586D6A
+      436F64650844617461547970650218084461746153697A6502320549734B6579
+      080F4E65656450726F636573734E616D65090001044E616D650607586D6A4E61
+      6D65094669656C644E616D650607586D6A4E616D650844617461547970650218
+      084461746153697A6503C8000549734B6579080F4E65656450726F636573734E
+      616D65090001044E616D650608586D6A556E697473094669656C644E616D6506
+      08586D6A556E6974730844617461547970650218084461746153697A65021405
+      49734B6579080F4E65656450726F636573734E616D65080001044E616D65060A
+      4E616D6544616E576569094669656C644E616D65060A4E616D6544616E576569
+      0844617461547970650218084461746153697A6503C8000549734B6579080F4E
+      65656450726F636573734E616D65090001044E616D6506094E616D6546656E42
+      75094669656C644E616D6506094E616D6546656E427508446174615479706502
+      18084461746153697A6503C8000549734B6579080F4E65656450726F63657373
+      4E616D65090001044E616D65060C4E616D6546656E5869616E67094669656C64
+      4E616D65060C4E616D6546656E5869616E670844617461547970650218084461
+      746153697A6503C8000549734B6579080F4E65656450726F636573734E616D65
+      090001044E616D6506084E616D65556E6974094669656C644E616D6506084E61
+      6D65556E69740844617461547970650218084461746153697A6503C800054973
+      4B6579080F4E65656450726F636573734E616D65090001044E616D6506035065
+      67094669656C644E616D65060350656708446174615479706502180844617461
+      53697A6503C8000549734B6579080F4E65656450726F636573734E616D650900
+      01044E616D650608506F736974696F6E094669656C644E616D650608506F7369
+      74696F6E0844617461547970650218084461746153697A6503C8000549734B65
+      79080F4E65656450726F636573734E616D65090001044E616D65060B44726177
+      696E67436F6465094669656C644E616D65060B44726177696E67436F64650844
+      617461547970650218084461746153697A6502320549734B6579080F4E656564
+      50726F636573734E616D65090001044E616D65060F4375724465616C5175616E
+      74697479094669656C644E616D65060F4375724465616C5175616E7469747908
+      44617461547970650206084461746153697A6502080549734B6579080F4E6565
+      6450726F636573734E616D65090001044E616D65060D43757251635175616E74
+      697479094669656C644E616D65060D43757251635175616E7469747908446174
+      61547970650206084461746153697A6502080549734B6579080F4E6565645072
+      6F636573734E616D65090001044E616D6506114375724761746865725175616E
+      74697479094669656C644E616D6506114375724761746865725175616E746974
+      790844617461547970650206084461746153697A6502080549734B6579080F4E
+      65656450726F636573734E616D65090001044E616D650610504D5F507265546F
+      74616C5072696365094669656C644E616D650610504D5F507265546F74616C50
+      726963650844617461547970650206084461746153697A6502080549734B6579
+      080F4E65656450726F636573734E616D65090001044E616D65060D504D5F546F
+      74616C5072696365094669656C644E616D65060D504D5F546F74616C50726963
+      650844617461547970650206084461746153697A6502080549734B6579080F4E
+      65656450726F636573734E616D65090000}
+  end
+  object sdvGclBills: TsdDataView
+    Active = False
+    DataSet = sddGclBills
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'B_Code'
+      end
+      item
+        FieldName = 'Name'
+      end
+      item
+        FieldName = 'Units'
+      end
+      item
+        FieldName = 'Price'
+      end
+      item
+        FieldName = 'CurDealQuantity'
+      end
+      item
+        FieldName = 'CurGatherQuantity'
+      end
+      item
+        FieldName = 'CurQcQuantity'
+      end>
+    OnCurrentChanged = sdvGclBillsCurrentChanged
+    OnGetText = sdvGclBillsGetText
+    Left = 64
+    Top = 136
+  end
+  object sdvDetailGclBills: TsdDataView
+    Active = False
+    DataSet = sddDetailGclBills
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'XmjCode'
+      end
+      item
+        FieldName = 'XmjName'
+      end
+      item
+        FieldName = 'XmjUnits'
+      end
+      item
+        FieldName = 'NameDanWei'
+      end
+      item
+        FieldName = 'NameFenBu'
+      end
+      item
+        FieldName = 'NameFenXiang'
+      end
+      item
+        FieldName = 'NameUnit'
+      end
+      item
+        FieldName = 'Peg'
+      end
+      item
+        FieldName = 'CurDealQuantity'
+      end
+      item
+        FieldName = 'CurGatherQuantity'
+      end
+      item
+        FieldName = 'CurQcQuantity'
+      end
+      item
+        FieldName = 'PM_TotalPrice'
+      end>
+    OnFilterRecord = sdvDetailGclBillsFilterRecord
+    OnCurrentChanged = sdvDetailGclBillsCurrentChanged
+    OnGetText = sdvDetailGclBillsGetText
+    Left = 160
+    Top = 136
+  end
+  object sdvDetailGL: TsdDataView
+    Active = False
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'Code'
+      end
+      item
+        FieldName = 'Name'
+        KeyFields = 'GLID'
+        LookupKeyFields = 'ID'
+        LookupResultField = 'Name'
+      end
+      item
+        FieldName = 'Units'
+        KeyFields = 'GLID'
+        LookupKeyFields = 'ID'
+        LookupResultField = 'Units'
+      end
+      item
+        FieldName = 'Quantity'
+      end
+      item
+        FieldName = 'PM_PreTotalPrice'
+      end
+      item
+        FieldName = 'PM_CurTotalPrice'
+      end
+      item
+        FieldName = 'PM_EndTotalPrice'
+      end>
+    AfterDeleteRecord = sdvDetailGLAfterDeleteRecord
+    AfterValueChanged = sdvDetailGLAfterValueChanged
+    OnFilterRecord = sdvDetailGLFilterRecord
+    Left = 264
+    Top = 136
+  end
+end

+ 377 - 0
DataModules/PriceMarginBillsDm.pas

@@ -0,0 +1,377 @@
+unit PriceMarginBillsDm;
+
+interface
+
+uses
+  SysUtils, Classes, sdDB, sdProvider, BillsTree, mDataRecord,
+  GclBillsGatherModel;
+
+type
+  TPriceMarginBillsData = class(TDataModule)
+    sdmpGclBills: TsdMemoryProvider;
+    sddGclBills: TsdDataSet;
+    sdmpDetailGclBills: TsdMemoryProvider;
+    sddDetailGclBills: TsdDataSet;
+    sdvGclBills: TsdDataView;
+    sdvDetailGclBills: TsdDataView;
+    sdvDetailGL: TsdDataView;
+    procedure sdvGclBillsCurrentChanged(ARecord: TsdDataRecord);
+    procedure sdvDetailGclBillsFilterRecord(ARecord: TsdDataRecord;
+      var Allow: Boolean);
+    procedure sdvDetailGLFilterRecord(ARecord: TsdDataRecord;
+      var Allow: Boolean);
+    procedure sdvDetailGclBillsCurrentChanged(ARecord: TsdDataRecord);
+    procedure sdvDetailGLAfterValueChanged(AValue: TsdValue);
+    procedure sdvDetailGclBillsGetText(var Text: String;
+      ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
+      DisplayText: Boolean);
+    procedure sdvDetailGLAfterDeleteRecord(ARecord: TsdDataRecord);
+    procedure sdvGclBillsGetText(var Text: String; ARecord: TsdDataRecord;
+      AValue: TsdValue; AColumn: TsdViewColumn; DisplayText: Boolean);
+  private
+    FProjectData: TObject;
+    procedure WriteGclBillsData(AGcls: TList);
+    function GetMainBillsTree: TBillsIDTree;
+  public
+    constructor Create(AProjectData: TObject);
+    destructor Destroy; override;
+
+    procedure RefreshBills;
+    procedure AddDetailGLs(AGls: TList);
+
+    procedure RefreshDetailBills(ABillsID: Integer);
+    procedure RefreshAllDetailBills;
+
+    property ProjectData: TObject read FProjectData;
+    property MainBillsTree: TBillsIDTree read GetMainBillsTree;
+  end;
+
+implementation
+
+uses
+  ZhAPI, ProjectData, UtilMethods;
+
+{$R *.dfm}
+
+{ TPriceMarginBillsData }
+
+constructor TPriceMarginBillsData.Create(AProjectData: TObject);
+begin
+  inherited Create(nil);
+  FProjectData := AProjectData;
+
+  sddGclBills.Open;
+  if not Assigned(sddGclBills.FindIndex('idxIndexCode')) then
+    sddGclBills.AddIndex('idxIndexCode', 'IndexCode');
+  sdvGclBills.Open;
+  sdvGclBills.IndexName := 'idxIndexCode';
+
+  sddDetailGclBills.Open;
+  if not Assigned(sddDetailGclBills.FindIndex('idxSerialNo')) then
+    sddDetailGclBills.AddIndex('idxSerialNo', 'BillsID;TreeSerialNo');
+  if not Assigned(sddDetailGclBills.FindIndex('idxRelaBills')) then
+    sddDetailGclBills.AddIndex('idxRelaBills', 'RelaBillsID');
+  sdvDetailGclBills.Open;
+  sdvDetailGclBills.IndexName := 'idxSerialNo';
+
+  sdvDetailGL.DataSet := TProjectData(FProjectData).DetailGLData.sddDetailGL;
+  sdvDetailGL.IndexName := 'idxView';
+  sdvDetailGL.Columns.FindColumn('Name').LookupDataSet := TProjectData(FProjectData).ProjectGLData.sddProjectGL;
+  sdvDetailGL.Columns.FindColumn('Units').LookupDataSet := TProjectData(FProjectData).ProjectGLData.sddProjectGL;
+end;
+
+destructor TPriceMarginBillsData.Destroy;
+begin
+  inherited;
+end;
+
+procedure TPriceMarginBillsData.RefreshBills;
+var
+  vGather: TGclGatherModel;
+begin
+  vGather := TGclGatherModel.Create(FProjectData);
+  try
+    vGather.WriteGatherData := WriteGclBillsData;
+    vGather.Execute;
+  finally
+    vGather.Free;
+  end;
+end;
+
+procedure TPriceMarginBillsData.WriteGclBillsData(AGcls: TList);
+
+  procedure BeforeWrite;
+  begin
+    sdvDetailGclBills.Filtered := False;
+    sdvDetailGL.Filtered := False;
+
+    sddGclBills.DisableControls;
+    sddGclBills.BeginUpdate;
+    sddGclBills.DeleteAll;
+
+    sddDetailGclBills.DisableControls;
+    sddDetailGclBills.BeginUpdate;
+    sddDetailGclBills.DeleteAll;
+  end;
+
+  procedure AfterWrite;
+  var
+    idx: TsdIndex;
+  begin
+    sddDetailGclBills.EndUpdate;
+    sddDetailGclBills.EnableControls;
+
+    sddGclBills.EndUpdate;
+    sddGclBills.EnableControls;
+
+    if not sdvDetailGL.Active then
+      sdvDetailGL.Open;
+
+    idx := sddGclBills.FindIndex('idxIndexCode');
+    sdvGclBills.LocateInControl(sdvGclBills.Records[0]);
+    sdvDetailGclBills.Filtered := True;
+    sdvDetailGclBills.LocateInControl(sdvDetailGclBills.Records[0]);
+    sdvDetailGL.Filtered := True;
+
+    sdvDetailGclBills.LocateInControl(sdvDetailGclBills.Records[0]);
+  end;
+
+  procedure WriteDetailGclNode(AGclNode: TGclNode);
+  var
+    iDetailGcl: Integer;
+    vDetailGcl: TDetailGclNode;
+    Rec: TsdDataRecord;
+  begin
+    for iDetailGcl := 0 to AGclNode.DetailGclCount -1 do
+    begin
+      vDetailGcl := AGclNode.DetailGcl[iDetailGcl];
+      Rec := sddDetailGclBills.Add;
+      Rec.ValueByName('ID').AsInteger := vDetailGcl.ID;
+      Rec.ValueByName('BillsID').AsInteger := AGclNode.ID;
+      Rec.ValueByName('TreeSerialNo').AsInteger := vDetailGcl.TreeSerialNo;
+      Rec.ValueByName('RelaBillsID').AsInteger := vDetailGcl.BillsID;
+
+      if Assigned(vDetailGcl.LeafXmj) then
+      begin
+        Rec.ValueByName('LeafXmjID').AsInteger := vDetailGcl.LeafXmj.ID;
+        Rec.ValueByName('XmjCode').AsString := vDetailGcl.LeafXmj.XmjCode;
+        Rec.ValueByName('XmjName').AsString := vDetailGcl.LeafXmj.XmjName;
+        Rec.ValueByName('XmjUnits').AsString := vDetailGcl.LeafXmj.XmjUnits;
+        Rec.ValueByName('NameDanWei').AsString := vDetailGcl.LeafXmj.NameDanWei;
+        Rec.ValueByName('NameFenXiang').AsString := vDetailGcl.LeafXmj.NameFenXiang;
+        Rec.ValueByName('NameFenBu').AsString := vDetailGcl.LeafXmj.NameFenBu;
+        Rec.ValueByName('NameUnit').AsString := vDetailGcl.LeafXmj.NameUnit;
+        Rec.ValueByName('Peg').AsString := vDetailGcl.LeafXmj.Peg;
+        Rec.ValueByName('Position').AsString := vDetailGcl.LeafXmj.Position;
+        Rec.ValueByName('DrawingCode').AsString := vDetailGcl.LeafXmj.DrawingCode;
+      end;
+
+      Rec.ValueByName('CurDealQuantity').AsFloat := vDetailGcl.CurDealQuantity;
+      Rec.ValueByName('CurQcQuantity').AsFloat := vDetailGcl.CurQcQuantity;
+      Rec.ValueByName('CurGatherQuantity').AsFloat := vDetailGcl.CurGatherQuantity;
+
+      Rec.ValueByName('PM_PreTotalPrice').AsFloat := vDetailGcl.PM_PreTotalPrice;
+      Rec.ValueByName('PM_TotalPrice').AsFloat := vDetailGcl.PM_TotalPrice;
+    end;
+  end;
+
+  procedure WriteGclNode(AGclNode: TGclNode);
+  var
+    Rec: TsdDataRecord;
+  begin
+    Rec := sddGclBills.Add;
+    Rec.ValueByName('ID').AsInteger := AGclNode.ID;
+    Rec.ValueByName('B_Code').AsString := AGclNode.B_Code;
+    Rec.ValueByName('IndexCode').AsString := AGclNode.IndexCode;
+    Rec.ValueByName('Name').AsString := AGclNode.Name;
+    Rec.ValueByName('Units').AsString := AGclNode.Units;
+    Rec.ValueByName('Price').AsFloat := AGclNode.Price;
+
+    Rec.ValueByName('CurDealQuantity').AsFloat := AGclNode.CurDealQuantity;
+    Rec.ValueByName('CurQcQuantity').AsFloat := AGclNode.CurQcQuantity;
+    Rec.ValueByName('CurGatherQuantity').AsFloat := AGclNode.CurGatherQuantity;
+    WriteDetailGclNode(AGclNode);
+  end;
+
+var
+  iGcl: Integer;
+  vGclNode: TGclNode;
+begin
+  BeforeWrite;
+  try
+    for iGcl := 0 to AGcls.Count - 1 do
+    begin
+      vGclNode := TGclNode(AGcls.Items[iGcl]);
+      WriteGclNode(vGclNode);
+    end;
+  finally
+    AfterWrite;
+  end;
+end;
+
+procedure TPriceMarginBillsData.sdvGclBillsCurrentChanged(
+  ARecord: TsdDataRecord);
+begin
+  sdvDetailGclBills.RefreshFilter;
+  sdvDetailGclBills.LocateInControl(sdvDetailGclBills.Records[0]);
+end;
+
+procedure TPriceMarginBillsData.sdvDetailGclBillsFilterRecord(
+  ARecord: TsdDataRecord; var Allow: Boolean);
+begin
+  if Assigned(sdvGclBills.Current) and Assigned(ARecord) then
+    Allow := ARecord.ValueByName('BillsID').AsInteger = sdvGclBills.Current.ValueByName('ID').AsInteger
+  else
+    Allow := False;
+end;
+
+procedure TPriceMarginBillsData.sdvDetailGLFilterRecord(
+  ARecord: TsdDataRecord; var Allow: Boolean);
+begin
+  if Assigned(sdvDetailGclBills.Current) and Assigned(ARecord) then
+    Allow := ARecord.ValueByName('BillsID').AsInteger = sdvDetailGclBills.Current.ValueByName('RelaBillsID').AsInteger
+  else
+    Allow := False;
+end;
+
+function TPriceMarginBillsData.GetMainBillsTree: TBillsIDTree;
+begin
+  Result := TProjectData(FProjectData).BillsMeasureData.BillsMeasureTree;
+end;
+
+procedure TPriceMarginBillsData.AddDetailGLs(AGls: TList);
+begin
+  TProjectData(FProjectData).DetailGLData.AddDetailGLs(
+      sdvDetailGclBills.Current.ValueByName('RelaBillsID').AsInteger, AGls);
+  sdvDetailGL.RefreshFilter;
+end;
+
+procedure TPriceMarginBillsData.sdvDetailGclBillsCurrentChanged(
+  ARecord: TsdDataRecord);
+begin
+  sdvDetailGL.RefreshFilter;
+end;
+
+procedure TPriceMarginBillsData.RefreshDetailBills(ABillsID: Integer);
+var
+  Rec: TsdDataRecord;
+  StageRec: TStageRecord;
+begin
+  Rec := sddDetailGclBills.FindKey('idxRelaBills', ABillsID);
+  if not Assigned(Rec) then Exit;
+
+  StageRec := TProjectData(FProjectData).PhaseData.StageData.StageRecord(ABillsID);
+  if Assigned(StageRec) then
+    Rec.ValueByName('PM_TotalPrice').AsFloat := StageRec.PM_TotalPrice.AsFloat
+  else
+    Rec.ValueByName('PM_TotalPrice').AsFloat := 0;
+end;
+
+procedure TPriceMarginBillsData.sdvDetailGLAfterValueChanged(
+  AValue: TsdValue);
+var
+  ARec: TDetailGLRecord;
+begin
+  if SameText(AValue.FieldName, 'Quantity') then
+  begin
+    ARec := TDetailGLRecord(AValue.Owner);
+    // 更新调差工料--本期价差
+    with TProjectData(FProjectData).ProjectGLData do
+      CalculateGL_PM(ARec.GLID.AsInteger);
+    // 更新清单调差数据,材料调差节点数据
+    with TProjectData(FProjectData).PhaseData.StageData do
+    begin
+      CalculatePriceMargin(ARec.BillsID.AsInteger);
+      CalculatePriceMarginNode;
+    end;
+    // 更新价差清单内存表信息
+    with TProjectData(FProjectData).PriceMarginBillsData do
+      RefreshDetailBills(ARec.BillsID.AsInteger);
+    // 更新合同支付
+    TProjectData(FProjectData).PhaseData.PhasePayData.CalculateAll;
+  end;
+end;
+
+procedure TPriceMarginBillsData.sdvDetailGclBillsGetText(var Text: String;
+  ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
+  DisplayText: Boolean);
+
+  procedure GetDisplayText;
+  begin
+    if ((Pos('Price', AColumn.FieldName) > 0) or
+        (Pos('Quantity', AColumn.FieldName) > 0)) then
+    begin
+      if AValue.AsFloat = 0 then
+        Text := '';
+    end;
+  end;
+
+begin
+  if DisplayText then
+    GetDisplayText;
+end;
+
+procedure TPriceMarginBillsData.sdvDetailGLAfterDeleteRecord(
+  ARecord: TsdDataRecord);
+var
+  ARec: TDetailGLRecord;
+begin
+  if ARecord.ValueByName('Quantity').AsFloat <> 0 then
+  begin
+    ARec := TDetailGLRecord(ARecord);
+    // 更新调差工料--本期价差
+    with TProjectData(FProjectData).ProjectGLData do
+      CalculateGL_PM(ARec.GLID.AsInteger);
+    // 更新清单调差数据,材料调差节点数据
+    with TProjectData(FProjectData).PhaseData.StageData do
+    begin
+      CalculatePriceMargin(ARec.BillsID.AsInteger);
+      CalculatePriceMarginNode;
+    end;
+    // 更新价差清单内存表信息
+    with TProjectData(FProjectData).PriceMarginBillsData do
+      RefreshDetailBills(ARec.BillsID.AsInteger);
+    // 更新合同支付
+    TProjectData(FProjectData).PhaseData.PhasePayData.CalculateAll;
+  end;
+end;
+
+procedure TPriceMarginBillsData.sdvGclBillsGetText(var Text: String;
+  ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
+  DisplayText: Boolean);
+
+  procedure GetDisplayText;
+  begin
+    if ((Pos('Price', AColumn.FieldName) > 0) or
+        (Pos('Quantity', AColumn.FieldName) > 0)) then
+    begin
+      if AValue.AsFloat = 0 then
+        Text := '';
+    end;
+  end;
+
+begin
+  if DisplayText then
+    GetDisplayText;
+end;
+
+procedure TPriceMarginBillsData.RefreshAllDetailBills;
+var
+  i: Integer;
+  Rec: TsdDataRecord;
+  StageRec: TStageRecord;
+begin
+  for i := 0 to sddDetailGclBills.RecordCount - 1 do
+  begin
+    Rec := sddDetailGclBills.Records[i];
+
+    with TProjectData(FProjectData).PhaseData.StageData do
+      StageRec := StageRecord(Rec.ValueByName('RelaBillsID').AsInteger);
+    if Assigned(StageRec) then
+      Rec.ValueByName('PM_TotalPrice').AsFloat := StageRec.PM_TotalPrice.AsFloat
+    else
+      Rec. ValueByName('PM_TotalPrice').AsFloat := 0;
+  end;
+end;
+
+end.

+ 117 - 0
DataModules/ProjectGLDm.dfm

@@ -0,0 +1,117 @@
+object ProjectGLData: TProjectGLData
+  OldCreateOrder = False
+  Left = 562
+  Top = 408
+  Height = 252
+  Width = 171
+  object sdpProjectGL: TsdADOProvider
+    TableName = 'ProjectGL'
+    Left = 56
+    Top = 24
+  end
+  object sddProjectGL: TsdDataSet
+    Active = False
+    Provider = sdpProjectGL
+    AfterAddRecord = sddProjectGLAfterAddRecord
+    BeforeDeleteRecord = sddProjectGLBeforeDeleteRecord
+    BeforeValueChange = sddProjectGLBeforeValueChange
+    AfterValueChanged = sddProjectGLAfterValueChanged
+    OnGetRecordClass = sddProjectGLGetRecordClass
+    Left = 57
+    Top = 80
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D650604436F6465094669656C644E616D650604
+      436F64650844617461547970650203084461746153697A6502040549734B6579
+      080F4E65656450726F636573734E616D65090001044E616D6506044E616D6509
+      4669656C644E616D6506044E616D650844617461547970650218084461746153
+      697A6503C8000549734B6579080F4E65656450726F636573734E616D65090001
+      044E616D650605556E697473094669656C644E616D650605556E697473084461
+      7461547970650218084461746153697A6502140549734B6579080F4E65656450
+      726F636573734E616D65090001044E616D6506055370656373094669656C644E
+      616D65060553706563730844617461547970650218084461746153697A6503C8
+      000549734B6579080F4E65656450726F636573734E616D65090001044E616D65
+      0609426173655072696365094669656C644E616D650609426173655072696365
+      0844617461547970650206084461746153697A6502080549734B6579080F4E65
+      656450726F636573734E616D65090001044E616D6506095269736B52616E6765
+      094669656C644E616D6506095269736B52616E67650844617461547970650206
+      084461746153697A6502080549734B6579080F4E65656450726F636573734E61
+      6D65090001044E616D65060D43726561746550686173654944094669656C644E
+      616D65060D437265617465506861736549440844617461547970650203084461
+      746153697A6502040549734B6579080F4E65656450726F636573734E616D6509
+      0001044E616D65060D4C6F636B656450686173654944094669656C644E616D65
+      060D4C6F636B6564506861736549440844617461547970650203084461746153
+      697A6502040549734B6579080F4E65656450726F636573734E616D6509000104
+      4E616D650609496E666F5072696365094669656C644E616D650609496E666F50
+      726963650844617461547970650206084461746153697A6502080549734B6579
+      080F4E65656450726F636573734E616D65090001044E616D650608496E666F44
+      617465094669656C644E616D650608496E666F44617465084461746154797065
+      0218084461746153697A6502140549734B6579080F4E65656450726F63657373
+      4E616D65090001044E616D65060A44656C74615072696365094669656C644E61
+      6D65060A44656C74615072696365084461746154797065020608446174615369
+      7A6502080549734B6579080F4E65656450726F636573734E616D65090001044E
+      616D65060F56616C696444656C74615072696365094669656C644E616D65060F
+      56616C696444656C746150726963650844617461547970650206084461746153
+      697A6502080549734B6579080F4E65656450726F636573734E616D6509000104
+      4E616D65060B504D5F5175616E74697479094669656C644E616D65060B504D5F
+      5175616E746974790844617461547970650206084461746153697A6502080549
+      734B6579080F4E65656450726F636573734E616D65090001044E616D65060D50
+      4D5F546F74616C5072696365094669656C644E616D65060D504D5F546F74616C
+      50726963650844617461547970650206084461746153697A6502080549734B65
+      79080F4E65656450726F636573734E616D65090000}
+  end
+  object sdvProjectGL: TsdDataView
+    Active = False
+    DataSet = sddProjectGL
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'Code'
+      end
+      item
+        FieldName = 'Name'
+      end
+      item
+        FieldName = 'Units'
+      end
+      item
+        FieldName = 'Specs'
+      end
+      item
+        FieldName = 'BasePrice'
+        DisplayFormat = '0.##'
+      end
+      item
+        FieldName = 'RiskRange'
+        DisplayFormat = '0.##'
+      end
+      item
+        FieldName = 'InfoPrice'
+        DisplayFormat = '0.##'
+      end
+      item
+        FieldName = 'InfoDate'
+      end
+      item
+        FieldName = 'DeltaPrice'
+        DisplayFormat = '0.##'
+      end
+      item
+        FieldName = 'ValidDeltaPrice'
+        DisplayFormat = '0.##'
+      end
+      item
+        FieldName = 'PM_Quantity'
+        DisplayFormat = '0.##'
+      end
+      item
+        FieldName = 'PM_TotalPrice'
+        DisplayFormat = '0.##'
+      end>
+    OnGetText = sdvProjectGLGetText
+    OnSetText = sdvProjectGLSetText
+    Left = 56
+    Top = 136
+  end
+end

+ 575 - 0
DataModules/ProjectGLDm.pas

@@ -0,0 +1,575 @@
+unit ProjectGLDm;
+
+interface
+
+uses
+  SysUtils, Classes, sdDB, sdProvider, ADODB, mDataRecord;
+
+type
+  TProjectGLData = class(TDataModule)
+    sdpProjectGL: TsdADOProvider;
+    sddProjectGL: TsdDataSet;
+    sdvProjectGL: TsdDataView;
+    procedure sddProjectGLAfterAddRecord(ARecord: TsdDataRecord);
+    procedure sddProjectGLBeforeValueChange(AValue: TsdValue;
+      const NewValue: Variant; var Allow: Boolean);
+    procedure sddProjectGLAfterValueChanged(AValue: TsdValue);
+    procedure sdvProjectGLGetText(var Text: String; ARecord: TsdDataRecord;
+      AValue: TsdValue; AColumn: TsdViewColumn; DisplayText: Boolean);
+    procedure sddProjectGLGetRecordClass(var ARecordClass: TsdRecordClass);
+    procedure sdvProjectGLSetText(var Text: String; ARecord: TsdDataRecord;
+      AValue: TsdValue; AColumn: TsdViewColumn; var Allow: Boolean);
+    procedure sddProjectGLBeforeDeleteRecord(ARecord: TsdDataRecord;
+      var Allow: Boolean);
+  private
+    FProjectData: TObject;
+    FTempGLs: TList;
+
+    function CheckSameCode(ACode: Integer): Boolean;
+    function CheckApplied(AGLID: Integer): Boolean;
+
+    procedure LoadDetailGLs(AGLID: Integer);
+
+    procedure CalculateDeltaPrice(ARec: TProjectGLRecord);
+    procedure CalculatePrice;
+
+    procedure CalculatePM_Quantity(ARec: TProjectGLRecord);
+    procedure CalculatePM_TotalPrice(ARec: TProjectGLRecord);
+    procedure CalculatePriceMargin;
+
+    procedure CalculateRelaBills(ARec: TProjectGLRecord);
+
+    procedure ExecuteSql(const ASql: string);
+    procedure SaveGLPrice;
+    procedure SavePM_CurData;
+
+    procedure BeforeBatchOperation;
+    procedure AfterBatchOperation;
+
+    function GetValidDeltaPrice(AID: Integer): Double;
+    function GetPM_TotalPrice: Double;
+    function GetActive: Boolean;
+  public
+    constructor Create(AProjectData: TObject);
+    destructor Destroy; override;
+
+    procedure Open(AConnection: TADOConnection);
+    procedure Save;
+
+    procedure LoadCurPhaseInfoPrice;
+    procedure LoadStagePM_CalcData;
+
+    procedure CalculateAll;
+    procedure CalculateGL_PM(AGLID: Integer);
+    procedure CalculateGLs_PM(ADetailGLs: TList);
+
+    property ProjectData: TObject read FProjectData write FProjectData;
+    property Active: Boolean read GetActive;
+
+    property ValidDeltaPrice[AID: Integer]: Double read GetValidDeltaPrice;
+    property PM_TotalPrice: Double read GetPM_TotalPrice;
+  end;
+
+implementation
+
+uses
+  ProjectData, UtilMethods, DB, Variants, PhaseData, DetailGLDm,
+  BillsMeasureDm, BillsTree, sdIDTree, PhasePayDm, DateUtils;
+
+{$R *.dfm}
+
+{ TProjectGLData }
+
+function TProjectGLData.CheckSameCode(ACode: Integer): Boolean;
+var
+  Rec: TsdDataRecord;
+begin
+  Rec := sddProjectGL.FindKey('idxCode', ACode);
+  Result := Assigned(Rec);
+end;
+
+constructor TProjectGLData.Create(AProjectData: TObject);
+begin
+  inherited Create(nil);
+  FProjectData := AProjectData;
+  FTempGLs := TList.Create;
+end;
+
+destructor TProjectGLData.Destroy;
+begin
+  FTempGLs.Free;
+  inherited;
+end;
+
+procedure TProjectGLData.LoadCurPhaseInfoPrice;
+const
+  sSelectSql = 'Select * From GLPrice Where PhaseID = %d';
+var
+  sSql: string;
+  vQuery: TADOQuery;
+
+  procedure LoadInfoPrice;
+  var
+    iRec: Integer;
+    Rec: TProjectGLRecord;
+  begin
+    for iRec := 0 to sddProjectGL.RecordCount - 1 do
+    begin
+      Rec := TProjectGLRecord(sddProjectGL.Records[iRec]);
+      if vQuery.Active and vQuery.Locate('GLID', Rec.ValueByName('ID').AsInteger, []) then
+      begin
+        Rec.InfoPrice.AsFloat := vQuery.FieldByName('InfoPrice').AsFloat;
+        Rec.InfoDate.AsString := vQuery.FieldByName('InfoDate').AsString;
+        Rec.DeltaPrice.AsFloat := vQuery.FieldByName('DeltaPrice').AsFloat;
+        Rec.ValidDeltaPrice.AsFloat := vQuery.FieldByName('ValidDeltaPrice').AsFloat;
+      end
+      else
+      begin
+        Rec.InfoPrice.AsFloat := 0;
+        Rec.InfoDate.AsString := '';
+        Rec.DeltaPrice.AsFloat := 0;
+        Rec.ValidDeltaPrice.AsFloat := 0;
+      end;
+    end;
+  end;
+
+begin
+  BeforeBatchOperation;
+  vQuery := TADOQuery.Create(nil);
+  try
+    vQuery.Connection := sdpProjectGL.Connection;
+    sSql := Format(sSelectSql, [TProjectData(FProjectData).PhaseIndex]);
+    vQuery.SQL.Clear;
+    vQuery.SQL.Add(sSql);
+    vQuery.Open;
+    LoadInfoPrice;
+  finally
+    vQuery.Free;
+    AfterBatchOperation;
+  end;
+end;
+
+procedure TProjectGLData.Open(AConnection: TADOConnection);
+begin
+  sdpProjectGL.Connection := AConnection;
+  sddProjectGL.Open;
+  if not Assigned(sddProjectGL.IndexList.FindByName('idxID')) then
+    sddProjectGL.AddIndex('idxID', 'ID');
+  if not Assigned(sddProjectGL.IndexList.FindByName('idxCode')) then
+    sddProjectGL.AddIndex('idxCode', 'Code');
+  sdvProjectGL.Open;
+  sdvProjectGL.IndexName := 'idxCode';
+  LoadCurPhaseInfoPrice;
+  LoadStagePM_CalcData;
+end;
+
+procedure TProjectGLData.Save;
+begin
+  sddProjectGL.Save;
+  if not TProjectData(FProjectData).PriceMarginReadOnly then
+    SaveGLPrice;
+  if not TProjectData(FProjectData).StageDataReadOnly then
+    SavePM_CurData;
+end;
+
+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' +
+               '  From ProjectGL';
+  sUpdateSql = 'Update GLPrice As G, ProjectGL As P'+
+               '    Set G.PM_PreQuantity = P.PM_PreQuantity, G.PM_PreTotalPrice = P.PM_PreTotalPrice'+
+               '  Where (G.PhaseID = %d) and (G.GLID = P.ID)';
+var
+  iPhaseID: Integer;
+  sSql: String;
+begin
+  iPhaseID := TProjectData(FProjectData).ProjProperties.PhaseCount;
+  sSql := Format(sDeleteSql, [iPhaseID]);
+  ExecuteSql(sSql);
+
+  sSql := Format(sInsertSql, [iPhaseID]);
+  ExecuteSql(sSql);
+
+  sSql := Format(sUpdateSql, [iPhaseID]);
+  ExecuteSql(sSql);
+end;
+
+procedure TProjectGLData.sddProjectGLAfterAddRecord(
+  ARecord: TsdDataRecord);
+begin
+  ARecord.ValueByName('ID').AsInteger := GetsdDataSetNewID(sddProjectGL, 'idxID');
+  ARecord.ValueByName('CreatePhaseID').AsInteger := TProjectData(FProjectData).ProjProperties.PhaseCount;
+end;
+
+procedure TProjectGLData.sddProjectGLBeforeValueChange(AValue: TsdValue;
+  const NewValue: Variant; var Allow: Boolean);
+var
+  Rec: TProjectGLRecord;
+begin
+  Rec := TProjectGLRecord(AValue.Owner);
+  if SameText(AValue.FieldName, 'Code') then
+  begin
+    if VarIsNull(NewValue) then
+    begin
+      DataSetErrorMessage(Allow, '编号不可为空。');
+      if Rec.Code.AsString = '' then
+        sddProjectGL.Remove(AValue.Owner);
+    end
+    else if CheckSameCode(NewValue) then
+    begin
+      DataSetErrorMessage(Allow, '编号不可重复。');
+      if Rec.Code.AsString = '' then
+        sddProjectGL.Remove(AValue.Owner);
+    end
+    else if CheckApplied(Rec.ID.AsInteger) then
+      DataSetErrorMessage(Allow, '工料已被应用,不可修改编号。');
+  end
+  else if not(SameText(AValue.FieldName, 'ID') or
+      SameText(AValue.FieldName, 'CreatePhaseID')) then
+  begin
+    if (Rec.Code.AsString = '') then
+    begin
+      DataSetErrorMessage(Allow, '编号不可为空,请先填写编号,再填写其他信息。');
+      sddProjectGL.Remove(AValue.Owner);
+    end;
+  end;
+end;
+
+procedure TProjectGLData.sddProjectGLAfterValueChanged(AValue: TsdValue);
+begin
+  if SameText(AValue.FieldName, 'BasePrice') or
+     SameText(AValue.FieldName, 'RiskRange') or
+     SameText(AValue.FieldName, 'InfoPrice') then
+  begin
+    CalculateDeltaPrice(TProjectGLRecord(AValue.Owner));
+    CalculatePM_Quantity(TProjectGLRecord(AValue.Owner));
+    CalculatePM_TotalPrice(TProjectGLRecord(AValue.Owner));
+    CalculateRelaBills(TProjectGLRecord(AValue.Owner));
+    TProjectData(FProjectData).PriceMarginBillsData.RefreshAllDetailBills;
+  end;
+end;
+
+procedure TProjectGLData.CalculateDeltaPrice(ARec: TProjectGLRecord);
+var
+  C0, Ci, r, DeltaC, RiskC, ValidDeltaC: Double;
+begin
+  C0 := ARec.BasePrice.AsFloat;
+  Ci := ARec.InfoPrice.AsFloat;
+  r := ARec.RiskRange.AsFloat;
+
+  DeltaC := Ci - C0;
+  RiskC := C0 * r / 100;
+  if (DeltaC > 0) and (DeltaC - RiskC > 0) then
+    ValidDeltaC := DeltaC - RiskC
+  else if (DeltaC < 0) and (DeltaC + RiskC < 0) then
+    ValidDeltaC := DeltaC + RiskC
+  else
+    ValidDeltaC := 0;
+
+  if DeltaC <> ARec.DeltaPrice.AsFloat then
+    ARec.DeltaPrice.AsFloat := PriceRoundTo(DeltaC);
+  if ValidDeltaC <> ARec.ValidDeltaPrice.AsFloat then
+    ARec.ValidDeltaPrice.AsFloat := PriceRoundTo(ValidDeltaC);
+end;
+
+procedure TProjectGLData.sdvProjectGLGetText(var Text: String;
+  ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
+  DisplayText: Boolean);
+
+  procedure GetDisplayText;
+  begin
+    if ((Pos('Price', AColumn.FieldName) > 0) or
+        (Pos('Quantity', AColumn.FieldName) > 0) or
+        SameText('RiskRange', AColumn.FieldName)) then
+    begin
+      if AValue.AsFloat = 0 then
+        Text := '';
+    end;
+  end;
+
+begin
+  if DisplayText then
+    GetDisplayText;
+end;
+
+procedure TProjectGLData.CalculateAll;
+begin
+  CalculatePrice;
+  CalculatePriceMargin;
+end;
+
+procedure TProjectGLData.ExecuteSql(const ASql: string);
+var
+  vQuery: TADOQuery;
+begin
+  vQuery := TADOQuery.Create(nil);
+  try
+    vQuery.Connection := sdpProjectGL.Connection;
+    vQuery.SQL.Add(ASql);
+    vQuery.ExecSQL;
+  finally
+    vQuery.Free;
+  end;
+end;
+
+function TProjectGLData.GetValidDeltaPrice(AID: Integer): Double;
+var
+  Rec: TProjectGLRecord;
+begin
+  Rec := TProjectGLRecord(sddProjectGL.FindKey('idxID', AID));
+  if Assigned(Rec) then
+    Result := Rec.ValidDeltaPrice.AsFloat
+  else
+    Result := 0;
+end;
+
+procedure TProjectGLData.CalculatePrice;
+var
+  iRec: Integer;
+begin
+  if TProjectData(FProjectData).PriceMarginReadOnly then Exit;
+
+  for iRec := 0 to sddProjectGL.RecordCount - 1 do
+    CalculateDeltaPrice(TProjectGLRecord(sddProjectGL.Records[iRec]));
+end;
+
+procedure TProjectGLData.CalculatePriceMargin;
+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]);
+    CalculatePM_Quantity(Rec);
+    CalculatePM_TotalPrice(Rec);
+  end;
+end;
+
+procedure TProjectGLData.CalculatePM_Quantity(ARec: TProjectGLRecord);
+var
+  vGLs: TList;
+  fQuantity: Double;
+  i: Integer;
+  GLRec: TsdDataRecord;
+  BillsNode: TBillsIDTreeNode;
+begin
+  vGLs := TList.Create;
+  try
+    fQuantity := 0;
+    with TProjectData(FProjectData).DetailGLData do
+      LoadProjectGL_DetailGLs(ARec.ValueByName('ID').AsInteger, vGLs);
+
+    for i := 0 to vGLs.Count - 1 do
+    begin
+      GLRec := TsdDataRecord(vGLs.Items[i]);
+      with TProjectData(FProjectData).BillsMeasureData do
+        BillsNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(GLRec.ValueByName('BillsID').AsInteger));
+      if Assigned(BillsNode.StageRec) then
+        fQuantity := fQuantity + BillsNode.StageRec.GatherQuantity.AsFloat * GLRec.ValueByName('Quantity').AsFloat;
+    end;
+
+    if fQuantity <> ARec.PM_Quantity.AsFloat then
+      ARec.PM_Quantity.AsFloat := fQuantity;
+  finally
+    vGLs.Free;
+  end;
+end;
+
+procedure TProjectGLData.CalculatePM_TotalPrice(ARec: TProjectGLRecord);
+var
+  fTotalPrice: Double;
+begin
+  fTotalPrice := ARec.ValidDeltaPrice.AsFloat * ARec.PM_Quantity.AsFloat;
+  if fTotalPrice <> ARec.PM_TotalPrice.AsFloat then
+    ARec.PM_TotalPrice.AsFloat := fTotalPrice;
+end;
+
+procedure TProjectGLData.sddProjectGLGetRecordClass(
+  var ARecordClass: TsdRecordClass);
+begin
+  ARecordClass := TProjectGLRecord;
+end;
+
+function TProjectGLData.GetPM_TotalPrice: Double;
+var
+  i: Integer;
+  Rec: TProjectGLRecord;
+begin
+  Result := 0;
+  for i := 0 to sddProjectGL.RecordCount - 1 do
+  begin
+    Rec := TProjectGLRecord(sddProjectGL.Records[i]);
+    Result := Result + Rec.PM_TotalPrice.AsFloat;
+  end;
+end;
+
+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'+
+               '  Where (G.PhaseID = %d) and (G.GLID = P.ID)';
+var
+  iStageIndex: Integer;
+  iPhaseCount: Integer;
+  sSql: string;
+begin
+  iStageIndex := TProjectData(FProjectData).PhaseData.StageIndex;
+  iPhaseCount := TProjectData(FProjectData).ProjProperties.PhaseCount;
+  sSql := Format(sUpdateSql, [iStageIndex, iStageIndex, iPhaseCount]);
+  ExecuteSql(sSql);
+end;
+
+procedure TProjectGLData.CalculateGL_PM(AGLID: Integer);
+var
+  Rec: TProjectGLRecord;
+begin
+  Rec := TProjectGLRecord(sddProjectGL.FindKey('idxID', AGLID));
+  if not Assigned(Rec) then Exit;
+
+  CalculatePM_Quantity(Rec);
+  CalculatePM_TotalPrice(Rec);
+end;
+
+procedure TProjectGLData.CalculateGLs_PM(ADetailGLs: TList);
+var
+  i: Integer;
+  DetailGLRec: TDetailGLRecord;
+begin
+  for i := 0 to ADetailGLs.Count - 1 do
+  begin
+    DetailGLRec := TDetailGLRecord(ADetailGLs.Items[i]);
+    CalculateGL_PM(DetailGLRec.GLID.AsInteger);
+  end;
+end;
+
+procedure TProjectGLData.CalculateRelaBills(ARec: TProjectGLRecord);
+var
+  iGL: Integer;
+  DetailGLRec: TDetailGLRecord;
+begin
+  LoadDetailGLs(ARec.ID.AsInteger);
+  for iGL := 0 to FTempGLs.Count - 1 do
+  begin
+    DetailGLRec := TDetailGLRecord(FTempGLs.Items[iGL]);
+    with TProjectData(FProjectData).PhaseData do
+      StageData.CalculatePriceMargin(DetailGLRec.BillsID.AsInteger);
+  end;
+  with TProjectData(FProjectData).PhaseData do
+    StageData.CalculatePriceMarginNode;
+end;
+
+procedure TProjectGLData.LoadDetailGLs(AGLID: Integer);
+begin
+  FTempGLs.Clear;
+  with TProjectData(FProjectData).DetailGLData do
+    LoadProjectGL_DetailGLs(AGLID, FTempGLs);
+end;
+
+function TProjectGLData.GetActive: Boolean;
+begin
+  Result := sddProjectGL.Active;
+end;
+
+procedure TProjectGLData.sdvProjectGLSetText(var Text: String;
+  ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
+  var Allow: Boolean);
+var
+  iPhaseID: Integer;
+begin
+  if SameText(AColumn.FieldName, 'Code') or
+     SameText(AColumn.FieldName, 'Name') or
+     SameText(AColumn.FieldName, 'Units') or
+     SameText(AColumn.FieldName, 'Specs') or
+     SameText(AColumn.FieldName, 'BasePrice') or
+     SameText(AColumn.FieldName, 'RiskRange') then
+  begin
+    iPhaseID := TProjectGLRecord(ARecord).LockedPhaseID.AsInteger;
+    if iPhaseID > 0 then
+      DataSetErrorMessage(Allow, Format('该工料在第%d期已进行调差计算,不可修改基础数据。', [iPhaseID]));
+  end;
+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'+
+               '  From GLPrice Where PhaseID = %d';
+var
+  sSql: string;
+  vQuery: TADOQuery;
+
+  procedure LoadPM_Calc;
+  var
+    iRec: Integer;
+    Rec: TProjectGLRecord;
+  begin
+    for iRec := 0 to sddProjectGL.RecordCount - 1 do
+    begin
+      Rec := TProjectGLRecord(sddProjectGL.Records[iRec]);
+      if vQuery.Active and vQuery.Locate('GLID', Rec.ValueByName('ID').AsInteger, []) then
+      begin
+        Rec.PM_Quantity.AsFloat := vQuery.FieldByName('PM_Quantity').AsFloat;
+        Rec.PM_TotalPrice.AsFloat := vQuery.FieldByName('PM_TotalPrice').AsFloat;
+      end
+      else
+      begin
+        Rec.PM_Quantity.AsFloat := 0;
+        Rec.PM_TotalPrice.AsFloat := 0;
+      end;
+    end;
+  end;
+
+begin
+  BeforeBatchOperation;
+  vQuery := TADOQuery.Create(nil);
+  try
+    vQuery.Connection := sdpProjectGL.Connection;
+    with TProjectData(FProjectData) do
+      sSql := Format(sSelectSql, [StageIndex, StageIndex, PhaseIndex]);
+    vQuery.SQL.Clear;
+    vQuery.SQL.Add(sSql);
+    vQuery.Open;
+    LoadPM_Calc;
+  finally
+    vQuery.Free;
+    AfterBatchOperation;
+  end;
+end;
+
+procedure TProjectGLData.AfterBatchOperation;
+begin                         
+  sddProjectGL.EndUpdate;
+  sddProjectGL.EnableControls;
+  sddProjectGL.BeforeValueChange := sddProjectGLBeforeValueChange;
+  sddProjectGL.AfterValueChanged := sddProjectGLAfterValueChanged;
+end;
+
+procedure TProjectGLData.BeforeBatchOperation;
+begin
+  sddProjectGL.AfterValueChanged := nil;
+  sddProjectGL.BeforeValueChange := nil;
+  sddProjectGL.DisableControls;         
+  sddProjectGL.BeginUpdate;
+end;
+
+function TProjectGLData.CheckApplied(AGLID: Integer): Boolean;
+begin
+  LoadDetailGLs(AGLID);
+  Result := FTempGLs.Count > 0;
+end;
+
+procedure TProjectGLData.sddProjectGLBeforeDeleteRecord(
+  ARecord: TsdDataRecord; var Allow: Boolean);
+begin
+  Allow := not CheckApplied(ARecord.ValueByName('ID').AsInteger);
+  if not Allow then
+    ErrorMessage('工料已被应用,不可删除。');
+end;
+
+end.

+ 102 - 444
DataModules/ReportMemoryDm/rmGcl_XmjBillsDm.pas

@@ -3,7 +3,8 @@ unit rmGcl_XmjBillsDm;
 interface
 
 uses
-  SysUtils, Classes, ProjectData, DB, DBClient, sdIDTree, sdDB;
+  SysUtils, Classes, ProjectData, DB, DBClient, sdIDTree, sdDB,
+  GclBillsGatherModel;
 
 type
   {-----------------------------
@@ -25,70 +26,6 @@ type
   -----------------------------}
   TGXType = (gxtTopGcl, gxtFlowGcl, gxtWithoutXmj);
 
-  TXmjNode = class
-  private
-    FCode: string;
-    FName: string;
-    FUnits: string;
-
-    FOrgQuantity: Double;
-    FOrgTotalPrice: Double;
-    FMisQuantity: Double;
-    FMisTotalPrice: Double;
-    FOthQuantity: Double;
-    FOthTotalPrice: Double;
-
-    FQuantity: Double;
-    FTotalPrice: Double;
-
-    FDrawingCode: string;
-    FPeg: string;
-    FNameDanWei: string;
-    FNameFenBu: string;
-    FNameFenXiang: string;
-    FNameUnit: string;
-    FPosition: string;
-  end;
-
-  TGclNode = class
-  private
-    FB_Code: string;
-    FIndexCode: string;
-    FName: string;
-    FUnits: string;
-    FPrice: Double;
-    FNewPrice: Double;
-
-    FDealQuantity: Double;
-    FDealTotalPrice: Double;
-
-    FOrgQuantity: Double;
-    FOrgTotalPrice: Double;
-    FMisQuantity: Double;
-    FMisTotalPrice: Double;
-    FOthQuantity: Double;
-    FOthTotalPrice: Double;
-
-    FQuantity: Double;
-    FTotalPrice: Double;
-
-    FXmjList: TList;
-
-    function FindXmjNode(ANode: TsdIDTreeNode): TXmjNode;
-    function NewXmjNode(ANode, APeg: TsdIDTreeNode): TXmjNode;
-
-    function GetXmjCount: Integer;
-    function GetXmjNode(AIndex: Integer): TXmjNode;
-  public
-    constructor Create;
-    destructor Destroy; override;
-
-    function AddXmjNode(ANode, APeg: TsdIDTreeNode): TXmjNode;
-
-    property XmjCount: Integer read GetXmjCount;
-    property XmjNode[AIndex: Integer]: TXmjNode read GetXmjNode;
-  end;
-
   TrmGcl_XmjBillsData = class(TDataModule)
     cdsGcl: TClientDataSet;
     cdsGclIndexCode: TStringField;
@@ -120,27 +57,22 @@ type
     cdsGclOthTotalPrice: TFloatField;
   private
     FProjectData: TProjectData;
-    FGclList: TList;
     FIndex: Integer;
     FGXType: TGXType;
 
     procedure BeforeOperation;
     procedure AfterOperation;
 
-    procedure AddRelaLeafXmj(AGclNode: TGclNode; ARec: TsdDataRecord);
-    function GetGclNode(ARec: TsdDataRecord): TGclNode;
-    procedure FilterGclBills(ANode: TsdIDTreeNode);
-    procedure FilterBills(ANode: TsdIDTreeNode);
-    procedure FilterDealBills;
-
     procedure WriteXmjNode(AGclNode: TGclNode);
     procedure WriteGclNode(AGclNode: TGclNode);
-    procedure WriteTopGclTypeData;
+    procedure WriteTopGclTypeData(AGcls: TList);
 
     procedure WriteFlowGclNode(AGclNode: TGclNode);
-    procedure WriteFlowGclTypeData;
+    procedure WriteFlowGclTypeData(AGcls: TList);
+
+    procedure WriteData(AGcls: TList);
 
-    procedure WriteData;
+    procedure GatherData;
   public
     function AssignData(AProjectData: TProjectData; AGXType: TGXType): TDataSet;
   end;
@@ -152,212 +84,10 @@ uses
 
 {$R *.dfm}
 
-{ TGclNode }
-
-constructor TGclNode.Create;
-begin
-  FXmjList := TList.Create;
-end;
-
-destructor TGclNode.Destroy;
-begin
-  ClearObjects(FXmjList);
-  FXmjList.Free;
-  inherited;
-end;
-
-function TGclNode.FindXmjNode(ANode: TsdIDTreeNode): TXmjNode;
-var
-  i: Integer;
-begin
-  Result := nil;
-  for i := 0 to XmjCount - 1 do
-  begin
-    if SameText(XmjNode[i].FCode, ANode.Rec.ValueByName('Code').AsString) and
-       SameText(XmjNode[i].FName, ANode.Rec.ValueByName('Name').AsString) and
-       SameText(XmjNode[i].FUnits, ANode.Rec.ValueByName('Units').AsString) then
-    begin
-      Result := XmjNode[i];
-      Break;
-    end;
-  end;
-end;
-
-function TGclNode.AddXmjNode(
-  ANode, APeg: TsdIDTreeNode): TXmjNode;
-begin
-  Result := FindXmjNode(ANode);
-  if not Assigned(Result) then
-    Result := NewXmjNode(ANode, APeg);
-end;
-
-function TGclNode.GetXmjCount: Integer;
-begin
-  Result := FXmjList.Count;
-end;
-
-function TGclNode.GetXmjNode(AIndex: Integer): TXmjNode;
-begin
-  Result := TXmjNode(FXmjList.Items[AIndex]);
-end;
-
-function TGclNode.NewXmjNode(
-  ANode, APeg: TsdIDTreeNode): TXmjNode;
-
-  function GetPegName(APegNode: TsdIDTreeNode): string;
-  begin
-    if Assigned(APegNode) then
-      Result := APegNode.Rec.ValueByName('Name').AsString
-    else
-      Result := '';
-  end;
-
-  // 取树结构的第ALevel层节点的名称(level从0开始)
-  function GetNameByLevel(ANode: TsdIDTreeNode; ALevel: Integer): string;
-  begin
-    Result := '';
-    if not Assigned(ANode) then Exit;
-    if ANode.Level = ALevel then
-      Result := ANode.Rec.ValueByName('Name').AsString
-    else if ANode.Level > ALevel then
-      Result := GetNameByLevel(ANode.Parent, ALevel);
-  end;
-
-  function GetNameDanWei(ANode: TsdIDTreeNode): string;
-  begin
-    // 取树结构的第二层节点的名称
-    Result := GetNameByLevel(ANode, 1);
-  end;
-
-  // ANode为计量单元节点,APegNode为桩号节点
-  function GetNameFenBu(ANode, APegNode: TsdIDTreeNode): string;
-  var
-    vCurNode: TsdIDTreeNode;
-  begin
-    // 如果计量单元节点的名称为桩号(转化为判断计量单元节点与桩号节点为同一个)
-    if not Assigned(APegNode) or (ANode.ID = APegNode.ID) then
-      // 取树结构的第三层节点的名称
-      Result := GetNameByLevel(ANode, 2)
-    // 否则,取桩号节点的子节点的名称
-    else
-    begin
-      vCurNode := ANode;
-      while vCurNode.Level > APegNode.Level + 1 do
-        vCurNode := vCurNode.Parent;
-      Result := vCurNode.Rec.ValueByName('Name').AsString;
-    end;
-  end;
-
-  function GetNameFenXiang(ANode, APegNode: TsdIDTreeNode): string;
-  var
-    iTopLevel: Integer;
-    vCurNode: TsdIDTreeNode;
-  begin
-    if Assigned(APegNode) then
-    begin
-      iTopLevel := 3;
-      if APegNode.ID <> ANode.ID then
-        iTopLevel := APegNode.Level + 2;
-      Result := '';
-      vCurNode := ANode.Parent;
-      while vCurNode.Level >= iTopLevel do
-      begin
-        Result := vCurNode.Rec.ValueByName('Name').AsString + ';' + Result;
-        vCurNode := vCurNode.Parent;
-      end;
-    end
-    else
-      Result := GetNameByLevel(ANode, 3);
-  end;
-
-  function GetNameUnit(ANode: TsdIDTreeNode): string;
-  begin
-    Result := ANode.Rec.ValueByName('Name').AsString;
-  end;
-
-  function GetDrawingCode(ANode: TsdIDTreeNode): string;
-  begin
-    Result := '';
-    if not Assigned(ANode) then Exit;
-    Result := ANode.Rec.ValueByName('DrawingCode').AsString;
-    if Result = '' then
-      Result := GetDrawingCode(ANode.Parent);
-  end;
-
-  function GetPosition(ANode, APegNode: TsdIDTreeNode): string;
-  begin
-    // 如果计量单元节点的名称为桩号(转化为判断计量单元节点与桩号节点为同一个)
-    if not Assigned(APegNode) or (ANode.ID = APegNode.ID) then
-      // 取分部工程
-      Result := GetNameFenXiang(ANode, APegNode)
-    // 反之,取分项工程+计量单元
-    else
-      Result := GetNameFenXiang(ANode, APegNode) + GetNameUnit(ANode);
-  end;
-
-begin
-  Result := TXmjNode.Create;
-  FXmjList.Add(Result);
-  Result.FCode := ANode.Rec.ValueByName('Code').AsString;
-  Result.FName := ANode.Rec.ValueByName('Name').AsString;
-  Result.FUnits := ANode.Rec.ValueByName('Units').AsString;
-  Result.FPeg := GetPegName(APeg);
-  Result.FNameDanWei := GetNameDanWei(ANode);
-  Result.FNameFenBu := GetNameFenBu(ANode, APeg);
-  Result.FNameFenXiang := GetNameFenXiang(ANode, APeg);
-  Result.FNameUnit := GetNameUnit(ANode);
-  Result.FPosition := GetPosition(ANode, APeg);
-  Result.FDrawingCode := GetDrawingCode(ANode);
-end;
-
 { TrmGclBillsData }
 
-procedure TrmGcl_XmjBillsData.AddRelaLeafXmj(AGclNode: TGclNode;
-  ARec: TsdDataRecord);
-
-  function GetFirstXmjParent(AID: Integer): TsdIDTreeNode;
-  begin
-    with TProjectData(FProjectData).BillsCompileData do
-      Result := BillsCompileTree.FindNode(AID);
-    while Assigned(Result) and (Result.Rec.ValueByName('B_Code').AsString <> '') do
-      Result := Result.Parent;
-  end;
-
-  function GetPegNode(ANode: TsdIDTreeNode): TsdIDTreeNode;
-  begin
-    Result := nil;
-    if not Assigned(ANode) then Exit;
-    if CheckPeg(ANode.Rec.ValueByName('Name').AsString) then
-      Result := ANode
-    else
-      Result := GetPegNode(ANode.Parent);
-  end;
-
-var
-  vNode, vPeg: TsdIDTreeNode;
-  XmjNode: TXmjNode;
-begin
-  vNode := GetFirstXmjParent(ARec.ValueByName('ID').AsInteger);
-  if not Assigned(vNode) then Exit;
-
-  vPeg := GetPegNode(vNode);
-  XmjNode := AGclNode.AddXmjNode(vNode, vPeg);
-
-  XmjNode.FOrgQuantity := XmjNode.FOrgQuantity + ARec.ValueByName('OrgQuantity').AsFloat;
-  XmjNode.FOrgTotalPrice := XmjNode.FOrgTotalPrice + ARec.ValueByName('OrgTotalPrice').AsFloat;
-  XmjNode.FMisQuantity := XmjNode.FMisQuantity + ARec.ValueByName('MisQuantity').AsFloat;
-  XmjNode.FMisTotalPrice := XmjNode.FMisTotalPrice + ARec.ValueByName('MisTotalPrice').AsFloat;
-  XmjNode.FOthQuantity := XmjNode.FOthQuantity + ARec.ValueByName('OthQuantity').AsFloat;
-  XmjNode.FOthTotalPrice := XmjNode.FOthTotalPrice + ARec.ValueByName('OthTotalPrice').AsFloat;
-
-  XmjNode.FQuantity := XmjNode.FQuantity + ARec.ValueByName('Quantity').AsFloat;
-  XmjNode.FTotalPrice := XmjNode.FTotalPrice + ARec.ValueByName('TotalPrice').AsFloat;
-end;
-
 procedure TrmGcl_XmjBillsData.AfterOperation;
 begin
-  ClearObjects(FGclList);
-  FGclList.Free;
   if FGXType = gxtWithoutXmj then
   begin
     cdsGcl.Filter := 'B_Code <> ''''';
@@ -369,13 +99,11 @@ end;
 function TrmGcl_XmjBillsData.AssignData(
   AProjectData: TProjectData; AGXType: TGXType): TDataSet;
 begin
+  FProjectData := AProjectData;
   FGXType := AGXType;
   BeforeOperation;
   try
-    FProjectData := AProjectData;
-    FilterBills(AProjectData.BillsCompileData.BillsCompileTree.FirstNode);
-    FilterDealBills;
-    WriteData;
+    GatherData;
   finally
     AfterOperation;
     Result := cdsGcl;
@@ -384,154 +112,82 @@ end;
 
 procedure TrmGcl_XmjBillsData.BeforeOperation;
 begin
-  FGclList := TList.Create;
   cdsGcl.Active := True;
   cdsGcl.Filtered := False;
   cdsGcl.EmptyDataSet;
 end;
 
-procedure TrmGcl_XmjBillsData.FilterBills(ANode: TsdIDTreeNode);
-begin
-  if not Assigned(ANode) then Exit;
-  if ANode.HasChildren then
-    FilterBills(ANode.FirstChild)
-  else
-    FilterGclBills(ANode);
-  FilterBills(ANode.NextSibling);
-end;
-
-procedure TrmGcl_XmjBillsData.FilterDealBills;
+procedure TrmGcl_XmjBillsData.GatherData;
 var
-  iIndex: Integer;
-  Rec: TsdDataRecord;
-  GclNode: TGclNode;
+  vGather: TGclGatherModel;
 begin
-  with FProjectData.DealBillsData do
-    for iIndex := 0 to sddDealBills.RecordCount - 1 do
-    begin
-      Rec := sddDealBills.Records[iIndex];
-      GclNode := GetGclNode(Rec);
-      GclNode.FDealQuantity := GclNode.FDealQuantity + Rec.ValueByName('Quantity').AsFloat;
-      GclNode.FDealTotalPrice := GclNode.FDealTotalPrice + Rec.ValueByName('TotalPrice').AsFloat;
-    end;
-end;
-
-procedure TrmGcl_XmjBillsData.FilterGclBills(ANode: TsdIDTreeNode);
-var
-  Rec: TsdDataRecord;
-  GclNode: TGclNode;
-begin
-  if not Assigned(ANode) then Exit;
-  Rec := ANode.Rec;
-  if Rec.ValueByName('B_Code').AsString = '' then Exit;
-
-  GclNode := GetGclNode(Rec);
-
-  GclNode.FOrgQuantity := GclNode.FOrgQuantity + Rec.ValueByName('OrgQuantity').AsFloat;
-  GclNode.FOrgTotalPrice := GclNode.FOrgTotalPrice + Rec.ValueByName('OrgTotalPrice').AsFloat;
-  GclNode.FMisQuantity := GclNode.FMisQuantity + Rec.ValueByName('MisQuantity').AsFloat;
-  GclNode.FMisTotalPrice := GclNode.FMisTotalPrice + Rec.ValueByName('MisTotalPrice').AsFloat;
-  GclNode.FOthQuantity := GclNode.FOthQuantity + Rec.ValueByName('OthQuantity').AsFloat;
-  GclNode.FOthTotalPrice := GclNode.FOthTotalPrice + Rec.ValueByName('OthTotalPrice').AsFloat;
-
-  GclNode.FQuantity := GclNode.FQuantity + Rec.ValueByName('Quantity').AsFloat;
-  GclNode.FTotalPrice := GclNode.FTotalPrice + Rec.ValueByName('TotalPrice').AsFloat;
-  AddRelaLeafXmj(GclNode, Rec);
-end;
-
-function TrmGcl_XmjBillsData.GetGclNode(ARec: TsdDataRecord): TGclNode;
-
-  function CreateGclNode: TGclNode;
-  begin
-    Result := TGclNode.Create;
-    FGclList.Add(Result);
-    Result.FB_Code := ARec.ValueByName('B_Code').AsString;
-    Result.FIndexCode := B_CodeToIndexCode(ARec.ValueByName('B_Code').AsString);
-    Result.FName := Trim(ARec.ValueByName('Name').AsString);
-    Result.FUnits := ARec.ValueByName('Units').AsString;
-    Result.FPrice := ARec.ValueByName('Price').AsFloat;
-    if Assigned(ARec.ValueByName('NewPrice')) then
-      Result.FNewPrice := ARec.ValueByName('NewPrice').AsFloat
-    else
-      Result.FNewPrice := 0;
-  end;
-
-var
-  I: Integer;
-  GclNode: TGclNode;
-begin
-  Result := nil;
-  for I := 0 to FGclList.Count - 1 do
-  begin
-    GclNode := TGclNode(FGclList.Items[I]);
-    if SameText(GclNode.FB_Code, ARec.ValueByName('B_Code').AsString) and
-        SameText(GclNode.FName, Trim(ARec.ValueByName('Name').AsString)) and
-        SameText(GclNode.FUnits, ARec.ValueByName('Units').AsString) and
-        (GclNode.FPrice = ARec.ValueByName('Price').AsFloat) then
-    begin
-      Result := GclNode;
-      Break;
-    end;
+  vGather := TGclGatherModel.Create(FProjectData);
+  try
+    vGather.GatherDeal := True;
+    vGather.WriteGatherData := WriteData;
+    vGather.Execute;
+  finally
+    vGather.Free;
   end;
-  if not Assigned(Result) then
-    Result := CreateGclNode;
 end;
 
-procedure TrmGcl_XmjBillsData.WriteData;
+procedure TrmGcl_XmjBillsData.WriteData(AGcls: TList);
 begin
   case FGXType of
-    gxtTopGcl, gxtWithoutXmj: WriteTopGclTypeData;
-    gxtFlowGcl: WriteFlowGclTypeData;
+    gxtTopGcl, gxtWithoutXmj: WriteTopGclTypeData(AGcls);
+    gxtFlowGcl: WriteFlowGclTypeData(AGcls);
   end;
 end;
 
 procedure TrmGcl_XmjBillsData.WriteFlowGclNode(AGclNode: TGclNode);
 var
   i: Integer;
-  XmjNode: TXmjNode;
+  DetailGcl: TDetailGclNode;
 begin
-  for i := 0 to AGclNode.XmjCount - 1 do
+  for i := 0 to AGclNode.DetailGclCount - 1 do
   begin
-    XmjNode := AGclNode.XmjNode[i];
+    DetailGcl := AGclNode.DetailGcl[i];
     cdsGcl.Append;
-    cdsGclIndexCode.AsString := AGclNode.FIndexCode;
+    cdsGclIndexCode.AsString := AGclNode.IndexCode;
     cdsGclIndexID.AsInteger := i+1;
 
-    cdsGclB_Code.AsString := AGclNode.FB_Code;
-    cdsGclName.AsString := AGclNode.FName;
-    cdsGclUnits.AsString := AGclNode.FUnits;
-    cdsGclPrice.AsFloat := AGclNode.FPrice;
-    cdsGclNewPrice.AsFloat := AGclNode.FNewPrice;
-
-    cdsGclCode.AsString := XmjNode.FCode;
-    cdsGclPeg.AsString := XmjNode.FPeg;
-    cdsGclNameDanWei.AsString := XmjNode.FNameDanWei;
-    cdsGclNameFenBu.AsString := XmjNode.FNameFenBu;
-    cdsGclNameFenXiang.AsString := XmjNode.FNameFenXiang;
-    cdsGclNameUnit.AsString := XmjNode.FNameUnit;
-    cdsGclDrawingCode.AsString := XmjNode.FDrawingCode;
-    cdsGclPosition.AsString := XmjNode.FPosition;
-
-    cdsGclOrgQuantity.AsFloat := XmjNode.FOrgQuantity;
-    cdsGclOrgTotalPrice.AsFloat := XmjNode.FOrgTotalPrice;
-    cdsGclMisQuantity.AsFloat := XmjNode.FMisQuantity;
-    cdsGclMisTotalPrice.AsFloat := XmjNode.FMisTotalPrice;
-    cdsGclOthQuantity.AsFloat := XmjNode.FOthQuantity;
-    cdsGclOthTotalPrice.AsFloat := XmjNode.FOthTotalPrice;
-
-    cdsGclQuantity.AsFloat := XmjNode.FQuantity;
-    cdsGclTotalPrice.AsFloat := XmjNode.FTotalPrice;
+    cdsGclB_Code.AsString := AGclNode.B_Code;
+    cdsGclName.AsString := AGclNode.Name;
+    cdsGclUnits.AsString := AGclNode.Units;
+    cdsGclPrice.AsFloat := AGclNode.Price;
+
+    if Assigned(DetailGcl.LeafXmj) then
+    begin
+      cdsGclCode.AsString := DetailGcl.LeafXmj.XmjCode;
+      cdsGclPeg.AsString := DetailGcl.LeafXmj.Peg;
+      cdsGclNameDanWei.AsString := DetailGcl.LeafXmj.NameDanWei;
+      cdsGclNameFenBu.AsString := DetailGcl.LeafXmj.NameFenBu;
+      cdsGclNameFenXiang.AsString := DetailGcl.LeafXmj.NameFenXiang;
+      cdsGclNameUnit.AsString := DetailGcl.LeafXmj.NameUnit;
+      cdsGclDrawingCode.AsString := DetailGcl.LeafXmj.DrawingCode;
+      cdsGclPosition.AsString := DetailGcl.LeafXmj.Position;
+    end;
+
+    cdsGclOrgQuantity.AsFloat := DetailGcl.OrgQuantity;
+    cdsGclOrgTotalPrice.AsFloat := DetailGcl.OrgTotalPrice;
+    cdsGclMisQuantity.AsFloat := DetailGcl.MisQuantity;
+    cdsGclMisTotalPrice.AsFloat := DetailGcl.MisTotalPrice;
+    cdsGclOthQuantity.AsFloat := DetailGcl.OthQuantity;
+    cdsGclOthTotalPrice.AsFloat := DetailGcl.OthTotalPrice;
+
+    cdsGclQuantity.AsFloat := DetailGcl.Quantity;
+    cdsGclTotalPrice.AsFloat := DetailGcl.TotalPrice;
     cdsGcl.Post;
   end;
 end;
 
-procedure TrmGcl_XmjBillsData.WriteFlowGclTypeData;
+procedure TrmGcl_XmjBillsData.WriteFlowGclTypeData(AGcls: TList);
 var
   i: Integer;
 begin
   FIndex := 0;
-  for i := 0 to FGclList.Count - 1 do
-    WriteFlowGclNode(TGclNode(FGclList.Items[i]));
+  for i := 0 to AGcls.Count - 1 do
+    WriteFlowGclNode(TGclNode(AGcls.Items[i]));
 end;
 
 procedure TrmGcl_XmjBillsData.WriteGclNode(
@@ -540,72 +196,74 @@ var
   i: Integer;
 begin
   cdsGcl.Append;
-  cdsGclIndexCode.AsString := AGclNode.FIndexCode;
+  cdsGclIndexCode.AsString := AGclNode.IndexCode;
   cdsGclIndexID.AsInteger := 0;
 
-  cdsGclB_Code.AsString := AGclNode.FB_Code;
-  cdsGclName.AsString := AGclNode.FName;
-  cdsGclUnits.AsString := AGclNode.FUnits;
-
-  cdsGclPrice.AsFloat := AGclNode.FPrice;
-  cdsGclNewPrice.AsFloat := AGclNode.FNewPrice;
-
-  cdsGclQuantity.AsFloat := AGclNode.FQuantity;
-  cdsGclTotalPrice.AsFloat := AGclNode.FTotalPrice;
-  cdsGclDealQuantity.AsFloat := AGclNode.FDealQuantity;
-  cdsGclDealTotalPrice.AsFloat := AGclNode.FDealTotalPrice;
-  cdsGclDifferQuantity.AsFloat := AGclNode.FDealQuantity - AGclNode.FQuantity;
-  cdsGclDifferTotalPrice.AsFloat := AGclNode.FDealTotalPrice - AGclNode.FTotalPrice;
-
-  cdsGclOrgQuantity.AsFloat := AGclNode.FOrgQuantity;
-  cdsGclOrgTotalPrice.AsFloat := AGclNode.FOrgTotalPrice;
-  cdsGclMisQuantity.AsFloat := AGclNode.FMisQuantity;
-  cdsGclMisTotalPrice.AsFloat := AGclNode.FMisTotalPrice;
-  cdsGclOthQuantity.AsFloat := AGclNode.FOthQuantity;
-  cdsGclOthTotalPrice.AsFloat := AGclNode.FOthTotalPrice;
+  cdsGclB_Code.AsString := AGclNode.B_Code;
+  cdsGclName.AsString := AGclNode.Name;
+  cdsGclUnits.AsString := AGclNode.Units;
+  cdsGclPrice.AsFloat := AGclNode.Price;
+
+  cdsGclQuantity.AsFloat := AGclNode.Quantity;
+  cdsGclTotalPrice.AsFloat := AGclNode.TotalPrice;
+  cdsGclDealQuantity.AsFloat := AGclNode.DealQuantity;
+  cdsGclDealTotalPrice.AsFloat := AGclNode.DealTotalPrice;
+  cdsGclDifferQuantity.AsFloat := AGclNode.DealQuantity - AGclNode.Quantity;
+  cdsGclDifferTotalPrice.AsFloat := AGclNode.DealTotalPrice - AGclNode.TotalPrice;
+
+  cdsGclOrgQuantity.AsFloat := AGclNode.OrgQuantity;
+  cdsGclOrgTotalPrice.AsFloat := AGclNode.OrgTotalPrice;
+  cdsGclMisQuantity.AsFloat := AGclNode.MisQuantity;
+  cdsGclMisTotalPrice.AsFloat := AGclNode.MisTotalPrice;
+  cdsGclOthQuantity.AsFloat := AGclNode.OthQuantity;
+  cdsGclOthTotalPrice.AsFloat := AGclNode.OthTotalPrice;
   cdsGcl.Post;
   WriteXmjNode(AGclNode);
 end;
 
-procedure TrmGcl_XmjBillsData.WriteTopGclTypeData;
+procedure TrmGcl_XmjBillsData.WriteTopGclTypeData(AGcls: TList);
 var
   i: Integer;
 begin
   FIndex := 0;
-  for i := 0 to FGclList.Count - 1 do
-    WriteGclNode(TGclNode(FGclList.Items[i]));
+  for i := 0 to AGcls.Count - 1 do
+    WriteGclNode(TGclNode(AGcls.Items[i]));
 end;
 
 procedure TrmGcl_XmjBillsData.WriteXmjNode(
   AGclNode: TGclNode);
 var
   i: Integer;
-  XmjNode: TXmjNode;
+  DetailGcl: TDetailGclNode;
 begin
-  for i := 0 to AGclNode.XmjCount - 1 do
+  for i := 0 to AGclNode.DetailGclCount - 1 do
   begin
-    XmjNode := AGclNode.XmjNode[i];
+    DetailGcl := AGclNode.DetailGcl[i];
     cdsGcl.Append;
-    cdsGclIndexCode.AsString := AGclNode.FIndexCode;
+    cdsGclIndexCode.AsString := AGclNode.IndexCode;
     cdsGclIndexID.AsInteger := FIndex;
-    cdsGclCode.AsString := XmjNode.FCode;
-    cdsGclPeg.AsString := XmjNode.FPeg;
-    cdsGclNameDanWei.AsString := XmjNode.FNameDanWei;
-    cdsGclNameFenBu.AsString := XmjNode.FNameFenBu;
-    cdsGclNameFenXiang.AsString := XmjNode.FNameFenXiang;
-    cdsGclNameUnit.AsString := XmjNode.FNameUnit;
-    cdsGclPosition.AsString := XmjNode.FPosition;
-    cdsGclDrawingCode.AsString := XmjNode.FDrawingCode;
-
-    cdsGclOrgQuantity.AsFloat := XmjNode.FOrgQuantity;
-    cdsGclOrgTotalPrice.AsFloat := XmjNode.FOrgTotalPrice;
-    cdsGclMisQuantity.AsFloat := XmjNode.FMisQuantity;
-    cdsGclMisTotalPrice.AsFloat := XmjNode.FMisTotalPrice;
-    cdsGclOthQuantity.AsFloat := XmjNode.FOthQuantity;
-    cdsGclOthTotalPrice.AsFloat := XmjNode.FOthTotalPrice;
-
-    cdsGclQuantity.AsFloat := XmjNode.FQuantity;
-    cdsGclTotalPrice.AsFloat := XmjNode.FTotalPrice;
+
+    if Assigned(DetailGcl.LeafXmj) then
+    begin
+      cdsGclCode.AsString := DetailGcl.LeafXmj.XmjCode;
+      cdsGclPeg.AsString := DetailGcl.LeafXmj.Peg;
+      cdsGclNameDanWei.AsString := DetailGcl.LeafXmj.NameDanWei;
+      cdsGclNameFenBu.AsString := DetailGcl.LeafXmj.NameFenBu;
+      cdsGclNameFenXiang.AsString := DetailGcl.LeafXmj.NameFenXiang;
+      cdsGclNameUnit.AsString := DetailGcl.LeafXmj.NameUnit;
+      cdsGclPosition.AsString := DetailGcl.LeafXmj.Position;
+      cdsGclDrawingCode.AsString := DetailGcl.LeafXmj.DrawingCode;
+    end;
+
+    cdsGclOrgQuantity.AsFloat := DetailGcl.OrgQuantity;
+    cdsGclOrgTotalPrice.AsFloat := DetailGcl.OrgTotalPrice;
+    cdsGclMisQuantity.AsFloat := DetailGcl.MisQuantity;
+    cdsGclMisTotalPrice.AsFloat := DetailGcl.MisTotalPrice;
+    cdsGclOthQuantity.AsFloat := DetailGcl.OthQuantity;
+    cdsGclOthTotalPrice.AsFloat := DetailGcl.OthTotalPrice;
+
+    cdsGclQuantity.AsFloat := DetailGcl.Quantity;
+    cdsGclTotalPrice.AsFloat := DetailGcl.TotalPrice;
     cdsGcl.Post;
     Inc(FIndex);
   end;

+ 6 - 0
DataModules/StageDm.dfm

@@ -146,6 +146,12 @@ object StageData: TStageData
       6450726F636573734E616D65090001044E616D6506084D61726B4D656D6F0946
       69656C644E616D6506084D61726B4D656D6F0844617461547970650218084461
       746153697A6503FF000549734B6579080F4E65656450726F636573734E616D65
+      090001044E616D650610504D5F507265546F74616C5072696365094669656C64
+      4E616D650610504D5F507265546F74616C507269636508446174615479706502
+      06084461746153697A6502080549734B6579080F4E65656450726F636573734E
+      616D65090001044E616D65060D504D5F546F74616C5072696365094669656C64
+      4E616D65060D504D5F546F74616C507269636508446174615479706502060844
+      61746153697A6502080549734B6579080F4E65656450726F636573734E616D65
       090000}
   end
 end

+ 224 - 22
DataModules/StageDm.pas

@@ -30,16 +30,30 @@ type
 
     procedure UpdateParentRecord(ABillsID: Integer; ATotalPrice: Double; const AFieldName: string);
     procedure UpdateComplete(ABillsID: Integer; AQuantity, ATotalPrice: Double);
+
+    // 向父项增量--PM_TotalPrice
+    procedure UpdateParentPriceMargin(ABillsID: Integer; ADiffer: Double);
+    // 向价差调整节点增量--GatherTotalPrice
+    procedure UpdatePriceMarginNode(ADiffer: Double);
+    // 重新计算相关的项目工料的价差数据
+    procedure UpdateProjectGL(ABillsID: Integer);
+
     procedure CalculateDeal(ABillsID: Integer);
     procedure CalculateQuantityChange(ABillsID: Integer);
     procedure CalculatePriceChange(ABillsID: Integer);
 
     procedure CalculateParent(ANode: TBillsIDTreeNode);
     procedure CalculateLeaf(ANode: TBillsIDTreeNode);
+    procedure CalculateSpecialLeaf(ANode: TBillsIDTreeNode);
 
     function GetTotalPrice(ABillsID, AType, AStageIndex: Integer): Double;
 
+<<<<<<< HEAD
     function GetCalcType(ABillsID: Integer): Integer;
+=======
+    function GetBillsUnitPriceMargin(ABillsID: Integer): Double;
+
+>>>>>>> 3.1.3.3
     function GetBillsPrice(ABillsID: Integer): Double;
     function GetBillsNewPrice(ABillsID: Integer): Double;
     function GetBillsPriceDiffer(ABillsID: Integer): Double;
@@ -64,6 +78,10 @@ type
     procedure Open(AConnection: TADOConnection);
     procedure Save;
 
+    // 计算任一清单节点的价差金额,并增量汇总至父项
+    procedure CalculatePriceMargin(ABillsID: Integer);
+    // 计算材料调差节点
+    procedure CalculatePriceMarginNode;
     procedure CalculateNode(ANode: TsdIDTreeNode);
     procedure CalculateAll;
 
@@ -76,7 +94,10 @@ type
     procedure ReCalculate(ABillsID: Integer);
     procedure UpdateBGLInfo(ARec: TsdDataRecord; const AType: string);
 
+    // 查找
     function StageRecord(ABillsID: Integer): TStageRecord;
+    // 查找,如未找到则新增
+    function StageRecordWithAdd(ABillsID: Integer): TStageRecord;
 
     // 将Bills表中存的累计计量数据拷贝至截止本期计量、截止上期计量,除新增一期计量外不可调用
     procedure CopyPrePhaseData;
@@ -117,7 +138,8 @@ implementation
 
 uses
   ProjectData, BillsDm, PhaseData, Math, BGLDm, BillsMeasureDm,
-  UtilMethods, ConditionalDefines, FormulaCalc;
+  UtilMethods, ConditionalDefines, FormulaCalc, DetailGLDm, ConstUnit,
+  ProjectGLDm;
 
 {$R *.dfm}
 
@@ -183,7 +205,13 @@ begin
   UpdateComplete(ABillsID, fQtyDiffer, fTPDiffer);
   if TPhaseData(FPhaseData).IsLastStage then
     with TProjectData(TPhaseData(FPhaseData).ProjectData).BillsMeasureData do
+<<<<<<< HEAD
       UpdateRecordDeal(ABillsID, fQtyDiffer, fTPDiffer);
+=======
+     UpdateRecordDeal(ABillsID, fQtyDiffer, fTPDiffer);
+
+  CalculatePriceMargin(ABillsID);
+>>>>>>> 3.1.3.3
 
   TPhaseData(FPhaseData).PhasePayData.CalculateAll;
 end;
@@ -237,6 +265,9 @@ begin
   if TPhaseData(FPhaseData).IsLastStage then
     with TProjectData(TPhaseData(FPhaseData).ProjectData).BillsMeasureData do
       UpdateRecordQc(ABillsID, fQtyDiffer, fTPDiffer);
+
+  CalculatePriceMargin(ABillsID);
+
   TPhaseData(FPhaseData).PhasePayData.CalculateAll;
 end;
 
@@ -344,6 +375,7 @@ end;
 
 procedure TStageData.Save;
 begin
+  sddStage.SaveToFile('E:\1.xml');
   sddStage.Save;
 end;
 
@@ -359,15 +391,19 @@ begin
   if (AValue.FieldName = 'DealQuantity') or
      (AValue.FieldName = 'DealFormula') or
      (AValue.FieldName = 'DealTotalPrice') then
-    CalculateDeal(AValue.Owner.ValueByName('BillsID').AsInteger);
+    CalculateDeal(iBillsID);
   if (AValue.FieldName = 'QcQuantity') or
      (AValue.FieldName = 'QcFormula') or
      (AValue.FieldName = 'QcTotalPrice') then
-    CalculateQuantityChange(AValue.Owner.ValueByName('BillsID').AsInteger);
+    CalculateQuantityChange(iBillsID);
   if (AValue.FieldName = 'PcQuantity') or
      (AValue.FieldName = 'PcFormula') or
      (AValue.FieldName = 'PcTotalPrice') then
-    CalculatePriceChange(AValue.Owner.ValueByName('BillsID').AsInteger);
+    CalculatePriceChange(iBillsID);
+
+  if (AValue.FieldName = 'DealQuantity') or
+     (AValue.FieldName = 'QcQuantity') then
+    UpdateProjectGL(iBillsID);
 end;
 
 function TStageData.GetMainBillsTree: TBillsIDTree;
@@ -404,7 +440,7 @@ procedure TStageData.sddStageBeforeValueChange(AValue: TsdValue;
         DataSetErrorMessage(Allow, '不可超过0号台账合同数量!');
     end;
   end;
-
+  
 begin
   // 不检查超计
   //CheckOverRange;
@@ -458,9 +494,7 @@ var
 begin
   iParentID := MainBillsTree.FindNode(ABillsID).ParentID;
   if iParentID = -1 then Exit;
-  Rec := StageRecord(iParentID);
-  if not Assigned(Rec) then
-    Rec := AddStageRecord(iParentID);
+  Rec := StageRecordWithAdd(iParentID);
   Rec.ValueByName(AFieldName).AsFloat := TotalPriceRoundTo(
       Rec.ValueByName(AFieldName).AsFloat + ATotalPrice);
   Rec.ValueByName('End' + AFieldName).AsFloat := TotalPriceRoundTo(
@@ -556,8 +590,9 @@ begin
         if (Rec.ValueByName('AddGatherTotalPrice').AsFloat = 0) and
            (Rec.ValueByName('AddDealTotalPrice').AsFloat = 0) and
            (Rec.ValueByName('AddQcTotalPrice').AsFloat = 0) and
-           (Rec.ValueByName('AddPcTotalPrice').AsFloat = 0) then Continue;
-           
+           (Rec.ValueByName('AddPcTotalPrice').AsFloat = 0) and
+           (Rec.ValueByName('PM_AddTotalPrice').AsFloat = 0) then Continue;
+
         NewRec := sddStage.Add;
         NewRec.ValueByName('BillsID').AsInteger := Rec.ValueByName('ID').AsInteger;
         NewRec.ValueByName('EndDealQuantity').AsFloat := Rec.ValueByName('AddDealQuantity').AsFloat;
@@ -584,6 +619,8 @@ begin
         NewRec.ValueByName('PrePcBGLNum').AsString := Rec.ValueByName('AddPcBGLNum').AsString;
         NewRec.ValueByName('PreGatherQuantity').AsFloat := Rec.ValueByName('AddGatherQuantity').AsFloat;
         NewRec.ValueByName('PreGatherTotalPrice').AsFloat := Rec.ValueByName('AddGatherTotalPrice').AsFloat;
+
+        NewRec.ValueByName('PM_PreTotalPrice').AsFloat := Rec.ValueByName('PM_AddTotalPrice').AsFloat;
       end;
   finally
     AfterBatchOperation;
@@ -611,6 +648,12 @@ begin
 end;
 
 procedure TStageData.CalculateNode(ANode: TsdIDTreeNode);
+
+  function IsSpecialNode: Boolean;
+  begin
+    Result := ANode.ID = iPriceMarginID;
+  end;
+
 begin
   if not Assigned(ANode) then Exit;
   if ANode.HasChildren then
@@ -619,7 +662,12 @@ begin
     CalculateParent(TBillsIDTreeNode(ANode));
   end
   else
-    CalculateLeaf(TBillsIDTreeNode(ANode));
+  begin
+    if IsSpecialNode then
+      CalculateSpecialLeaf(TBillsIDTreeNode(ANode))
+    else
+      CalculateLeaf(TBillsIDTreeNode(ANode));
+  end;
   CalculateNode(ANode.NextSibling);
 end;
 
@@ -627,13 +675,14 @@ procedure TStageData.CalculateParent(ANode: TBillsIDTreeNode);
 var
   iChild: Integer;
   ChildNode: TBillsIDTreeNode;
-  fDeal, fQc, fPc: Double;
+  fDeal, fQc, fPc, fPM: Double;
 begin
   if not Assigned(ANode.StageRec) then Exit;
 
   fDeal := 0;
   fQc := 0;
-  FPc := 0;
+  fPc := 0;
+  fPM := 0;
   for iChild := 0 to ANode.ChildCount - 1 do
   begin
     ChildNode := TBillsIDTreeNode(ANode.ChildNodes[iChild]);
@@ -641,19 +690,28 @@ begin
     fDeal := TotalPriceRoundTo(fDeal + ChildNode.StageRec.DealTotalPrice.AsFloat);
     fQc := TotalPriceRoundTo(fQc + ChildNode.StageRec.QcTotalPrice.AsFloat);
     fPc := TotalPriceRoundTo(fPc + ChildNode.StageRec.PcTotalPrice.AsFloat);
+    fPM := TotalPriceRoundTo(fPM + ChildNode.StageRec.PM_TotalPrice.AsFloat);
   end;
 
   with ANode.StageRec do
   begin
-    DealTotalPrice.AsFloat := fDeal;
-    QcTotalPrice.AsFloat := fQc;
-    PcTotalPrice.AsFloat := fPc;
-    GatherTotalPrice.AsFloat := TotalPriceRoundTo(fDeal + fQc + fPc);
-    EndDealTotalPrice.AsFloat := TotalPriceRoundTo(PreDealTotalPrice.AsFloat + fDeal);
-    EndQcTotalPrice.AsFloat := TotalPriceRoundTo(PreQcTotalPrice.AsFloat + fQc);
-    EndPcTotalPrice.AsFloat := TotalPriceRoundTo(PrePcTotalPrice.AsFloat + fPc);
-    EndGatherTotalPrice.AsFloat := TotalPriceRoundTo(
-      PreGatherTotalPrice.AsFloat + GatherTotalPrice.AsFloat);
+    if (DealTotalPrice.AsFloat <> fDeal) or
+       (QcTotalPrice.AsFloat <> fQc) or
+       (PcTotalPrice.AsFloat <> fPc) then
+    begin
+      DealTotalPrice.AsFloat := fDeal;
+      QcTotalPrice.AsFloat := fQc;
+      PcTotalPrice.AsFloat := fPc;
+      GatherTotalPrice.AsFloat := TotalPriceRoundTo(fDeal + fQc + fPc);
+      EndDealTotalPrice.AsFloat := TotalPriceRoundTo(PreDealTotalPrice.AsFloat + fDeal);
+      EndQcTotalPrice.AsFloat := TotalPriceRoundTo(PreQcTotalPrice.AsFloat + fQc);
+      EndPcTotalPrice.AsFloat := TotalPriceRoundTo(PrePcTotalPrice.AsFloat + fPc);
+      EndGatherTotalPrice.AsFloat := TotalPriceRoundTo(
+        PreGatherTotalPrice.AsFloat + GatherTotalPrice.AsFloat);
+    end;
+
+    if PM_TotalPrice.AsFloat <> fPM then
+      PM_TotalPrice.AsFloat := fPM;
   end;
 end;
 
@@ -675,6 +733,14 @@ procedure TStageData.CalculateLeaf(ANode: TBillsIDTreeNode);
         ARec.ValueByName('Pre' + AType + 'TotalPrice').AsFloat + ARec.ValueByName(AType + 'TotalPrice').AsFloat);
   end;
 
+  procedure CalculatePriceMargin(ARec: TStageRecord);
+  var
+    fPrice: Double;
+  begin
+    fPrice := GetBillsUnitPriceMargin(ARec.BillsID.AsInteger);
+    ARec.SetFloatValue(ARec.PM_TotalPrice, TotalPriceRoundTo(ARec.GatherQuantity.AsFloat * fPrice));
+  end;
+
 var
   Rec: TStageRecord;
 begin
@@ -691,6 +757,8 @@ begin
       Rec.PreGatherQuantity.AsFloat + Rec.GatherQuantity.AsFloat);
   Rec.EndGatherTotalPrice.AsFloat := TotalPriceRoundTo(
       Rec.PreGatherTotalPrice.AsFloat + Rec.GatherTotalPrice.AsFloat);
+      
+  CalculatePriceMargin(Rec);
 end;
 
 function TStageData.GetActive: Boolean;
@@ -747,9 +815,143 @@ begin
   end;
 end;
 
+<<<<<<< HEAD
 function TStageData.GetCalcType(ABillsID: Integer): Integer;
 begin
   Result := MainBillsTree.FindNode(ABillsID).Rec.ValueByName('CalcType').AsInteger;
+=======
+procedure TStageData.CalculatePriceMarginNode;
+var
+  Rec: TStageRecord;
+  fDiffer: Double;
+begin
+  with TProjectData(TPhaseData(FPhaseData).ProjectData) do
+  begin
+    Rec := StageRecord(iPriceMarginID);
+    if not Assigned(Rec) then
+      Rec := AddStageRecord(iPriceMarginID);
+
+    fDiffer := TotalPriceRoundTo(ProjectGLData.PM_TotalPrice - Rec.GatherTotalPrice.AsFloat);
+    if fDiffer <> 0 then
+    begin
+      Rec.AddDifferValue(Rec.GatherTotalPrice, fDiffer);
+      Rec.AddDifferValue(Rec.EndGatherTotalPrice, fDiffer);
+      UpdateParentRecord(Rec.BillsID.AsInteger, fDiffer, 'GatherTotalPrice');
+    end;
+  end;
+end;
+
+function TStageData.GetBillsUnitPriceMargin(ABillsID: Integer): Double;
+var
+  vGLs: TList;
+  iGL: Integer;
+  GLRec: TDetailGLRecord;
+begin
+  Result := 0;
+  vGLs := TList.Create;
+  try
+    with TProjectData(TPhaseData(FPhaseData).ProjectData).DetailGLData do
+      LoadDetailGLs(ABillsID, vGLs);
+    for iGL := 0 to vGLs.Count - 1 do
+    begin
+      GLRec := TDetailGLRecord(vGLs.Items[iGL]);
+      Result := Result + GLRec.Quantity.AsFloat * GLRec.RelaProjectGL.ValidDeltaPrice.AsFloat;
+    end;
+  finally
+    vGLs.Free;
+  end;
+end;
+
+procedure TStageData.CalculatePriceMargin(ABillsID: Integer);
+var
+  Rec: TStageRecord;
+  fPM, fPMDiffer: Double;
+begin
+  Rec := StageRecord(ABillsID);
+  if not Assigned(Rec) then Exit;
+
+  fPM := TotalPriceRoundTo(Rec.GatherQuantity.AsFloat * GetBillsUnitPriceMargin(ABillsID));
+  if fPM <> Rec.PM_TotalPrice.AsFloat then
+  begin
+    fPMDiffer := fPM - Rec.PM_TotalPrice.AsFloat;
+    Rec.PM_TotalPrice.AsFloat := fPM;
+    UpdateParentPriceMargin(ABillsID, fPMDiffer);
+    UpdatePriceMarginNode(fPMDiffer);
+    with TProjectData(TPhaseData(FPhaseData).ProjectData).BillsMeasureData do
+     UpdateRecordPM(ABillsID, fPMDiffer);
+  end;
+end;
+
+procedure TStageData.UpdatePriceMarginNode(ADiffer: Double);
+var
+  Rec: TStageRecord;
+begin
+  Rec := StageRecordWithAdd(iPriceMarginID);
+  Rec.AddDifferValue(Rec.GatherTotalPrice, ADiffer);
+  Rec.AddDifferValue(Rec.EndGatherTotalPrice, ADiffer);
+  UpdateParentRecord(iPriceMarginID, ADiffer, 'GatherTotalPrice');
+  with TProjectData(TPhaseData(FPhaseData).ProjectData).BillsMeasureData do
+    UpdateGather(Rec.BillsID.AsInteger, ADiffer);
+end;
+
+procedure TStageData.UpdateParentPriceMargin(ABillsID: Integer; ADiffer: Double);
+var
+  iParentID: Integer;
+  Rec: TStageRecord;
+begin
+  iParentID := MainBillsTree.FindNode(ABillsID).ParentID;
+  if iParentID = -1 then Exit;
+
+  Rec := StageRecordWithAdd(iParentID);
+  Rec.PM_TotalPrice.AsFloat := TotalPriceRoundTo(Rec.PM_TotalPrice.AsFloat + ADiffer);
+  UpdateParentPriceMargin(iParentID, ADiffer);
+end;
+
+function TStageData.StageRecordWithAdd(ABillsID: Integer): TStageRecord;
+begin
+  Result := StageRecord(ABillsID);
+  if not Assigned(Result) then
+    Result := AddStageRecord(ABillsID);
+end;
+
+procedure TStageData.UpdateProjectGL(ABillsID: Integer);
+var
+  vGLs: TList;
+  iGL: Integer;
+  GLRec: TDetailGLRecord;
+begin
+  vGLs := TList.Create;
+  try
+    with TProjectData(TPhaseData(FPhaseData).ProjectData) do
+    begin
+      DetailGLData.LoadDetailGLs(ABillsID, vGLs);
+      ProjectGLData.CalculateGLs_PM(vGLs);
+    end;
+  finally
+    vGLs.Free;
+  end;
+end;
+
+procedure TStageData.CalculateSpecialLeaf(ANode: TBillsIDTreeNode);
+
+  procedure GatherPriceMargin(ARec: TStageRecord);
+  begin
+    with TProjectData(TPhaseData(FPhaseData).ProjectData).ProjectGLData do
+        ARec.SetFloatValue(ARec.GatherTotalPrice, PM_TotalPrice);
+    ARec.SetFloatValue(ARec.EndGatherTotalPrice,
+        ARec.PreGatherTotalPrice.AsFloat + ARec.GatherTotalPrice.AsFloat);
+  end;
+
+var
+  StageRec: TStageRecord;
+begin
+  StageRec := ANode.StageRec;
+  if not Assigned(StageRec) then Exit;
+
+  case ANode.ID of
+    iPriceMarginID: GatherPriceMargin(StageRec);
+  end;
+>>>>>>> 3.1.3.3
 end;
 
 end.

+ 14 - 0
Dprs/Pro/Measure.dof

@@ -119,7 +119,14 @@ Release=5
 Build=109
 =======
 Release=3
+<<<<<<< HEAD
 Build=2041
+<<<<<<< HEAD
+>>>>>>> 3.1.3.3
+=======
+=======
+Build=3011
+>>>>>>> 3.1.3.3PriceMargin(Temp)
 >>>>>>> 3.1.3.3
 Debug=0
 PreRelease=0
@@ -132,10 +139,17 @@ CodePage=936
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化专业版
 <<<<<<< HEAD
+<<<<<<< HEAD
 FileVersion=3.1.5.109
 =======
 FileVersion=3.1.3.2041
 >>>>>>> 3.1.3.3
+=======
+FileVersion=3.1.3.2041
+=======
+FileVersion=3.1.3.3011
+>>>>>>> 3.1.3.3PriceMargin(Temp)
+>>>>>>> 3.1.3.3
 InternalName=Measure
 LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
 LegalTrademarks=Measure

+ 20 - 0
Dprs/Pro/Measure.dpr

@@ -137,6 +137,7 @@ uses
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
 <<<<<<< HEAD
+<<<<<<< HEAD
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
   mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm};
@@ -145,6 +146,25 @@ uses
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
 >>>>>>> 3.1.3.3
+=======
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
+  BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
+=======
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
+  BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm},
+  BaseClipboard in '..\..\Units\BaseClipboard.pas';
+>>>>>>> 3.1.3.3PriceMargin(Temp)
+>>>>>>> 3.1.3.3
 
 {$R *.res}
 

+ 14 - 0
Dprs/Pro/Measure_Cloud.dof

@@ -119,7 +119,14 @@ Release=5
 Build=109
 =======
 Release=3
+<<<<<<< HEAD
 Build=2041
+<<<<<<< HEAD
+>>>>>>> 3.1.3.3
+=======
+=======
+Build=3011
+>>>>>>> 3.1.3.3PriceMargin(Temp)
 >>>>>>> 3.1.3.3
 Debug=0
 PreRelease=0
@@ -132,10 +139,17 @@ CodePage=936
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化云版
 <<<<<<< HEAD
+<<<<<<< HEAD
 FileVersion=3.1.5.109
 =======
 FileVersion=3.1.3.2041
 >>>>>>> 3.1.3.3
+=======
+FileVersion=3.1.3.2041
+=======
+FileVersion=3.1.3.3011
+>>>>>>> 3.1.3.3PriceMargin(Temp)
+>>>>>>> 3.1.3.3
 InternalName=Measure
 LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
 LegalTrademarks=Measure

+ 20 - 0
Dprs/Pro/Measure_Cloud.dpr

@@ -141,6 +141,7 @@ uses
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
 <<<<<<< HEAD
+<<<<<<< HEAD
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
   mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm};
@@ -149,6 +150,25 @@ uses
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
 >>>>>>> 3.1.3.3
+=======
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
+  BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
+=======
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
+  BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm},
+  BaseClipboard in '..\..\Units\BaseClipboard.pas';
+>>>>>>> 3.1.3.3PriceMargin(Temp)
+>>>>>>> 3.1.3.3
 
 {$R *.res}
 

+ 14 - 0
Dprs/Pro/Measure_GuangDong.dof

@@ -119,7 +119,14 @@ Release=5
 Build=106
 =======
 Release=3
+<<<<<<< HEAD
 Build=2041
+<<<<<<< HEAD
+>>>>>>> 3.1.3.3
+=======
+=======
+Build=3011
+>>>>>>> 3.1.3.3PriceMargin(Temp)
 >>>>>>> 3.1.3.3
 Debug=0
 PreRelease=0
@@ -132,10 +139,17 @@ CodePage=936
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化广东专业版
 <<<<<<< HEAD
+<<<<<<< HEAD
 FileVersion=3.1.5.106
 =======
 FileVersion=3.1.3.2041
 >>>>>>> 3.1.3.3
+=======
+FileVersion=3.1.3.2041
+=======
+FileVersion=3.1.3.3011
+>>>>>>> 3.1.3.3PriceMargin(Temp)
+>>>>>>> 3.1.3.3
 InternalName=Measure
 LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
 LegalTrademarks=Measure

+ 16 - 0
Dprs/Pro/Measure_GuangDong.dpr

@@ -137,12 +137,28 @@ uses
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
 <<<<<<< HEAD
+<<<<<<< HEAD
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
   mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm};
 =======
+=======
+>>>>>>> 3.1.3.3
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
+  BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+=======
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
   rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+>>>>>>> 3.1.3.3PriceMargin(Temp)
   DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
 >>>>>>> 3.1.3.3
 

+ 14 - 0
Dprs/Pro/Measure_GuangDong_Cloud.dof

@@ -119,7 +119,14 @@ Release=5
 Build=106
 =======
 Release=3
+<<<<<<< HEAD
 Build=2041
+<<<<<<< HEAD
+>>>>>>> 3.1.3.3
+=======
+=======
+Build=3011
+>>>>>>> 3.1.3.3PriceMargin(Temp)
 >>>>>>> 3.1.3.3
 Debug=0
 PreRelease=0
@@ -132,10 +139,17 @@ CodePage=936
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化广东云版
 <<<<<<< HEAD
+<<<<<<< HEAD
 FileVersion=3.1.5.106
 =======
 FileVersion=3.1.3.2041
 >>>>>>> 3.1.3.3
+=======
+FileVersion=3.1.3.2041
+=======
+FileVersion=3.1.3.3011
+>>>>>>> 3.1.3.3PriceMargin(Temp)
+>>>>>>> 3.1.3.3
 InternalName=Measure
 LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
 LegalTrademarks=Measure

+ 16 - 0
Dprs/Pro/Measure_GuangDong_Cloud.dpr

@@ -141,12 +141,28 @@ uses
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
 <<<<<<< HEAD
+<<<<<<< HEAD
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
   mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm};
 =======
+=======
+>>>>>>> 3.1.3.3
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
+  BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+=======
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
   rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+>>>>>>> 3.1.3.3PriceMargin(Temp)
   DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
 >>>>>>> 3.1.3.3
 

+ 17 - 2
Dprs/Pro/Measure_GuangDong_TZ.dof

@@ -119,7 +119,14 @@ Release=5
 Build=105
 =======
 Release=3
+<<<<<<< HEAD
 Build=2040
+<<<<<<< HEAD
+>>>>>>> 3.1.3.3
+=======
+=======
+Build=3010
+>>>>>>> 3.1.3.3PriceMargin(Temp)
 >>>>>>> 3.1.3.3
 Debug=0
 PreRelease=0
@@ -130,6 +137,7 @@ Locale=2052
 CodePage=936
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
+<<<<<<< HEAD
 FileDescription=
 <<<<<<< HEAD
 FileVersion=3.1.5.105
@@ -139,9 +147,16 @@ FileVersion=3.1.3.2040
 InternalName=
 LegalCopyright=
 LegalTrademarks=
+=======
+FileDescription=纵横0号台账广东专业版
+FileVersion=3.1.3.3010
+InternalName=Measure
+LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
+LegalTrademarks=Measure
+>>>>>>> 3.1.3.3PriceMargin(Temp)
 OriginalFilename=
-ProductName=
-ProductVersion=1.0.0.0
+ProductName=纵横公路工程0号台账软件
+ProductVersion=1
 Comments=
 [Excluded Packages]
 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.

+ 16 - 0
Dprs/Pro/Measure_GuangDong_TZ.dpr

@@ -137,12 +137,28 @@ uses
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
 <<<<<<< HEAD
+<<<<<<< HEAD
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
   mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm};
 =======
+=======
+>>>>>>> 3.1.3.3
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
+  BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+=======
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
   rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+>>>>>>> 3.1.3.3PriceMargin(Temp)
   DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
 >>>>>>> 3.1.3.3
 

+ 14 - 0
Dprs/Pro/Measure_TZ.dof

@@ -119,7 +119,14 @@ Release=5
 Build=106
 =======
 Release=3
+<<<<<<< HEAD
 Build=2041
+<<<<<<< HEAD
+>>>>>>> 3.1.3.3
+=======
+=======
+Build=3011
+>>>>>>> 3.1.3.3PriceMargin(Temp)
 >>>>>>> 3.1.3.3
 Debug=0
 PreRelease=0
@@ -132,10 +139,17 @@ CodePage=936
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横0号台账专业版
 <<<<<<< HEAD
+<<<<<<< HEAD
 FileVersion=3.1.5.106
 =======
 FileVersion=3.1.3.2041
 >>>>>>> 3.1.3.3
+=======
+FileVersion=3.1.3.2041
+=======
+FileVersion=3.1.3.3011
+>>>>>>> 3.1.3.3PriceMargin(Temp)
+>>>>>>> 3.1.3.3
 InternalName=Measure
 LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
 LegalTrademarks=Measure

+ 16 - 0
Dprs/Pro/Measure_TZ.dpr

@@ -137,12 +137,28 @@ uses
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
 <<<<<<< HEAD
+<<<<<<< HEAD
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
   mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm};
 =======
+=======
+>>>>>>> 3.1.3.3
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
+  BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+=======
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
   rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+>>>>>>> 3.1.3.3PriceMargin(Temp)
   DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
 >>>>>>> 3.1.3.3
 

+ 14 - 0
Dprs/Trail/Measure.dof

@@ -119,7 +119,14 @@ Release=5
 Build=106
 =======
 Release=3
+<<<<<<< HEAD
 Build=2041
+<<<<<<< HEAD
+>>>>>>> 3.1.3.3
+=======
+=======
+Build=3011
+>>>>>>> 3.1.3.3PriceMargin(Temp)
 >>>>>>> 3.1.3.3
 Debug=0
 PreRelease=0
@@ -132,10 +139,17 @@ CodePage=936
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化专业版
 <<<<<<< HEAD
+<<<<<<< HEAD
 FileVersion=3.1.5.106
 =======
 FileVersion=3.1.3.2041
 >>>>>>> 3.1.3.3
+=======
+FileVersion=3.1.3.2041
+=======
+FileVersion=3.1.3.3011
+>>>>>>> 3.1.3.3PriceMargin(Temp)
+>>>>>>> 3.1.3.3
 InternalName=Measure
 LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
 LegalTrademarks=Measure

+ 16 - 0
Dprs/Trail/Measure.dpr

@@ -137,12 +137,28 @@ uses
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
 <<<<<<< HEAD
+<<<<<<< HEAD
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
   mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm};
 =======
+=======
+>>>>>>> 3.1.3.3
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
+  BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+=======
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
   rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+>>>>>>> 3.1.3.3PriceMargin(Temp)
   DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
 >>>>>>> 3.1.3.3
 

+ 14 - 0
Dprs/Trail/Measure_GuangDong.dof

@@ -119,7 +119,14 @@ Release=5
 Build=106
 =======
 Release=3
+<<<<<<< HEAD
 Build=2041
+<<<<<<< HEAD
+>>>>>>> 3.1.3.3
+=======
+=======
+Build=3011
+>>>>>>> 3.1.3.3PriceMargin(Temp)
 >>>>>>> 3.1.3.3
 Debug=0
 PreRelease=0
@@ -132,10 +139,17 @@ CodePage=936
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化广东学习版
 <<<<<<< HEAD
+<<<<<<< HEAD
 FileVersion=3.1.5.106
 =======
 FileVersion=3.1.3.2041
 >>>>>>> 3.1.3.3
+=======
+FileVersion=3.1.3.2041
+=======
+FileVersion=3.1.3.3011
+>>>>>>> 3.1.3.3PriceMargin(Temp)
+>>>>>>> 3.1.3.3
 InternalName=Measure
 LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
 LegalTrademarks=Measure

+ 16 - 0
Dprs/Trail/Measure_GuangDong.dpr

@@ -137,12 +137,28 @@ uses
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
 <<<<<<< HEAD
+<<<<<<< HEAD
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
   mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm};
 =======
+=======
+>>>>>>> 3.1.3.3
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
+  BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+=======
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
   rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+>>>>>>> 3.1.3.3PriceMargin(Temp)
   DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
 >>>>>>> 3.1.3.3
 

+ 6 - 0
Forms/BatchInsertBillsFrm.dfm

@@ -106,6 +106,8 @@ object BatchInsertBillsForm: TBatchInsertBillsForm
           DefaultFixedColWidth = 25
           Selection.AlphaBlend = False
           Selection.TransparentColor = False
+          FrozenCol = 0
+          FrozenRow = 0
           OnCellTextChanged = zgPositionCellTextChanged
           OnCustomPaste = zgPositionCustomPaste
           OnMouseDown = zgPositionMouseDown
@@ -153,6 +155,8 @@ object BatchInsertBillsForm: TBatchInsertBillsForm
           DefaultFixedColWidth = 60
           Selection.AlphaBlend = False
           Selection.TransparentColor = False
+          FrozenCol = 0
+          FrozenRow = 0
           OnCellTextChanged = zgBillsCellTextChanged
           OnMouseDown = zgPositionMouseDown
         end
@@ -257,6 +261,8 @@ object BatchInsertBillsForm: TBatchInsertBillsForm
         DefaultFixedColWidth = 25
         Selection.AlphaBlend = False
         Selection.TransparentColor = False
+        FrozenCol = 0
+        FrozenRow = 0
         OnMouseDown = zgDealBillsMouseDown
       end
       object pnlDealBillsSpr: TPanel

+ 1 - 0
Forms/BatchInsertBillsFrm.pas

@@ -338,6 +338,7 @@ begin
       zgBills.Cells[2, Row].Align := gaCenterLeft;
       zgBills.Cells[3, Row].Text := Rec.ValueByName('Units').AsString;
       zgBills.Cells[3, Row].Align := gaCenterLeft;
+      zgBills.Cells[3, Row].Font.Name := 'smartSimSun';
       zgBills.Cells[4, Row].Text := Rec.ValueByName('Price').AsString;
       zgBills.Cells[4, Row].Align := gaCenterRight;
     end;

+ 3 - 3
Forms/BatchReplaceBillsFrm.dfm

@@ -7,12 +7,12 @@ object BatchReplaceBillsForm: TBatchReplaceBillsForm
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
-  Font.Height = -11
-  Font.Name = 'MS Sans Serif'
+  Font.Height = -12
+  Font.Name = 'smartSimSun'
   Font.Style = []
   OldCreateOrder = False
   PixelsPerInch = 96
-  TextHeight = 13
+  TextHeight = 12
   object pnlBills: TPanel
     Left = 0
     Top = 92

+ 26 - 0
Forms/MainFrm.dfm

@@ -968,6 +968,32 @@ object MainForm: TMainForm
       Hint = #35774#32622#35745#25552#26399#38480
       Visible = ivAlways
     end
+    object dxbtnAddDetailGLs: TdxBarButton
+      Caption = #26032#22686#35843#24046#24037#26009
+      Category = 0
+      Hint = #26032#22686#35843#24046#24037#26009
+      Visible = ivAlways
+    end
+    object dxbtnCopyDetailGls: TdxBarButton
+      Caption = #22797#21046#35843#24046#24037#26009
+      Category = 0
+      Hint = #22797#21046#35843#24046#24037#26009
+      Visible = ivAlways
+      ImageIndex = 4
+    end
+    object dxbtnApplyToSameBills: TdxBarButton
+      Caption = #24212#29992#35843#24046#24037#26009#33267#30456#21516#28165#21333
+      Category = 0
+      Hint = #24212#29992#35843#24046#24037#26009#33267#30456#21516#28165#21333
+      Visible = ivAlways
+    end
+    object dxbtnCalculatePriceMargin: TdxBarButton
+      Caption = #20215#24046#35745#31639
+      Category = 0
+      Hint = #20215#24046#35745#31639
+      Visible = ivAlways
+      ImageIndex = 15
+    end
   end
   object Images: TImageList
     DrawingStyle = dsTransparent

+ 4 - 0
Forms/MainFrm.pas

@@ -144,6 +144,10 @@ type
     dxbtnLocateBookmark: TdxBarButton;
     dxbtnImportPlaneFxBillsToXmj: TdxBarButton;
     dxbtnSetDealPayPlan: TdxBarButton;
+    dxbtnAddDetailGLs: TdxBarButton;
+    dxbtnCopyDetailGls: TdxBarButton;
+    dxbtnApplyToSameBills: TdxBarButton;
+    dxbtnCalculatePriceMargin: TdxBarButton;
     procedure FormCreate(Sender: TObject);
     procedure FormDestroy(Sender: TObject);
     procedure jtsProjectsChange(Sender: TObject; NewTab: Integer;

+ 1 - 1
Forms/ReportsFrm.dfm

@@ -61,7 +61,7 @@ object ReportsForm: TReportsForm
     Width = 223
     Height = 25
     BevelInner = bvLowered
-    TabOrder = 4
+    TabOrder = 3
     object chkExcelMode: TCheckBox
       Left = 6
       Top = 4

+ 1 - 0
Forms/ReportsFrm.pas

@@ -180,6 +180,7 @@ begin
     ReportsForm.ShowModal;
   finally
     ReportsForm.Free;
+    AProjectData.ClearReportCacheData;
   end;
 end;
 

+ 269 - 0
Forms/SelectDetailGLsFrm.dfm

@@ -0,0 +1,269 @@
+object SelectDetailGLsForm: TSelectDetailGLsForm
+  Left = 567
+  Top = 305
+  Width = 480
+  Height = 529
+  BorderIcons = [biSystemMenu]
+  Caption = #36873#25321#35843#24046#24037#26009
+  Color = clBtnFace
+  Font.Charset = DEFAULT_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -11
+  Font.Name = 'MS Sans Serif'
+  Font.Style = []
+  OldCreateOrder = False
+  DesignSize = (
+    472
+    495)
+  PixelsPerInch = 96
+  TextHeight = 13
+  object pnlData: TPanel
+    Left = 0
+    Top = 0
+    Width = 472
+    Height = 457
+    Align = alTop
+    BevelOuter = bvNone
+    TabOrder = 0
+    DesignSize = (
+      472
+      457)
+    object imgSearch: TImage
+      Left = 440
+      Top = 3
+      Width = 26
+      Height = 25
+      Anchors = [akTop, akRight]
+      Picture.Data = {
+        055449636F6E0000010001001818000000002000880900001600000028000000
+        1800000030000000010020000000000000120000000000000000000000000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        000000000000000000000000000000009B9B9B1C9B9B9B709898983900000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        000000000000000000000000909090179A9A9AB39B9B9BF99B9B9BD89A9A9A3F
+        0000000000000000000000000000000000000000000000000000000000000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        0000000000000001949494269B9B9BCC9B9B9BFF9B9B9BFF9B9B9BFF9B9B9BBF
+        9999991900000000000000000000000000000000000000000000000000000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        AAAAAA039797974C9A9A9AD69B9B9BFF9B9B9BFF9B9B9BFF9B9B9BFF9B9B9BFC
+        9B9B9B7A00000000000000000000000000000000000000000000000000000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        989898579A9A9AE69B9B9BFE9B9B9BFF9B9B9BFF9B9B9BFF9B9B9BFF9B9B9BFF
+        9A9A9AD7000000000000000000000000000000007F7F7F028E8E8E1297979720
+        9A9A9A269A9A9A269999991E9292920E00000001000000000000000097979736
+        9A9A9AE29A9A9AFD9B9B9BFF9B9B9BFF9B9B9BFF9B9B9BFF9B9B9BFC9A9A9ADA
+        9A9A9A530000000000000000000000009595951898989872999999B79A9A9AE1
+        9A9A9AF39A9A9AF29A9A9ADA9A9A9AAA999999628989890DD1D1D10BCBCBCB58
+        AFAFAF609B9B9BCC9B9B9BFE9B9B9BFF9B9B9BFF9A9A9AF59B9B9B999999992D
+        0000000100000000000000009494942B9A9A9ACE9A9A9AF69A9A9AE69A9A9A97
+        9A9A9A6D97979771989898A6999999EE9A9A9AF39B9B9BB5BCBCBC54CECECEDD
+        CECECECBA9A9A9749A9A9AEE9B9B9BFF9B9B9BDB9C9C9C4B8B8B8B0B00000000
+        00000000000000019B9B9B2E9B9B9BDC9B9B9BEF9B9B9B8CB7B7B727CFCFCF45
+        CECECE74CDCDCD71CFCFCF3AA8A8A8359B9B9BAD9B9B9BF6999999B0C3C3C36A
+        CFCFCFEFCBCBCB6D999999BE9A9A9AB19D9D9D22000000000000000000000000
+        000000009999991E9A9A9AA79A9A9AF49C9C9C6CCACACA5BCECECECACFCFCFFE
+        CFCFCFFFCFCFCFFFCECECEF8CFCFCFB5C3C3C3409A9A9A869A9A9AF399999980
+        CDCDCD60CECECE1F9797973B9F9F9F0800000000000000000000000000000000
+        000000009A9A9A6F9A9A9AF59898988EC8C8C83CCECECEE7CFCFCFFECFCFCFFF
+        CFCFCFFFCFCFCFFFCFCFCFFFCFCFCFFECFCFCFDEB6B6B6319B9B9BB39A9A9AF3
+        9595951D00000000000000000000000000000000000000000000000000000000
+        000000009A9A9AC39B9B9BEB95959529CECECEC1CFCFCFFFCFCFCFFFCFCFCFFF
+        CFCFCFFFCFCFCFFFCFCFCFFFCFCFCFFFCFCFCFFFCECECEA2999999679A9A9AF6
+        9A9A9A7500000000000000000000000000000000000000000000000000000000
+        000000009B9B9BEE9B9B9BBFB9B9B937CFCFCFFCCFCFCFFFCFCFCFFFCFCFCFFF
+        CFCFCFFFCFCFCFFFCFCFCFFFCFCFCFFFCFCFCFFFCECECEDDABABAB529B9B9BE6
+        9B9B9BB000000000000000000000000000000000000000000000000000000000
+        000000009A9A9AF8999999ADC1C1C153CFCFCFFFCFCFCFFFCFCFCFFFCFCFCFFF
+        CFCFCFFFCFCFCFFFCFCFCFFFCFCFCFFFCFCFCFFFCECECEE5B5B5B5569B9B9BE0
+        9A9A9AC600000000000000000000000000000000000000000000000000000000
+        000000009A9A9AF89A9A9AB9C0C0C041CFCFCFFDCFCFCFFFCFCFCFFFCFCFCFFF
+        CFCFCFFFCFCFCFFFCFCFCFFFCFCFCFFFCFCFCFFFCECECEDFADADAD549B9B9BE4
+        9B9B9BB800000000000000000000000000000000000000000000000000000000
+        000000009A9A9AEC9B9B9BE09D9D9D27CDCDCDD4CFCFCFFFCFCFCFFFCFCFCFFF
+        CFCFCFFFCFCFCFFFCFCFCFFFCFCFCFFFCFCFCFFFCECECEB49C9C9C5F9A9A9AF2
+        9A9A9A8300000000000000000000000000000000000000000000000000000000
+        000000009A9A9ABA9A9A9AFA97979774CECECE4FCECECEF6CFCFCFFFCFCFCFFF
+        CFCFCFFFCFCFCFFFCFCFCFFFCFCFCFFFCDCDCDF5C0C0C03D9A9A9AA29B9B9BFC
+        9898982A00000000000000000000000000000000000000000000000000000000
+        000000009999994E9A9A9ABD9A9A9AF39D9D9D41CDCDCD7CCECECEE8CFCFCFFD
+        CFCFCFFFCFCFCFFFCFCFCFFBCFCFCFDECACACA52959595599A9A9AF3999999A1
+        0000000000000000000000000000000000000000000000000000000000000000
+        000000007F7F7F049C9C9C489A9A9AE4999999DD9B9B9B66C5C5C54FCDCDCD86
+        CECECEA3CECECEA1CDCDCD7CBBBBBB4B9A9A9A799A9A9AED9A9A9AC796969622
+        0000000000000000000000000000000000000000000000000000000000000000
+        0000000000000000AAAAAA03999999469A9A9AEB9A9A9AF19A9A9AC89D9D9D7D
+        9F9F9F5D9E9E9E5F9B9B9B8A9A9A9AD19B9B9BF79A9A9AD596969633FFFFFF01
+        0000000000000000000000000000000000000000000000000000000000000000
+        0000000000000000000000000000000097979720999999A89A9A9AE29A9A9AF1
+        9B9B9BF79A9A9AF89A9A9AF09B9B9BDE9A9A9A929999990F0000000000000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        0000000000000000000000000000000000000000999999059898982F98989859
+        9898986B9797976A96969653959595247F7F7F02000000000000000000000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        0000000000000000000000000000000000000000000000000000000000000000
+        00000000FFFFFF00FFFFFF00FFFFE300FFFFC100FFFF8100FFFF0000FFFE0100
+        F81F0300E1848F00C7E29F009811FF009009FF002005FF002004FF002004FF00
+        2004FF002004FF003009FF009819FF00CC73FF00E387FF00F00FFF00FFFFFF00
+        FFFFFF}
+      OnClick = imgSearchClick
+    end
+    object leSearch: TLabeledEdit
+      Left = 102
+      Top = 6
+      Width = 331
+      Height = 19
+      Anchors = [akLeft, akTop, akRight]
+      Ctl3D = False
+      EditLabel.Width = 92
+      EditLabel.Height = 13
+      EditLabel.Caption = #24037#26009#32534#21495'/'#21517#31216#65306' '
+      LabelPosition = lpLeft
+      ParentCtl3D = False
+      TabOrder = 0
+    end
+    object zgGL: TZJGrid
+      Left = 6
+      Top = 32
+      Width = 460
+      Height = 425
+      Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+      OptionsEx = []
+      ColCount = 6
+      ShowGridLine = False
+      DefaultColWidth = 73
+      DefaultFixedColWidth = 25
+      Selection.AlphaBlend = False
+      Selection.TransparentColor = False
+      FrozenCol = 0
+      FrozenRow = 0
+      OnGetCellText = zgGLGetCellText
+      OnSetCellText = zgGLSetCellText
+      Anchors = [akLeft, akTop, akRight, akBottom]
+    end
+  end
+  object btnOk: TButton
+    Left = 303
+    Top = 466
+    Width = 75
+    Height = 21
+    Anchors = [akRight, akBottom]
+    Caption = #30830'    '#23450
+    TabOrder = 1
+    OnClick = btnOkClick
+  end
+  object btnCancel: TButton
+    Left = 388
+    Top = 466
+    Width = 75
+    Height = 21
+    Anchors = [akRight, akBottom]
+    Caption = #21462'    '#28040
+    ModalResult = 2
+    TabOrder = 2
+  end
+  object saGL: TsdGridDBA
+    Columns = <
+      item
+        Title.Caption = #36873#25321
+        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
+        EditType = sgeCheckBox
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        Width = 35
+        ReadOnly = False
+      end
+      item
+        Title.Caption = #32534#21495
+        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 = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Code'
+        Width = 50
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21517#31216
+        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 = 'Name'
+        Width = 150
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21333#20301
+        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 = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = 'smartSimSun'
+        Font.Style = []
+        FieldName = 'Units'
+        Width = 45
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #35268#26684
+        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 = 'Specs'
+        Width = 120
+        ReadOnly = True
+      end>
+    Grid = zgGL
+    ExtendRowCount = 0
+    Left = 112
+    Top = 136
+  end
+end

+ 158 - 0
Forms/SelectDetailGLsFrm.pas

@@ -0,0 +1,158 @@
+unit SelectDetailGLsFrm;
+
+interface
+
+uses
+  ProjectGLDm, sdDB, mDataRecord,
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, ExtCtrls, StdCtrls, sdGridDBA, ZJGrid;
+
+type
+  TSelectDetailGLsForm = class(TForm)
+    pnlData: TPanel;
+    btnOk: TButton;
+    btnCancel: TButton;
+    leSearch: TLabeledEdit;
+    imgSearch: TImage;
+    zgGL: TZJGrid;
+    saGL: TsdGridDBA;
+    procedure zgGLGetCellText(Sender: TObject; const ACoord: TPoint;
+      var Value: String; DisplayText: Boolean);
+    procedure zgGLSetCellText(Sender: TObject; const ACoord: TPoint;
+      var Value: String; DisplayText: Boolean);
+    procedure btnOkClick(Sender: TObject);
+    procedure imgSearchClick(Sender: TObject);
+  private
+    FResults: TList;
+
+    function FindProjectGL(AStr: string): TProjectGLRecord;
+  public
+    constructor Create(AProjectGLData: TProjectGLData);
+    destructor Destroy; override;
+
+    property Results: TList read FResults;
+  end;
+
+function SelectDetailGLs(AProjectGLData: TProjectGLData; AGLs: TList): Boolean;
+
+implementation
+
+uses
+  UtilMethods;
+
+{$R *.dfm}
+
+function SelectDetailGLs(AProjectGLData: TProjectGLData; AGLs: TList): Boolean;
+var
+  SelectForm: TSelectDetailGLsForm;
+begin
+  SelectForm := TSelectDetailGLsForm.Create(AProjectGLData);
+  try
+    Result := SelectForm.ShowModal = mrOk;
+    if Result then
+      AGLs.Assign(SelectForm.Results);
+  finally
+    SelectForm.Free;
+  end;
+end;
+
+{ TAddDetailGLsForm }
+
+constructor TSelectDetailGLsForm.Create(AProjectGLData: TProjectGLData);
+begin
+  inherited Create(nil);
+  saGL.DataView := AProjectGLData.sdvProjectGL;
+  FResults := TList.Create;
+  ClientHeight := 495;
+  ClientWidth := 472;
+end;
+
+destructor TSelectDetailGLsForm.Destroy;
+begin
+  FResults.Free;
+  inherited;
+end;
+
+procedure TSelectDetailGLsForm.zgGLGetCellText(Sender: TObject;
+  const ACoord: TPoint; var Value: String; DisplayText: Boolean);
+var
+  Rec: TsdDataRecord;
+begin
+  if (ACoord.X = 1) and (ACoord.Y > 0) then
+  begin
+    Rec := saGL.DataView.Records[ACoord.Y -1];
+    if Assigned(Rec) and (FResults.IndexOf(Rec) >= 0) then
+      Value := 'True'
+    else
+      Value := 'False';
+  end;
+end;
+
+procedure TSelectDetailGLsForm.zgGLSetCellText(Sender: TObject;
+  const ACoord: TPoint; var Value: String; DisplayText: Boolean);
+var
+  Rec: TsdDataRecord;
+begin
+  if (ACoord.X = 1) and (ACoord.Y > 0) then
+  begin
+    Rec := saGL.DataView.Records[ACoord.Y -1];
+    if Value = 'True' then
+      FResults.Add(Rec)
+    else if Value = 'False' then
+      FResults.Remove(Rec);
+  end;
+end;
+
+procedure TSelectDetailGLsForm.btnOkClick(Sender: TObject);
+begin
+  if FResults.Count > 0 then
+    ModalResult := mrOk
+  else
+    TipMessage('没有选择任何工料。');
+end;
+
+function TSelectDetailGLsForm.FindProjectGL(AStr: string): TProjectGLRecord;
+
+  function SearchProjectGL(ABegin, AEnd: Integer): TProjectGLRecord;
+  var
+    iGL: Integer;
+    Rec: TProjectGLRecord;
+  begin
+    Result := nil;
+    for iGL := ABegin to AEnd do
+    begin
+      Rec := TProjectGLRecord(saGL.DataView.Records[iGL]);
+      if (Pos(AStr, Rec.Code.AsString) > 0) or
+          (Pos(AStr, Rec.Name.AsString) > 0) then
+      begin
+        Result := Rec;
+        Break;
+      end;
+    end;
+  end;
+
+var
+  iCur, iGL: Integer;
+  GLRec: TProjectGLRecord;
+begin
+  Result := nil;
+  if AStr = '' then Exit;
+
+  iCur := saGL.DataView.IndexOf(saGL.DataView.Current);
+  Result := SearchProjectGL(iCur + 1, saGL.DataView.RecordCount - 1);
+  if not Assigned(Result) then
+    Result := SearchProjectGL(0, iCur);
+end;
+
+procedure TSelectDetailGLsForm.imgSearchClick(Sender: TObject);
+var
+  Rec: TProjectGLRecord;
+begin
+  Rec := FindProjectGL(leSearch.Text);
+  if Assigned(Rec) then
+    saGL.DataView.LocateInControl(Rec)
+  else
+    TipMessage(Format('找不到编号、名称含有“%s”的工料。', [leSearch.Text]));
+end;
+
+end.

+ 1 - 1
Frames/BGLFme.dfm

@@ -349,7 +349,7 @@ object BGLFrame: TBGLFrame
         Font.Charset = GB2312_CHARSET
         Font.Color = clWindowText
         Font.Height = -12
-        Font.Name = #23435#20307
+        Font.Name = 'smartSimSun'
         Font.Style = []
         FieldName = 'Units'
         Width = 35

+ 1 - 1
Frames/BillsCompileFme.dfm

@@ -261,7 +261,7 @@ object BillsCompileFrame: TBillsCompileFrame
         Font.Charset = GB2312_CHARSET
         Font.Color = clWindowText
         Font.Height = -12
-        Font.Name = #23435#20307
+        Font.Name = 'smartSimSun'
         Font.Style = []
         FieldName = 'Units'
         Width = 55

+ 549 - 236
Frames/BillsGatherFme.dfm

@@ -1,8 +1,8 @@
 object BillsGatherFrame: TBillsGatherFrame
   Left = 0
   Top = 0
-  Width = 798
-  Height = 513
+  Width = 1477
+  Height = 574
   Font.Charset = ANSI_CHARSET
   Font.Color = clWindowText
   Font.Height = -12
@@ -12,8 +12,8 @@ object BillsGatherFrame: TBillsGatherFrame
   TabOrder = 0
   object sprBillsGather: TSplitter
     Left = 0
-    Top = 317
-    Width = 798
+    Top = 378
+    Width = 1477
     Height = 3
     Cursor = crVSplit
     Align = alBottom
@@ -21,16 +21,16 @@ object BillsGatherFrame: TBillsGatherFrame
   object pnlBillsGather: TPanel
     Left = 0
     Top = 0
-    Width = 798
-    Height = 317
+    Width = 1477
+    Height = 378
     Align = alClient
     BevelOuter = bvNone
     TabOrder = 0
-    object zgBillsGather: TZJGrid
+    object zgGclBills: TZJGrid
       Left = 0
       Top = 0
-      Width = 798
-      Height = 317
+      Width = 1477
+      Height = 378
       Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection, goShowTreeLine]
       OptionsEx = []
       ColCount = 29
@@ -38,16 +38,19 @@ object BillsGatherFrame: TBillsGatherFrame
       FixedRowCount = 2
       ShowGridLine = False
       DefaultColWidth = 73
+      DefaultFixedColWidth = 25
       Selection.AlphaBlend = False
       Selection.TransparentColor = False
-      OnCellGetColor = zgBillsGatherCellGetColor
+      FrozenCol = 0
+      FrozenRow = 0
+      OnCellGetColor = zgGclBillsCellGetColor
       Align = alClient
     end
   end
   object pnlRelaXmj: TPanel
     Left = 0
-    Top = 320
-    Width = 798
+    Top = 381
+    Width = 1477
     Height = 193
     Align = alBottom
     BevelOuter = bvNone
@@ -55,7 +58,7 @@ object BillsGatherFrame: TBillsGatherFrame
     object pnlRelaXmjType: TPanel
       Left = 0
       Top = 0
-      Width = 798
+      Width = 1477
       Height = 21
       Align = alTop
       BevelOuter = bvNone
@@ -63,49 +66,548 @@ object BillsGatherFrame: TBillsGatherFrame
       object tbToolsButton: TToolBar
         Left = 0
         Top = 0
-        Width = 79
+        Width = 273
         Height = 21
         Align = alLeft
         AutoSize = True
         ButtonHeight = 20
-        ButtonWidth = 79
+        ButtonWidth = 91
         Caption = 'tbToolsButton'
         EdgeBorders = []
         Flat = True
         ShowCaptions = True
         TabOrder = 0
-        object tobtnFlatType: TToolButton
+        object tobtnDetailGcl: TToolButton
           Left = 0
           Top = 0
           Caption = ' '#25152#23646#39033#30446#33410' '
           Down = True
           ImageIndex = 0
           Style = tbsCheck
+          OnClick = tobtnDetailGclClick
         end
+        object tobtnDetailDeal: TToolButton
+          Tag = 1
+          Left = 91
+          Top = 0
+          Caption = ' '#30456#20851#31614#32422#28165#21333' '
+          ImageIndex = 1
+          Style = tbsCheck
+          OnClick = tobtnDetailGclClick
+        end
+        object tobtnDetailBGL: TToolButton
+          Tag = 2
+          Left = 182
+          Top = 0
+          Caption = #30456#20851#21464#26356#28165#21333
+          ImageIndex = 2
+          Style = tbsCheck
+          OnClick = tobtnDetailGclClick
+        end
+      end
+    end
+    object jpsRela: TJimPages
+      Left = 0
+      Top = 21
+      Width = 1477
+      Height = 172
+      ActivePage = jpsRelaDetailGcl
+      ActivePageIndex = 0
+      Align = alClient
+      object jpsRelaDetailGcl: TJimPage
+        Left = 0
+        Top = 0
+        Width = 1477
+        Height = 172
+        TabName = 'DetailGcl'
+        Caption = 'Xmj'
+        object zgDetailGcl: TZJGrid
+          Left = 0
+          Top = 0
+          Width = 1477
+          Height = 172
+          Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+          OptionsEx = []
+          ColCount = 9
+          ShowGridLine = False
+          DefaultColWidth = 73
+          DefaultFixedColWidth = 25
+          Selection.AlphaBlend = False
+          Selection.TransparentColor = False
+          FrozenCol = 0
+          FrozenRow = 0
+          Align = alClient
+        end
+      end
+      object jpsRelaDetailDeal: TJimPage
+        Left = 0
+        Top = 0
+        Width = 1477
+        Height = 172
+        TabName = 'DetailDeal'
+        Caption = 'Deal'
+        object zgDetailDeal: TZJGrid
+          Left = 0
+          Top = 0
+          Width = 1477
+          Height = 172
+          Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+          OptionsEx = []
+          ColCount = 7
+          ShowGridLine = False
+          DefaultColWidth = 73
+          DefaultFixedColWidth = 25
+          Selection.AlphaBlend = False
+          Selection.TransparentColor = False
+          FrozenCol = 0
+          FrozenRow = 0
+          Align = alClient
+        end
+      end
+      object jpsRelaDetailBGL: TJimPage
+        Left = 0
+        Top = 0
+        Width = 1477
+        Height = 172
+        TabName = 'DetailBGL'
+        Caption = 'BGL'
+        object zgDetailBGL: TZJGrid
+          Left = 0
+          Top = 0
+          Width = 1477
+          Height = 172
+          Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+          OptionsEx = []
+          ColCount = 7
+          ShowGridLine = False
+          DefaultColWidth = 73
+          DefaultFixedColWidth = 25
+          Selection.AlphaBlend = False
+          Selection.TransparentColor = False
+          FrozenCol = 0
+          FrozenRow = 0
+          Align = alClient
+        end
+      end
+    end
+  end
+  object xpm: TXPMenu
+    DimLevel = 30
+    GrayLevel = 10
+    Font.Charset = DEFAULT_CHARSET
+    Font.Color = clMenuText
+    Font.Height = -12
+    Font.Name = #23435#20307
+    Font.Style = []
+    Color = clBtnFace
+    IconBackColor = clBtnFace
+    MenuBarColor = clBtnFace
+    SelectColor = 38640
+    SelectBorderColor = clHighlight
+    SelectFontColor = clMenuText
+    DisabledColor = clInactiveCaption
+    SeparatorColor = clBtnFace
+    CheckedColor = clHighlight
+    IconWidth = 24
+    DrawSelect = True
+    UseSystemColors = False
+    OverrideOwnerDraw = False
+    Gradient = False
+    FlatMenu = False
+    AutoDetect = True
+    XPControls = [xcToolbar]
+    Active = True
+    ControlUseTrueXPStyle = True
+    BtnRoundArc = 5
+    BtnOutLineBorderColor = 7552000
+    BtnInnerBorderMoveColor = 3257087
+    BtnInnerBorderFocusColor = 15183500
+    BtnSurfaceNormalColor = 16251903
+    BtnSurfaceDownColor = 14608359
+    BtnSurfaceBottomLineColor = 14608359
+    BtnSurfaceDownBottomLineColor = 15199215
+    RdoChkControlChkColor = 41472
+    ComboBoxChkColor = 9201994
+    ComboboxSurfaceMoveColor = 16771030
+    ControlDisabledBorderColor = 11913158
+    Left = 7
+    Top = 8
+  end
+  object saDetailGcl: TsdGridDBA
+    Columns = <
+      item
+        Title.Caption = #39033#30446#33410#32534#21495
+        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 = 'XmjCode'
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #26729#21495
+        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 = 'Pos'
+        Width = 180
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #25968#37327
+        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 = 'Quantity'
+        Width = 60
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21333#20301#24037#31243
+        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 = 'NameDanWei'
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #20998#37096#24037#31243
+        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 = 'NameFenBu'
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #20998#39033#24037#31243
+        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 = 'NameFenXiang'
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #35745#37327#21333#20803
+        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 = 'NameUnit'
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #22270'('#20876')'#21495
+        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 = 'DrawingCode'
+        ReadOnly = False
+      end>
+    Grid = zgDetailGcl
+    ExtendRowCount = 3
+    Options = []
+    Left = 160
+    Top = 456
+  end
+  object saDetailDeal: TsdGridDBA
+    Columns = <
+      item
+        Title.Caption = #28165#21333#32534#21495
+        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 = 'B_Code'
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21517#31216
+        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 = 'Name'
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21333#20301
+        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 = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Units'
+        Width = 45
+        ReadOnly = False
+      end
+      item
+        Title.Caption = #21333#20215
+        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 = 'Price'
+        Width = 60
+        ReadOnly = False
+      end
+      item
+        Title.Caption = #25968#37327
+        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 = 'Quantity'
+        ReadOnly = True
+      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 = 'TotalPrice'
+        ReadOnly = True
+      end>
+    Grid = zgDetailDeal
+    ExtendRowCount = 3
+    Options = []
+    Left = 224
+    Top = 456
+  end
+  object saDetailBGL: TsdGridDBA
+    Columns = <
+      item
+        Title.Caption = #21464#26356#20196#21495
+        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 = 'BGLCode'
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21517#31216
+        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 = 'BGLName'
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #25209#22797#25991#21495
+        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 = 'BGLApprovalCode'
+        ReadOnly = False
+      end
+      item
+        Title.Caption = #21464#26356#22270#21495
+        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 = 'BGLDrawingCode'
+        ReadOnly = False
       end
-    end
-    object zgRelaXmj: TZJGrid
-      Left = 0
-      Top = 21
-      Width = 798
-      Height = 172
-      Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
-      OptionsEx = []
-      ColCount = 9
-      ShowGridLine = False
-      DefaultColWidth = 73
-      DefaultFixedRowHeight = 25
-      Selection.AlphaBlend = False
-      Selection.TransparentColor = False
-      Align = alClient
-    end
+      item
+        Title.Caption = #25968#37327
+        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 = 'Quantity'
+        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 = 'TotalPrice'
+        Width = 60
+        ReadOnly = False
+      end>
+    Grid = zgDetailBGL
+    ExtendRowCount = 3
+    Options = []
+    Left = 288
+    Top = 456
   end
-  object zdBillsGather: TZjGridDBA
+  object saGclBills: TsdGridDBA
     Columns = <
       item
-        Title.Caption = 'IndexCode'
+        Title.Caption = #32034#24341#32534#21495
         Title.CaptionAcrossCols = '1'
-        Title.CaptionAcrossRows = 2
         Title.Font.Charset = GB2312_CHARSET
         Title.Font.Color = clWindowText
         Title.Font.Height = -12
@@ -118,7 +620,6 @@ object BillsGatherFrame: TBillsGatherFrame
         Font.Name = #23435#20307
         Font.Style = []
         FieldName = 'IndexCode'
-        Width = 60
         Visible = False
         ReadOnly = False
       end
@@ -167,7 +668,7 @@ object BillsGatherFrame: TBillsGatherFrame
         Title.Font.Charset = GB2312_CHARSET
         Title.Font.Color = clWindowText
         Title.Font.Height = -12
-        Title.Font.Name = #23435#20307
+        Title.Font.Name = 'smartSimSun'
         Title.Font.Style = []
         Alignment = taCenter
         Font.Charset = GB2312_CHARSET
@@ -233,7 +734,7 @@ object BillsGatherFrame: TBillsGatherFrame
         Font.Style = []
         FieldName = 'DealQuantity'
         Width = 60
-        ReadOnly = False
+        ReadOnly = True
       end
       item
         Title.Caption = '|'#37329#39069
@@ -251,7 +752,7 @@ object BillsGatherFrame: TBillsGatherFrame
         Font.Style = []
         FieldName = 'DealTotalPrice'
         Width = 60
-        ReadOnly = False
+        ReadOnly = True
       end
       item
         Title.Caption = '0'#21495#21488#36134#21512#21516'|'#25968#37327
@@ -417,7 +918,7 @@ object BillsGatherFrame: TBillsGatherFrame
       end
       item
         Title.Caption = '|'#37329#39069
-        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossCols = '2'
         Title.Font.Charset = GB2312_CHARSET
         Title.Font.Color = clWindowText
         Title.Font.Height = -12
@@ -578,7 +1079,7 @@ object BillsGatherFrame: TBillsGatherFrame
         ReadOnly = True
       end
       item
-        Title.Caption = #21512#21516#21152#21464#26356#20196'|'#25968#37327
+        Title.Caption = #21512#21516'+'#21464#26356#20196'|'#25968#37327
         Title.CaptionAcrossCols = '3'
         Title.Font.Charset = GB2312_CHARSET
         Title.Font.Color = clWindowText
@@ -593,7 +1094,7 @@ object BillsGatherFrame: TBillsGatherFrame
         Font.Style = []
         FieldName = 'Deal_BGLQuantity'
         Width = 60
-        ReadOnly = False
+        ReadOnly = True
       end
       item
         Title.Caption = '|'#37329#39069
@@ -611,7 +1112,7 @@ object BillsGatherFrame: TBillsGatherFrame
         Font.Style = []
         FieldName = 'Deal_BGLTotalPrice'
         Width = 60
-        ReadOnly = False
+        ReadOnly = True
       end
       item
         Title.Caption = '|'#23436#25104#29575'(%)'
@@ -627,201 +1128,13 @@ object BillsGatherFrame: TBillsGatherFrame
         Font.Height = -12
         Font.Name = #23435#20307
         Font.Style = []
-        FieldName = 'CompletionRate'
+        FieldName = 'Deal_BGLPercent'
         Width = 63
-        ReadOnly = False
-      end>
-    Grid = zgBillsGather
-    ExtendRowCount = 0
-    Options = []
-    Left = 160
-    Top = 104
-  end
-  object zaRelaXmj: TZjGridDBA
-    Columns = <
-      item
-        Title.Caption = #39033#30446#33410#32534#21495
-        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 = 'Code'
-        Width = 80
-        ReadOnly = True
-      end
-      item
-        Title.Caption = #26729#21495
-        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 = 'Peg'
-        Width = 180
-        ReadOnly = True
-      end
-      item
-        Title.Caption = #25968#37327
-        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 = 'Quantity'
-        Width = 60
-        ReadOnly = True
-      end
-      item
-        Title.Caption = #21333#20301#24037#31243
-        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 = 'NameDanWei'
-        ReadOnly = True
-      end
-      item
-        Title.Caption = #20998#37096#24037#31243
-        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 = 'NameFenBu'
-        ReadOnly = True
-      end
-      item
-        Title.Caption = #20998#39033#24037#31243
-        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 = 'NameFenXiang'
-        ReadOnly = True
-      end
-      item
-        Title.Caption = #35745#37327#21333#20803
-        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 = 'NameUnit'
-        ReadOnly = True
-      end
-      item
-        Title.Caption = #22270'('#20876')'#21495
-        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 = 'DrawingCode'
         ReadOnly = True
       end>
-    Grid = zgRelaXmj
-    Left = 160
-    Top = 400
-  end
-  object xpm: TXPMenu
-    DimLevel = 30
-    GrayLevel = 10
-    Font.Charset = DEFAULT_CHARSET
-    Font.Color = clMenuText
-    Font.Height = -12
-    Font.Name = #23435#20307
-    Font.Style = []
-    Color = clBtnFace
-    IconBackColor = clBtnFace
-    MenuBarColor = clBtnFace
-    SelectColor = 38640
-    SelectBorderColor = clHighlight
-    SelectFontColor = clMenuText
-    DisabledColor = clInactiveCaption
-    SeparatorColor = clBtnFace
-    CheckedColor = clHighlight
-    IconWidth = 24
-    DrawSelect = True
-    UseSystemColors = False
-    OverrideOwnerDraw = False
-    Gradient = False
-    FlatMenu = False
-    AutoDetect = True
-    XPControls = [xcToolbar]
-    Active = True
-    ControlUseTrueXPStyle = True
-    BtnRoundArc = 5
-    BtnOutLineBorderColor = 7552000
-    BtnInnerBorderMoveColor = 3257087
-    BtnInnerBorderFocusColor = 15183500
-    BtnSurfaceNormalColor = 16251903
-    BtnSurfaceDownColor = 14608359
-    BtnSurfaceBottomLineColor = 14608359
-    BtnSurfaceDownBottomLineColor = 15199215
-    RdoChkControlChkColor = 41472
-    ComboBoxChkColor = 9201994
-    ComboboxSurfaceMoveColor = 16771030
-    ControlDisabledBorderColor = 11913158
-    Left = 7
-    Top = 8
+    Grid = zgGclBills
+    ExtendRowCount = 3
+    Left = 224
+    Top = 104
   end
 end

+ 51 - 26
Frames/BillsGatherFme.pas

@@ -3,26 +3,37 @@ unit BillsGatherFme;
 interface
 
 uses
-  BillsGatherDm, Globals,
+  BillsGatherDm, Globals, sdDB,
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
   Dialogs, ZJGrid, ExtCtrls, ZjGridDBA, ZjGridTreeDBA, ComCtrls, ToolWin,
-  XPMenu;
+  XPMenu, sdGridDBA, JimPages;
 
 type
   TBillsGatherFrame = class(TFrame)
     pnlBillsGather: TPanel;
-    zgBillsGather: TZJGrid;
-    zdBillsGather: TZjGridDBA;
+    zgGclBills: TZJGrid;
     pnlRelaXmj: TPanel;
     pnlRelaXmjType: TPanel;
     tbToolsButton: TToolBar;
-    tobtnFlatType: TToolButton;
-    zgRelaXmj: TZJGrid;
+    tobtnDetailGcl: TToolButton;
     sprBillsGather: TSplitter;
-    zaRelaXmj: TZjGridDBA;
     xpm: TXPMenu;
-    procedure zgBillsGatherCellGetColor(Sender: TObject; ACoord: TPoint;
+    tobtnDetailDeal: TToolButton;
+    tobtnDetailBGL: TToolButton;
+    jpsRela: TJimPages;
+    jpsRelaDetailGcl: TJimPage;
+    jpsRelaDetailDeal: TJimPage;
+    jpsRelaDetailBGL: TJimPage;
+    zgDetailGcl: TZJGrid;
+    saDetailGcl: TsdGridDBA;
+    saDetailDeal: TsdGridDBA;
+    saDetailBGL: TsdGridDBA;
+    zgDetailBGL: TZJGrid;
+    zgDetailDeal: TZJGrid;
+    saGclBills: TsdGridDBA;
+    procedure zgGclBillsCellGetColor(Sender: TObject; ACoord: TPoint;
       var AColor: TColor);
+    procedure tobtnDetailGclClick(Sender: TObject);
   private
     FBillsGatherData: TBillsGatherData;
     FShowPhaseData: Boolean;
@@ -53,13 +64,14 @@ constructor TBillsGatherFrame.Create(AProjectFrame: TFrame;
 begin
   inherited Create(AProjectFrame);
   FBillsGatherData := ABillsGatherData;
-  zdBillsGather.DataSet := FBillsGatherData.cdsBillsGather;
-  zaRelaXmj.DataSet := FBillsGatherData.cdsRelaXmj;
+  saGclBills.DataView := FBillsGatherData.sdvGclBills;
+  saDetailGcl.DataView := FBillsGatherData.sdvDetailGclBills;
+  saDetailDeal.DataView := FBillsGatherData.sdvDetailDealBills;
+  saDetailBGL.DataView := FBillsGatherData.sdvDetailBGLBills;
 end;
 
 destructor TBillsGatherFrame.Destroy;
 begin
-
   inherited;
 end;
 
@@ -72,9 +84,9 @@ procedure TBillsGatherFrame.SetColumnVisible(const AColumn: string;
   AVisible: Boolean);
 begin
   if AVisible then
-    zdBillsGather.Column(AColumn).Width := 60
+    saGclBills.Columns.ColumnByName(AColumn).Width := 60
   else
-    zdBillsGather.Column(AColumn).Width := 0;
+    saGclBills.Columns.ColumnByName(AColumn).Width := 0;
 end;
 
 procedure TBillsGatherFrame.SetShowPhaseData(const Value: Boolean);
@@ -108,27 +120,32 @@ begin
   SetColumnVisible('EndPcTotalPrice', FShowPriceChange and FShowPhaseData);
 end;
 
-procedure TBillsGatherFrame.zgBillsGatherCellGetColor(Sender: TObject;
+procedure TBillsGatherFrame.zgGclBillsCellGetColor(Sender: TObject;
   ACoord: TPoint; var AColor: TColor);
 
   function CheckSimilarBills(ARow1, ARow2: Integer): Boolean;
   var
     bHasSame, bHasDiffer: Boolean;
   begin
-    bHasSame := SameText(zgBillsGather.Cells[1, ARow1].Text, zgBillsGather.Cells[1, ARow2].Text);
-    bHasDiffer := (not SameText(zgBillsGather.Cells[2, ARow1].Text, zgBillsGather.Cells[2, ARow2].Text))
-               or (not SameText(zgBillsGather.Cells[3, ARow1].Text, zgBillsGather.Cells[3, ARow2].Text))
-               or (not SameText(zgBillsGather.Cells[4, ARow1].Text, zgBillsGather.Cells[4, ARow2].Text));
+    bHasSame := SameText(zgGclBills.Cells[1, ARow1].Text, zgGclBills.Cells[1, ARow2].Text);
+    bHasDiffer := (not SameText(zgGclBills.Cells[2, ARow1].Text, zgGclBills.Cells[2, ARow2].Text))
+               or (not SameText(zgGclBills.Cells[3, ARow1].Text, zgGclBills.Cells[3, ARow2].Text))
+               or (not SameText(zgGclBills.Cells[4, ARow1].Text, zgGclBills.Cells[4, ARow2].Text));
     Result := bHasSame and bHasDiffer;
   end;
 
-  function CheckOverRange(ARow: Integer): Boolean;
+  function CheckOverRange(ARecIndex: Integer): Boolean;
   var
+    Rec: TsdDataRecord;
     fQuantity, fDealQuantity, fEndDealQuantity: Double;
   begin
-    fDealQuantity := StrToFloatDef(zgBillsGather.Cells[6, ARow].Text, 0);
-    fQuantity := StrToFloatDef(zgBillsGather.Cells[8, ARow].Text, 0);
-    fEndDealQuantity := StrToFloatDef(zgBillsGather.Cells[18, ARow].Text, 0);
+    Rec := saGclBills.DataView.Records[ARecIndex];
+    Result := False;
+    if not Assigned(Rec) then Exit;
+
+    fDealQuantity := Rec.ValueByName('DealQuantity').AsFloat;
+    fQuantity := Rec.ValueByName('Quantity').AsFloat;
+    fEndDealQuantity := Rec.ValueByName('EndDealQuantity').AsFloat;
     case SupportManager.ConfigInfo.OverRangeType of
       0: Result := fEndDealQuantity > fQuantity;
       1: Result := fEndDealQuantity > fDealQuantity;
@@ -139,11 +156,11 @@ procedure TBillsGatherFrame.zgBillsGatherCellGetColor(Sender: TObject;
 var
   bSimilarBills: Boolean;
 begin
-  if ACoord.Y >= zgBillsGather.FixedRowCount then
+  if (ACoord.Y >= zgGclBills.FixedRowCount) then
   begin
-    if ACoord.Y = zgBillsGather.FixedRowCount then
+    if ACoord.Y = zgGclBills.FixedRowCount then
       bSimilarBills := CheckSimilarBills(ACoord.Y, ACoord.Y + 1)
-    else if ACoord.Y < zgBillsGather.RowCount - zgBillsGather.FixedRowCount then
+    else if ACoord.Y < zgGclBills.RowCount - zgGclBills.FixedRowCount then
       bSimilarBills := CheckSimilarBills(ACoord.Y, ACoord.Y - 1) or
           CheckSimilarBills(ACoord.Y, ACoord.Y + 1)
     else
@@ -152,9 +169,17 @@ begin
       AColor := $00646AFE;}
      if bSimilarBills then
        AColor := $0000FFFF; // »ÆÉ«
-     if CheckOverRange(ACoord.Y) then
+     if CheckOverRange(ACoord.Y - zgGclBills.FixedRowCount) then
        AColor := $00505AFF; // ºìÉ«
   end;
 end;
 
+procedure TBillsGatherFrame.tobtnDetailGclClick(Sender: TObject);
+begin
+  jpsRela.ActivePageIndex := TToolButton(Sender).Tag;
+  tobtnDetailGcl.Down := tobtnDetailGcl.Tag = TToolButton(Sender).Tag;
+  tobtnDetailDeal.Down := tobtnDetailDeal.Tag = TToolButton(Sender).Tag;
+  tobtnDetailBGL.Down := tobtnDetailBGL.Tag = TToolButton(Sender).Tag;
+end;
+
 end.

+ 58 - 1
Frames/BillsMeasureFme.dfm

@@ -218,7 +218,7 @@ object BillsMeasureFrame: TBillsMeasureFrame
         Font.Charset = GB2312_CHARSET
         Font.Color = clWindowText
         Font.Height = -12
-        Font.Name = #23435#20307
+        Font.Name = 'smartSimSun'
         Font.Style = []
         FieldName = 'Units'
         Width = 55
@@ -959,6 +959,63 @@ object BillsMeasureFrame: TBillsMeasureFrame
         Font.Style = []
         FieldName = 'MemoStr'
         ReadOnly = False
+      end
+      item
+        Title.Caption = #26448#26009#35843#24046'|'#25130#27490#19978#26399
+        Title.CaptionAcrossCols = '3'
+        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 = 'PM_PreTotalPrice'
+        Width = 60
+        Visible = False
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#26412#26399
+        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 = 'PM_TotalPrice'
+        Width = 60
+        Visible = False
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#32047#35745
+        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 = 'PM_AddTotalPrice'
+        Width = 60
+        Visible = False
+        ReadOnly = True
       end>
     Grid = zgBillsMeasure
     ExtendRowCount = 3

+ 20 - 3
Frames/BillsMeasureFme.pas

@@ -56,13 +56,15 @@ type
     FShowBGLCode: Boolean;
     FShowDesignQuantity: Boolean;
     FShowAddField: Boolean; // For Inner Test
+    FShowPMField: Boolean; // For Inner Test
     FOnAfterSetBookmark: TBookmarkRefreshEvent;
     FShowAlias: Boolean;
 
     function CheckExprsColumn: Boolean;
 
     procedure SetColumnVisible(const AColumn: string; AVisible: Boolean);
-    procedure SetAddFieldVisiblie(AValue: Boolean);
+    procedure SetAddFieldVisible(AValue: Boolean);
+    procedure SetPMFieldVisible(AValue: Boolean);
 
     procedure LoadDealProperty(ARec: TsdDataRecord);
 
@@ -384,7 +386,7 @@ begin
   stdBillsMeasure.Column('AddDgnPrice').Visible := FShowDesignQuantity;
 end;
 
-procedure TBillsMeasureFrame.SetAddFieldVisiblie(AValue: Boolean);
+procedure TBillsMeasureFrame.SetAddFieldVisible(AValue: Boolean);
 begin
   FShowAddField := AValue;
   stdBillsMeasure.Column('AddDealQuantity').Visible := AValue;
@@ -404,7 +406,7 @@ begin
   if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
       and (Key in [65, 97]) // 'a', 'A'
       and (zgBillsMeasure.CurCol = 4) then
-    SetAddFieldVisiblie(not FShowAddField);
+    SetAddFieldVisible(not FShowAddField);
 
   if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
       and (Key in [80, 112]) // 'p', 'P' - Parent
@@ -415,6 +417,13 @@ begin
   end;
 
   if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
+      and (Key in [77, 109]) // 'm', 'M' - PriceMargin
+      and (zgBillsMeasure.CurCol = 5) then
+  begin
+    SetPMFieldVisible(not FShowPMField);
+  end;
+
+  if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
       and (Key in [67, 99]) then // 'c', 'C'
     actnCalculateAll.Execute;
 end;
@@ -638,4 +647,12 @@ begin
     stdBillsMeasure.Options := stdBillsMeasure.Options - [aoAllowInsert];
 end;
 
+procedure TBillsMeasureFrame.SetPMFieldVisible(AValue: Boolean);
+begin
+  FShowAddField := AValue;
+  stdBillsMeasure.Column('PM_PreTotalPrice').Visible := AValue;
+  stdBillsMeasure.Column('PM_TotalPrice').Visible := AValue;
+  stdBillsMeasure.Column('PM_AddTotalPrice').Visible := AValue;
+end;
+
 end.

+ 3 - 1
Frames/DealBillsFme.dfm

@@ -26,6 +26,8 @@ object DealBillsFrame: TDealBillsFrame
       DefaultFixedColWidth = 25
       Selection.AlphaBlend = False
       Selection.TransparentColor = False
+      FrozenCol = 0
+      FrozenRow = 0
       OnMouseDown = zgDealBillsMouseDown
       Align = alClient
     end
@@ -107,7 +109,7 @@ object DealBillsFrame: TDealBillsFrame
         Font.Charset = GB2312_CHARSET
         Font.Color = clWindowText
         Font.Height = -12
-        Font.Name = #23435#20307
+        Font.Name = 'smartSimSun'
         Font.Style = []
         FieldName = 'Units'
         Width = 45

+ 1 - 1
Frames/PhaseCompareFme.dfm

@@ -104,7 +104,7 @@ object PhaseCompareFrame: TPhaseCompareFrame
         Font.Charset = GB2312_CHARSET
         Font.Color = clWindowText
         Font.Height = -12
-        Font.Name = #23435#20307
+        Font.Name = 'smartSimSun'
         Font.Style = []
         FieldName = 'Units'
         Width = 50

+ 745 - 0
Frames/PriceMarginBillsFme.dfm

@@ -0,0 +1,745 @@
+object PriceMarginBillsFrame: TPriceMarginBillsFrame
+  Left = 0
+  Top = 0
+  Width = 1178
+  Height = 645
+  TabOrder = 0
+  object pnlBills: TPanel
+    Left = 0
+    Top = 0
+    Width = 1178
+    Height = 645
+    Align = alClient
+    BevelOuter = bvNone
+    TabOrder = 0
+    object sprDetail: TSplitter
+      Left = 0
+      Top = 435
+      Width = 1178
+      Height = 3
+      Cursor = crVSplit
+      Align = alBottom
+    end
+    object pnlGclBills: TPanel
+      Left = 0
+      Top = 0
+      Width = 1178
+      Height = 435
+      Align = alClient
+      BevelOuter = bvNone
+      TabOrder = 0
+      object zgGclBills: TZJGrid
+        Left = 0
+        Top = 0
+        Width = 1178
+        Height = 435
+        Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+        OptionsEx = []
+        ColCount = 8
+        RowCount = 6
+        FixedRowCount = 2
+        ShowGridLine = False
+        DefaultColWidth = 73
+        DefaultFixedColWidth = 25
+        Selection.AlphaBlend = False
+        Selection.TransparentColor = False
+        FrozenCol = 0
+        FrozenRow = 0
+        Align = alClient
+      end
+    end
+    object pnlDetail: TPanel
+      Left = 0
+      Top = 438
+      Width = 1178
+      Height = 207
+      Align = alBottom
+      BevelOuter = bvNone
+      TabOrder = 1
+      object sprRela: TSplitter
+        Left = 638
+        Top = 0
+        Height = 207
+        Align = alRight
+      end
+      object pnlRelaData: TPanel
+        Left = 641
+        Top = 0
+        Width = 537
+        Height = 207
+        Align = alRight
+        BevelOuter = bvNone
+        TabOrder = 0
+        object pnlRelaTop: TPanel
+          Left = 0
+          Top = 0
+          Width = 537
+          Height = 21
+          Align = alTop
+          BevelOuter = bvNone
+          TabOrder = 0
+          object tbRelaTop: TToolBar
+            Left = 0
+            Top = 0
+            Width = 134
+            Height = 21
+            Align = alLeft
+            AutoSize = True
+            ButtonHeight = 21
+            ButtonWidth = 67
+            EdgeBorders = []
+            Flat = True
+            ShowCaptions = True
+            TabOrder = 0
+            object tobtnDetailGL: TToolButton
+              Left = 0
+              Top = 0
+              Caption = '  '#35843#24046#24037#26009'  '
+              Down = True
+              ImageIndex = 2
+              Style = tbsCheck
+            end
+            object tobtnParent: TToolButton
+              Tag = 1
+              Left = 67
+              Top = 0
+              Caption = #28165#21333#29238#39033
+              ImageIndex = 0
+              Style = tbsCheck
+            end
+          end
+        end
+        object jpsRela: TJimPages
+          Left = 0
+          Top = 21
+          Width = 537
+          Height = 186
+          ActivePage = jpsRelaDetailGL
+          ActivePageIndex = 0
+          Align = alClient
+          Caption = 'jpsRela'
+          object jpsRelaDetailGL: TJimPage
+            Left = 0
+            Top = 0
+            Width = 537
+            Height = 186
+            TabName = 'DetailGL'
+            Caption = 'DetailGL'
+            object zgDetailGL: TZJGrid
+              Left = 0
+              Top = 0
+              Width = 537
+              Height = 186
+              Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+              OptionsEx = []
+              ShowGridLine = False
+              DefaultColWidth = 73
+              DefaultFixedColWidth = 25
+              Selection.AlphaBlend = False
+              Selection.TransparentColor = False
+              FrozenCol = 0
+              FrozenRow = 0
+              OnMouseDown = zgDetailGLMouseDown
+              Align = alClient
+            end
+          end
+          object jpsRelaBillsParent: TJimPage
+            Left = 0
+            Top = 0
+            Width = 537
+            Height = 186
+            TabName = 'BillsParent'
+            Caption = 'BillsParent'
+          end
+        end
+      end
+      object pnlDetailBills: TPanel
+        Left = 0
+        Top = 0
+        Width = 638
+        Height = 207
+        Align = alClient
+        BevelOuter = bvNone
+        TabOrder = 1
+        object labTitle: TJimGradLabel
+          Left = 0
+          Top = 0
+          Width = 638
+          Height = 20
+          Align = alTop
+          AutoSize = False
+          ColorBegin = clGradientInactiveCaption
+          ColorEnd = clGradientInactiveCaption
+          Caption = ' '#35814#32454#28165#21333
+          Font.Charset = GB2312_CHARSET
+          Font.Color = clWindowText
+          Font.Height = -12
+          Font.Name = #23435#20307
+          Font.Style = [fsBold]
+          ParentFont = False
+          Layout = tlCenter
+        end
+        object zgDetailGclBills: TZJGrid
+          Left = 0
+          Top = 20
+          Width = 638
+          Height = 187
+          Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+          OptionsEx = []
+          ColCount = 13
+          RowCount = 6
+          FixedRowCount = 2
+          ShowGridLine = False
+          DefaultColWidth = 73
+          DefaultFixedColWidth = 25
+          Selection.AlphaBlend = False
+          Selection.TransparentColor = False
+          FrozenCol = 0
+          FrozenRow = 0
+          OnMouseDown = zgDetailGclBillsMouseDown
+          Align = alClient
+        end
+      end
+    end
+  end
+  object saGclBills: TsdGridDBA
+    Columns = <
+      item
+        Title.Caption = #28165#21333#32534#21495
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 2
+        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 = 'B_Code'
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21517#31216
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 2
+        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 = 'Name'
+        Width = 180
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21333#20301
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 2
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = 'smartSimSun'
+        Font.Style = []
+        FieldName = 'Units'
+        Width = 45
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21333#20215
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 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 = 'Price'
+        Width = 60
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #26412#26399#35745#37327#25968#37327'|'#21512#21516
+        Title.CaptionAcrossCols = '3'
+        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 = 'CurDealQuantity'
+        Width = 65
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#25968#37327#21464#26356
+        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 = 'CurQcQuantity'
+        Width = 65
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#23567#35745
+        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 = 'CurGatherQuantity'
+        Width = 65
+        ReadOnly = True
+      end>
+    Grid = zgGclBills
+    ExtendRowCount = 3
+    Options = []
+    Left = 112
+    Top = 96
+  end
+  object saDetailGclBills: TsdGridDBA
+    Columns = <
+      item
+        Title.Caption = #25152#23646#39033#30446#33410'|'#32534#21495
+        Title.CaptionAcrossCols = '3'
+        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 = 'XmjCode'
+        Width = 80
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#21517#31216
+        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 = 'XmjName'
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#21333#20301
+        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 = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'XmjUnits'
+        Width = 45
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #37096#20301#20449#24687'|'#26729#21495
+        Title.CaptionAcrossCols = '5'
+        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 = 'Peg'
+        Width = 80
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#21333#20301#24037#31243
+        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 = 'NameDanWei'
+        Width = 80
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#20998#37096#24037#31243
+        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 = 'NameFenBu'
+        Width = 80
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#20998#39033#24037#31243
+        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 = 'NameFenXiang'
+        Width = 80
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#35745#37327#21333#20803
+        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 = 'NameUnit'
+        Width = 80
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #26412#26399#35745#37327#25968#37327'|'#21512#21516
+        Title.CaptionAcrossCols = '3'
+        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 = 'CurDealQuantity'
+        Width = 60
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#25968#37327#21464#26356
+        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 = 'CurQcQuantity'
+        Width = 60
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#23567#35745
+        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 = 'CurGatherQuantity'
+        Width = 60
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #26412#26399#20215#24046
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 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 = 'PM_TotalPrice'
+        Width = 60
+        ReadOnly = True
+      end>
+    Grid = zgDetailGclBills
+    ExtendRowCount = 3
+    Options = []
+    Left = 96
+    Top = 496
+  end
+  object saDetailGL: TsdGridDBA
+    Columns = <
+      item
+        Title.Caption = #32534#21495
+        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 = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Code'
+        Width = 50
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21517#31216
+        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 = 'Name'
+        Width = 120
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21333#20301
+        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 = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = 'smartSimSun'
+        Font.Style = []
+        FieldName = 'Units'
+        Width = 45
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #25968#37327
+        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 = 'Quantity'
+        Width = 60
+        ReadOnly = False
+      end>
+    Grid = zgDetailGL
+    ExtendRowCount = 3
+    Options = [aoAllowEdit, aoAllowDelete, aoAutoInsert]
+    Left = 728
+    Top = 504
+  end
+  object dxpmDetailGL: TdxBarPopupMenu
+    BarManager = MainForm.dxBarManager
+    ItemLinks = <
+      item
+        Item = MainForm.dxbtnAddDetailGLs
+        Visible = True
+      end
+      item
+        Item = MainForm.dxbtnDelete
+        Visible = True
+      end>
+    UseOwnFont = False
+    OnPopup = dxpmDetailGLPopup
+    Left = 768
+    Top = 504
+  end
+  object actnPriceMarginBills: TActionList
+    Images = MainForm.Images
+    Left = 160
+    Top = 96
+    object actnAddDetailGLs: TAction
+      Caption = #26032#22686#35843#24046#24037#26009
+      ImageIndex = 2
+      OnExecute = actnAddDetailGLsExecute
+      OnUpdate = actnAddDetailGLsUpdate
+    end
+    object actnCopyDetailGLs: TAction
+      Caption = #22797#21046#35843#24046#24037#26009
+      ImageIndex = 4
+    end
+    object actnApplyToSameBills: TAction
+      Caption = #24212#29992#35843#24046#24037#26009#33267#30456#21516#28165#21333
+      OnExecute = actnApplyToSameBillsExecute
+      OnUpdate = actnAddDetailGLsUpdate
+    end
+  end
+  object dxpmDetailGclBills: TdxBarPopupMenu
+    BarManager = MainForm.dxBarManager
+    ItemLinks = <
+      item
+        Item = MainForm.dxbtnApplyToSameBills
+        Visible = True
+      end
+      item
+        BeginGroup = True
+        Item = MainForm.dxbtnCopyDetailGls
+        Visible = True
+      end
+      item
+        Item = MainForm.dxbtnPaste
+        Visible = True
+      end>
+    UseOwnFont = False
+    OnPopup = dxpmDetailGclBillsPopup
+    Left = 136
+    Top = 496
+  end
+  object xpm: TXPMenu
+    DimLevel = 30
+    GrayLevel = 10
+    Font.Charset = DEFAULT_CHARSET
+    Font.Color = clMenuText
+    Font.Height = -12
+    Font.Name = #23435#20307
+    Font.Style = []
+    Color = clBtnFace
+    IconBackColor = clBtnFace
+    MenuBarColor = clBtnFace
+    SelectColor = 38640
+    SelectBorderColor = clHighlight
+    SelectFontColor = clMenuText
+    DisabledColor = clInactiveCaption
+    SeparatorColor = clBtnFace
+    CheckedColor = clHighlight
+    IconWidth = 24
+    DrawSelect = True
+    UseSystemColors = False
+    OverrideOwnerDraw = False
+    Gradient = False
+    FlatMenu = False
+    AutoDetect = True
+    XPControls = [xcToolbar]
+    Active = True
+    ControlUseTrueXPStyle = True
+    BtnRoundArc = 5
+    BtnOutLineBorderColor = 7552000
+    BtnInnerBorderMoveColor = 3257087
+    BtnInnerBorderFocusColor = 15183500
+    BtnSurfaceNormalColor = 16251903
+    BtnSurfaceDownColor = 14608359
+    BtnSurfaceBottomLineColor = 14608359
+    BtnSurfaceDownBottomLineColor = 15199215
+    RdoChkControlChkColor = 41472
+    ComboBoxChkColor = 9201994
+    ComboboxSurfaceMoveColor = 16771030
+    ControlDisabledBorderColor = 11913158
+    Left = 207
+    Top = 96
+  end
+end

+ 190 - 0
Frames/PriceMarginBillsFme.pas

@@ -0,0 +1,190 @@
+unit PriceMarginBillsFme;
+
+interface
+
+uses
+  SelectDetailGLsFrm,
+  PriceMarginBillsDm, ProjectGLDm, DetailGLDm, sdDB,
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, sdGridDBA, ZJGrid, ExtCtrls, StdCtrls, JimLabels, dxBar,
+  JimPages, ComCtrls, ToolWin, ActnList, XPMenu;
+
+type
+  TPriceMarginBillsFrame = class(TFrame)
+    pnlGclBills: TPanel;
+    pnlDetail: TPanel;
+    sprDetail: TSplitter;
+    zgGclBills: TZJGrid;
+    saGclBills: TsdGridDBA;
+    pnlRelaData: TPanel;
+    sprRela: TSplitter;
+    pnlDetailBills: TPanel;
+    labTitle: TJimGradLabel;
+    zgDetailGclBills: TZJGrid;
+    saDetailGclBills: TsdGridDBA;
+    pnlRelaTop: TPanel;
+    tbRelaTop: TToolBar;
+    tobtnDetailGL: TToolButton;
+    tobtnParent: TToolButton;
+    jpsRela: TJimPages;
+    jpsRelaDetailGL: TJimPage;
+    jpsRelaBillsParent: TJimPage;
+    zgDetailGL: TZJGrid;
+    saDetailGL: TsdGridDBA;
+    dxpmDetailGL: TdxBarPopupMenu;
+    pnlBills: TPanel;
+    actnPriceMarginBills: TActionList;
+    actnAddDetailGLs: TAction;
+    dxpmDetailGclBills: TdxBarPopupMenu;
+    actnCopyDetailGLs: TAction;
+    xpm: TXPMenu;
+    actnApplyToSameBills: TAction;
+    procedure zgDetailGLMouseDown(Sender: TObject; Button: TMouseButton;
+      Shift: TShiftState; X, Y: Integer);
+    procedure dxpmDetailGLPopup(Sender: TObject);
+    procedure actnAddDetailGLsExecute(Sender: TObject);
+    procedure dxpmDetailGclBillsPopup(Sender: TObject);
+    procedure actnApplyToSameBillsExecute(Sender: TObject);
+    procedure zgDetailGclBillsMouseDown(Sender: TObject;
+      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
+    procedure actnAddDetailGLsUpdate(Sender: TObject);
+  private
+    FPriceMarginBillsData: TPriceMarginBillsData;
+    FProjectGLData: TProjectGLData;
+    FDetailGLData: TDetailGLData;
+
+    procedure AddDetailGLs;
+  public
+    constructor Create(APriceMarginBillsData: TPriceMarginBillsData);
+    destructor Destroy; override;
+
+    procedure ResetViewControl;
+  end;
+
+implementation
+
+uses
+  UtilMethods, MainFrm, BillsTree, ProjectData;
+
+{$R *.dfm}
+
+{ TPriceMarginBillsFrame }
+
+constructor TPriceMarginBillsFrame.Create(
+  APriceMarginBillsData: TPriceMarginBillsData);
+begin
+  inherited Create(nil);
+  FPriceMarginBillsData := APriceMarginBillsData;
+  FProjectGLData := TProjectData(FPriceMarginBillsData.ProjectData).ProjectGLData;
+  FDetailGLData := TProjectData(FPriceMarginBillsData.ProjectData).DetailGLData;
+
+  saGclBills.DataView := APriceMarginBillsData.sdvGclBills;
+  saDetailGclBills.DataView := APriceMarginBillsData.sdvDetailGclBills;
+  saDetailGL.DataView := APriceMarginBillsData.sdvDetailGL;
+end;
+
+destructor TPriceMarginBillsFrame.Destroy;
+begin
+  inherited;
+end;
+
+procedure TPriceMarginBillsFrame.zgDetailGLMouseDown(Sender: TObject;
+  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
+begin
+  if Button = mbRight then
+    dxpmDetailGL.PopupFromCursorPos;
+end;
+
+procedure TPriceMarginBillsFrame.dxpmDetailGLPopup(Sender: TObject);
+begin
+  SetDxBtnAction(actnAddDetailGLs, MainForm.dxbtnAddDetailGLs);
+end;
+
+procedure TPriceMarginBillsFrame.actnAddDetailGLsExecute(Sender: TObject);
+var
+  iID: Integer;
+  vNode: TBillsIDTreeNode;
+begin
+  iID := saDetailGclBills.DataView.Current.ValueByName('RelaBillsID').AsInteger;
+  vNode := TBillsIDTreeNode(FPriceMarginBillsData.MainBillsTree.FindNode(iID));
+  AddDetailGLs;
+  {  ErrorMessage('当前清单已进行材料调差,不可再添加调差工料。');}
+end;
+
+procedure TPriceMarginBillsFrame.AddDetailGLs;
+var
+  DetailGLs: TList;
+begin
+  DetailGLs := TList.Create;
+  try
+    if SelectDetailGLs(FProjectGLData, DetailGLs) then
+      FPriceMarginBillsData.AddDetailGLs(DetailGLs);
+  finally
+    DetailGLs.Free;
+  end;
+end;
+
+procedure TPriceMarginBillsFrame.dxpmDetailGclBillsPopup(Sender: TObject);
+begin
+  SetDxBtnAction(actnApplyToSameBills, MainForm.dxbtnApplyToSameBills);
+  SetDxBtnAction(actnCopyDetailGLs, MainForm.dxbtnCopyDetailGls);
+end;
+
+procedure TPriceMarginBillsFrame.actnApplyToSameBillsExecute(
+  Sender: TObject);
+var
+  CurRec, Rec: TsdDataRecord;
+  vGLs: TList;
+  iRec: Integer;
+begin
+  if saDetailGclBills.DataView.RecordCount = 1 then Exit;
+
+  vGLs := TList.Create;
+  try
+    CurRec := saDetailGclBills.DataView.Current;
+    FDetailGLData.LoadDetailGLs(CurRec.ValueByName('RelaBillsID').AsInteger, vGLs);
+    for iRec := 0 to saDetailGclBills.DataView.RecordCount - 1 do
+    begin
+      Rec := saDetailGclBills.DataView.Records[iRec];
+      if Rec <> CurRec then
+      begin
+        FDetailGLData.ResetDetailGLs(Rec.ValueByName('RelaBillsID').AsInteger, vGLs);
+        // 应重新计算清单
+        with TProjectData(FPriceMarginBillsData.ProjectData) do
+          PhaseData.StageData.CalculatePriceMargin(Rec.ValueByName('RelaBillsID').AsInteger);
+        FPriceMarginBillsData.RefreshDetailBills(Rec.ValueByName('RelaBillsID').AsInteger);
+      end;
+      // 应重新计算使用到的工料
+      FProjectGLData.CalculateGLs_PM(vGLs);
+    end;
+  finally
+    vGLs.Free;
+  end;
+end;
+
+procedure TPriceMarginBillsFrame.zgDetailGclBillsMouseDown(Sender: TObject;
+  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
+begin
+  if Button = mbRight then
+    dxpmDetailGclBills.PopupFromCursorPos;
+end;
+
+procedure TPriceMarginBillsFrame.actnAddDetailGLsUpdate(Sender: TObject);
+begin
+  with TProjectData(FPriceMarginBillsData.ProjectData) do
+    TAction(Sender).Enabled := (not PriceMarginReadOnly) and Assigned(saDetailGclBills.DataView.Current);
+end;
+
+procedure TPriceMarginBillsFrame.ResetViewControl;
+begin
+  with TProjectData(FPriceMarginBillsData.ProjectData) do
+  begin
+    saDetailGL.Columns.ColumnByName('Quantity').ReadOnly := PriceMarginReadOnly;
+    if PriceMarginReadOnly then
+      saDetailGL.Options := saDetailGL.Options - [aoAllowDelete]
+    else
+      saDetailGL.Options := saDetailGL.Options + [aoAllowDelete];
+  end;
+end;
+
+end.

+ 115 - 0
Frames/PriceMarginFme.dfm

@@ -0,0 +1,115 @@
+object PriceMarginFrame: TPriceMarginFrame
+  Left = 0
+  Top = 0
+  Width = 1109
+  Height = 591
+  TabOrder = 0
+  object pnlTopTag: TPanel
+    Left = 0
+    Top = 0
+    Width = 1109
+    Height = 21
+    Align = alTop
+    BevelOuter = bvNone
+    TabOrder = 0
+    object tbTopTag: TToolBar
+      Left = 0
+      Top = 0
+      Width = 134
+      Height = 21
+      Align = alLeft
+      AutoSize = True
+      ButtonHeight = 21
+      ButtonWidth = 67
+      EdgeBorders = []
+      Flat = True
+      ShowCaptions = True
+      TabOrder = 0
+      object tobtnGL: TToolButton
+        Left = 0
+        Top = 0
+        Caption = '  '#35843#24046#24037#26009'  '
+        Down = True
+        ImageIndex = 2
+        Style = tbsCheck
+        OnClick = tobtnBillsClick
+      end
+      object tobtnBills: TToolButton
+        Tag = 1
+        Left = 67
+        Top = 0
+        Caption = ' '#28165#21333#27719#24635' '
+        ImageIndex = 0
+        Style = tbsCheck
+        OnClick = tobtnBillsClick
+      end
+    end
+  end
+  object jpsPriceMargin: TJimPages
+    Left = 0
+    Top = 21
+    Width = 1109
+    Height = 570
+    ActivePage = jpsPriceMarginGL
+    ActivePageIndex = 0
+    Align = alClient
+    object jpsPriceMarginGL: TJimPage
+      Left = 0
+      Top = 0
+      Width = 1109
+      Height = 570
+      TabName = 'GL'
+      Caption = 'GL'
+    end
+    object jpsPriceMarginBills: TJimPage
+      Left = 0
+      Top = 0
+      Width = 1109
+      Height = 570
+      TabName = 'Bills'
+      Caption = 'Bills'
+    end
+  end
+  object xpm: TXPMenu
+    DimLevel = 30
+    GrayLevel = 10
+    Font.Charset = DEFAULT_CHARSET
+    Font.Color = clMenuText
+    Font.Height = -12
+    Font.Name = #23435#20307
+    Font.Style = []
+    Color = clBtnFace
+    IconBackColor = clBtnFace
+    MenuBarColor = clBtnFace
+    SelectColor = 38640
+    SelectBorderColor = clHighlight
+    SelectFontColor = clMenuText
+    DisabledColor = clInactiveCaption
+    SeparatorColor = clBtnFace
+    CheckedColor = clHighlight
+    IconWidth = 24
+    DrawSelect = True
+    UseSystemColors = False
+    OverrideOwnerDraw = False
+    Gradient = False
+    FlatMenu = False
+    AutoDetect = True
+    XPControls = [xcToolbar]
+    Active = True
+    ControlUseTrueXPStyle = True
+    BtnRoundArc = 5
+    BtnOutLineBorderColor = 7552000
+    BtnInnerBorderMoveColor = 3257087
+    BtnInnerBorderFocusColor = 15183500
+    BtnSurfaceNormalColor = 16251903
+    BtnSurfaceDownColor = 14608359
+    BtnSurfaceBottomLineColor = 14608359
+    BtnSurfaceDownBottomLineColor = 15199215
+    RdoChkControlChkColor = 41472
+    ComboBoxChkColor = 9201994
+    ComboboxSurfaceMoveColor = 16771030
+    ControlDisabledBorderColor = 11913158
+    Left = 279
+    Top = 56
+  end
+end

+ 82 - 0
Frames/PriceMarginFme.pas

@@ -0,0 +1,82 @@
+unit PriceMarginFme;
+
+interface
+
+uses
+  ProjectGLFme, PriceMarginBillsFme,
+  ProjectData,
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, ExtCtrls, JimPages, ComCtrls, ToolWin, XPMenu;
+
+type
+  TPriceMarginFrame = class(TFrame)
+    pnlTopTag: TPanel;
+    tbTopTag: TToolBar;
+    tobtnBills: TToolButton;
+    tobtnGL: TToolButton;
+    jpsPriceMargin: TJimPages;
+    jpsPriceMarginBills: TJimPage;
+    jpsPriceMarginGL: TJimPage;
+    xpm: TXPMenu;
+    procedure tobtnBillsClick(Sender: TObject);
+  private
+    FProjectData: TProjectData;
+
+    FProjectGLFrame: TProjectGLFrame;
+    FPriceMarginBillsFrame: TPriceMarginBillsFrame;
+  public
+    constructor Create(AProjectData: TProjectData);
+    destructor Destroy; override;
+
+    procedure RefreshBills;
+
+    procedure ResetViewControl;
+  end;
+
+implementation
+
+uses
+  UtilMethods;
+
+{$R *.dfm}
+
+{ TPriceMarginFrame }
+
+constructor TPriceMarginFrame.Create(AProjectData: TProjectData);
+begin
+  inherited Create(nil);
+  FProjectData := AProjectData;
+
+  FProjectGLFrame := TProjectGLFrame.Create(FProjectData.ProjectGLData);
+  AlignControl(FProjectGLFrame, jpsPriceMarginGL, alClient);
+
+  FPriceMarginBillsFrame := TPriceMarginBillsFrame.Create(FProjectData.PriceMarginBillsData);
+  AlignControl(FPriceMarginBillsFrame, jpsPriceMarginBills, alClient);
+end;
+
+destructor TPriceMarginFrame.Destroy;
+begin
+  FPriceMarginBillsFrame.Free;
+  FProjectGLFrame.Free;
+  inherited;
+end;
+
+procedure TPriceMarginFrame.RefreshBills;
+begin
+  FProjectData.PriceMarginBillsData.RefreshBills;
+end;
+
+procedure TPriceMarginFrame.ResetViewControl;
+begin
+  FProjectGLFrame.ResetViewControl;
+  FPriceMarginBillsFrame.ResetViewControl;
+end;
+
+procedure TPriceMarginFrame.tobtnBillsClick(Sender: TObject);
+begin
+  tobtnGL.Down := tobtnGL.Tag = TToolButton(Sender).Tag;
+  tobtnBills.Down := tobtnBills.Tag = TToolButton(Sender).Tag;
+  jpsPriceMargin.ActivePageIndex := TToolButton(Sender).Tag;
+end;
+
+end.

+ 35 - 8
Frames/ProjectFme.dfm

@@ -67,24 +67,33 @@ object ProjectFrame: TProjectFrame
               Tag = 2
             end
             item
+              Caption = #26448#26009#35843#24046
+              Index = 3
+              IsDefault = False
+              LargeImage = 4
+              SmallImage = 4
+              StoredItem = xbiPriceMargin
+              Tag = 3
+            end
+            item
               Caption = #23457#26680#27604#36739
               Hint = #23457#26680#27604#36739
-              Index = 3
+              Index = 4
               IsDefault = False
               LargeImage = 3
               SmallImage = 3
               StoredItem = xbiStageCompare
-              Tag = 3
+              Tag = 4
             end
             item
               Caption = #25253#34920
               Hint = #25253#34920
-              Index = 4
+              Index = 5
               IsDefault = False
               LargeImage = 6
               SmallImage = 6
               StoredItem = xbiReport
-              Tag = 4
+              Tag = 5
             end>
         end>
       ActiveGroupIndex = 0
@@ -2830,6 +2839,15 @@ object ProjectFrame: TProjectFrame
         TabName = 'BillsGather'
         Caption = 'PhaseCompare'
       end
+      object jpsMainPriceMargin: TJimPage
+        Tag = -1
+        Left = 0
+        Top = 0
+        Width = 903
+        Height = 415
+        TabName = 'PriceMargin'
+        Caption = 'PriceMargin'
+      end
       object jpsMainStageCompare: TJimPage
         Tag = -1
         Left = 0
@@ -3109,6 +3127,7 @@ object ProjectFrame: TProjectFrame
       #35745#37327#21488#36134
       #28165#21333#27719#24635
       #23457#26680#27604#36739
+      #26448#26009#35843#24046
       #24418#35937#36827#24230
       #25253#34920)
     DefaultLargeImage = -1
@@ -3135,7 +3154,7 @@ object ProjectFrame: TProjectFrame
       SmallImage = 2
     end
     object xbiStageCompare: TdxStoredSideItem
-      Tag = 3
+      Tag = 4
       Caption = #23457#26680#27604#36739
       Category = 3
       Enabled = True
@@ -3146,16 +3165,16 @@ object ProjectFrame: TProjectFrame
     object xbiCompleteDegree: TdxStoredSideItem
       Tag = -1
       Caption = #24418#35937#36827#24230
-      Category = 4
+      Category = 5
       Enabled = True
       Hint = #24418#35937#36827#24230
       LargeImage = 5
       SmallImage = 5
     end
     object xbiReport: TdxStoredSideItem
-      Tag = 4
+      Tag = 5
       Caption = #25253#34920
-      Category = 5
+      Category = 6
       Enabled = True
       Hint = #25253#34920
       LargeImage = 6
@@ -3169,6 +3188,14 @@ object ProjectFrame: TProjectFrame
       LargeImage = 1
       SmallImage = 1
     end
+    object xbiPriceMargin: TdxStoredSideItem
+      Tag = 3
+      Caption = #26448#26009#35843#24046
+      Category = 4
+      Enabled = True
+      LargeImage = 4
+      SmallImage = 4
+    end
   end
   object ilstLarge: TImageList
     Height = 32

+ 43 - 13
Frames/ProjectFme.pas

@@ -6,6 +6,7 @@ uses
   BillsCompileFme, BillsMeasureFme, PhaseCompareFme, DealPaymentFme,
   BillsGatherFme, ZJJLFme, BGLFme, ReportsFrm, SearchFme, BookmarkFme,
   ProjectData, UtilMethods, Globals, mEncryptEditions, DealBillsFme,
+  PriceMarginFme,
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, ImgList, XPMenu, Buttons, ComCtrls, ToolWin, ExtCtrls, JimPages,
   StdCtrls, JimCombos, dxsbar, ActnList, dxBar, OrderCheckerFme, CheckerFme,
@@ -77,6 +78,8 @@ type
     tobtnUpFile: TToolButton;
     jpsAssistantDealBills: TJimPage;
     tobtnDealBills: TToolButton;
+    jpsMainPriceMargin: TJimPage;
+    xbiPriceMargin: TdxStoredSideItem;
     procedure tobtnStandardBillsClick(Sender: TObject);
     procedure jcbPhaseChanged(Sender: TObject);
     procedure sbtnExpendClick(Sender: TObject);
@@ -99,8 +102,9 @@ type
 
     FBillsCompileFrame: TBillsCompileFrame;
     FBillsMeasureFrame: TBillsMeasureFrame;
-    FPhaseCompareFrame: TPhaseCompareFrame;
     FBillsGatherFrame: TBillsGatherFrame;
+    FPriceMarginFrame: TPriceMarginFrame;
+    FPhaseCompareFrame: TPhaseCompareFrame;
     FCheckerFrame: TCheckerFrame;
 
     FDealPaymentFrame: TDealPaymentFrame;
@@ -114,6 +118,7 @@ type
     procedure CreateBillsFrame;
     procedure CreateDealPaymentFrame;
     procedure CreateBillsGatherFrame;
+    procedure CreatePriceMarginFrame;
     procedure CreateCheckerFrame;
     procedure CreateUpFile;
     procedure CreateFrames;
@@ -171,6 +176,7 @@ type
     property BillsCompileFrame: TBillsCompileFrame read FBillsCompileFrame;
     property BillsMeasureFrame: TBillsMeasureFrame read FBillsMeasureFrame;
     property BillsGatherFrame: TBillsGatherFrame read FBillsGatherFrame;
+    property PriceMarginFrame: TPriceMarginFrame read FPriceMarginFrame;
 
     property CheckerFrame: TCheckerFrame read FCheckerFrame;
     property UpFileManageView: TUpFileManageView read FUpFileManageView write SetUpFileManageView;
@@ -359,7 +365,7 @@ begin
     jcbAudit.Enabled := True;
     jcbPhase.Items.Add(Format(' 第 %d 期数据', [jcbPhase.Items.Count + 1]));
     jcbPhase.ItemIndex := jcbPhase.Items.Count - 1;
-    FProjectData.PhaseData.CopyPreData;
+    FProjectData.CopyPreData;
     RefreshProjectState;
 
     if G_IsCloud then
@@ -431,7 +437,7 @@ end;
 procedure TProjectFrame.jcbAuditChanged(Sender: TObject);
 begin
   if FProjectData.PhaseData.StageIndex = jcbAudit.ItemIndex then Exit;
-  FProjectData.PhaseData.StageIndex := jcbAudit.ItemIndex;
+  FProjectData.StageIndex := jcbAudit.ItemIndex;
   RefreshProjectState;
 end;
 
@@ -480,6 +486,8 @@ procedure TProjectFrame.dxsbViewControlItemClick(Sender: TObject;
                           or (Item.Tag = xbiBillsMeasure.Tag);
     tobtnBGL.Visible := Item.Tag = xbiBillsMeasure.Tag;
     tobtnZJJL.Visible := Item.Tag = xbiBillsMeasure.Tag;
+    // 控制整个按钮工具栏显示,
+    pnlToolBar.Visible := pnlPhaseSelect.Visible or tbExpand.Visible or tbToolsButton.Visible;
     // 根据当前View控制右侧按钮是否按下,右侧工具窗是否弹开
     jpsAssistant.ActivePageIndex := jpsMain.ActivePage.Tag;
     sbtnExpend.Tag := jpsMain.ActivePage.Tag;
@@ -499,14 +507,17 @@ procedure TProjectFrame.dxsbViewControlItemClick(Sender: TObject;
     // 切换至清单汇总,须重新汇总
     if Item.Tag = xbiBillsGather.Tag then
       BillsGatherFrame.RefreshBills;
+    // 切换至材料调差,须重新汇总展示调差清单
+    if Item.Tag = xbiPriceMargin.Tag then
+      PriceMarginFrame.RefreshBills;
 
     if G_IsCloud then
       if (Item.Tag = xbiBillsCompile.Tag) or (Item.Tag = xbiBillsMeasure.Tag) then
         CheckUpFile;
 
-      tobtnUpFile.Enabled := Item.Tag = xbiBillsMeasure.Tag;
-      if (tobtnUpFile.Enabled = False) and (jpsAssistant.ActivePage = jpsAssistantUpFile) then
-        jpsAssistant.ActivePage := jpsAssistantStandardBills;
+    tobtnUpFile.Enabled := Item.Tag = xbiBillsMeasure.Tag;
+    if (tobtnUpFile.Enabled = False) and (jpsAssistant.ActivePage = jpsAssistantUpFile) then
+      jpsAssistant.ActivePage := jpsAssistantStandardBills;
   end;
 
   procedure ChangeView;
@@ -514,8 +525,7 @@ procedure TProjectFrame.dxsbViewControlItemClick(Sender: TObject;
     BeforeChangeView;
     case Item.Tag of
       0, 2: jpsMain.ActivePageIndex := Item.Tag;
-      1: if CheckMeasureEdition then jpsMain.ActivePageIndex := Item.Tag;
-      //2: if CheckPlanEdition then jpsMain.ActivePageIndex := Item.Tag;
+      1, 3: if CheckMeasureEdition then jpsMain.ActivePageIndex := Item.Tag;
     end;
     AfterChangeView;
   end;
@@ -549,22 +559,34 @@ procedure TProjectFrame.dxsbViewControlItemClick(Sender: TObject;
         jpsMain.ActivePageIndex := Item.Tag;
       end;
       AfterChangeView;
-    finally             
+    finally
       Screen.Cursor := crDefault;
       CloseProgressHint;
     end;
   end;
 
+  procedure DisplayPriceMargin;
+  begin
+    if ProjectData.ProjProperties.PhaseCount = 0 then
+    begin
+      TipMessage('未计量前不可进行材料调差。');
+      dxsbViewControl.SelectedItem := dxsbViewControl.ActiveGroup.Items[jpsMain.ActivePageIndex];
+      Abort;
+    end;
+    ChangeView;
+  end;
+
 begin
   if Item.Tag = jpsMain.ActivePageIndex then Exit;
 
-  if (Item.Tag in [0..2]) and (jpsMain.ActivePageIndex = 3) then
+  if (Item.Tag in [0..3]) and (jpsMain.ActivePageIndex = 4) then
     CloseCompare;
-    
+
   case Item.Tag of
     0..2: ChangeView;
-    3: DisplayCompare;
-    4: DisplayReports;
+    3: DisplayPriceMargin;
+    4: DisplayCompare;
+    5: DisplayReports;
   end;
 end;
 
@@ -1130,6 +1152,7 @@ begin
   UpdateSysProgress(140, '正在解析数据');
   CreateBillsGatherFrame;
   UpdateSysProgress(150, '正在解析数据');
+  CreatePriceMarginFrame;
 
   FZJJLFrame := TZJJLFrame.Create(Self, FProjectData.PhaseData.ZJJLData);
   FZJJLFrame.DataReadOnly := FProjectData.PhaseData.StageDataReadOnly;
@@ -1357,6 +1380,7 @@ begin
   FBillsCompileFrame.RefreshPhase_Stage;
   FBillsMeasureFrame.RefreshPhase_Stage;
   FDealPaymentFrame.RefreshPhase_Stage;
+  FPriceMarginFrame.ResetViewControl;
 end;
 
 procedure TProjectFrame.ExpandCurPhase;
@@ -1389,4 +1413,10 @@ begin
   end;
 end;
 
+procedure TProjectFrame.CreatePriceMarginFrame;
+begin
+  FPriceMarginFrame := TPriceMarginFrame.Create(FProjectData);
+  AlignControl(FPriceMarginFrame, jpsMainPriceMargin, alClient);
+end;
+
 end.

+ 291 - 0
Frames/ProjectGLFme.dfm

@@ -0,0 +1,291 @@
+object ProjectGLFrame: TProjectGLFrame
+  Left = 0
+  Top = 0
+  Width = 946
+  Height = 313
+  TabOrder = 0
+  object zgProjectGL: TZJGrid
+    Left = 0
+    Top = 0
+    Width = 946
+    Height = 313
+    Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+    OptionsEx = []
+    ColCount = 13
+    RowCount = 6
+    FixedRowCount = 2
+    ShowGridLine = False
+    DefaultColWidth = 73
+    DefaultFixedColWidth = 25
+    Selection.AlphaBlend = False
+    Selection.TransparentColor = False
+    FrozenCol = 0
+    FrozenRow = 0
+    OnMouseDown = zgProjectGLMouseDown
+    Align = alClient
+  end
+  object saProjectGL: TsdGridDBA
+    Columns = <
+      item
+        Title.Caption = #32534#21495
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 2
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Code'
+        Width = 60
+        ReadOnly = False
+      end
+      item
+        Title.Caption = #21517#31216
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 2
+        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 = 'Name'
+        Width = 150
+        ReadOnly = False
+      end
+      item
+        Title.Caption = #21333#20301
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 2
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = 'smartSimSun'
+        Font.Style = []
+        FieldName = 'Units'
+        Width = 45
+        ReadOnly = False
+      end
+      item
+        Title.Caption = #35268#26684
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 2
+        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 = 'Specs'
+        Width = 60
+        ReadOnly = False
+      end
+      item
+        Title.Caption = #22522#20934#20215
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 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 = 'BasePrice'
+        Width = 60
+        ReadOnly = False
+      end
+      item
+        Title.Caption = #39118#38505#24133#24230
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 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 = 'RiskRange'
+        Width = 60
+        ReadOnly = False
+      end
+      item
+        Title.Caption = #26412#26399#20449#24687#20215'|'#20215#26684
+        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 = 'InfoPrice'
+        Width = 60
+        ReadOnly = False
+      end
+      item
+        Title.Caption = '|'#26102#38388
+        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 = 'InfoDate'
+        ReadOnly = False
+      end
+      item
+        Title.Caption = '|'#20215#24046
+        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 = 'DeltaPrice'
+        Width = 60
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#26377#25928#20215#24046
+        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 = 'ValidDeltaPrice'
+        Width = 60
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #26412#26399#20215#24046#35745#31639'|'#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 = 'PM_Quantity'
+        Width = 60
+        ReadOnly = True
+      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 = 'PM_TotalPrice'
+        Width = 60
+        ReadOnly = True
+      end>
+    Grid = zgProjectGL
+    ExtendRowCount = 3
+    Left = 96
+    Top = 88
+  end
+  object dxpmProjectGL: TdxBarPopupMenu
+    BarManager = MainForm.dxBarManager
+    ItemLinks = <
+      item
+        Item = MainForm.dxbtnCalculatePriceMargin
+        Visible = True
+      end
+      item
+        BeginGroup = True
+        Item = MainForm.dxbtnCopy
+        Visible = True
+      end
+      item
+        Item = MainForm.dxbtnPaste
+        Visible = True
+      end
+      item
+        BeginGroup = True
+        Item = MainForm.dxbtnDelete
+        Visible = True
+      end>
+    UseOwnFont = False
+    OnPopup = dxpmProjectGLPopup
+    Left = 152
+    Top = 88
+  end
+  object actnProjectGL: TActionList
+    Images = MainForm.Images
+    Left = 208
+    Top = 88
+    object actnCalculatePriceMargin: TAction
+      Caption = #20215#24046#35745#31639
+      ImageIndex = 15
+      OnExecute = actnCalculatePriceMarginExecute
+    end
+  end
+end

+ 94 - 0
Frames/ProjectGLFme.pas

@@ -0,0 +1,94 @@
+unit ProjectGLFme;
+
+interface
+
+uses
+  ProjectGLDm,
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
+  Dialogs, sdGridDBA, ZJGrid, dxBar, ActnList;
+
+type
+  TProjectGLFrame = class(TFrame)
+    zgProjectGL: TZJGrid;
+    saProjectGL: TsdGridDBA;
+    dxpmProjectGL: TdxBarPopupMenu;
+    actnProjectGL: TActionList;
+    actnCalculatePriceMargin: TAction;
+    procedure zgProjectGLMouseDown(Sender: TObject; Button: TMouseButton;
+      Shift: TShiftState; X, Y: Integer);
+    procedure dxpmProjectGLPopup(Sender: TObject);
+    procedure actnCalculatePriceMarginExecute(Sender: TObject);
+  private
+    FProjectGLData: TProjectGLData;
+  public
+    constructor Create(AProjectGLData: TProjectGLData);
+    destructor Destroy; override;
+
+    procedure ResetViewControl;
+  end;
+
+implementation
+
+uses
+  ProjectData, MainFrm, UtilMethods;
+
+{$R *.dfm}
+
+{ TProjectGLFrame }
+
+constructor TProjectGLFrame.Create(AProjectGLData: TProjectGLData);
+begin
+  inherited Create(nil);
+  FProjectGLData := AProjectGLData;
+  saProjectGL.DataView := FProjectGLData.sdvProjectGL;
+  ResetViewControl;
+end;
+
+destructor TProjectGLFrame.Destroy;
+begin
+  inherited;
+end;
+
+procedure TProjectGLFrame.ResetViewControl;
+var
+  AReadOnly: Boolean;
+begin
+  with TProjectData(FProjectGLData.ProjectData) do
+    AReadOnly := PriceMarginReadOnly;
+
+  saProjectGL.Columns.ColumnByName('Code').ReadOnly := AReadOnly;
+  saProjectGL.Columns.ColumnByName('Name').ReadOnly := AReadOnly;
+  saProjectGL.Columns.ColumnByName('Units').ReadOnly := AReadOnly;
+  saProjectGL.Columns.ColumnByName('Specs').ReadOnly := AReadOnly;
+  saProjectGL.Columns.ColumnByName('BasePrice').ReadOnly := AReadOnly;
+  saProjectGL.Columns.ColumnByName('RiskRange').ReadOnly := AReadOnly;
+  saProjectGL.Columns.ColumnByName('InfoPrice').ReadOnly := AReadOnly;
+  saProjectGL.Columns.ColumnByName('InfoDate').ReadOnly := AReadOnly;
+
+  if AReadOnly then
+    saProjectGL.Options := saProjectGL.Options - [aoAllowInsert, aoAllowDelete]
+  else
+    saProjectGL.Options := saProjectGL.Options + [aoAllowInsert, aoAllowDelete];
+end;
+
+procedure TProjectGLFrame.zgProjectGLMouseDown(Sender: TObject;
+  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
+begin
+  if Button = mbRight then
+    dxpmProjectGL.PopupFromCursorPos;
+end;
+
+procedure TProjectGLFrame.dxpmProjectGLPopup(Sender: TObject);
+begin
+  SetDxBtnAction(actnCalculatePriceMargin, MainForm.dxbtnCalculatePriceMargin);
+end;
+
+procedure TProjectGLFrame.actnCalculatePriceMarginExecute(Sender: TObject);
+begin
+  if TProjectData(FProjectGLData.ProjectData).PhaseData.StageDataReadOnly then
+    TipMessage('历史数据不可重新计算。')
+  else
+    TProjectData(FProjectGLData.ProjectData).CalculatePriceMargin;
+end;
+
+end.

+ 3 - 1
Frames/SearchFme.dfm

@@ -153,6 +153,8 @@ object SearchFrame: TSearchFrame
         DefaultFixedRowHeight = 35
         Selection.AlphaBlend = False
         Selection.TransparentColor = False
+        FrozenCol = 0
+        FrozenRow = 0
         OnMouseDown = zgSearchResultMouseDown
         Align = alClient
       end
@@ -227,7 +229,7 @@ object SearchFrame: TSearchFrame
         Font.Charset = GB2312_CHARSET
         Font.Color = clWindowText
         Font.Height = -12
-        Font.Name = #23435#20307
+        Font.Name = 'smartSimSun'
         Font.Style = []
         FieldName = 'Units'
         Width = 40

+ 3 - 1
Frames/StandardBillsFme.dfm

@@ -87,6 +87,8 @@ object StandardBillsFrame: TStandardBillsFrame
     DefaultFixedColWidth = 28
     Selection.AlphaBlend = False
     Selection.TransparentColor = False
+    FrozenCol = 0
+    FrozenRow = 0
     OnMouseDown = zgBillsMouseDown
     Align = alClient
   end
@@ -215,7 +217,7 @@ object StandardBillsFrame: TStandardBillsFrame
         Font.Charset = GB2312_CHARSET
         Font.Color = clWindowText
         Font.Height = -12
-        Font.Name = #23435#20307
+        Font.Name = 'smartSimSun'
         Font.Style = []
         FieldName = 'Unit'
         Width = 50

+ 159 - 0
Units/BaseClipboard.pas

@@ -0,0 +1,159 @@
+unit BaseClipboard;
+
+interface
+
+uses
+  Clipbrd, Classes, Windows, XmlDoc, XmlIntf, SysUtils;
+
+type
+  TInnerClipboard = class(TClipboard);
+
+  TBaseClipboard = class
+  private
+    FStream: TMemoryStream;
+  protected
+    procedure LoadXmlData(AXmlDoc: IXMLDocument); virtual; abstract;
+    procedure SaveXmlData(AXmlDoc: IXMLDocument); virtual; abstract;
+
+    procedure SaveToClipboard(AFormat: Word);
+    procedure LoadFromClipboard(AFormat: Word);
+
+    procedure SaveToStream;
+    procedure LoadFromStream;
+    procedure SaveToXmlFile(const AFileName: string);
+    procedure LoadFromXmlFile(const AFileName: string);
+  public
+    constructor Create;
+    destructor Destroy; override;
+  end;
+
+function HasClipboardFormat(AFormat: Word): Boolean;
+
+implementation
+
+function HasClipboardFormat(AFormat: Word): Boolean;
+begin
+  Result := Clipboard.HasFormat(AFormat);  
+end;
+
+{ TBaseClipboard }
+
+constructor TBaseClipboard.Create;
+begin
+  FStream := TMemoryStream.Create;
+end;
+
+destructor TBaseClipboard.Destroy;
+begin
+  FStream.Free;
+  inherited;
+end;
+
+procedure TBaseClipboard.LoadFromClipboard(AFormat: Word);
+
+  procedure LockAndLoadData(AData: THandle);
+  var
+    DataPtr: Pointer;
+  begin
+    DataPtr := GlobalLock(AData);
+    try
+      FStream.WriteBuffer(DataPtr^, GlobalSize(AData));
+      FStream.Position := 0;
+    finally
+      GlobalUnlock(AData);
+    end;
+  end;
+
+var
+  Data: THandle;
+begin
+  Clipboard.Open;
+  try
+    Data := GetClipboardData(AFormat);
+    if Data <> 0 then
+      LockAndLoadData(Data);
+  finally
+    Clipboard.Close;
+  end;
+end;
+
+procedure TBaseClipboard.LoadFromStream;
+var
+  FXmlDocument: IXMLDocument;
+  I: Integer;
+begin
+  FXmlDocument := TXMLDocument.Create(nil) as IXMLDocument;
+  try
+    FXmlDocument.LoadFromStream(FStream);
+    FXmlDocument.Options := [doNodeAutoCreate,doNodeAutoIndent,doAutoPrefix,doNamespaceDecl];
+    LoadXmlData(FXmlDocument);
+  finally
+    FXmlDocument := nil;
+  end;
+end;
+
+procedure TBaseClipboard.LoadFromXmlFile(const AFileName: string);
+var
+  FXmlDocument: IXMLDocument;
+  I: Integer;
+begin
+  FXmlDocument := TXMLDocument.Create(nil) as IXMLDocument;
+  try
+    FXmlDocument.Options := [doNodeAutoCreate,doNodeAutoIndent,doAutoPrefix,doNamespaceDecl];
+    if not FileExists(AFileName) then Exit;
+    FXmlDocument.LoadFromFile(AFileName);
+    LoadXmlData(FXmlDocument);
+  finally
+    FXmlDocument := nil;
+  end;
+end;
+
+procedure TBaseClipboard.SaveToClipboard(AFormat: Word);
+begin
+  Clipboard.Open;
+  try
+    EmptyClipboard;
+    FStream.Position := 0;
+    TInnerClipboard(Clipboard).SetBuffer(AFormat, FStream.Memory^, FStream.Size);
+  finally
+    Clipboard.Close;
+  end;
+end;
+
+procedure TBaseClipboard.SaveToStream;
+var
+  FXmlDocument: IXMLDocument;
+  I: Integer;
+begin
+  FXmlDocument := TXMLDocument.Create(nil) as IXMLDocument;
+  try
+    FXmlDocument.Options := [doNodeAutoCreate,doNodeAutoIndent,doAttrNull,doAutoPrefix,doNamespaceDecl];
+    FXmlDocument.Active := True;
+    FXmlDocument.Encoding := 'GB2312';
+    FXmlDocument.AddChild('BillsBlock_M');
+    SaveXmlData(FXmlDocument);
+    FXmlDocument.SaveToStream(FStream);
+  finally
+    FXmlDocument := nil;
+  end;
+end;
+
+procedure TBaseClipboard.SaveToXmlFile(const AFileName: string);
+var
+  FXmlDocument: IXMLDocument;
+  I: Integer;
+begin
+  FXmlDocument := TXMLDocument.Create(nil) as IXMLDocument;
+  try
+    FXmlDocument.Options := [doNodeAutoCreate,doNodeAutoIndent,doAttrNull,doAutoPrefix,doNamespaceDecl];
+    FXmlDocument.Active := True;
+    FXmlDocument.Encoding := 'GB2312';
+    FXmlDocument.AddChild('BillsBlock_M');
+    SaveXmlData(FXmlDocument);
+    FXmlDocument.SaveToFile(AFileName);
+  finally
+    FXmlDocument := nil;
+  end;
+end;
+
+end.

+ 16 - 121
Units/BillsClipboard.pas

@@ -3,11 +3,9 @@ unit BillsClipboard;
 interface
 
 uses
-  Clipbrd, Classes, BillsDm, ZhAPI, XmlDoc, XmlIntf, Windows, sdIDTree;
+  BaseClipboard, Classes, BillsDm, ZhAPI, XmlDoc, XmlIntf, Windows, sdIDTree;
 
 type
-  TInnerClipboard = class(TClipboard);
-
   TBillsBlockNode = class
   private
     FID: Integer;
@@ -34,20 +32,11 @@ type
     procedure LoadFromXmlNode(AXmlNode: IXMLNode);
   end;
 
-  TBillsClipboard = class
+  TBillsClipboard = class(TBaseClipboard)
   private
-    FStream: TMemoryStream;
     FBillsData: TBillsData;
     FNodeList: TList;
 
-    procedure SaveToClipboard(AFormat: Word);
-    procedure LoadFromClipboard(AFormat: Word);
-
-    procedure SaveToStream;
-    procedure LoadFromStream;
-    procedure SaveToXmlFile(const AFileName: string);
-    procedure LoadFromXmlFile(const AFileName: string);
-
     procedure SaveNodesToXml(AXmlNode: IXMLNode);
     procedure LoadNodesFromXml(AXmlNode: IXMLNode);
 
@@ -63,6 +52,9 @@ type
     procedure PasteData(ANode: TsdIDTreeNode; APos: Integer);
 
     procedure Clear;
+  protected
+    procedure LoadXmlData(AXmlDoc: IXmlDocument); override;
+    procedure SaveXmlData(AXmlDoc: IXmlDocument); override;
   public
     constructor Create(ABillsData: TBillsData);
     destructor Destroy; override;
@@ -81,10 +73,9 @@ uses sdDB, Math, SysUtils, UtilMethods;
 var
   CF_BillsBlock: Word;
 
-
 function HasBillsBlockFormat: Boolean;
 begin
-  Result := Clipboard.HasFormat(CF_BillsBlock);
+  Result := HasClipboardFormat(CF_BillsBlock);
 end;
 
 { TBillsClipboard }
@@ -168,7 +159,7 @@ end;
 
 constructor TBillsClipboard.Create(ABillsData: TBillsData);
 begin
-  FStream := TMemoryStream.Create;
+  inherited Create;
   FBillsData := ABillsData;
   FNodeList := TList.Create;
 end;
@@ -177,69 +168,9 @@ destructor TBillsClipboard.Destroy;
 begin
   ClearObjects(FNodeList);
   FNodeList.Free;
-  FStream.Free;
   inherited;
 end;
 
-procedure TBillsClipboard.LoadFromClipboard(AFormat: Word);
-
-  procedure LockAndLoadData(AData: THandle);
-  var
-    DataPtr: Pointer;
-  begin
-    DataPtr := GlobalLock(AData);
-    try
-      FStream.WriteBuffer(DataPtr^, GlobalSize(AData));
-      FStream.Position := 0;
-    finally
-      GlobalUnlock(AData);
-    end;
-  end;
-
-var
-  Data: THandle;
-begin
-  Clipboard.Open;
-  try
-    Data := GetClipboardData(AFormat);
-    if Data <> 0 then
-      LockAndLoadData(Data);
-  finally
-    Clipboard.Close;
-  end;
-end;
-
-procedure TBillsClipboard.LoadFromStream;
-var
-  FXmlDocument: IXMLDocument;
-  I: Integer;
-begin
-  FXmlDocument := TXMLDocument.Create(nil) as IXMLDocument;
-  try
-    FXmlDocument.LoadFromStream(FStream);
-    FXmlDocument.Options := [doNodeAutoCreate,doNodeAutoIndent,doAutoPrefix,doNamespaceDecl];
-    LoadNodesFromXml(FXmlDocument.DocumentElement);
-  finally
-    FXmlDocument := nil;
-  end;
-end;
-
-procedure TBillsClipboard.LoadFromXmlFile(const AFileName: string);
-var
-  FXmlDocument: IXMLDocument;
-  I: Integer;
-begin
-  FXmlDocument := TXMLDocument.Create(nil) as IXMLDocument;
-  try
-    FXmlDocument.Options := [doNodeAutoCreate,doNodeAutoIndent,doAutoPrefix,doNamespaceDecl];
-    if not FileExists(AFileName) then Exit;
-    FXmlDocument.LoadFromFile(AFileName);
-    LoadNodesFromXml(FXmlDocument.DocumentElement);
-  finally
-    FXmlDocument := nil;
-  end;
-end;
-
 procedure TBillsClipboard.LoadNodesFromXml(AXmlNode: IXMLNode);
 var
   BillsBlockNode: TBillsBlockNode;
@@ -256,6 +187,12 @@ begin
   end;
 end;
 
+procedure TBillsClipboard.LoadXmlData(AXmlDoc: IXmlDocument);
+begin
+  inherited;
+  LoadNodesFromXml(AXmlDoc.DocumentElement);
+end;
+
 procedure TBillsClipboard.Paste(ANode: TsdIDTreeNode; APos: Integer);
 begin
   Clear;
@@ -346,52 +283,10 @@ begin
   end;
 end;
 
-procedure TBillsClipboard.SaveToClipboard(AFormat: Word);
-begin
-  Clipboard.Open;
-  try
-    EmptyClipboard;
-    FStream.Position := 0;
-    TInnerClipboard(Clipboard).SetBuffer(AFormat, FStream.Memory^, FStream.Size);
-  finally
-    Clipboard.Close;
-  end;
-end;
-
-procedure TBillsClipboard.SaveToStream;
-var
-  FXmlDocument: IXMLDocument;
-  I: Integer;
+procedure TBillsClipboard.SaveXmlData(AXmlDoc: IXmlDocument);
 begin
-  FXmlDocument := TXMLDocument.Create(nil) as IXMLDocument;
-  try
-    FXmlDocument.Options := [doNodeAutoCreate,doNodeAutoIndent,doAttrNull,doAutoPrefix,doNamespaceDecl];
-    FXmlDocument.Active := True;
-    FXmlDocument.Encoding := 'GB2312';
-    FXmlDocument.AddChild('BillsBlock_M');
-    SaveNodesToXml(FXmlDocument.DocumentElement);
-    FXmlDocument.SaveToStream(FStream);
-  finally
-    FXmlDocument := nil;
-  end;
-end;
-
-procedure TBillsClipboard.SaveToXmlFile(const AFileName: string);
-var
-  FXmlDocument: IXMLDocument;
-  I: Integer;
-begin
-  FXmlDocument := TXMLDocument.Create(nil) as IXMLDocument;
-  try
-    FXmlDocument.Options := [doNodeAutoCreate,doNodeAutoIndent,doAttrNull,doAutoPrefix,doNamespaceDecl];
-    FXmlDocument.Active := True;
-    FXmlDocument.Encoding := 'GB2312';
-    FXmlDocument.AddChild('BillsBlock_M');
-    SaveNodesToXml(FXmlDocument.DocumentElement);
-    FXmlDocument.SaveToFile(AFileName);
-  finally
-    FXmlDocument := nil;
-  end;
+  SaveNodesToXml(AXmlDoc.DocumentElement);
+  inherited;
 end;
 
 { TBillsBlockNode }

+ 3 - 0
Units/ConstUnit.pas

@@ -16,6 +16,9 @@ const
   iTotalPriceDigit = 0;
 
   iMaxStageCount = 15;
+// 固定ID
+  iPriceMarginID = 54;
+  sBills_PMHint = '该清单为材料调差清单节点,结果由材料调差计算得到,不可编辑。';
 
 {$O-}
   {$IFDEF _mCloud}

+ 127 - 3
Units/DataBaseTables.pas

@@ -103,7 +103,11 @@ const
 
   {清单数据 -- 台账编辑界面}
   SBills = 'Bills';
+<<<<<<< HEAD
   tdBills: array [0..82] of TScFieldDef =(
+=======
+  tdBills: array [0..79] of TScFieldDef =(
+>>>>>>> 3.1.3.3
     (FieldName: 'ID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
     (FieldName: 'ParentID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'NextSiblingID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: False; ForceUpdate: False),
@@ -275,8 +279,9 @@ const
     // 签约清单数量
     (FieldName: 'GclDealQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 签约清单金额
-    (FieldName: 'GclDealTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+    (FieldName: 'GclDealTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     {------------------ End Reports --------------------------}
+    (FieldName: 'PM_AddTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
 
   {合同支付}
@@ -408,6 +413,121 @@ const
     (FieldName: 'TotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
 
+  {调差工料}
+  SProjectGL = 'ProjectGL';
+  tdProjectGL: array [0..16] of TScFieldDef =(
+    (FieldName: 'ID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 工料机编号
+    (FieldName: 'Code'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 名称
+    (FieldName: 'Name'; FieldType: ftString; Size: 200; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 单位
+    (FieldName: 'Units'; FieldType: ftString; Size: 20; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 规格
+    (FieldName: 'Specs'; FieldType: ftString; Size: 200; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 基准价
+    (FieldName: 'BasePrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 风险幅度
+    (FieldName: 'RiskRange'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 锁定期号: 取值范围0~50, 0表示未锁定, 1~50表示在第1~50期锁定
+    (FieldName: 'LockedPhaseID'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 创建期号: 取值范围0~50(台账编制, 1期~50期)
+    (FieldName: 'CreatePhaseID'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    {--------------------Begin 当期缓存数据----------------------}
+    // 信息价
+    (FieldName: 'InfoPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 信息价时间
+    (FieldName: 'InfoDate'; FieldType: ftString; Size: 20; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 价差
+    (FieldName: 'DeltaPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 有效价差
+    (FieldName: 'ValidDeltaPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 -- 调差数量
+    (FieldName: 'PM_PreQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 -- 调差金额
+    (FieldName: 'PM_PreTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 当前阶段 -- 调差数量
+    (FieldName: 'PM_Quantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 当期阶段 -- 调差金额
+    (FieldName: 'PM_TotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+    {--------------------End 当期缓存数据----------------------}
+  );
+
+  {调差工料--价格信息及计算}
+  SGLPrice = 'GLPrice';
+  tdGLPrice: array [0..39] of TScFieldDef =(
+    // 工料ID
+    (FieldName: 'GLID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 期号
+    (FieldName: 'PhaseID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 信息价
+    (FieldName: 'InfoPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 信息价--时间
+    (FieldName: 'InfoDate'; FieldType: ftString; Size: 20; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 价差
+    (FieldName: 'DeltaPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 有效价差
+    (FieldName: 'ValidDeltaPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期
+    (FieldName: 'PM_PreQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_PreTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 -- 原报
+    (FieldName: 'PM_Quantity0'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice0'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 -- 1审~14审
+    (FieldName: 'PM_Quantity1'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice1'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity2'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice2'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity3'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice3'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity4'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice4'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity5'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice5'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity6'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice6'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity7'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice7'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity8'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice8'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity9'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice9'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity10'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice10'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity11'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice11'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity12'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice12'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity13'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice13'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity14'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice14'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 -- 终审数据(当前文件中最后一人的数据)-- 数据缓存
+    (FieldName: 'PM_Quantity_F'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice_F'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+  );
+
+  {清单使用的工料}
+  SDetailGL = 'DetailGL';
+  tdDetailGL: array [0..7] of TScFieldDef =(
+    (FieldName: 'ID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 清单ID
+    (FieldName: 'BillsID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: False; ForceUpdate: False),
+    // 工料ID
+    (FieldName: 'GLID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: False; ForceUpdate: False),
+    // 工料机编号
+    (FieldName: 'Code'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 消耗量
+    (FieldName: 'Quantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 创建期号
+    (FieldName: 'CreatePhaseID'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 最新一期最新一阶段的清单计量信息 -- 数据缓存
+    (FieldName: 'LastBillsQuantity'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 锁定期号
+    (FieldName: 'LockedPhaseID'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+  );
+
   {各期总数据 -- 为更新项目管理而储存的缓存数据}
   SMainDataList = 'MainDataList';
   tdMainDataList: array [0..15] of TScFieldDef =(
@@ -454,7 +574,7 @@ const
   // ......
   SRefer = 'Refer';
   SAudit = 'Audit';
-  tdRefer_Audit: array [0..44] of TScFieldDef = (
+  tdRefer_Audit: array [0..46] of TScFieldDef = (
     (FieldName: 'BillsID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
     //------------------   本期合同计量  ----------------
     // 数量
@@ -558,7 +678,11 @@ const
     // 附件 暂时不用,用台帐的
 //    (FieldName: 'HasAttachment'; FieldType: ftBoolean; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 书签批注
-    (FieldName: 'MarkMemo'; FieldType: ftString; Size: 255; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+    (FieldName: 'MarkMemo'; FieldType: ftString; Size: 255; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期材料调差
+    (FieldName: 'PM_PreTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期材料调差
+    (FieldName: 'PM_TotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
 
   // 计量期合同支付

ファイルの差分が大きいため隠しています
+ 1081 - 0
Units/GclBillsGatherModel.pas


+ 190 - 37
Units/ProjectData.pas

@@ -6,11 +6,12 @@ uses
   Connections, BillsDm, PhaseData, UpdateDataBase, ZhAPI, ProjectProperty,
   PhaseCompareDm, DealPaymentDm, SearchDm, DealBillsDm, MainDataListDm,
   BillsGatherDm, BGLDm, StaffDm, BillsCompileDm, BillsMeasureDm,
-  BillsBookmarkDm, UpFileManageUnit,
+  BillsBookmarkDm, UpFileManageUnit, ProjectGLDm, PriceMarginBillsDm,
+  DetailGLDm,
   Classes, SysUtils, ADODB, sdDB, Checker;
 
 type
-  
+
   TProjectData = class
   private
     // 临时文件夹,解压项目后存放文件的文件夹
@@ -40,6 +41,10 @@ type
     FSearchData: TSearchData;
     FMainListData: TMainListData;
 
+    FProjectGLData: TProjectGLData;
+    FDetailGLData: TDetailGLData;
+    FPriceMarginBillsData: TPriceMarginBillsData;
+
     FCanUnlockInfo: Boolean;
 
     FWebID: Integer;
@@ -70,6 +75,8 @@ type
     procedure LockBillsBaseData;
     procedure LockDealPaymentData;
     procedure LockBGLData;
+    procedure LockProjectGLData;
+    procedure LockDetailGLData;
 
     procedure UpdatePhaseData;
 
@@ -85,6 +92,9 @@ type
     function GetADOConnection: TADOConnection;
     procedure SetCheckers(const Value: TCheckers);
     function GetStageDataReadOnly: Boolean;
+    function GetPriceMarginReadOnly: Boolean;
+    function GetStageIndex: Integer;
+    procedure SetStageIndex(const Value: Integer);
   public
     constructor Create;
     destructor Destroy; override;
@@ -100,7 +110,7 @@ type
     {OpenForSubmit: ProjProperties, StaffData}
     procedure OpenForSubmit(const AFileName: string);
     procedure SaveAsForSubmit(const AFileName: string);
-    {OpenForReply: ProjProperties, StaffData, PhaseData}
+    {OpenForReply: ProjProperties, StaffData, PhaseData, DetailGLData}
     procedure OpenForReply(const AFileName: string);
     procedure SaveForReply(const AFileName: string);
     {OpenForReceive: ProjProperties, StaffData, PhaseData, StageData}
@@ -119,6 +129,7 @@ type
 
     procedure SaveLastestPhaseMainData;
 
+    procedure CopyPreData;
     procedure CreateNewPhase;
 
     {重设所有LookUpDataset连接}
@@ -152,8 +163,10 @@ type
 
     {For Reports: 复制当期的全部数据到项目数据中}
     procedure CopyPhaseData;
+    procedure ClearReportCacheData;
 
     procedure CalculateAll;
+    procedure CalculatePriceMargin;
 
     function CheckDataBaseInfo(APhaseCount, AAuditStatus: Integer): Boolean;
 
@@ -171,6 +184,7 @@ type
     property BillsBookmarkData: TBillsBookmarkData read FBillsBookmarkData;
     property DealBillsData: TDealBillsData read FDealBillsData;
     property PhaseIndex: Integer read FPhaseIndex write SetPhaseIndex;
+    property StageIndex: Integer read GetStageIndex write SetStageIndex;
     property PhaseData: TPhaseData read FPhaseData;
     property ProjProperties: TProjProperties read FProjProperties;
     property PhaseCompareData: TPhaseCompareData read FPhaseCompareData;
@@ -182,10 +196,15 @@ type
     property MainListData: TMainListData read FMainListData;
     property AttachmentData: TUpFiles read FAttachmentData;   // 附件
 
+    property ProjectGLData: TProjectGLData read FProjectGLData;
+    property DetailGLData: TDetailGLData read FDetailGLData;
+    property PriceMarginBillsData: TPriceMarginBillsData read FPriceMarginBillsData;
+
     // 台账、合同支付
     property AllowInsert: Boolean read GetAllowInsert;
     property BaseDataReadOnly: Boolean read GetBaseDataReadOnly;
     property StageDataReadOnly: Boolean read GetStageDataReadOnly;
+    property PriceMarginReadOnly: Boolean read GetPriceMarginReadOnly;
 
     property CanUnlockInfo: Boolean read FCanUnlockInfo write FCanUnlockInfo;
 
@@ -210,7 +229,11 @@ implementation
 
 uses UtilMethods, Globals, ProjectCommands, sdIDTree, StageDm,
   ZJJLDm, PHPWebDm, XMLDoc, XMLIntf, ConstUnit, PasswordInputFrm,
+<<<<<<< HEAD
   mProgressProFrm;
+=======
+  mDataRecord;
+>>>>>>> 3.1.3.3
 
 { TProjectData }
 
@@ -256,6 +279,9 @@ begin
   FStaffData := TStaffData.Create(Self);
   FSearchData := TSearchData.Create(Self);
   FMainListData := TMainListData.Create(Self);
+  FProjectGLData := TProjectGLData.Create(Self);
+  FDetailGLData := TDetailGLData.Create(Self);
+  FPriceMarginBillsData := TPriceMarginBillsData.Create(Self);
   FAttachmentData := TUpFiles.Create;
   FPhaseIndex := 0;
 end;
@@ -275,6 +301,9 @@ end;
 destructor TProjectData.Destroy;
 begin
   FCheckers.Free;
+  FPriceMarginBillsData.Free;
+  FDetailGLData.Free;
+  FProjectGLData.Free;
   FMainListData.Free;
   FSearchData.Free;
   FStaffData.Free;
@@ -330,6 +359,8 @@ procedure TProjectData.LockedDataForReply;
 begin
   LockBillsBaseData;
   LockDealPaymentData;
+  LockProjectGLData;
+  LockDetailGLData;
   FPhaseData.PhaseProperty.FinalAudit := True;
   // 有顺序限制,谨慎修改
   FProjProperties.AuditCompany := FStaffData.FinalStaffCompany;
@@ -382,20 +413,30 @@ begin
   FBillsCompileData.Open;
   FBillsMeasureData.Open;
   UpdateSysProgress(65, '正在读取数据');
+
   FBillsBookmarkData.Open;
   UpdateSysProgress(70, '正在读取数据');
+
   FDealBillsData.Open(FConnection.Connection);
   UpdateSysProgress(80, '正在读取数据');
+
   FDealPaymentData.Open(FConnection.Connection);
   if FIsNewFile then
     FDealPaymentData.Init;
   UpdateSysProgress(90, '正在读取数据');
+
   OpenLastPhaseData;
   UpdateSysProgress(140, '正在读取数据');
+
+  // 价差数据应在当期数据打开后打开
+  FProjectGLData.Open(FConnection.Connection);
+  FDetailGLData.Open(FConnection.Connection);
   FBGLData.Open(FConnection.Connection);
   UpdateSysProgress(160, '正在读取数据');
+
   FStaffData.Open(FConnection.Connection);
   UpdateSysProgress(180, '正在读取数据');
+
   //FBillsGatherData.RefreshBills;
   FMainListData.Open(FConnection.Connection);
   UpdateSysProgress(200, '就绪');
@@ -414,29 +455,38 @@ procedure TProjectData.Save;
 begin
   UpdateSysProgress(5, '正在保存数据');
   SaveLastestPhaseMainData;
+  UpdateSysProgress(10, '正在保存数据');
   if FPhaseData.Active then
     FPhaseData.Save;
-  UpdateSysProgress(20, '正在保存数据');
+  UpdateSysProgress(40, '正在保存数据');
   FMainListData.Save;
   FDealPaymentData.Save;
-  UpdateSysProgress(40, '正在保存数据');
-  FStaffData.Save;
   UpdateSysProgress(50, '正在保存数据');
-  FBGLData.Save;
+  FStaffData.Save;
   UpdateSysProgress(60, '正在保存数据');
+  FBGLData.Save;
+  UpdateSysProgress(70, '正在保存数据');
   FDealBillsData.Save;
   UpdateSysProgress(80, '正在保存数据');
+
+  FProjectGLData.Save;
+  FDetailGLData.Save;
+  UpdateSysProgress(100, '正在保存数据');
+
   FBillsCompileData.ReLockBaseData;
-  UpdateSysProgress(85, '正在保存数据');
+  UpdateSysProgress(110, '正在保存数据');
   FBillsData.Save;
   UpdateSysProgress(170, '正在保存数据');
+
   FProjProperties.Save;
   UpdateSysProgress(180, '正在保存数据');
   FConnection.Save;
   UpdateSysProgress(190, '正在保存数据');
+
   ZipFolder(FTempFolder, FileName);
   SaveInfoToManager;
   UpdateSysProgress(200, '就绪');
+
   ProjectManager.AddSaveTenderBackup(FProjectID);
 end;
 
@@ -477,11 +527,15 @@ procedure TProjectData.SetPhaseIndex(const Value: Integer);
 
 begin
   SaveLastestPhaseMainData;
+  FProjectGLData.Save;
   FPhaseIndex := Value;
   ProjProperties.PhaseIndex := FPhaseIndex;
   ReCreatePhaseData;
   FPhaseData.Open(GetPhaseFileName);
   ResetPhaseDataLink;
+  // 须保存项目工料数据,重新加载当期的项目工料数据
+  FProjectGLData.LoadCurPhaseInfoPrice;
+  FProjectGLData.LoadStagePM_CalcData;
   //BillsGatherData.RefreshBills;
 end;
 
@@ -536,6 +590,21 @@ begin
 end;
 
 procedure TProjectData.UpdatePhaseData;
+
+  procedure UpdateGLPriceData;
+  const
+    sUpdateSql = 'Update GLPrice Set PM_Quantity%d = PM_Quantity%d, PM_TotalPrice%d = PM_TotalPrice%d'+
+                 '  Where PhaseID = %d';
+  var
+    sSql: string;
+  begin
+    if (ProjProperties.PhaseCount < 1) or (ProjProperties.AuditStatus < 1) then Exit;
+
+    with ProjProperties do
+      sSql := Format(sUpdateSql, [AuditStatus, AuditStatus-1, AuditStatus, AuditStatus-1, PhaseCount]);
+    ExecuteSql(sSql);
+  end;
+
 var
   iPhase: Integer;
 begin
@@ -545,6 +614,7 @@ begin
     SetPhaseIndexSimple(iPhase);
     PhaseData.CreateNewAuditData;
     StaffData.UpdateDataForNewAudit;
+    UpdateGLPriceData;
   end;
 end;
 
@@ -694,30 +764,6 @@ end;
 
 procedure TProjectData.CopyPhaseData;
 
-  procedure DeletePhaseTable;
-  var
-    FTableList: TStringList;
-    iIndex: Integer;
-    sDeleteTableSql: String;
-  begin
-    FTableList := TStringList.Create;
-    try
-      FConnection.Connection.GetTableNames(FTableList);
-      iIndex := 0;
-      while iIndex < FTableList.Count do
-      begin
-        if Pos('P_', FTableList.Strings[iIndex]) = 1 then
-        begin
-          sDeleteTableSql := Format('Drop Table %s', [FTableList.Strings[iIndex]]);
-          ExecuteSql(sDeleteTableSql);
-        end;
-        Inc(iIndex);
-      end;
-    finally
-      FTableList.Free;
-    end;
-  end;
-
   procedure CopyStageData(const AFileName, ASourceTable, AResultTable: string);
   const
     sCopySql = 'Select BillsID, DealQuantity, DealTotalPrice, QcQuantity, QcTotalPrice, QcBGLCode, QcBGLNum,' +
@@ -972,7 +1018,7 @@ procedure TProjectData.CopyPhaseData;
 
 begin
   Save;
-  DeletePhaseTable;
+  ClearReportCacheData;
   CopyCacheReportsData;
   if FPhaseIndex > 0 then
     CopyCurPhaseData;
@@ -1066,10 +1112,11 @@ end;
 
 procedure TProjectData.CalculateAll;
 begin
-  FBillsCompileData.CalculateAll;
-  if not FPhaseData.StageDataReadOnly then
-    FPhaseData.StageData.CalculateAll;
-  FBillsMeasureData.CalculateAll;
+  FBillsCompileData.CalculateAll; //台账
+  FProjectGLData.CalculateAll; //工料价差
+  FPhaseData.StageData.CalculateAll; //计量&清单价差
+  FBillsMeasureData.CalculateAll; //累计
+  FPhaseData.PhasePayData.CalculateAll;
 end;
 
 procedure TProjectData.ImportCloudTenderFile(const AFileName: string);
@@ -1303,10 +1350,12 @@ begin
     FPhaseData.SimpleOpen(Format('%sPhase%d.dat', [TempPath, FPhaseIndex]));
   end;
   FStaffData.Open(FConnection.Connection);
+  FDetailGLData.Open(FConnection.Connection);
 end;
 
 procedure TProjectData.SaveForReply(const AFileName: string);
 begin
+  FDetailGLData.Save;
   FStaffData.Save;
   if FPhaseData.Active then
     FPhaseData.SimpleSave;
@@ -1557,4 +1606,108 @@ begin
   FBillsMeasureData.ResetTreeNodeStageRec;
 end;
 
+function TProjectData.GetPriceMarginReadOnly: Boolean;
+begin
+  if FPhaseData.Active then
+    Result := not((FPhaseIndex = FProjProperties.PhaseCount) and (FPhaseData.StageCount = 1) and (FProjProperties.AuditStatus <> -1))
+  else
+    Result := True;
+end;
+
+procedure TProjectData.CalculatePriceMargin;
+begin
+  // 计算工料价差数据
+  FProjectGLData.CalculateAll;
+  if not FPhaseData.StageDataReadOnly then
+  begin
+    // 计算清单价差节点
+    PhaseData.StageData.CalculatePriceMarginNode;
+    // 计算合同支付
+    PhaseData.PhasePayData.CalculateAll;
+  end;
+end;
+
+procedure TProjectData.LockProjectGLData;
+const
+  sLockSql = 'Update ProjectGL As P, GLPrice As G' +
+             '  Set P.LockedPhaseID = %d'+
+             '  Where (P.ID = G.GLID) and (G.PM_Quantity_F <> 0) and (IsNull(P.LockedPhaseID) or (P.LockedPhaseID = 0))';
+var
+  sSql: string;
+begin
+  sSql := Format(sLockSql, [FProjProperties.PhaseCount]);
+  ExecuteSql(sSql);
+end;
+
+procedure TProjectData.LockDetailGLData;
+const
+  sLockSql = 'Update DetailGL As D Set D.LockedPhaseID = %d' +
+             '  Where (D.LastBillsQuantity <> 0) and (IsNull(D.LockedPhaseID) or (D.LockedPhaseID = 0))';
+var
+  sSql: string;
+begin
+  sSql := Format(sLockSql, [FProjProperties.PhaseCount]);
+  ExecuteSql(sSql);
+end;
+
+procedure TProjectData.CopyPreData;
+
+  procedure CopyPreGLPrice;
+  const
+    sCopySql = 'Insert Into GLPrice (GLID, PhaseID,' +
+               '    InfoPrice, InfoDate, DeltaPrice, ValidDeltaPrice,' +
+               '    PM_PreQuantity, PM_PreTotalPrice)'+
+               '  Select GLID, %d,'+
+               '    InfoPrice, InfoDate, DeltaPrice, ValidDeltaPrice,'+
+               '    PM_PreQuantity+PM_Quantity_F, PM_PreTotalPrice+PM_TotalPrice_F'+
+               '  From GLPrice Where PhaseID = %d';
+  begin
+    if FProjProperties.PhaseCount > 1 then
+      ExecuteSql(Format(sCopySql, [FProjProperties.PhaseCount, FProjProperties.PhaseCount - 1]));
+  end;
+
+begin
+  CopyPreGLPrice;
+  PhaseData.CopyPreData;
+  ProjectGLData.LoadCurPhaseInfoPrice;
+  ProjectGLData.LoadStagePM_CalcData;
+  BillsMeasureData.ResetTreeNodeStageRec;
+end;
+
+function TProjectData.GetStageIndex: Integer;
+begin
+  Result := FPhaseData.StageIndex;
+end;
+
+procedure TProjectData.SetStageIndex(const Value: Integer);
+begin
+  FProjectGLData.Save;
+  FPhaseData.StageIndex := Value;
+  FProjectGLData.LoadStagePM_CalcData;
+end;
+
+procedure TProjectData.ClearReportCacheData;
+var
+  FTableList: TStringList;
+  iIndex: Integer;
+  sDeleteTableSql: String;
+begin
+  FTableList := TStringList.Create;
+  try
+    FConnection.Connection.GetTableNames(FTableList);
+    iIndex := 0;
+    while iIndex < FTableList.Count do
+    begin
+      if Pos('P_', FTableList.Strings[iIndex]) = 1 then
+      begin
+        sDeleteTableSql := Format('Drop Table %s', [FTableList.Strings[iIndex]]);
+        ExecuteSql(sDeleteTableSql);
+      end;
+      Inc(iIndex);
+    end;
+  finally
+    FTableList.Free;
+  end;
+end;
+
 end.

+ 3 - 0
Units/UpdateDataBase.pas

@@ -86,6 +86,9 @@ begin
     Updater.AddTableDef(SStaff, @tdStaff, Length(tdStaff), False, False);
     Updater.AddTableDef(SDealBills, @tdDealBills, Length(tdDealBills), False, False);
     Updater.AddTableDef(SMainDataList, @tdMainDataList, Length(tdMainDataList), False, False);
+    Updater.AddTableDef(SProjectGL, @tdProjectGL, Length(tdProjectGL), False, False);
+    Updater.AddTableDef(SGLPrice, @tdGLPrice, Length(tdGLPrice), False, False);
+    Updater.AddTableDef(SDetailGL, @tdDetailGL, Length(tdDetailGL), False, False);
     Updater.ExcuteUpdate;
   finally
     Updater.Free;

+ 21 - 0
Units/UtilMethods.pas

@@ -13,11 +13,15 @@ type
   function QuantityRoundTo(AValue: Double): Double;
   function PriceRoundTo(AValue: Double): Double;
   function TotalPriceRoundTo(AValue: Double): Double;
+  function CommonRoundTo(AValue: Double; ADigit: Integer): Double;
 
   {Interface Control}
   procedure AlignControl(AControl, AParent: TWinControl; AAlign: TAlign);
   procedure SetDxBtnAction(AAction: TAction; ADxBtn: TObject);
 
+  {DataBase Rela}
+  function GetsdDataSetNewID(ADataSet: TsdDataSet; const AIndex: string): Integer;
+
   {Message}
   procedure WarningMessage(const AMsg: string);
   procedure ErrorMessage(const AMsg: string);
@@ -139,6 +143,11 @@ begin
     Result := ScRoundTo(AValue, iTotalPriceDigit);
 end;
 
+function CommonRoundTo(AValue: Double; ADigit: Integer): Double;
+begin
+  Result := ScRoundTo(AValue, ADigit);
+end;
+
 {Interface Control}
 procedure AlignControl(AControl, AParent: TWinControl; AAlign: TAlign);
 begin
@@ -158,6 +167,18 @@ begin
       TdxBarButton(ADxBtn).Action := AAction;
 end;
 
+{DataBase Rela}
+function GetsdDataSetNewID(ADataSet: TsdDataSet; const AIndex: string): Integer;
+var
+  idx: TsdIndex;
+begin
+  idx := ADataSet.FindIndex(AIndex);
+  if idx.RecordCount > 0 then
+    Result := idx.Records[idx.RecordCount - 1].ValueByName('ID').AsInteger + 1
+  else
+    Result := 1;
+end;
+
 {Message}
 procedure WarningMessage(const AMsg: string);
 begin

+ 185 - 2
Units/mDataRecord.pas

@@ -6,7 +6,16 @@ uses
   Classes, sdDB;
 
 type
-  TBillsRecord = class(TsdDataRecord)
+  TMeasureBaseRecord = class(TsdDataRecord)
+  public
+    procedure SetFloatValue(AValue: TsdValue; AFloat: Double);
+    procedure SetIntValue(AValue: TsdValue; AInt: Integer);
+    procedure SetBoolValue(AValue: TsdValue; ABool: Boolean);
+
+    procedure AddDifferValue(AValue: TsdValue; ADiffer: Double);
+  end;
+
+  TBillsRecord = class(TMeasureBaseRecord)
   private
     // 树结构
     FID: TsdValue;
@@ -89,9 +98,13 @@ type
 
     FAddCompleteRate: TsdValue;
 
+<<<<<<< HEAD
     FCacheMisTP: Double;
     FCacheOrgTP: Double;
     FCacheOthTP: Double;
+=======
+    FPM_AddTotalPrice: TsdValue;
+>>>>>>> 3.1.3.3
   protected
     procedure DoAfterAddFields; override;
   public
@@ -174,13 +187,17 @@ type
 
     property AddCompleteRate: TsdValue read FAddCompleteRate;
 
+<<<<<<< HEAD
     // Cache Data 用于增量计算,记录原始值
     property CacheOrgTP: Double read FCacheOrgTP write FCacheOrgTP;
     property CacheMisTP: Double read FCacheMisTP write FCacheMisTP;
     property CacheOthTP: Double read FCacheOthTP write FCacheOthTP;
+=======
+    property PM_AddTotalPrice: TsdValue read FPM_AddTotalPrice;
+>>>>>>> 3.1.3.3
   end;
 
-  TStageRecord = class(TsdDataRecord)
+  TStageRecord = class(TMeasureBaseRecord)
   private
     FBillsID: TsdValue;
 
@@ -235,7 +252,12 @@ type
     FHasBookMark: TsdValue;
     FMarkMemo: TsdValue;
 
+<<<<<<< HEAD
     FCacheDealTP: Double;
+=======
+    FPM_PreTotalPrice: TsdValue;
+    FPM_TotalPrice: TsdValue;
+>>>>>>> 3.1.3.3
   protected
     procedure DoAfterAddFields; override;
   public
@@ -292,7 +314,90 @@ type
     property HasBookMark: TsdValue read FHasBookMark;
     property MarkMemo: TsdValue read FMarkMemo;
 
+<<<<<<< HEAD
     property CacheDealTP: Double read FCacheDealTP write FCacheDealTP;
+=======
+    property PM_PreTotalPrice: TsdValue read FPM_PreTotalPrice;
+    property PM_TotalPrice: TsdValue read FPM_TotalPrice;
+  end;
+
+  TProjectGLRecord = class(TMeasureBaseRecord)
+  private
+    FID: TsdValue;
+    FCode: TsdValue;
+    FName: TsdValue;
+    FUnits: TsdValue;
+    FSpecs: TsdValue;
+    FBasePrice: TsdValue;
+    FRiskRange: TsdValue;
+    FLockedPhaseID: TsdValue;
+    FCreatePhaseID: TsdValue;
+
+    FInfoPrice: TsdValue;
+    FInfoDate: TsdValue;
+    FDeltaPrice: TsdValue;
+    FValidDeltaPrice: TsdValue;
+
+    FPM_PreQuantity: TsdValue;
+    FPM_PreTotalPrice: TsdValue;
+    FPM_Quantity: TsdValue;
+    FPM_TotalPrice: TsdValue;
+  protected
+    procedure DoAfterAddFields; override;
+  public
+    property ID: TsdValue read FID;
+    property Code: TsdValue read FCode;
+    property Name: TsdValue read FName;
+    property Units: TsdValue read FUnits;
+    property Specs: TsdValue read FSpecs;
+    property BasePrice: TsdValue read FBasePrice;
+    property RiskRange: TsdValue read FRiskRange;
+    property LockedPhaseID: TsdValue read FLockedPhaseID;
+    property CreatePhaseID: TsdValue read FCreatePhaseID;
+
+    property InfoPrice: TsdValue read FInfoPrice;
+    property InfoDate: TsdValue read FInfoDate;
+    property DeltaPrice: TsdValue read FDeltaPrice;
+    property ValidDeltaPrice: TsdValue read FValidDeltaPrice;
+
+    property PM_PreQuantity: TsdValue read FPM_PreQuantity;
+    property PM_PreTotalPrice: TsdValue read FPM_PreTotalPrice;
+    property PM_Quantity: TsdValue read FPM_Quantity;
+    property PM_TotalPrice: TsdValue read FPM_TotalPrice;
+  end;
+
+  TDetailGLRecord = class(TMeasureBaseRecord)
+  private
+    FID: TsdValue;
+    FBillsID: TsdValue;
+    FGLID: TsdValue;
+
+    FCode: TsdValue;
+    FQuantity: TsdValue;
+
+    FCreatePhaseID: TsdValue;
+
+    FLastBillsQuantity: TsdValue;
+    FLockedPhaseID: TsdValue;
+
+    FRelaProjectGL: TProjectGLRecord;
+  protected
+    procedure DoAfterAddFields; override;
+  public
+    property ID: TsdValue read FID;
+    property BillsID: TsdValue read FBillsID;
+    property GLID: TsdValue read FGLID;
+
+    property Code: TsdValue read FCode;
+    property Quantity: TsdValue read FQuantity;
+
+    property CreatePhaseID: TsdValue read FCreatePhaseID;
+
+    property LastBillsQuantity: TsdValue read FLastBillsQuantity;
+    property LockedPhaseID: TsdValue read FLockedPhaseID;
+
+    property RelaProjectGL: TProjectGLRecord read FRelaProjectGL write FRelaProjectGL;
+>>>>>>> 3.1.3.3
   end;
 
 implementation
@@ -380,6 +485,8 @@ begin
   FAddPayTotalPrice := ValueByName('AddPayTotalPrice');
 
   FAddCompleteRate := ValueByName('AddCompleteRate');
+  
+  FPM_AddTotalPrice := ValueByName('PM_AddTotalPrice');
 end;
 
 { TStageRecord }
@@ -439,6 +546,82 @@ begin
 
   FHasBookMark := ValueByName('HasBookMark');
   FMarkMemo := ValueByName('MarkMemo');
+
+  FPM_PreTotalPrice := ValueByName('PM_PreTotalPrice');
+  FPM_TotalPrice := ValueByName('PM_TotalPrice');
+end;
+
+{ TProjectGLRecord }
+
+procedure TProjectGLRecord.DoAfterAddFields;
+begin
+  inherited;
+  FID := ValueByName('ID');
+  FCode := ValueByName('Code');
+  FName := ValueByName('Name');
+  FUnits := ValueByName('Units');
+  FSpecs := ValueByName('Specs');
+  FBasePrice := ValueByName('BasePrice');
+  FRiskRange := ValueByName('RiskRange');
+  FLockedPhaseID := ValueByName('LockedPhaseID');
+  FCreatePhaseID := ValueByName('CreatePhaseID');
+
+  FInfoPrice := ValueByName('InfoPrice');
+  FInfoDate := ValueByName('InfoDate');
+  FDeltaPrice := ValueByName('DeltaPrice');
+  FValidDeltaPrice := ValueByName('ValidDeltaPrice');
+
+  FPM_PreQuantity := ValueByName('PM_PreQuantity');
+  FPM_PreTotalPrice := ValueByName('PM_PreTotalPrice');
+  FPM_Quantity := ValueByName('PM_Quantity');
+  FPM_TotalPrice := ValueByName('PM_TotalPrice');
+end;
+
+{ TDetailGLRecord }
+
+procedure TDetailGLRecord.DoAfterAddFields;
+begin
+  inherited;
+  FID := ValueByName('ID');
+  FBillsID := ValueByName('BillsID');
+  FGLID := ValueByName('GLID');
+
+  FCode := ValueByName('Code');
+  FQuantity := ValueByName('Quantity');
+
+  FCreatePhaseID := ValueByName('CreatePhaseID');
+
+  FLastBillsQuantity := ValueByName('LastBillsQuantity');
+  FLockedPhaseID := ValueByName('LockedPhaseID');
+end;
+
+{ TMeasureBaseRecord }
+
+procedure TMeasureBaseRecord.AddDifferValue(AValue: TsdValue;
+  ADiffer: Double);
+begin
+  if ADiffer <> 0 then
+    AValue.AsFloat := AValue.AsFloat + ADiffer;
+end;
+
+procedure TMeasureBaseRecord.SetBoolValue(AValue: TsdValue;
+  ABool: Boolean);
+begin
+  if AValue.AsBoolean <> ABool then
+    AValue.AsBoolean := ABool;
+end;
+
+procedure TMeasureBaseRecord.SetFloatValue(AValue: TsdValue;
+  AFloat: Double);
+begin
+  if AValue.AsFloat <> AFloat then
+    AValue.AsFloat := AFloat;
+end;
+
+procedure TMeasureBaseRecord.SetIntValue(AValue: TsdValue; AInt: Integer);
+begin
+  if AValue.AsInteger <> AInt then
+    AValue.AsInteger := AInt;
 end;
 
 end.