Pārlūkot izejas kodu

合并[清单汇总][材料调差]两部分的清单汇总算法,便于以后维护

MaiXinRong 9 gadi atpakaļ
vecāks
revīzija
fcf94e9620

+ 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
+      73734E616D65090001044E616D65060742696C6C734944094669656C644E616D
+      65060742696C6C7349440844617461547970650203084461746153697A650204
+      0549734B6579080F4E65656450726F636573734E616D65090001044E616D6506
+      09424742696C6C734944094669656C644E616D650609424742696C6C73494408
+      44617461547970650203084461746153697A6502040549734B6579080F4E6565
+      6450726F636573734E616D65090001044E616D65060542474C4944094669656C
+      644E616D65060542474C49440844617461547970650203084461746153697A65
+      02040549734B6579080F4E65656450726F636573734E616D65090001044E616D
+      65060742474C436F6465094669656C644E616D65060742474C436F6465084461
+      7461547970650218084461746153697A6502320549734B6579080F4E65656450
+      726F636573734E616D65090001044E616D65060742474C4E616D65094669656C
+      644E616D65060742474C4E616D65084461746154797065021808446174615369
+      7A6503C8000549734B6579080F4E65656450726F636573734E616D6509000104
+      4E616D65060F42474C417070726F76616C436F6465094669656C644E616D6506
+      0F42474C417070726F76616C436F646508446174615479706502180844617461
+      53697A6502320549734B6579080F4E65656450726F636573734E616D65090001
+      044E616D65060E42474C44726177696E67436F6465094669656C644E616D6506
+      0E42474C44726177696E67436F64650844617461547970650218084461746153
+      697A6502320549734B6579080F4E65656450726F636573734E616D6509000104
+      4E616D6506085175616E74697479094669656C644E616D6506085175616E7469
+      74790844617461547970650206084461746153697A6502080549734B6579080F
+      4E65656450726F636573734E616D65090001044E616D65060A546F74616C5072
+      696365094669656C644E616D65060A546F74616C507269636508446174615479
+      70650206084461746153697A6502080549734B6579080F4E65656450726F6365
+      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

+ 237 - 432
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,247 @@ 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.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.RefreshRelaXmj;
-begin
-  cdsRelaXmj.EmptyDataSet;
-  AddRelaXmjs(cdsBillsGatherB_Code.AsString, cdsBillsGatherName.AsString,
-    cdsBillsGatherUnits.AsString, cdsBillsGatherPrice.AsFloat);
-end;
+procedure TBillsGatherData.WriteGatherRecord(AGcls: TList);
 
-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.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;
-  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);
+      vBGL := AGclNode.DetailBGL[iBGL];
+      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 GetPegName(APegNode: TsdIDTreeNode): string;
+  procedure WriteDetailGclNode(AGclNode: TGclNode);
+  var
+    iDetailGcl: Integer;
+    vDetailGcl: TDetailGclNode;
+    Rec: TsdDataRecord;
   begin
-    if Assigned(APegNode) then
-      Result := APegNode.Rec.ValueByName('Name').AsString
-    else
-      Result := '';
+    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;
+      Rec.ValueByName('LeafXmjID').AsInteger := vDetailGcl.LeafXmjID;
+      Rec.ValueByName('XmjCode').AsString := vDetailGcl.XmjCode;
+      Rec.ValueByName('XmjName').AsString := vDetailGcl.XmjName;
+      Rec.ValueByName('XmjUnits').AsString := vDetailGcl.XmjUnits;
+      Rec.ValueByName('NameDanWei').AsString := vDetailGcl.NameDanWei;
+      Rec.ValueByName('NameFenXiang').AsString := vDetailGcl.NameFenXiang;
+      Rec.ValueByName('NameFenBu').AsString := vDetailGcl.NameFenBu;
+      Rec.ValueByName('NameUnit').AsString := vDetailGcl.NameUnit;
+
+      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.

+ 544 - 239
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,18 +38,19 @@ object BillsGatherFrame: TBillsGatherFrame
       FixedRowCount = 2
       ShowGridLine = False
       DefaultColWidth = 73
+      DefaultFixedColWidth = 25
       Selection.AlphaBlend = False
       Selection.TransparentColor = False
       FrozenCol = 0
       FrozenRow = 0
-      OnCellGetColor = zgBillsGatherCellGetColor
+      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
@@ -57,7 +58,7 @@ object BillsGatherFrame: TBillsGatherFrame
     object pnlRelaXmjType: TPanel
       Left = 0
       Top = 0
-      Width = 798
+      Width = 1477
       Height = 21
       Align = alTop
       BevelOuter = bvNone
@@ -65,51 +66,544 @@ 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
+        end
+        object tobtnDetailBGL: TToolButton
+          Tag = 2
+          Left = 182
+          Top = 0
+          Caption = #30456#20851#21464#26356#28165#21333
+          ImageIndex = 2
+        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
-      FrozenCol = 0
-      FrozenRow = 0
-      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
@@ -122,7 +616,6 @@ object BillsGatherFrame: TBillsGatherFrame
         Font.Name = #23435#20307
         Font.Style = []
         FieldName = 'IndexCode'
-        Width = 60
         Visible = False
         ReadOnly = False
       end
@@ -171,13 +664,13 @@ 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
         Font.Color = clWindowText
         Font.Height = -12
-        Font.Name = 'smartSimSun'
+        Font.Name = #23435#20307
         Font.Style = []
         FieldName = 'Units'
         Width = 45
@@ -237,7 +730,7 @@ object BillsGatherFrame: TBillsGatherFrame
         Font.Style = []
         FieldName = 'DealQuantity'
         Width = 60
-        ReadOnly = False
+        ReadOnly = True
       end
       item
         Title.Caption = '|'#37329#39069
@@ -255,7 +748,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
@@ -421,7 +914,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
@@ -582,7 +1075,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
@@ -597,7 +1090,7 @@ object BillsGatherFrame: TBillsGatherFrame
         Font.Style = []
         FieldName = 'Deal_BGLQuantity'
         Width = 60
-        ReadOnly = False
+        ReadOnly = True
       end
       item
         Title.Caption = '|'#37329#39069
@@ -615,7 +1108,7 @@ object BillsGatherFrame: TBillsGatherFrame
         Font.Style = []
         FieldName = 'Deal_BGLTotalPrice'
         Width = 60
-        ReadOnly = False
+        ReadOnly = True
       end
       item
         Title.Caption = '|'#23436#25104#29575'(%)'
@@ -631,201 +1124,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.

+ 187 - 25
Units/GclBillsGatherModel.pas

@@ -44,6 +44,20 @@ type
     FPreGatherQuantity: Double;
     FPreGatherTotalPrice: Double;
 
+    FEndDealQuantity: Double;
+    FEndDealTotalPrice: Double;
+    FEndQcQuantity: Double;
+    FEndQcTotalPrice: Double;
+    FEndGatherQuantity: Double;
+    FEndGatherTotalPrice: Double;
+
+    FAddDealQuantity: Double;
+    FAddDealTotalPrice: Double;
+    FAddQcQuantity: Double;
+    FAddQcTotalPrice: Double;
+    FAddGatherQuantity: Double;
+    FAddGatherTotalPrice: Double;
+
     FPM_PreTotalPrice: Double;
     FPM_TotalPrice: Double;
   public
@@ -84,6 +98,20 @@ type
     property PreGatherQuantity: Double read FPreGatherQuantity write FPreGatherQuantity;
     property PreGatherTotalPrice: Double read FPreGatherTotalPrice write FPreGatherTotalPrice;
 
+    property EndDealQuantity: Double read FEndDealQuantity write FEndDealQuantity;
+    property EndDealTotalPrice: Double read FEndDealTotalPrice write FEndDealTotalPrice;
+    property EndQcQuantity: Double read FEndQcQuantity write FEndQcQuantity;
+    property EndQcTotalPrice: Double read FEndQcTotalPrice write FEndQcTotalPrice;
+    property EndGatherQuantity: Double read FEndGatherQuantity write FEndGatherQuantity;
+    property EndGatherTotalPrice: Double read FEndGatherTotalPrice write FEndGatherTotalPrice;
+
+    property AddDealQuantity: Double read FAddDealQuantity write FAddDealQuantity;
+    property AddDealTotalPrice: Double read FAddDealTotalPrice write FAddDealTotalPrice;
+    property AddQcQuantity: Double read FAddQcQuantity write FAddQcQuantity;
+    property AddQcTotalPrice: Double read FAddQcTotalPrice write FAddQcQuantity;
+    property AddGatherQuantity: Double read FAddGatherQuantity write FAddGatherQuantity;
+    property AddGatherTotalPrice: Double read FAddGatherTotalPrice write FAddGatherTotalPrice;
+
     property PM_PreTotalPrice: Double read FPM_PreTotalPrice write FPM_PreTotalPrice;
     property PM_TotalPrice: Double read FPM_TotalPrice write FPM_TotalPrice;
   end;
@@ -108,15 +136,27 @@ type
   TDetailBGLNode = class
   private
     FID: Integer;
+    FBGBillsID: Integer;
     FBGLID: Integer;
 
+    FBGLCode: string;
+    FBGLName: string;
+    FBGLApprovalCode: string;
+    FBGLDrawingCode: string;
+
     FQuantity: Double;
     FTotalPrice: Double;
   public
     constructor Create(AID: Integer);
 
     property ID: Integer read FID;
-    property BGLID: Integer read FBGLID;
+    property BGBillsID: Integer read FBGBillsID write FBGBillsID;
+    property BGLID: Integer read FBGLID write FBGLID;
+
+    property BGLCode: string read FBGLCode write FBGLCode;
+    property BGLName: string read FBGLName write FBGLName;
+    property BGLApprovalCode: string read FBGLApprovalCode write FBGLApprovalCode;
+    property BGLDrawingCode: string read FBGLDrawingCode write FBGLDrawingCode;
 
     property Quantity: Double read FQuantity write FQuantity;
     property TotalPrice: Double read FTotalPrice write FTotalPrice;
@@ -153,16 +193,35 @@ type
     FPreGatherQuantity: Double;
     FPreGatherTotalPrice: Double;
 
+    FEndDealQuantity: Double;
+    FEndDealTotalPrice: Double;
+    FEndQcQuantity: Double;
+    FEndQcTotalPrice: Double;
+    FEndGatherQuantity: Double;
+    FEndGatherTotalPrice: Double;
+
+    FAddDealQuantity: Double;
+    FAddDealTotalPrice: Double;
+    FAddQcQuantity: Double;
+    FAddQcTotalPrice: Double;
+    FAddGatherQuantity: Double;
+    FAddGatherTotalPrice: Double;
+
     FDealQuantity: Double;
     FDealTotalPrice: Double;
 
     FBGLQuantity: Double;
     FBGLTotalPrice: Double;
 
+    FDeal_BGLQuantity: Double;
+    FDeal_BGLTotalPrice: Double;
+    FDeal_BGLPercent: Double;
+
     procedure InitCalculate;
     procedure GatherDetailGcl;
     procedure GatherDetailDeal;
     procedure GatherDetailBGL;
+    procedure CalculateOther;
 
     procedure SetB_Code(const Value: string);
     function GetDetailBGL(AIndex: Integer): TDetailBGLNode;
@@ -189,28 +248,48 @@ type
     property Units: string read FUnits write FUnits;
     property Price: Double read FPrice write FPrice;
 
-    property Quantity: Double read FQuantity write FQuantity;
-    property TotalPrice: Double read FTotalPrice write FTotalPrice;
-
-    property CurDealQuantity: Double read FCurDealQuantity write FCurDealQuantity;
-    property CurDealTotalPrice: Double read FCurDealTotalPrice write FCurDealTotalPrice;
-    property CurQcQuantity: Double read FCurQcQuantity write FCurQcQuantity;
-    property CurQcTotalPrice: Double read FCurQcTotalPrice write FCurQcTotalPrice;
-    property CurGatherQuantity: Double read FCurGatherQuantity write FCurGatherQuantity;
-    property CurGatherTotalPrice: Double read FCurGatherTotalPrice write FCurGatherTotalPrice;
-
-    property PreDealQuantity: Double read FPreDealQuantity write FPreDealQuantity;
-    property PreDealTotalPrice: Double read FPreGatherTotalPrice write FPreGatherTotalPrice;
-    property PreQcQuantity: Double read FPreQcQuantity write FPreQcQuantity;
-    property PreQcTotalPrice: Double read FPreQcTotalPrice write FPreQcTotalPrice;
-    property PreGatherQuantity: Double read FPreGatherQuantity write FPreGatherQuantity;
-    property PreGatherTotalPrice: Double read FPreGatherTotalPrice write FPreGatherTotalPrice;
-
-    property DealQuantity: Double read FDealQuantity write FDealQuantity;
-    property DealTotalPrice: Double read FDealTotalPrice write FDealTotalPrice;
-
-    property BGLQuantity: Double read FBGLQuantity write FBGLQuantity;
-    property BGLTotalPrice: Double read FBGLTotalPrice write FBGLTotalPrice;
+    property Quantity: Double read FQuantity;
+    property TotalPrice: Double read FTotalPrice;
+
+    property CurDealQuantity: Double read FCurDealQuantity;
+    property CurDealTotalPrice: Double read FCurDealTotalPrice;
+    property CurQcQuantity: Double read FCurQcQuantity;
+    property CurQcTotalPrice: Double read FCurQcTotalPrice;
+    property CurGatherQuantity: Double read FCurGatherQuantity;
+    property CurGatherTotalPrice: Double read FCurGatherTotalPrice;
+
+    property PreDealQuantity: Double read FPreDealQuantity;
+    property PreDealTotalPrice: Double read FPreGatherTotalPrice;
+    property PreQcQuantity: Double read FPreQcQuantity;
+    property PreQcTotalPrice: Double read FPreQcTotalPrice;
+    property PreGatherQuantity: Double read FPreGatherQuantity;
+    property PreGatherTotalPrice: Double read FPreGatherTotalPrice;
+
+    property EndDealQuantity: Double read FEndDealQuantity;
+    property EndDealTotalPrice: Double read FEndDealTotalPrice;
+    property EndQcQuantity: Double read FEndQcQuantity;
+    property EndQcTotalPrice: Double read FEndQcTotalPrice;
+    property EndGatherQuantity: Double read FEndGatherQuantity;
+    property EndGatherTotalPrice: Double read FEndGatherTotalPrice;
+
+    property AddDealQuantity: Double read FAddDealQuantity;
+    property AddDealTotalPrice: Double read FAddGatherTotalPrice;
+    property AddQcQuantity: Double read FAddQcQuantity;
+    property AddQcTotalPrice: Double read FAddQcTotalPrice;
+    property AddGatherQuantity: Double read FAddGatherQuantity;
+    property AddGatherTotalPrice: Double read FAddGatherTotalPrice;
+
+    property DealQuantity: Double read FDealQuantity;
+    property DealTotalPrice: Double read FDealTotalPrice;
+
+    property BGLQuantity: Double read FBGLQuantity;
+    property BGLTotalPrice: Double read FBGLTotalPrice;
+
+    // ---------- Calculate --------------
+    property Deal_BGLQuantity: Double read FDeal_BGLQuantity;
+    property Deal_BGLTotalPrice: Double read FDeal_BGLTotalPrice;
+    property Deal_BGLPercent: Double read FDeal_BGLPercent;
+    // -----------------------------------
 
     property DetailGclCount: Integer read GetDetailGclCount;
     property DetailGcl[AIndex: Integer]: TDetailGclNode read GetDetailGcl;
@@ -275,7 +354,8 @@ type
 implementation
 
 uses
-  ZhAPI, SysUtils, ProjectData, UtilMethods, sdDB, sdIDTree;
+  ZhAPI, SysUtils, ProjectData, UtilMethods, sdDB, sdIDTree, BGLDm, DB,
+  Math;
 
 { TGclGatherModel }
 
@@ -327,10 +407,24 @@ begin
     vDetailGclNode.PreGatherQuantity := ANode.StageRec.PreGatherQuantity.AsFloat;
     vDetailGclNode.PreGatherTotalPrice := ANode.StageRec.PreGatherTotalPrice.AsFloat;
 
+    vDetailGclNode.EndDealQuantity := ANode.StageRec.EndDealQuantity.AsFloat;
+    vDetailGclNode.EndDealTotalPrice := ANode.StageRec.EndDealTotalPrice.AsFloat;
+    vDetailGclNode.EndQcQuantity := ANode.StageRec.EndQcQuantity.AsFloat;
+    vDetailGclNode.EndQcTotalPrice := ANode.StageRec.EndQcTotalPrice.AsFloat;
+    vDetailGclNode.EndGatherQuantity := ANode.StageRec.EndGatherQuantity.AsFloat;
+    vDetailGclNode.EndGatherTotalPrice := ANode.StageRec.EndGatherTotalPrice.AsFloat;
+
     vDetailGclNode.PM_PreTotalPrice := ANode.StageRec.PM_PreTotalPrice.AsFloat;
     vDetailGclNode.PM_TotalPrice := ANode.StageRec.PM_TotalPrice.AsFloat;
   end;
 
+  vDetailGclNode.AddDealQuantity := ANode.Rec.AddDealQuantity.AsFloat;
+  vDetailGclNode.AddDealTotalPrice := ANode.Rec.AddDealTotalPrice.AsFloat;
+  vDetailGclNode.AddQcQuantity := ANode.Rec.AddQcQuantity.AsFloat;
+  vDetailGclNode.AddQcTotalPrice := ANode.Rec.AddQcTotalPrice.AsFloat;
+  vDetailGclNode.AddGatherQuantity := ANode.Rec.AddGatherQuantity.AsFloat;
+  vDetailGclNode.AddGatherTotalPrice := ANode.Rec.AddGatherTotalPrice.AsFloat;
+
   vLeafXmj := GetFirstXmjParent;
   vPeg := GetPegNode(vLeafXmj);
   vDetailGclNode.AddPosData(vLeafXmj, vPeg);
@@ -405,9 +499,34 @@ begin
 end;
 
 procedure TGclGatherModel.GatherBGLData;
+var
+  vGclNode: TGclNode;
+  DetailBGL: TDetailBGLNode;
 begin
   if not FGatherBGL then Exit;
-  // To Do
+
+  with TProjectData(FProjectData).BGLData do
+  begin
+    cdsBGBills.First;
+    while not cdsBGBills.Eof do
+    begin
+      vGclNode := GetGclNode(cdsBGBillsB_Code.AsString, cdsBGBillsName.AsString,
+          cdsBGBillsUnits.AsString, cdsBGBillsPrice.AsFloat);
+
+      if cdsBGL.FindKey([cdsBGBillsBGID.AsInteger]) then
+      begin
+        DetailBGL := vGclNode.AddDetailBGL(NewDetailBGLID);
+        DetailBGL.BGBillsID := cdsBGBillsID.AsInteger;
+        DetailBGL.BGLCode := cdsBGLCode.AsString;
+        DetailBGL.BGLName := cdsBGLName.AsString;
+        DetailBGL.BGLApprovalCode := cdsBGLApprovalCode.AsString;
+        DetailBGL.BGLDrawingCode := cdsBGLDrawingCode.AsString;
+        DetailBGL.BGLID := cdsBGBillsBGID.AsInteger;
+        DetailBGL.Quantity := cdsBGBillsQuantity.AsFloat;
+        DetailBGL.TotalPrice := cdsBGBillsTotalPrice.AsFloat;
+      end;
+    end;
+  end;
 end;
 
 procedure TGclGatherModel.GatherBillsData;
@@ -515,6 +634,17 @@ begin
   GatherDetailGcl;
   GatherDetailDeal;
   GatherDetailBGL;
+  CalculateOther;
+end;
+
+procedure TGclNode.CalculateOther;
+begin
+  FDeal_BGLQuantity := FQuantity + FBGLQuantity;
+  FDeal_BGLTotalPrice := FTotalPrice + FBGLTotalPrice;
+  if FDeal_BGLTotalPrice <> 0 then
+    FDeal_BGLPercent := CommonRoundTo(FEndGatherTotalPrice/FDeal_BGLTotalPrice*100, -2)
+  else
+    FDeal_BGLPercent := 0;
 end;
 
 constructor TGclNode.Create(AID: Integer);
@@ -586,6 +716,20 @@ begin
     FPreQcTotalPrice := FPreQcTotalPrice + vDetailGcl.PreQcTotalPrice;
     FPreGatherQuantity := FPreGatherQuantity + vDetailGcl.PreGatherQuantity;
     FPreGatherTotalPrice := FPreGatherTotalPrice + vDetailGcl.PreGatherTotalPrice;
+
+    FEndDealQuantity := FEndDealQuantity + vDetailGcl.EndDealQuantity;
+    FEndDealTotalPrice := FEndDealTotalPrice + vDetailGcl.EndDealTotalPrice;
+    FEndQcQuantity := FEndQcQuantity + vDetailGcl.EndQcQuantity;
+    FEndQcTotalPrice := FEndQcTotalPrice + vDetailGcl.EndQcTotalPrice;
+    FEndGatherQuantity := FEndGatherQuantity + vDetailGcl.EndGatherQuantity;
+    FEndGatherTotalPrice := FEndGatherTotalPrice + vDetailGcl.EndGatherTotalPrice;
+
+    FAddDealQuantity := FAddDealQuantity + vDetailGcl.AddDealQuantity;
+    FAddDealTotalPrice := FAddDealTotalPrice + vDetailGcl.AddDealTotalPrice;
+    FAddQcQuantity := FAddQcQuantity + vDetailGcl.AddQcQuantity;
+    FAddQcTotalPrice := FAddQcTotalPrice + vDetailGcl.AddQcTotalPrice;
+    FAddGatherQuantity := FAddGatherQuantity + vDetailGcl.AddGatherQuantity;
+    FAddGatherTotalPrice := FAddGatherTotalPrice + vDetailGcl.AddGatherTotalPrice;
   end;
 end;
 
@@ -638,11 +782,29 @@ begin
   FPreGatherQuantity := 0;
   FPreGatherTotalPrice := 0;
 
+  FEndDealQuantity := 0;
+  FEndDealTotalPrice := 0;
+  FEndQcQuantity := 0;
+  FEndQcTotalPrice := 0;
+  FEndGatherQuantity := 0;
+  FEndGatherTotalPrice := 0;
+
+  FAddDealQuantity := 0;
+  FAddDealTotalPrice := 0;
+  FAddQcQuantity := 0;
+  FAddQcTotalPrice := 0;
+  FAddGatherQuantity := 0;
+  FAddGatherTotalPrice := 0;
+
   FDealQuantity := 0;
   FDealTotalPrice := 0;
 
   FBGLQuantity := 0;
   FBGLTotalPrice := 0;
+
+  FDeal_BGLQuantity := 0;
+  FDeal_BGLTotalPrice := 0;
+  FDeal_BGLPercent := 0;
 end;
 
 procedure TGclNode.SetB_Code(const Value: string);

+ 6 - 0
Units/UtilMethods.pas

@@ -13,6 +13,7 @@ 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);
@@ -142,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