Browse Source

Merge branch 'master' of http://192.168.1.12:3000/MaiXinRong/Measure

CSL 9 years ago
parent
commit
81c2b10d26
80 changed files with 6453 additions and 110 deletions
  1. 8 0
      DataModules/BGLDm.dfm
  2. 2 0
      DataModules/BGLDm.pas
  3. 7 0
      DataModules/BillsCompileDm.pas
  4. 89 4
      DataModules/ProjectManagerDm.dfm
  5. 4 0
      DataModules/ProjectManagerDm.pas
  6. 1 1
      DataModules/ZJJLDm.pas
  7. 2 2
      Dprs/Pro/Measure.dof
  8. 24 1
      Dprs/Pro/Measure.dpr
  9. BIN
      Dprs/Pro/Measure.res
  10. 2 2
      Dprs/Pro/Measure_Cloud.dof
  11. 24 1
      Dprs/Pro/Measure_Cloud.dpr
  12. BIN
      Dprs/Pro/Measure_Cloud.res
  13. 2 2
      Dprs/Pro/Measure_GuangDong.dof
  14. 24 1
      Dprs/Pro/Measure_GuangDong.dpr
  15. BIN
      Dprs/Pro/Measure_GuangDong.res
  16. 2 2
      Dprs/Pro/Measure_GuangDong_Cloud.dof
  17. 24 1
      Dprs/Pro/Measure_GuangDong_Cloud.dpr
  18. BIN
      Dprs/Pro/Measure_GuangDong_Cloud.res
  19. 24 1
      Dprs/Pro/Measure_GuangDong_TZ.dpr
  20. 2 2
      Dprs/Pro/Measure_TZ.dof
  21. 24 1
      Dprs/Pro/Measure_TZ.dpr
  22. BIN
      Dprs/Pro/Measure_TZ.res
  23. 1 0
      Forms/BatchInsertBillsFrm.dfm
  24. 8 2
      Forms/BatchInsertBillsFrm.pas
  25. 41 2
      Forms/MainFrm.dfm
  26. 12 1
      Forms/MainFrm.pas
  27. 21 2
      Forms/ProgressHintFrm.pas
  28. 41 1
      Frames/BGLFme.dfm
  29. 46 2
      Frames/BGLFme.pas
  30. 12 1
      Frames/BillsCompileFme.pas
  31. 9 0
      Frames/ProjectFme.dfm
  32. 18 0
      Frames/ProjectFme.pas
  33. 1 0
      Frames/ProjectManagerFme.dfm
  34. 47 0
      Frames/ProjectManagerFme.pas
  35. 29 14
      Frames/ZJJLFme.dfm
  36. 78 9
      Frames/ZJJLFme.pas
  37. 207 0
      TenderPartition/tpBaseGatherData.pas
  38. 202 0
      TenderPartition/tpGatherGcl.pas
  39. 300 0
      TenderPartition/tpGatherTree.pas
  40. 165 0
      TenderPartition/tpMainData.pas
  41. 515 0
      TenderPartition/tpMainFrm.dfm
  42. 153 0
      TenderPartition/tpMainFrm.pas
  43. 94 0
      TenderPartition/tpNoPegDm.dfm
  44. 82 0
      TenderPartition/tpNoPegDm.pas
  45. 203 0
      TenderPartition/tpPartTender.pas
  46. 153 0
      TenderPartition/tpPartTenderFme.dfm
  47. 100 0
      TenderPartition/tpPartTenderFme.pas
  48. 171 0
      TenderPartition/tpPartTenderSet.pas
  49. 71 0
      TenderPartition/tpPartTenderSetFme.dfm
  50. 87 0
      TenderPartition/tpPartTenderSetFme.pas
  51. 282 0
      TenderPartition/tpPeg.pas
  52. 173 0
      TenderPartition/tpPegBlock.pas
  53. 131 0
      TenderPartition/tpPegGclGatherDm.dfm
  54. 124 0
      TenderPartition/tpPegGclGatherDm.pas
  55. 262 0
      TenderPartition/tpPegGclGatherFme.dfm
  56. 39 0
      TenderPartition/tpPegGclGatherFme.pas
  57. 79 0
      TenderPartition/tpPegPartSettingFrm.dfm
  58. 185 0
      TenderPartition/tpPegPartSettingFrm.pas
  59. 132 0
      TenderPartition/tpPeg_GclDm.dfm
  60. 131 0
      TenderPartition/tpPeg_GclDm.pas
  61. 331 0
      TenderPartition/tpPeg_GclFme.dfm
  62. 39 0
      TenderPartition/tpPeg_GclFme.pas
  63. 118 0
      TenderPartition/tpPricePartSettingFrm.dfm
  64. 146 0
      TenderPartition/tpPricePartSettingFrm.pas
  65. 49 0
      TenderPartition/tpSelectTenderDm.dfm
  66. 42 0
      TenderPartition/tpSelectTenderDm.pas
  67. 48 0
      TenderPartition/tpSelectTenderNode.pas
  68. 235 0
      TenderPartition/tpSelectTendersFrm.dfm
  69. 354 0
      TenderPartition/tpSelectTendersFrm.pas
  70. 54 0
      TenderPartition/tpTrialPegInputFrm.dfm
  71. 60 0
      TenderPartition/tpTrialPegInputFrm.pas
  72. 1 0
      TenderPartition/说明.txt
  73. 4 2
      Units/DataBaseTables.pas
  74. 3 3
      Units/DetailExcelImport.pas
  75. 52 42
      Units/ExcelImport.pas
  76. 1 1
      Units/MCacheTree.pas
  77. 7 7
      Units/PhaseProperty.pas
  78. 4 0
      Units/ProjectData.pas
  79. 37 0
      Units/UtilMethods.pas
  80. 198 0
      Units/mPegFilter.pas

+ 8 - 0
DataModules/BGLDm.dfm

@@ -60,6 +60,10 @@ object BGLData: TBGLData
     object cdsBGLExecutionRate: TFloatField
     object cdsBGLExecutionRate: TFloatField
       FieldName = 'ExecutionRate'
       FieldName = 'ExecutionRate'
     end
     end
+    object cdsBGLBGLType: TWideStringField
+      FieldName = 'BGLType'
+      Size = 10
+    end
   end
   end
   object cdsBGLView: TClientDataSet
   object cdsBGLView: TClientDataSet
     Aggregates = <>
     Aggregates = <>
@@ -109,6 +113,10 @@ object BGLData: TBGLData
     object cdsBGLViewExecutionRate: TFloatField
     object cdsBGLViewExecutionRate: TFloatField
       FieldName = 'ExecutionRate'
       FieldName = 'ExecutionRate'
     end
     end
+    object cdsBGLViewBGLType: TWideStringField
+      FieldName = 'BGLType'
+      Size = 10
+    end
   end
   end
   object dsBGL: TDataSource
   object dsBGL: TDataSource
     DataSet = cdsBGLView
     DataSet = cdsBGLView

+ 2 - 0
DataModules/BGLDm.pas

@@ -98,6 +98,8 @@ type
     cdsBGBillsViewTotalPrice: TFloatField;
     cdsBGBillsViewTotalPrice: TFloatField;
     cdsBGBillsViewUsedQuantity: TFloatField;
     cdsBGBillsViewUsedQuantity: TFloatField;
     cdsBGBillsViewLocked: TBooleanField;
     cdsBGBillsViewLocked: TBooleanField;
+    cdsBGLBGLType: TWideStringField;
+    cdsBGLViewBGLType: TWideStringField;
     procedure cdsBGBillsViewAfterInsert(DataSet: TDataSet);
     procedure cdsBGBillsViewAfterInsert(DataSet: TDataSet);
     procedure cdsBGBillsViewAfterPost(DataSet: TDataSet);
     procedure cdsBGBillsViewAfterPost(DataSet: TDataSet);
     procedure cdsBGBillsViewQuantityChange(Sender: TField);
     procedure cdsBGBillsViewQuantityChange(Sender: TField);

+ 7 - 0
DataModules/BillsCompileDm.pas

@@ -252,6 +252,13 @@ begin
     stnNode := BillsCompileTree.FindNode(AValue.Owner.ValueByName('ID').AsInteger);
     stnNode := BillsCompileTree.FindNode(AValue.Owner.ValueByName('ID').AsInteger);
     ResetChildrenLockedInfo(stnNode, AValue.AsBoolean);
     ResetChildrenLockedInfo(stnNode, AValue.AsBoolean);
   end;
   end;
+
+  if (AValue.FieldName = 'B_Code') then
+  begin
+    AValue.Owner.ValueByName('DgnQuantity1').Clear;
+    AValue.Owner.ValueByName('DgnQuantity2').Clear;
+    AValue.Owner.ValueByName('DgnPrice').Clear;
+  end;
 end;
 end;
 
 
 function TBillsCompileData.GatherChildrenOrg(ANode: TsdIDTreeNode): Double;
 function TBillsCompileData.GatherChildrenOrg(ANode: TsdIDTreeNode): Double;

+ 89 - 4
DataModules/ProjectManagerDm.dfm

@@ -4,7 +4,7 @@ object ProjectManagerData: TProjectManagerData
   Left = 713
   Left = 713
   Top = 241
   Top = 241
   Height = 223
   Height = 223
-  Width = 227
+  Width = 316
   object sdpProjectsInfo: TsdADOProvider
   object sdpProjectsInfo: TsdADOProvider
     TableName = 'ProjectsInfo'
     TableName = 'ProjectsInfo'
     Left = 40
     Left = 40
@@ -174,13 +174,13 @@ object ProjectManagerData: TProjectManagerData
   end
   end
   object sdpTenderProperty: TsdADOProvider
   object sdpTenderProperty: TsdADOProvider
     TableName = 'TenderProperty'
     TableName = 'TenderProperty'
-    Left = 136
+    Left = 232
     Top = 16
     Top = 16
   end
   end
   object sddTenderProperty: TsdDataSet
   object sddTenderProperty: TsdDataSet
     Active = False
     Active = False
     Provider = sdpTenderProperty
     Provider = sdpTenderProperty
-    Left = 136
+    Left = 232
     Top = 72
     Top = 72
   end
   end
   object sdvTenderProperty: TsdDataView
   object sdvTenderProperty: TsdDataView
@@ -188,7 +188,92 @@ object ProjectManagerData: TProjectManagerData
     DataSet = sddTenderProperty
     DataSet = sddTenderProperty
     Filtered = False
     Filtered = False
     Columns = <>
     Columns = <>
-    Left = 136
+    Left = 232
+    Top = 128
+  end
+  object sdvProjectsSpare: TsdDataView
+    Active = False
+    DataSet = sddProjectsInfo
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'ID'
+      end
+      item
+        FieldName = 'ParentID'
+      end
+      item
+        FieldName = 'NextSiblingID'
+      end
+      item
+        FieldName = 'Name'
+      end
+      item
+        FieldName = 'Type'
+      end
+      item
+        FieldName = 'DealTotalPrice'
+      end
+      item
+        FieldName = 'PhaseTotalPrice'
+      end
+      item
+        FieldName = 'EndDealTotalPrice'
+      end
+      item
+        FieldName = 'EndChangeTotalPrice'
+      end
+      item
+        FieldName = 'EndTotalPrice'
+      end
+      item
+        FieldName = 'PreTotalPrice'
+      end
+      item
+        FieldName = 'PhasePay'
+      end
+      item
+        FieldName = 'PhaseCount'
+      end
+      item
+        FieldName = 'AuditStatus'
+      end
+      item
+        FieldName = 'FileName'
+      end
+      item
+        FieldName = 'CreateDate'
+      end
+      item
+        FieldName = 'BackupFolder'
+      end
+      item
+        FieldName = 'Deal_BGLTotalPrice'
+      end
+      item
+        FieldName = 'WebID'
+      end
+      item
+        FieldName = 'WebOwnerID'
+      end
+      item
+        FieldName = 'WebAuthorID'
+      end
+      item
+        FieldName = 'WebMD5'
+      end
+      item
+        FieldName = 'WebUserID'
+      end
+      item
+        FieldName = 'WebFolderLevel'
+      end
+      item
+        FieldName = 'WebKey'
+      end>
+    OnFilterRecord = sdvProjectsInfoFilterRecord
+    OnGetText = sdvProjectsInfoGetText
+    Left = 128
     Top = 128
     Top = 128
   end
   end
 end
 end

+ 4 - 0
DataModules/ProjectManagerDm.pas

@@ -15,6 +15,7 @@ type
     sdpTenderProperty: TsdADOProvider;
     sdpTenderProperty: TsdADOProvider;
     sddTenderProperty: TsdDataSet;
     sddTenderProperty: TsdDataSet;
     sdvTenderProperty: TsdDataView;
     sdvTenderProperty: TsdDataView;
+    sdvProjectsSpare: TsdDataView;
     procedure sdvProjectsInfoGetText(var Text: String;
     procedure sdvProjectsInfoGetText(var Text: String;
       ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
       ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
       DisplayText: Boolean);
       DisplayText: Boolean);
@@ -283,8 +284,10 @@ begin
   sdpProjectsInfo.Connection := FConnection.Connection;
   sdpProjectsInfo.Connection := FConnection.Connection;
   sddProjectsInfo.Open;
   sddProjectsInfo.Open;
   sdvProjectsInfo.Open;
   sdvProjectsInfo.Open;
+  sdvProjectsSpare.Open;
   sddProjectsInfo.AddIndex('idxID', 'ID');
   sddProjectsInfo.AddIndex('idxID', 'ID');
   sdvProjectsInfo.IndexName := 'idxID';
   sdvProjectsInfo.IndexName := 'idxID';
+
   sdpTenderProperty.Connection := FConnection.Connection;
   sdpTenderProperty.Connection := FConnection.Connection;
   sddTenderProperty.Open;
   sddTenderProperty.Open;
   sdvTenderProperty.Open;
   sdvTenderProperty.Open;
@@ -398,6 +401,7 @@ begin
   // 单机版也要过滤:防止单机版程序能显示所有用户的项目。
   // 单机版也要过滤:防止单机版程序能显示所有用户的项目。
 //  if G_IsOnLine then
 //  if G_IsOnLine then
     sdvProjectsInfo.Filtered := True;
     sdvProjectsInfo.Filtered := True;
+    sdvProjectsSpare.Filtered := True;
 end;
 end;
 
 
 function TProjectManagerData.NewID: Integer;
 function TProjectManagerData.NewID: Integer;

+ 1 - 1
DataModules/ZJJLDm.pas

@@ -541,7 +541,7 @@ begin
   with TProjectData(TPhaseData(FPhaseData).ProjectData) do
   with TProjectData(TPhaseData(FPhaseData).ProjectData) do
   begin
   begin
     Rec := BillsData.sddBills.FindKey('idxID', cdsZJJLViewBillsID.AsInteger);
     Rec := BillsData.sddBills.FindKey('idxID', cdsZJJLViewBillsID.AsInteger);
-    BillsCompileData.sdvBillsCompile.LocateInControl(Rec);
+    BillsMeasureData.sdvBillsMeasure.LocateInControl(Rec);
   end;
   end;
 end;
 end;
 
 

+ 2 - 2
Dprs/Pro/Measure.dof

@@ -115,7 +115,7 @@ AutoIncBuild=1
 MajorVer=3
 MajorVer=3
 MinorVer=1
 MinorVer=1
 Release=5
 Release=5
-Build=203
+Build=204
 Debug=0
 Debug=0
 PreRelease=0
 PreRelease=0
 Special=0
 Special=0
@@ -126,7 +126,7 @@ CodePage=936
 [Version Info Keys]
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化专业版
 FileDescription=纵横结算决算计量一体化专业版
-FileVersion=3.1.5.203
+FileVersion=3.1.5.204
 InternalName=
 InternalName=
 LegalCopyright=
 LegalCopyright=
 LegalTrademarks=
 LegalTrademarks=

+ 24 - 1
Dprs/Pro/Measure.dpr

@@ -149,7 +149,30 @@ uses
   SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
   SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
   rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
   rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
   DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm},
   DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm},
-  BaseClipboard in '..\..\Units\BaseClipboard.pas';
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  tpBaseGatherData in '..\..\TenderPartition\tpBaseGatherData.pas',
+  tpGatherGcl in '..\..\TenderPartition\tpGatherGcl.pas',
+  tpGatherTree in '..\..\TenderPartition\tpGatherTree.pas',
+  tpMainData in '..\..\TenderPartition\tpMainData.pas',
+  tpMainFrm in '..\..\TenderPartition\tpMainFrm.pas' {tpMainForm},
+  tpNoPegDm in '..\..\TenderPartition\tpNoPegDm.pas' {tpNoPegData: TDataModule},
+  tpPartTender in '..\..\TenderPartition\tpPartTender.pas',
+  tpPartTenderFme in '..\..\TenderPartition\tpPartTenderFme.pas' {tpPartTenderFrame: TFrame},
+  tpPartTenderSet in '..\..\TenderPartition\tpPartTenderSet.pas',
+  tpPartTenderSetFme in '..\..\TenderPartition\tpPartTenderSetFme.pas' {tpPartTenderSetFrame: TFrame},
+  tpPeg in '..\..\TenderPartition\tpPeg.pas',
+  tpPeg_GclDm in '..\..\TenderPartition\tpPeg_GclDm.pas' {tpPeg_GclData: TDataModule},
+  tpPeg_GclFme in '..\..\TenderPartition\tpPeg_GclFme.pas' {tpPeg_GclFrame: TFrame},
+  tpPegBlock in '..\..\TenderPartition\tpPegBlock.pas',
+  tpPegGclGatherDm in '..\..\TenderPartition\tpPegGclGatherDm.pas' {tpPegGclGatherData: TDataModule},
+  tpPegGclGatherFme in '..\..\TenderPartition\tpPegGclGatherFme.pas' {tpPegGclGatherFrame: TFrame},
+  tpPegPartSettingFrm in '..\..\TenderPartition\tpPegPartSettingFrm.pas' {tpPegPartSettingForm},
+  tpPricePartSettingFrm in '..\..\TenderPartition\tpPricePartSettingFrm.pas' {tpPricePartSettingForm},
+  tpSelectTenderDm in '..\..\TenderPartition\tpSelectTenderDm.pas' {tpSelectTenderData: TDataModule},
+  tpSelectTenderNode in '..\..\TenderPartition\tpSelectTenderNode.pas',
+  tpSelectTendersFrm in '..\..\TenderPartition\tpSelectTendersFrm.pas' {SelectTendersForm},
+  tpTrialPegInputFrm in '..\..\TenderPartition\tpTrialPegInputFrm.pas' {TrialPegInputForm},
+  mPegFilter in '..\..\Units\mPegFilter.pas';
 
 
 {$R *.res}
 {$R *.res}
 
 

BIN
Dprs/Pro/Measure.res


+ 2 - 2
Dprs/Pro/Measure_Cloud.dof

@@ -115,7 +115,7 @@ AutoIncBuild=1
 MajorVer=3
 MajorVer=3
 MinorVer=1
 MinorVer=1
 Release=5
 Release=5
-Build=203
+Build=204
 Debug=0
 Debug=0
 PreRelease=0
 PreRelease=0
 Special=0
 Special=0
@@ -126,7 +126,7 @@ CodePage=936
 [Version Info Keys]
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化云版
 FileDescription=纵横结算决算计量一体化云版
-FileVersion=3.1.5.203
+FileVersion=3.1.5.204
 InternalName=
 InternalName=
 LegalCopyright=
 LegalCopyright=
 LegalTrademarks=
 LegalTrademarks=

+ 24 - 1
Dprs/Pro/Measure_Cloud.dpr

@@ -153,7 +153,30 @@ uses
   ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
   ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
   SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
   SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
   DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm},
   DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm},
-  BaseClipboard in '..\..\Units\BaseClipboard.pas';
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  mPegFilter in '..\..\Units\mPegFilter.pas',
+  tpBaseGatherData in '..\..\TenderPartition\tpBaseGatherData.pas',
+  tpGatherGcl in '..\..\TenderPartition\tpGatherGcl.pas',
+  tpGatherTree in '..\..\TenderPartition\tpGatherTree.pas',
+  tpMainData in '..\..\TenderPartition\tpMainData.pas',
+  tpMainFrm in '..\..\TenderPartition\tpMainFrm.pas' {tpMainForm},
+  tpNoPegDm in '..\..\TenderPartition\tpNoPegDm.pas' {tpNoPegData: TDataModule},
+  tpPartTender in '..\..\TenderPartition\tpPartTender.pas',
+  tpPartTenderFme in '..\..\TenderPartition\tpPartTenderFme.pas' {tpPartTenderFrame: TFrame},
+  tpPartTenderSet in '..\..\TenderPartition\tpPartTenderSet.pas',
+  tpPartTenderSetFme in '..\..\TenderPartition\tpPartTenderSetFme.pas' {tpPartTenderSetFrame: TFrame},
+  tpPeg in '..\..\TenderPartition\tpPeg.pas',
+  tpPeg_GclDm in '..\..\TenderPartition\tpPeg_GclDm.pas' {tpPeg_GclData: TDataModule},
+  tpPeg_GclFme in '..\..\TenderPartition\tpPeg_GclFme.pas' {tpPeg_GclFrame: TFrame},
+  tpPegBlock in '..\..\TenderPartition\tpPegBlock.pas',
+  tpPegGclGatherDm in '..\..\TenderPartition\tpPegGclGatherDm.pas' {tpPegGclGatherData: TDataModule},
+  tpPegGclGatherFme in '..\..\TenderPartition\tpPegGclGatherFme.pas' {tpPegGclGatherFrame: TFrame},
+  tpPegPartSettingFrm in '..\..\TenderPartition\tpPegPartSettingFrm.pas' {tpPegPartSettingForm},
+  tpPricePartSettingFrm in '..\..\TenderPartition\tpPricePartSettingFrm.pas' {tpPricePartSettingForm},
+  tpSelectTenderDm in '..\..\TenderPartition\tpSelectTenderDm.pas' {tpSelectTenderData: TDataModule},
+  tpSelectTenderNode in '..\..\TenderPartition\tpSelectTenderNode.pas',
+  tpSelectTendersFrm in '..\..\TenderPartition\tpSelectTendersFrm.pas' {SelectTendersForm},
+  tpTrialPegInputFrm in '..\..\TenderPartition\tpTrialPegInputFrm.pas' {TrialPegInputForm};
 
 
 {$R *.res}
 {$R *.res}
 
 

BIN
Dprs/Pro/Measure_Cloud.res


+ 2 - 2
Dprs/Pro/Measure_GuangDong.dof

@@ -115,7 +115,7 @@ AutoIncBuild=1
 MajorVer=3
 MajorVer=3
 MinorVer=1
 MinorVer=1
 Release=5
 Release=5
-Build=203
+Build=204
 Debug=0
 Debug=0
 PreRelease=0
 PreRelease=0
 Special=0
 Special=0
@@ -126,7 +126,7 @@ CodePage=936
 [Version Info Keys]
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化广东专业版
 FileDescription=纵横结算决算计量一体化广东专业版
-FileVersion=3.1.5.203
+FileVersion=3.1.5.204
 InternalName=
 InternalName=
 LegalCopyright=
 LegalCopyright=
 LegalTrademarks=
 LegalTrademarks=

+ 24 - 1
Dprs/Pro/Measure_GuangDong.dpr

@@ -149,7 +149,30 @@ uses
   PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
   PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
   ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
   ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
   SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
   SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
-  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm},
+  tpBaseGatherData in '..\..\TenderPartition\tpBaseGatherData.pas',
+  tpGatherGcl in '..\..\TenderPartition\tpGatherGcl.pas',
+  tpGatherTree in '..\..\TenderPartition\tpGatherTree.pas',
+  tpMainData in '..\..\TenderPartition\tpMainData.pas',
+  tpMainFrm in '..\..\TenderPartition\tpMainFrm.pas' {tpMainForm},
+  tpNoPegDm in '..\..\TenderPartition\tpNoPegDm.pas' {tpNoPegData: TDataModule},
+  tpPartTender in '..\..\TenderPartition\tpPartTender.pas',
+  tpPartTenderFme in '..\..\TenderPartition\tpPartTenderFme.pas' {tpPartTenderFrame: TFrame},
+  tpPartTenderSet in '..\..\TenderPartition\tpPartTenderSet.pas',
+  tpPartTenderSetFme in '..\..\TenderPartition\tpPartTenderSetFme.pas' {tpPartTenderSetFrame: TFrame},
+  tpPeg in '..\..\TenderPartition\tpPeg.pas',
+  tpPeg_GclDm in '..\..\TenderPartition\tpPeg_GclDm.pas' {tpPeg_GclData: TDataModule},
+  tpPeg_GclFme in '..\..\TenderPartition\tpPeg_GclFme.pas' {tpPeg_GclFrame: TFrame},
+  tpPegBlock in '..\..\TenderPartition\tpPegBlock.pas',
+  tpPegGclGatherDm in '..\..\TenderPartition\tpPegGclGatherDm.pas' {tpPegGclGatherData: TDataModule},
+  tpPegGclGatherFme in '..\..\TenderPartition\tpPegGclGatherFme.pas' {tpPegGclGatherFrame: TFrame},
+  tpPegPartSettingFrm in '..\..\TenderPartition\tpPegPartSettingFrm.pas' {tpPegPartSettingForm},
+  tpPricePartSettingFrm in '..\..\TenderPartition\tpPricePartSettingFrm.pas' {tpPricePartSettingForm},
+  tpSelectTenderDm in '..\..\TenderPartition\tpSelectTenderDm.pas' {tpSelectTenderData: TDataModule},
+  tpSelectTenderNode in '..\..\TenderPartition\tpSelectTenderNode.pas',
+  tpSelectTendersFrm in '..\..\TenderPartition\tpSelectTendersFrm.pas' {SelectTendersForm},
+  tpTrialPegInputFrm in '..\..\TenderPartition\tpTrialPegInputFrm.pas' {TrialPegInputForm},
+  mPegFilter in '..\..\Units\mPegFilter.pas';
 
 
 {$R *.res}
 {$R *.res}
 
 

BIN
Dprs/Pro/Measure_GuangDong.res


+ 2 - 2
Dprs/Pro/Measure_GuangDong_Cloud.dof

@@ -115,7 +115,7 @@ AutoIncBuild=1
 MajorVer=3
 MajorVer=3
 MinorVer=1
 MinorVer=1
 Release=5
 Release=5
-Build=203
+Build=204
 Debug=0
 Debug=0
 PreRelease=0
 PreRelease=0
 Special=0
 Special=0
@@ -126,7 +126,7 @@ CodePage=936
 [Version Info Keys]
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化广东云版
 FileDescription=纵横结算决算计量一体化广东云版
-FileVersion=3.1.5.203
+FileVersion=3.1.5.204
 InternalName=
 InternalName=
 LegalCopyright=
 LegalCopyright=
 LegalTrademarks=
 LegalTrademarks=

+ 24 - 1
Dprs/Pro/Measure_GuangDong_Cloud.dpr

@@ -153,7 +153,30 @@ uses
   PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
   PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
   ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
   ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
   SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
   SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
-  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm},
+  tpBaseGatherData in '..\..\TenderPartition\tpBaseGatherData.pas',
+  tpGatherGcl in '..\..\TenderPartition\tpGatherGcl.pas',
+  tpGatherTree in '..\..\TenderPartition\tpGatherTree.pas',
+  tpMainData in '..\..\TenderPartition\tpMainData.pas',
+  tpMainFrm in '..\..\TenderPartition\tpMainFrm.pas' {tpMainForm},
+  tpNoPegDm in '..\..\TenderPartition\tpNoPegDm.pas' {tpNoPegData: TDataModule},
+  tpPartTender in '..\..\TenderPartition\tpPartTender.pas',
+  tpPartTenderFme in '..\..\TenderPartition\tpPartTenderFme.pas' {tpPartTenderFrame: TFrame},
+  tpPartTenderSet in '..\..\TenderPartition\tpPartTenderSet.pas',
+  tpPartTenderSetFme in '..\..\TenderPartition\tpPartTenderSetFme.pas' {tpPartTenderSetFrame: TFrame},
+  tpPeg in '..\..\TenderPartition\tpPeg.pas',
+  tpPeg_GclDm in '..\..\TenderPartition\tpPeg_GclDm.pas' {tpPeg_GclData: TDataModule},
+  tpPeg_GclFme in '..\..\TenderPartition\tpPeg_GclFme.pas' {tpPeg_GclFrame: TFrame},
+  tpPegBlock in '..\..\TenderPartition\tpPegBlock.pas',
+  tpPegGclGatherDm in '..\..\TenderPartition\tpPegGclGatherDm.pas' {tpPegGclGatherData: TDataModule},
+  tpPegGclGatherFme in '..\..\TenderPartition\tpPegGclGatherFme.pas' {tpPegGclGatherFrame: TFrame},
+  tpPegPartSettingFrm in '..\..\TenderPartition\tpPegPartSettingFrm.pas' {tpPegPartSettingForm},
+  tpPricePartSettingFrm in '..\..\TenderPartition\tpPricePartSettingFrm.pas' {tpPricePartSettingForm},
+  tpSelectTenderDm in '..\..\TenderPartition\tpSelectTenderDm.pas' {tpSelectTenderData: TDataModule},
+  tpSelectTenderNode in '..\..\TenderPartition\tpSelectTenderNode.pas',
+  tpSelectTendersFrm in '..\..\TenderPartition\tpSelectTendersFrm.pas' {SelectTendersForm},
+  tpTrialPegInputFrm in '..\..\TenderPartition\tpTrialPegInputFrm.pas' {TrialPegInputForm},
+  mPegFilter in '..\..\Units\mPegFilter.pas';
 
 
 {$R *.res}
 {$R *.res}
 
 

BIN
Dprs/Pro/Measure_GuangDong_Cloud.res


+ 24 - 1
Dprs/Pro/Measure_GuangDong_TZ.dpr

@@ -149,7 +149,30 @@ uses
   PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
   PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
   ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
   ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
   SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
   SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
-  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm},
+  tpBaseGatherData in '..\..\TenderPartition\tpBaseGatherData.pas',
+  tpGatherGcl in '..\..\TenderPartition\tpGatherGcl.pas',
+  tpGatherTree in '..\..\TenderPartition\tpGatherTree.pas',
+  tpMainData in '..\..\TenderPartition\tpMainData.pas',
+  tpMainFrm in '..\..\TenderPartition\tpMainFrm.pas' {tpMainForm},
+  tpNoPegDm in '..\..\TenderPartition\tpNoPegDm.pas' {tpNoPegData: TDataModule},
+  tpPartTender in '..\..\TenderPartition\tpPartTender.pas',
+  tpPartTenderFme in '..\..\TenderPartition\tpPartTenderFme.pas' {tpPartTenderFrame: TFrame},
+  tpPartTenderSet in '..\..\TenderPartition\tpPartTenderSet.pas',
+  tpPartTenderSetFme in '..\..\TenderPartition\tpPartTenderSetFme.pas' {tpPartTenderSetFrame: TFrame},
+  tpPeg in '..\..\TenderPartition\tpPeg.pas',
+  tpPeg_GclDm in '..\..\TenderPartition\tpPeg_GclDm.pas' {tpPeg_GclData: TDataModule},
+  tpPeg_GclFme in '..\..\TenderPartition\tpPeg_GclFme.pas' {tpPeg_GclFrame: TFrame},
+  tpPegBlock in '..\..\TenderPartition\tpPegBlock.pas',
+  tpPegGclGatherDm in '..\..\TenderPartition\tpPegGclGatherDm.pas' {tpPegGclGatherData: TDataModule},
+  tpPegGclGatherFme in '..\..\TenderPartition\tpPegGclGatherFme.pas' {tpPegGclGatherFrame: TFrame},
+  tpPegPartSettingFrm in '..\..\TenderPartition\tpPegPartSettingFrm.pas' {tpPegPartSettingForm},
+  tpPricePartSettingFrm in '..\..\TenderPartition\tpPricePartSettingFrm.pas' {tpPricePartSettingForm},
+  tpSelectTenderDm in '..\..\TenderPartition\tpSelectTenderDm.pas' {tpSelectTenderData: TDataModule},
+  tpSelectTenderNode in '..\..\TenderPartition\tpSelectTenderNode.pas',
+  tpSelectTendersFrm in '..\..\TenderPartition\tpSelectTendersFrm.pas' {SelectTendersForm},
+  tpTrialPegInputFrm in '..\..\TenderPartition\tpTrialPegInputFrm.pas' {TrialPegInputForm},
+  mPegFilter in '..\..\Units\mPegFilter.pas';
 
 
 {$R *.res}
 {$R *.res}
 
 

+ 2 - 2
Dprs/Pro/Measure_TZ.dof

@@ -115,7 +115,7 @@ AutoIncBuild=1
 MajorVer=3
 MajorVer=3
 MinorVer=1
 MinorVer=1
 Release=5
 Release=5
-Build=203
+Build=204
 Debug=0
 Debug=0
 PreRelease=0
 PreRelease=0
 Special=0
 Special=0
@@ -126,7 +126,7 @@ CodePage=936
 [Version Info Keys]
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横0号台账专业版
 FileDescription=纵横0号台账专业版
-FileVersion=3.1.5.203
+FileVersion=3.1.5.204
 InternalName=
 InternalName=
 LegalCopyright=
 LegalCopyright=
 LegalTrademarks=
 LegalTrademarks=

+ 24 - 1
Dprs/Pro/Measure_TZ.dpr

@@ -149,7 +149,30 @@ uses
   PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
   PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
   ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
   ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
   SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
   SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
-  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm},
+  tpBaseGatherData in '..\..\TenderPartition\tpBaseGatherData.pas',
+  tpGatherGcl in '..\..\TenderPartition\tpGatherGcl.pas',
+  tpGatherTree in '..\..\TenderPartition\tpGatherTree.pas',
+  tpMainData in '..\..\TenderPartition\tpMainData.pas',
+  tpMainFrm in '..\..\TenderPartition\tpMainFrm.pas' {tpMainForm},
+  tpNoPegDm in '..\..\TenderPartition\tpNoPegDm.pas' {tpNoPegData: TDataModule},
+  tpPartTender in '..\..\TenderPartition\tpPartTender.pas',
+  tpPartTenderFme in '..\..\TenderPartition\tpPartTenderFme.pas' {tpPartTenderFrame: TFrame},
+  tpPartTenderSet in '..\..\TenderPartition\tpPartTenderSet.pas',
+  tpPartTenderSetFme in '..\..\TenderPartition\tpPartTenderSetFme.pas' {tpPartTenderSetFrame: TFrame},
+  tpPeg in '..\..\TenderPartition\tpPeg.pas',
+  tpPeg_GclDm in '..\..\TenderPartition\tpPeg_GclDm.pas' {tpPeg_GclData: TDataModule},
+  tpPeg_GclFme in '..\..\TenderPartition\tpPeg_GclFme.pas' {tpPeg_GclFrame: TFrame},
+  tpPegBlock in '..\..\TenderPartition\tpPegBlock.pas',
+  tpPegGclGatherDm in '..\..\TenderPartition\tpPegGclGatherDm.pas' {tpPegGclGatherData: TDataModule},
+  tpPegGclGatherFme in '..\..\TenderPartition\tpPegGclGatherFme.pas' {tpPegGclGatherFrame: TFrame},
+  tpPegPartSettingFrm in '..\..\TenderPartition\tpPegPartSettingFrm.pas' {tpPegPartSettingForm},
+  tpPricePartSettingFrm in '..\..\TenderPartition\tpPricePartSettingFrm.pas' {tpPricePartSettingForm},
+  tpSelectTenderDm in '..\..\TenderPartition\tpSelectTenderDm.pas' {tpSelectTenderData: TDataModule},
+  tpSelectTenderNode in '..\..\TenderPartition\tpSelectTenderNode.pas',
+  tpSelectTendersFrm in '..\..\TenderPartition\tpSelectTendersFrm.pas' {SelectTendersForm},
+  tpTrialPegInputFrm in '..\..\TenderPartition\tpTrialPegInputFrm.pas' {TrialPegInputForm},
+  mPegFilter in '..\..\Units\mPegFilter.pas';
 
 
 {$R *.res}
 {$R *.res}
 
 

BIN
Dprs/Pro/Measure_TZ.res


+ 1 - 0
Forms/BatchInsertBillsFrm.dfm

@@ -149,6 +149,7 @@ object BatchInsertBillsForm: TBatchInsertBillsForm
           Width = 475
           Width = 475
           Height = 105
           Height = 105
           OptionsEx = []
           OptionsEx = []
+          ColCount = 6
           RowCount = 7
           RowCount = 7
           ShowGridLine = False
           ShowGridLine = False
           DefaultColWidth = 50
           DefaultColWidth = 50

+ 8 - 2
Forms/BatchInsertBillsFrm.pas

@@ -249,6 +249,7 @@ begin
     ValueByName('Units').AsString := zgBills.Cells[3, ARow].Text;
     ValueByName('Units').AsString := zgBills.Cells[3, ARow].Text;
     ValueByName('Price').AsFloat := StrToFloatDef(zgBills.Cells[4, ARow].Text, 0);
     ValueByName('Price').AsFloat := StrToFloatDef(zgBills.Cells[4, ARow].Text, 0);
     ValueByName('OrgQuantity').AsFloat := StrToFloatDef(zgPosition.Cells[ARow + 1, AQtyRow].Text, 0);
     ValueByName('OrgQuantity').AsFloat := StrToFloatDef(zgPosition.Cells[ARow + 1, AQtyRow].Text, 0);
+    ValueByName('DrawingCode').AsString := zgBills.Cells[5, ARow].Text;
   end;
   end;
 end;
 end;
 
 
@@ -264,6 +265,8 @@ begin
   zgBills.ColWidths[3] := 60;
   zgBills.ColWidths[3] := 60;
   zgBills.Cells[4, 0].Text := 'µ¥¼Û';
   zgBills.Cells[4, 0].Text := 'µ¥¼Û';
   zgBills.ColWidths[4] := 60;
   zgBills.ColWidths[4] := 60;
+  zgBills.Cells[5, 0].Text := 'ͼ(²á)ºÅ';
+  zgBills.ColWidths[5] := 60;
   for iRow := 1 to zgBills.RowCount - 1 do
   for iRow := 1 to zgBills.RowCount - 1 do
     zgBills.Cells[0, iRow].Text := 'Çåµ¥' + IntToStr(iRow);
     zgBills.Cells[0, iRow].Text := 'Çåµ¥' + IntToStr(iRow);
 end;
 end;
@@ -337,10 +340,11 @@ begin
       zgBills.Cells[2, Row].Text := Rec.ValueByName('Name').AsString;
       zgBills.Cells[2, Row].Text := Rec.ValueByName('Name').AsString;
       zgBills.Cells[2, Row].Align := gaCenterLeft;
       zgBills.Cells[2, Row].Align := gaCenterLeft;
       zgBills.Cells[3, Row].Text := Rec.ValueByName('Units').AsString;
       zgBills.Cells[3, Row].Text := Rec.ValueByName('Units').AsString;
-      zgBills.Cells[3, Row].Align := gaCenterLeft;
+      zgBills.Cells[3, Row].Align := gaCenterCenter;
       zgBills.Cells[3, Row].Font.Name := 'smartSimSun';
       zgBills.Cells[3, Row].Font.Name := 'smartSimSun';
       zgBills.Cells[4, Row].Text := Rec.ValueByName('Price').AsString;
       zgBills.Cells[4, Row].Text := Rec.ValueByName('Price').AsString;
       zgBills.Cells[4, Row].Align := gaCenterRight;
       zgBills.Cells[4, Row].Align := gaCenterRight;
+      zgBills.Cells[5, Row].Align := gaCenterLeft;
     end;
     end;
   end
   end
   else if (Col = 4) and (Row > 0) then
   else if (Col = 4) and (Row > 0) then
@@ -348,7 +352,9 @@ begin
     zgBills.Cells[Col, Row].Value := PriceRoundTo(
     zgBills.Cells[Col, Row].Value := PriceRoundTo(
         StrToFloatDef(zgBills.Cells[Col, Row].Text, 0));
         StrToFloatDef(zgBills.Cells[Col, Row].Text, 0));
     zgBills.Cells[Col, Row].Align := gaCenterRight;
     zgBills.Cells[Col, Row].Align := gaCenterRight;
-  end;
+  end
+  else if (Col = 5) and (Row > 0) then
+    zgBills.Cells[Col, Row].Align := gaCenterLeft;
 end;
 end;
 
 
 procedure TBatchInsertBillsForm.zgDealBillsMouseDown(Sender: TObject;
 procedure TBatchInsertBillsForm.zgDealBillsMouseDown(Sender: TObject;

+ 41 - 2
Forms/MainFrm.dfm

@@ -246,6 +246,10 @@ object MainForm: TMainForm
             Visible = True
             Visible = True
           end
           end
           item
           item
+            Item = dxsiData
+            Visible = True
+          end
+          item
             Item = dxsiHelp
             Item = dxsiHelp
             Visible = True
             Visible = True
           end
           end
@@ -960,8 +964,8 @@ object MainForm: TMainForm
       Caption = #23548#20837#21488#36134'('#24179#38754#32467#26500')'#33267#39033#30446#33410
       Caption = #23548#20837#21488#36134'('#24179#38754#32467#26500')'#33267#39033#30446#33410
       Category = 0
       Category = 0
       Hint = #23548#20837#21488#36134'('#24179#38754#32467#26500')'#33267#39033#30446#33410
       Hint = #23548#20837#21488#36134'('#24179#38754#32467#26500')'#33267#39033#30446#33410
-	  Visible = ivAlways
-    end	  
+      Visible = ivAlways
+    end
     object dxbtnSetDealPayPlan: TdxBarButton
     object dxbtnSetDealPayPlan: TdxBarButton
       Caption = #35774#32622#35745#25552#26399#38480
       Caption = #35774#32622#35745#25552#26399#38480
       Category = 0
       Category = 0
@@ -974,6 +978,29 @@ object MainForm: TMainForm
       Hint = #26032#22686#35843#24046#24037#26009
       Hint = #26032#22686#35843#24046#24037#26009
       Visible = ivAlways
       Visible = ivAlways
     end
     end
+    object dxbtnAllPeg: TdxBarButton
+      Caption = #21482#26174#31034#26729#21495'('#39033#30446#33410')'
+      Category = 0
+      Hint = #21482#26174#31034#26729#21495'('#39033#30446#33410')'
+      Visible = ivAlways
+    end
+    object dxsiData: TdxBarSubItem
+      Caption = #25968#25454'(D)'
+      Category = 0
+      Visible = ivAlways
+      ItemLinks = <
+        item
+          Item = dxbtnTenderPartition
+          Visible = True
+        end>
+    end
+    object dxbtnTenderPartition: TdxBarButton
+      Caption = #26631#27573#21010#20998
+      Category = 0
+      Hint = #26631#27573#21010#20998
+      Visible = ivAlways
+      OnClick = dxbtnTenderPartitionClick
+    end
     object dxbtnCopyDetailGls: TdxBarButton
     object dxbtnCopyDetailGls: TdxBarButton
       Caption = #22797#21046#35843#24046#24037#26009
       Caption = #22797#21046#35843#24046#24037#26009
       Category = 0
       Category = 0
@@ -994,6 +1021,18 @@ object MainForm: TMainForm
       Visible = ivAlways
       Visible = ivAlways
       ImageIndex = 15
       ImageIndex = 15
     end
     end
+    object dxbtnFxZJJL: TdxBarButton
+      Caption = '0'#21495#21488#36134#26684#24335
+      Category = 0
+      Hint = '0'#21495#21488#36134#26684#24335
+      Visible = ivAlways
+    end
+    object dxbtnGclZJJL: TdxBarButton
+      Caption = #24635#37327#25511#21046#26684#24335
+      Category = 0
+      Hint = #24635#37327#25511#21046#26684#24335
+      Visible = ivAlways
+    end
   end
   end
   object Images: TImageList
   object Images: TImageList
     DrawingStyle = dsTransparent
     DrawingStyle = dsTransparent

+ 12 - 1
Forms/MainFrm.pas

@@ -143,11 +143,16 @@ type
     dxsiExpandTo: TdxBarSubItem;
     dxsiExpandTo: TdxBarSubItem;
     dxbtnLocateBookmark: TdxBarButton;
     dxbtnLocateBookmark: TdxBarButton;
     dxbtnImportPlaneFxBillsToXmj: TdxBarButton;
     dxbtnImportPlaneFxBillsToXmj: TdxBarButton;
+    dxbtnAllPeg: TdxBarButton;
+    dxsiData: TdxBarSubItem;
+    dxbtnTenderPartition: TdxBarButton;
     dxbtnSetDealPayPlan: TdxBarButton;
     dxbtnSetDealPayPlan: TdxBarButton;
     dxbtnAddDetailGLs: TdxBarButton;
     dxbtnAddDetailGLs: TdxBarButton;
     dxbtnCopyDetailGls: TdxBarButton;
     dxbtnCopyDetailGls: TdxBarButton;
     dxbtnApplyToSameBills: TdxBarButton;
     dxbtnApplyToSameBills: TdxBarButton;
     dxbtnCalculatePriceMargin: TdxBarButton;
     dxbtnCalculatePriceMargin: TdxBarButton;
+    dxbtnFxZJJL: TdxBarButton;
+    dxbtnGclZJJL: TdxBarButton;
     procedure FormCreate(Sender: TObject);
     procedure FormCreate(Sender: TObject);
     procedure FormDestroy(Sender: TObject);
     procedure FormDestroy(Sender: TObject);
     procedure jtsProjectsChange(Sender: TObject; NewTab: Integer;
     procedure jtsProjectsChange(Sender: TObject; NewTab: Integer;
@@ -190,6 +195,7 @@ type
     procedure dxseBatchInsertKeyDown(Sender: TObject; var Key: Word;
     procedure dxseBatchInsertKeyDown(Sender: TObject; var Key: Word;
       Shift: TShiftState);
       Shift: TShiftState);
     procedure actnReplyUpdate(Sender: TObject);
     procedure actnReplyUpdate(Sender: TObject);
+    procedure dxbtnTenderPartitionClick(Sender: TObject);
   private
   private
     FProjectManagerFrame: TProjectManagerFrame;
     FProjectManagerFrame: TProjectManagerFrame;
     FProjectFrames: TList;
     FProjectFrames: TList;
@@ -224,7 +230,7 @@ implementation
 uses
 uses
   ProjectProperty, ConstUnit, PHPWebDm, Math, ShellAPI,
   ProjectProperty, ConstUnit, PHPWebDm, Math, ShellAPI,
   FindUserFrm, ImportExcelHintFrm, ConfigDoc, ExportExcel,
   FindUserFrm, ImportExcelHintFrm, ConfigDoc, ExportExcel,
-  ProjectCommands, BillsCompileDm;
+  ProjectCommands, BillsCompileDm, tpMainFrm;
 
 
 {$R *.dfm}
 {$R *.dfm}
 {$R MeasureIcons.RES}
 {$R MeasureIcons.RES}
@@ -808,4 +814,9 @@ begin
     TAction(Sender).Enabled := (ProjProperties.PhaseCount > 0);
     TAction(Sender).Enabled := (ProjProperties.PhaseCount > 0);
 end;
 end;
 
 
+procedure TMainForm.dxbtnTenderPartitionClick(Sender: TObject);
+begin
+  PartTendersModel;
+end;
+
 end.
 end.

+ 21 - 2
Forms/ProgressHintFrm.pas

@@ -4,7 +4,7 @@ interface
 
 
 uses
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
-  Dialogs, Gauges, StdCtrls, ExtCtrls;
+  Dialogs, Gauges, StdCtrls, ExtCtrls, Math;
 
 
 type
 type
   TProgressHintForm = class(TForm)
   TProgressHintForm = class(TForm)
@@ -31,7 +31,8 @@ var
 procedure ShowProgressHint(const AHint: string; AMaxValue: Integer = 0;
 procedure ShowProgressHint(const AHint: string; AMaxValue: Integer = 0;
   const ASubHint: string = ''; ASubMaxValue: Integer = 0);
   const ASubHint: string = ''; ASubMaxValue: Integer = 0);
 procedure UpdateProgressMaxValue(AMaxValue: Integer; AIsSub: Boolean = False);
 procedure UpdateProgressMaxValue(AMaxValue: Integer; AIsSub: Boolean = False);
-procedure UpdateProgressPosition(APos: Integer; ASubPos: Integer = 0);
+procedure UpdateProgressPosition(APos: Integer; ASubPos: Integer = 0); overload;
+procedure UpdateProgressPosition(AIsSub: Boolean = False); overload;
 procedure UpdateProgressHint(const AHint: string; AIsSub: Boolean = False); overload;
 procedure UpdateProgressHint(const AHint: string; AIsSub: Boolean = False); overload;
 procedure UpdateProgressHint(APos: Integer; AIsSub: Boolean = False); overload;
 procedure UpdateProgressHint(APos: Integer; AIsSub: Boolean = False); overload;
 procedure CloseProgressHint;
 procedure CloseProgressHint;
@@ -72,6 +73,24 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure UpdateProgressPosition(AIsSub: Boolean = False);
+begin
+  with ProgressHintForm do
+  begin
+    if AIsSub then
+    begin
+      gSubProgress.Progress := Min(gSubProgress.Progress + 1, gSubProgress.MaxValue);
+      lblSubPrecent.Caption := Format('%3d', [gSubProgress.PercentDone])+'%'
+    end
+    else
+    begin
+      gProgress.Progress := Min(gProgress.Progress + 1, gProgress.MaxValue);
+      lblPrecent.Caption := Format('%3d', [gProgress.PercentDone])+'%';
+    end;
+    Update;
+  end;
+end;
+
 procedure UpdateProgressHint(const AHint: string; AIsSub: Boolean = False);
 procedure UpdateProgressHint(const AHint: string; AIsSub: Boolean = False);
 begin
 begin
   if AIsSub then
   if AIsSub then

+ 41 - 1
Frames/BGLFme.dfm

@@ -117,7 +117,7 @@ object BGLFrame: TBGLFrame
         Height = 271
         Height = 271
         Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
         Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
         OptionsEx = []
         OptionsEx = []
-        ColCount = 7
+        ColCount = 8
         RowCount = 2
         RowCount = 2
         ShowGridLine = False
         ShowGridLine = False
         DefaultColWidth = 73
         DefaultColWidth = 73
@@ -129,6 +129,9 @@ object BGLFrame: TBGLFrame
         FrozenRow = 0
         FrozenRow = 0
         OnCopy = zgBGLCopy
         OnCopy = zgBGLCopy
         OnPaste = zgBGLPaste
         OnPaste = zgBGLPaste
+        OnGetCellEditor = zgBGLGetCellEditor
+        OnEditorLoadCell = zgBGLEditorLoadCell
+        OnEditorSaveCell = zgBGLEditorSaveCell
         OnMouseDown = zgBGLMouseDown
         OnMouseDown = zgBGLMouseDown
         Align = alClient
         Align = alClient
       end
       end
@@ -184,6 +187,25 @@ object BGLFrame: TBGLFrame
       end
       end
     end
     end
   end
   end
+  object cbbBGLType: TZjComboBox
+    Left = 198
+    Top = 160
+    Width = 145
+    Height = 20
+    Font.Charset = ANSI_CHARSET
+    Font.Color = clWindowText
+    Font.Height = -12
+    Font.Name = 'smartSimSun'
+    Font.Style = []
+    ItemHeight = 12
+    ParentFont = False
+    TabOrder = 3
+    Visible = False
+    Items.Strings = (
+      #19968#33324
+      #36739#22823
+      #37325#22823)
+  end
   object zaBGL: TZjGridDBA
   object zaBGL: TZjGridDBA
     Columns = <
     Columns = <
       item
       item
@@ -277,6 +299,24 @@ object BGLFrame: TBGLFrame
         ReadOnly = False
         ReadOnly = False
       end
       end
       item
       item
+        Title.Caption = #21464#26356#24615#36136
+        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 = 'BGLType'
+        Width = 60
+        ReadOnly = False
+      end
+      item
         Title.Caption = #24050#25191#34892'(%)'
         Title.Caption = #24050#25191#34892'(%)'
         Title.CaptionAcrossCols = '1'
         Title.CaptionAcrossCols = '1'
         Title.Font.Charset = GB2312_CHARSET
         Title.Font.Charset = GB2312_CHARSET

+ 46 - 2
Frames/BGLFme.pas

@@ -6,7 +6,7 @@ uses
   BGLDm,
   BGLDm,
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, ZjGridDBA, StdCtrls, DBCtrls, ZJGrid, ExtCtrls, ComCtrls,
   Dialogs, ZjGridDBA, StdCtrls, DBCtrls, ZJGrid, ExtCtrls, ComCtrls,
-  ToolWin, JimLabels, ActnList, DB, dxBar;
+  ToolWin, JimLabels, ActnList, DB, dxBar, ZJEdits;
 
 
 type
 type
   TBGLFrame = class(TFrame)
   TBGLFrame = class(TFrame)
@@ -33,6 +33,7 @@ type
     pnlBGL: TPanel;
     pnlBGL: TPanel;
     sprBGL: TSplitter;
     sprBGL: TSplitter;
     actnCopyBGLBlock: TAction;
     actnCopyBGLBlock: TAction;
+    cbbBGLType: TZjComboBox;
     procedure actnNewExecute(Sender: TObject);
     procedure actnNewExecute(Sender: TObject);
     procedure dbmPos_ReasonExit(Sender: TObject);
     procedure dbmPos_ReasonExit(Sender: TObject);
     procedure zgBGLMouseDown(Sender: TObject; Button: TMouseButton;
     procedure zgBGLMouseDown(Sender: TObject; Button: TMouseButton;
@@ -49,6 +50,12 @@ type
     procedure zgBGLPaste(Sender: TObject; const ABounds: TRect;
     procedure zgBGLPaste(Sender: TObject; const ABounds: TRect;
       var Allow: Boolean);
       var Allow: Boolean);
     procedure actnCopyBGLBlockUpdate(Sender: TObject);
     procedure actnCopyBGLBlockUpdate(Sender: TObject);
+    procedure zgBGLGetCellEditor(Sender: TObject; ACoord: TPoint;
+      var AControl: TWinControl);
+    procedure zgBGLEditorSaveCell(Sender: TObject; ACoord: TPoint;
+      AControl: TWinControl);
+    procedure zgBGLEditorLoadCell(Sender: TObject; ACoord: TPoint;
+      AControl: TWinControl);
   private
   private
     FBGLData: TBGLData;
     FBGLData: TBGLData;
 
 
@@ -62,7 +69,7 @@ implementation
 
 
 uses
 uses
   UtilMethods, MergeTextFrm, ProjectData, MainFrm, mEncryptEditions,
   UtilMethods, MergeTextFrm, ProjectData, MainFrm, mEncryptEditions,
-  BGLClipboard, ConstUnit;
+  BGLClipboard, ConstUnit, ZjCells;
 
 
 {$R *.dfm}
 {$R *.dfm}
 
 
@@ -72,7 +79,13 @@ constructor TBGLFrame.Create(AParent: TFrame; ABGLData: TBGLData);
 begin
 begin
   inherited Create(AParent);
   inherited Create(AParent);
   FBGLData := ABGLData;
   FBGLData := ABGLData;
+  zgBGL.CellClass.Cols[zaBGL.ColumnCol('BGLType')] := TZjComboCell;
   zaBGL.DataSet := FBGLData.cdsBGLView;
   zaBGL.DataSet := FBGLData.cdsBGLView;
+
+  zgBGL.OnGetCellEditor := zgBGLGetCellEditor;
+  zgBGL.OnEditorLoadCell := zgBGLEditorLoadCell;
+  zgBGL.OnEditorSaveCell := zgBGLEditorSaveCell;
+
   dbmPos_Reason.DataSource := FBGLData.dsBGL;
   dbmPos_Reason.DataSource := FBGLData.dsBGL;
   dbmDirection.DataSource := FBGLData.dsBGL;
   dbmDirection.DataSource := FBGLData.dsBGL;
   zaBGBills.DataSet := FBGLData.cdsBGBillsView;
   zaBGBills.DataSet := FBGLData.cdsBGBillsView;
@@ -193,4 +206,35 @@ begin
     TAction(Sender).Visible := False;
     TAction(Sender).Visible := False;
 end;
 end;
 
 
+procedure TBGLFrame.zgBGLGetCellEditor(Sender: TObject; ACoord: TPoint;
+  var AControl: TWinControl);
+begin
+  if ACoord.X = zaBGL.ColumnCol('BGLType') then
+    AControl := cbbBGLType;
+end;
+
+procedure TBGLFrame.zgBGLEditorSaveCell(Sender: TObject; ACoord: TPoint;
+  AControl: TWinControl);
+begin
+  if AControl = cbbBGLType then
+  begin
+    zaBGL.DataSet.Edit;
+    if cbbBGLType.ItemIndex = -1 then
+      zaBGL.DataSet.FieldByName('BGLType').Clear
+    else
+      zaBGL.DataSet.FieldByName('BGLType').AsString := cbbBGLType.Text;
+    zaBGL.DataSet.Post;
+  end;
+end;
+
+procedure TBGLFrame.zgBGLEditorLoadCell(Sender: TObject; ACoord: TPoint;
+  AControl: TWinControl);
+begin
+  if AControl = cbbBGLType then
+    if zaBGL.DataSet.FieldByName('BGLType').AsString = '' then
+      cbbBGLType.ItemIndex := -1
+    else
+      cbbBGLType.Text := zaBGL.DataSet.FieldByName('BGLType').AsString;
+end;
+
 end.
 end.

+ 12 - 1
Frames/BillsCompileFme.pas

@@ -95,6 +95,7 @@ type
 
 
     procedure ExpandNodeTo(ALevel: Integer);
     procedure ExpandNodeTo(ALevel: Integer);
     procedure ExpandXmjNode;
     procedure ExpandXmjNode;
+    procedure ExpandPegXmjNode;
 
 
     procedure RefreshPhase_Stage;
     procedure RefreshPhase_Stage;
 
 
@@ -242,7 +243,7 @@ var
   stnNode: TsdIDTreeNode;
   stnNode: TsdIDTreeNode;
   iCreatePhaseID: Integer;
   iCreatePhaseID: Integer;
 begin
 begin
-  if ACoord.Y > stdBillsCompile.IDTree.Count + 1 then Exit;
+  if ACoord.Y > stdBillsCompile.IDTree.Count + 2 then Exit;
   stnNode := stdBillsCompile.IDTree.Items[ACoord.Y - 3];
   stnNode := stdBillsCompile.IDTree.Items[ACoord.Y - 3];
   if not Assigned(stnNode) then Exit;
   if not Assigned(stnNode) then Exit;
   iCreatePhaseID := stnNode.Rec.ValueByName('CreatePhaseID').AsInteger;
   iCreatePhaseID := stnNode.Rec.ValueByName('CreatePhaseID').AsInteger;
@@ -599,4 +600,14 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TBillsCompileFrame.ExpandPegXmjNode;
+begin
+  BeginExpandNode;
+  try
+    FBillsCompileData.ExpandPegXmjNode;
+  finally
+    EndExpandNode;
+  end;
+end;
+
 end.
 end.

+ 9 - 0
Frames/ProjectFme.dfm

@@ -5235,6 +5235,10 @@ object ProjectFrame: TProjectFrame
       item
       item
         Item = MainForm.dxbtnAllXmj
         Item = MainForm.dxbtnAllXmj
         Visible = True
         Visible = True
+      end
+      item
+        Item = MainForm.dxbtnAllPeg
+        Visible = True
       end>
       end>
     UseOwnFont = False
     UseOwnFont = False
     OnPopup = dxpmExpandBillsPopup
     OnPopup = dxpmExpandBillsPopup
@@ -5291,5 +5295,10 @@ object ProjectFrame: TProjectFrame
       Caption = #21482#26174#31034#26412#26399
       Caption = #21482#26174#31034#26412#26399
       OnExecute = actnCurPhaseExecute
       OnExecute = actnCurPhaseExecute
     end
     end
+    object actnAllPeg: TAction
+      Category = 'ExpandBills'
+      Caption = #21482#26174#31034#26729#21495'('#39033#30446#33410')'
+      OnExecute = actnAllPegExecute
+    end
   end
   end
 end
 end

+ 18 - 0
Frames/ProjectFme.pas

@@ -78,6 +78,7 @@ type
     tobtnUpFile: TToolButton;
     tobtnUpFile: TToolButton;
     jpsAssistantDealBills: TJimPage;
     jpsAssistantDealBills: TJimPage;
     tobtnDealBills: TToolButton;
     tobtnDealBills: TToolButton;
+    actnAllPeg: TAction;
     jpsMainPriceMargin: TJimPage;
     jpsMainPriceMargin: TJimPage;
     xbiPriceMargin: TdxStoredSideItem;
     xbiPriceMargin: TdxStoredSideItem;
     procedure tobtnStandardBillsClick(Sender: TObject);
     procedure tobtnStandardBillsClick(Sender: TObject);
@@ -97,6 +98,7 @@ type
     procedure actnCurPhaseExecute(Sender: TObject);
     procedure actnCurPhaseExecute(Sender: TObject);
     procedure tobtnUpFileClick(Sender: TObject);
     procedure tobtnUpFileClick(Sender: TObject);
     procedure jpsAssistantActivePageChanged(Sender: TObject);
     procedure jpsAssistantActivePageChanged(Sender: TObject);
+    procedure actnAllPegExecute(Sender: TObject);
   private
   private
     FProjectData: TProjectData;
     FProjectData: TProjectData;
 
 
@@ -624,6 +626,7 @@ end;
 
 
 procedure TProjectFrame.dxpmExpandBillsPopup(Sender: TObject);
 procedure TProjectFrame.dxpmExpandBillsPopup(Sender: TObject);
 begin
 begin
+  dxpmExpandBills.ItemLinks.Items[8].Visible := G_IsTest;
   dxpmExpandBills.ItemLinks.Items[7].Visible := jpsMain.ActivePageIndex in [0, 1, 3];
   dxpmExpandBills.ItemLinks.Items[7].Visible := jpsMain.ActivePageIndex in [0, 1, 3];
   dxpmExpandBills.ItemLinks.Items[6].Visible := jpsMain.ActivePageIndex in [1, 3];
   dxpmExpandBills.ItemLinks.Items[6].Visible := jpsMain.ActivePageIndex in [1, 3];
   SetDxBtnAction(actnFirstLevel, MainForm.dxbtnFirstLevel);
   SetDxBtnAction(actnFirstLevel, MainForm.dxbtnFirstLevel);
@@ -634,6 +637,7 @@ begin
   SetDxBtnAction(actnAllLevel, MainForm.dxbtnAllLevel);
   SetDxBtnAction(actnAllLevel, MainForm.dxbtnAllLevel);
   SetDxBtnAction(actnCurPhase, MainForm.dxbtnCurPhase);
   SetDxBtnAction(actnCurPhase, MainForm.dxbtnCurPhase);
   SetDxBtnAction(actnAllXmj, MainForm.dxbtnAllXmj);
   SetDxBtnAction(actnAllXmj, MainForm.dxbtnAllXmj);
+  SetDxBtnAction(actnAllPeg, MainForm.dxbtnAllPeg);
 end;
 end;
 
 
 procedure TProjectFrame.actnFirstLevelExecute(Sender: TObject);
 procedure TProjectFrame.actnFirstLevelExecute(Sender: TObject);
@@ -1414,6 +1418,20 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TProjectFrame.actnAllPegExecute(Sender: TObject);
+begin
+  Screen.Cursor := crHourGlass;
+  UpdateSysProgress(0, '正在显示至桩号(项目节)');
+  try
+    case jpsMain.ActivePageIndex of
+      0: FBillsCompileFrame.ExpandPegXmjNode;
+    end;
+  finally
+    UpdateSysProgress(0, '就绪');
+    Screen.Cursor := crDefault;
+  end;
+end;
+
 procedure TProjectFrame.CreatePriceMarginFrame;
 procedure TProjectFrame.CreatePriceMarginFrame;
 begin
 begin
   FPriceMarginFrame := TPriceMarginFrame.Create(FProjectData);
   FPriceMarginFrame := TPriceMarginFrame.Create(FProjectData);

+ 1 - 0
Frames/ProjectManagerFme.dfm

@@ -88,6 +88,7 @@ object ProjectManagerFrame: TProjectManagerFrame
     FrozenRow = 0
     FrozenRow = 0
     OnCurrentChanged = zgProjectsCurrentChanged
     OnCurrentChanged = zgProjectsCurrentChanged
     OnDrawCellText = zgProjectsDrawCellText
     OnDrawCellText = zgProjectsDrawCellText
+    OnShowHint = zgProjectsShowHint
     OnMouseDown = zgProjectsMouseDown
     OnMouseDown = zgProjectsMouseDown
     Align = alClient
     Align = alClient
   end
   end

+ 47 - 0
Frames/ProjectManagerFme.pas

@@ -84,6 +84,8 @@ type
     procedure actnDeleteUpdate(Sender: TObject);
     procedure actnDeleteUpdate(Sender: TObject);
     procedure actnOpenBackupFolderExecute(Sender: TObject);
     procedure actnOpenBackupFolderExecute(Sender: TObject);
     procedure actnRenameUpdate(Sender: TObject);
     procedure actnRenameUpdate(Sender: TObject);
+    procedure zgProjectsShowHint(var HintStr: String; var CanShow: Boolean;
+      var HintInfo: THintInfo; const ACoord: TPoint);
   private
   private
     FProjectManagerData: TProjectManagerData;
     FProjectManagerData: TProjectManagerData;
 
 
@@ -1671,4 +1673,49 @@ begin
   BubbleSort(stdProjects.IDTree.FirstNode);
   BubbleSort(stdProjects.IDTree.FirstNode);
 end;
 end;
 
 
+procedure TProjectManagerFrame.zgProjectsShowHint(var HintStr: String;
+  var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint);
+var
+  vCell: TZjCell;
+  vNode: TsdIDTreeNode;
+  iLevelWidth: Integer;
+  rText: TRect;
+
+  procedure CalcTextRect(var R: TRect);
+  var
+    DC: HDC;
+    iTextHeight: Integer;
+  begin
+    DC := CreateCompatibleDC(0);
+    try
+      SelectObject(DC, vCell.Font.Handle);
+      iTextHeight := DrawText(DC, PChar(vCell.Text), Length(vCell.Text), R, DT_SINGLELINE or DT_VCenter
+        or DT_NOCLIP or DT_CALCRECT);
+    finally
+      DeleteDC(DC);
+    end;
+  end;
+
+begin
+  if (ACoord.Y < 1) and (ACoord.X <> 1) then Exit;
+  
+  vCell := zgProjects.Cells[ACoord.X, ACoord.Y];
+  with HintInfo do
+  begin
+    vNode := stdProjects.IDTree.Items[ACoord.Y - 1];
+    if not Assigned(vNode) then Exit;
+    iLevelWidth := (vNode.Level + 1) * 20 + 16;
+
+    rText := CursorRect;
+    CalcTextRect(rText);
+    if (rText.Right - rText.Left + iLevelWidth > CursorRect.Right - CursorRect.Left) or
+      (rText.Right > ClientWidth) then
+    begin
+      CanShow := True;
+      HintStr := vCell.Text;
+      GetCursorPos(HintPos);
+    end;
+  end;
+end;
+
 end.
 end.

+ 29 - 14
Frames/ZJJLFme.dfm

@@ -80,20 +80,6 @@ object ZJJLFrame: TZJJLFrame
       TabOrder = 1
       TabOrder = 1
       OnExit = lePreTextExit
       OnExit = lePreTextExit
     end
     end
-    object rgType: TRadioGroup
-      Left = 214
-      Top = -3
-      Width = 150
-      Height = 29
-      Columns = 2
-      Ctl3D = False
-      ItemIndex = 0
-      Items.Strings = (
-        '0'#21495#21488#36134
-        #24635#37327#25511#21046)
-      ParentCtl3D = False
-      TabOrder = 2
-    end
   end
   end
   object pnlZJJL: TPanel
   object pnlZJJL: TPanel
     Left = 0
     Left = 0
@@ -116,6 +102,8 @@ object ZJJLFrame: TZJJLFrame
       DefaultFixedColWidth = 25
       DefaultFixedColWidth = 25
       Selection.AlphaBlend = False
       Selection.AlphaBlend = False
       Selection.TransparentColor = False
       Selection.TransparentColor = False
+      FrozenCol = 0
+      FrozenRow = 0
       OnMouseDown = zgZJJLMouseDown
       OnMouseDown = zgZJJLMouseDown
       Align = alClient
       Align = alClient
     end
     end
@@ -205,12 +193,23 @@ object ZJJLFrame: TZJJLFrame
       Caption = #33258#21160#29983#25104
       Caption = #33258#21160#29983#25104
       ImageIndex = 32
       ImageIndex = 32
       OnExecute = actnGenerateExecute
       OnExecute = actnGenerateExecute
+      OnUpdate = actnGenerateUpdate
     end
     end
     object actnLocateBills: TAction
     object actnLocateBills: TAction
       Caption = #23450#20301#33267#21488#36134
       Caption = #23450#20301#33267#21488#36134
       OnExecute = actnLocateBillsExecute
       OnExecute = actnLocateBillsExecute
       OnUpdate = actnLocateBillsUpdate
       OnUpdate = actnLocateBillsUpdate
     end
     end
+    object actnGenerateFxZJJL: TAction
+      Caption = '0'#21495#21488#36134#26684#24335
+      ImageIndex = 32
+      OnExecute = actnGenerateFxZJJLExecute
+    end
+    object actnGenerateGclZJJL: TAction
+      Caption = #24635#37327#25511#21046#26684#24335
+      ImageIndex = 32
+      OnExecute = actnGenerateGclZJJLExecute
+    end
   end
   end
   object zaZJJL: TZjGridDBA
   object zaZJJL: TZjGridDBA
     Columns = <
     Columns = <
@@ -288,4 +287,20 @@ object ZJJLFrame: TZJJLFrame
     Left = 104
     Left = 104
     Top = 160
     Top = 160
   end
   end
+  object dxpmAutoGenerate: TdxBarPopupMenu
+    BarManager = MainForm.dxBarManager
+    ItemLinks = <
+      item
+        Item = MainForm.dxbtnFxZJJL
+        Visible = True
+      end
+      item
+        Item = MainForm.dxbtnGclZJJL
+        Visible = True
+      end>
+    UseOwnFont = False
+    OnPopup = dxpmAutoGeneratePopup
+    Left = 104
+    Top = 200
+  end
 end
 end

+ 78 - 9
Frames/ZJJLFme.pas

@@ -29,8 +29,10 @@ type
     lblDataTiel: TLabel;
     lblDataTiel: TLabel;
     pnlDataBar: TPanel;
     pnlDataBar: TPanel;
     dxpmZJJL: TdxBarPopupMenu;
     dxpmZJJL: TdxBarPopupMenu;
-    rgType: TRadioGroup;
     actnLocateBills: TAction;
     actnLocateBills: TAction;
+    dxpmAutoGenerate: TdxBarPopupMenu;
+    actnGenerateFxZJJL: TAction;
+    actnGenerateGclZJJL: TAction;
     procedure actnGenerateExecute(Sender: TObject);
     procedure actnGenerateExecute(Sender: TObject);
     procedure lePreTextExit(Sender: TObject);
     procedure lePreTextExit(Sender: TObject);
     procedure zgZJJLMouseDown(Sender: TObject; Button: TMouseButton;
     procedure zgZJJLMouseDown(Sender: TObject; Button: TMouseButton;
@@ -38,10 +40,17 @@ type
     procedure dxpmZJJLPopup(Sender: TObject);
     procedure dxpmZJJLPopup(Sender: TObject);
     procedure actnLocateBillsExecute(Sender: TObject);
     procedure actnLocateBillsExecute(Sender: TObject);
     procedure actnLocateBillsUpdate(Sender: TObject);
     procedure actnLocateBillsUpdate(Sender: TObject);
+    procedure dxpmAutoGeneratePopup(Sender: TObject);
+    procedure actnGenerateFxZJJLExecute(Sender: TObject);
+    procedure actnGenerateGclZJJLExecute(Sender: TObject);
+    procedure actnGenerateUpdate(Sender: TObject);
   private
   private
     FZJJLData: TZJJLData;
     FZJJLData: TZJJLData;
     FDataReadOnly: Boolean;
     FDataReadOnly: Boolean;
     procedure SetDataReadOnly(const Value: Boolean);
     procedure SetDataReadOnly(const Value: Boolean);
+
+    procedure RefreshTitle;
+    procedure GenerateZJJL;
   public
   public
     constructor Create(AParent: TFrame; AZJJLData: TZJJLData);
     constructor Create(AParent: TFrame; AZJJLData: TZJJLData);
     destructor Destroy; override;
     destructor Destroy; override;
@@ -54,7 +63,8 @@ type
 implementation
 implementation
 
 
 uses
 uses
-  MergeTextFrm, PhaseData, MainFrm, ProjectData, UtilMethods;
+  MergeTextFrm, PhaseData, MainFrm, ProjectData, UtilMethods,
+  PhaseProperty;
 
 
 {$R *.dfm}
 {$R *.dfm}
 
 
@@ -66,6 +76,7 @@ begin
   ResetFrameLink(AZJJLData);
   ResetFrameLink(AZJJLData);
   with TProjectData(TPhaseData(FZJJLData.PhaseData).ProjectData) do
   with TProjectData(TPhaseData(FZJJLData.PhaseData).ProjectData) do
     lePreText.Text := ProjProperties.ZJJLPreText;
     lePreText.Text := ProjProperties.ZJJLPreText;
+  RefreshTitle;
 end;
 end;
 
 
 destructor TZJJLFrame.Destroy;
 destructor TZJJLFrame.Destroy;
@@ -81,14 +92,19 @@ begin
 end;
 end;
 
 
 procedure TZJJLFrame.actnGenerateExecute(Sender: TObject);
 procedure TZJJLFrame.actnGenerateExecute(Sender: TObject);
+var
+  bIsRefer: Boolean; 
+  P: TPoint;
 begin
 begin
   with TProjectData(TPhaseData(FZJJLData.PhaseData).ProjectData) do
   with TProjectData(TPhaseData(FZJJLData.PhaseData).ProjectData) do
-    ProjProperties.ZJJLPreText := lePreText.Text;
-  if rgType.ItemIndex = 0 then
-    FZJJLData.GenerateAll
-  else if rgType.ItemIndex = 1 then
-    FZJJLData.GenerateAllByB_Code;
-  FZJJLData.AssignedCurData;
+    bIsRefer := ProjProperties.AuditStatus = 0;
+  if bIsRefer then
+  begin
+    P := pnlButton.ClientToScreen(Point(tobtnGenerate.Left, tobtnGenerate.Top + tobtnGenerate.Height));
+    dxpmAutoGenerate.Popup(P.X, P.Y);
+  end
+  else
+    GenerateZJJL;
 end;
 end;
 
 
 procedure TZJJLFrame.lePreTextExit(Sender: TObject);
 procedure TZJJLFrame.lePreTextExit(Sender: TObject);
@@ -102,7 +118,6 @@ begin
   FDataReadOnly := Value;
   FDataReadOnly := Value;
   actnGenerate.Enabled := not FDataReadOnly;
   actnGenerate.Enabled := not FDataReadOnly;
   lePreText.Enabled := not FDataReadOnly;
   lePreText.Enabled := not FDataReadOnly;
-  rgType.Enabled := not FDataReadOnly;
   zaZJJL.Column('Code').ReadOnly := FDataReadOnly;
   zaZJJL.Column('Code').ReadOnly := FDataReadOnly;
   zaZJJL.Column('CertificateCode').ReadOnly := FDataReadOnly;
   zaZJJL.Column('CertificateCode').ReadOnly := FDataReadOnly;
 end;
 end;
@@ -134,4 +149,58 @@ begin
   TAction(Sender).Enabled := FZJJLData.cdsZJJLView.RecordCount > 0;
   TAction(Sender).Enabled := FZJJLData.cdsZJJLView.RecordCount > 0;
 end;
 end;
 
 
+procedure TZJJLFrame.RefreshTitle;
+var
+  iType: Integer;
+begin
+  if not TPhaseData(FZJJLData.PhaseData).Active then Exit;
+  iType := TPhaseData(FZJJLData.PhaseData).PhaseProperty.ZJJLType;
+  case iType of
+    0: labTitle.Caption := '中间计量(0号台账)';
+    1: labTitle.Caption := '中间计量(总量控制)';
+  end;
+end;
+
+procedure TZJJLFrame.dxpmAutoGeneratePopup(Sender: TObject);
+begin
+  SetDxBtnAction(actnGenerateFxZJJL, MainForm.dxbtnFxZJJL);
+  SetDxBtnAction(actnGenerateGclZJJL, MainForm.dxbtnGclZJJL);
+end;
+
+procedure TZJJLFrame.actnGenerateFxZJJLExecute(Sender: TObject);
+begin
+  with TPhaseData(FZJJLData.PhaseData).PhaseProperty do
+    ZJJLType := 0;
+  GenerateZJJL;
+end;
+
+procedure TZJJLFrame.GenerateZJJL;
+var
+  iType: Integer;
+begin
+  with TProjectData(TPhaseData(FZJJLData.PhaseData).ProjectData) do
+    ProjProperties.ZJJLPreText := lePreText.Text;
+
+  iType := TPhaseData(FZJJLData.PhaseData).PhaseProperty.ZJJLType;
+  case iType of
+    0: FZJJLData.GenerateAll;
+    1: FZJJLData.GenerateAllByB_Code;
+  end;
+  FZJJLData.AssignedCurData;
+  RefreshTitle;
+end;
+
+procedure TZJJLFrame.actnGenerateGclZJJLExecute(Sender: TObject);
+begin
+  with TPhaseData(FZJJLData.PhaseData).PhaseProperty do
+    ZJJLType := 1;
+  GenerateZJJL;
+end;
+
+procedure TZJJLFrame.actnGenerateUpdate(Sender: TObject);
+begin
+  with TProjectData(TPhaseData(FZJJLData.PhaseData).ProjectData) do
+    TAction(Sender).Enabled := not StageDataReadOnly;
+end;
+
 end.
 end.

+ 207 - 0
TenderPartition/tpBaseGatherData.pas

@@ -0,0 +1,207 @@
+unit tpBaseGatherData;
+
+interface
+
+uses
+  Classes, tpGatherTree, tpPeg, BillsTree, tpSelectTenderNode,
+  ProjectData, tpNoPegDm;
+
+type
+  TtpBaseGatherData = class
+  private
+    FTree: TtpGatherTree;
+    FPegs: TtpPegList;
+
+    FNoPegTree: TtpGatherTree;
+    FNoPegData: TtpNoPegData;
+
+    function AddBillsNode(ANode: TBillsIDTreeNode; AParent: TtpGatherTreeNode): TtpGatherTreeNode;
+    procedure CheckPeg(ANode: TtpGatherTreeNode);
+    procedure AddBills(ANode: TBillsIDTreeNode; AParent: TtpGatherTreeNode);
+    procedure GatherTender(ATender: TtpSelectTenderNode);
+
+    function AddNoPegTreeNode(AOrgNode, AParent: TtpGatherTreeNode): TtpGatherTreeNode;
+    procedure FilterNoPegTreeNode(AOrgNode, AParent: TtpGatherTreeNode);
+    procedure FilterNoPegTree;
+  public
+    constructor Create;
+    destructor Destroy; override;
+
+    procedure GatherTenders(ATenders: TList);
+
+    property Tree: TtpGatherTree read FTree;
+    property Pegs: TtpPegList read FPegs;
+    property NoPegData: TtpNoPegData read FNoPegData;
+  end;
+
+implementation
+
+uses
+  ProgressHintFrm, mPegFilter, Globals, UtilMethods, Forms, Controls;
+
+{ TtpBaseGatherData }
+
+procedure TtpBaseGatherData.AddBills(ANode: TBillsIDTreeNode;
+  AParent: TtpGatherTreeNode);
+var
+  ACur: TtpGatherTreeNode;
+begin
+  if not Assigned(ANode) then Exit;
+
+  ACur := AddBillsNode(ANode, AParent);
+  CheckPeg(ACur);
+  AddBills(TBillsIDTreeNode(ANode.FirstChild), ACur);
+  AddBills(TBillsIDTreeNode(ANode.NextSibling), AParent);
+end;
+
+function TtpBaseGatherData.AddBillsNode(ANode: TBillsIDTreeNode;
+  AParent: TtpGatherTreeNode): TtpGatherTreeNode;
+var
+  vNextSibling: TtpGatherTreeNode;
+  vPeg: TtpPegNode;
+begin
+  Result := FTree.FindNode(AParent, ANode.Rec);
+  if not Assigned(Result) then
+  begin
+    vNextSibling := FTree.FindNextSibling(AParent, ANode.Rec);
+    Result := FTree.AddNode(AParent, vNextSibling);
+    Result.Code := ANode.Rec.Code.AsString;
+    Result.B_Code := ANode.Rec.B_Code.AsString;
+    Result.Name := ANode.Rec.Name.AsString;
+    Result.Units := ANode.Rec.Units.AsString;
+    Result.Price := ANode.Rec.Price.AsFloat;
+  end;
+
+  Result.Quantity := Result.Quantity + ANode.Rec.Quantity.AsFloat;
+  Result.TotalPrice := Result.TotalPrice + ANode.Rec.TotalPrice.AsFloat;
+end;
+
+procedure TtpBaseGatherData.CheckPeg(ANode: TtpGatherTreeNode);
+var
+  vPegNode: TtpPegNode;
+begin
+  if not Assigned(ANode) then Exit;
+
+  if PegFilter.Filter(ANode.Name) then
+  begin
+    vPegNode := TtpPegNode.Create(ANode, PegFilter);
+    FPegs.AddPegs(vPegNode);
+  end;
+end;
+
+constructor TtpBaseGatherData.Create;
+begin
+  FTree := TtpGatherTree.Create;
+  FPegs := TtpPegList.Create;
+  FNoPegTree := TtpGatherTree.Create;
+  FNoPegData := TtpNoPegData.Create;
+end;
+
+destructor TtpBaseGatherData.Destroy;
+begin
+  FNoPegData.Free;
+  FNoPegTree.Free;
+  FPegs.Free;
+  FTree.Free;
+  inherited;
+end;
+
+procedure TtpBaseGatherData.GatherTenders(ATenders: TList);
+var
+  iTender: Integer;
+  vTender: TtpSelectTenderNode;
+begin
+  Screen.Cursor := crHourGlass;
+  ShowProgressHint('正在汇总项目', ATenders.Count*2);
+  try
+    FTree.ClearTreeNodes;
+    FPegs.Clear;
+    for iTender := 0 to ATenders.Count - 1 do
+    begin
+      vTender := TtpSelectTenderNode(ATenders.Items[iTender]);
+      GatherTender(vTender);
+    end;
+    FPegs.LoadRelaGclNodes;
+    FPegs.SortPegs;
+    FilterNoPegTree;
+  finally
+    CloseProgressHint;
+    Screen.Cursor := crDefault;
+  end;
+end;
+
+procedure TtpBaseGatherData.GatherTender(ATender: TtpSelectTenderNode);
+var
+  vProjectData: TProjectData;
+
+  procedure OpenProject;
+  begin
+    vProjectData := OpenProjectManager.FindProjectData(ATender.ID);
+    if not Assigned(vProjectData) then
+    begin
+      vProjectData := TProjectData.Create;
+      vProjectData.OpenForReport(GetMyProjectsFilePath + ATender.FileName);
+    end;
+    ATender.NodeCount := vProjectData.BillsCompileData.BillsCompileTree.Count;
+  end;
+
+  procedure FreeProject;
+  begin
+    if not Assigned(OpenProjectManager.FindProjectData(ATender.ID)) then
+      vProjectData.Free;
+  end;
+
+begin
+  try
+    UpdateProgressHint('正在打开项目: ' + ATender.Name);
+    OpenProject;
+    UpdateProgressPosition;
+
+    UpdateProgressHint('正在汇总项目: ' + ATender.Name);
+    with vProjectData.BillsCompileData do
+      AddBills(TBillsIDTreeNode(BillsCompileTree.FirstNode), nil);
+    UpdateProgressPosition;
+  finally
+    FreeProject;
+  end;
+end;
+
+procedure TtpBaseGatherData.FilterNoPegTreeNode(
+  AOrgNode, AParent: TtpGatherTreeNode);
+var
+  vCur: TtpGatherTreeNode;
+begin
+  if not Assigned(AOrgNode) then Exit;
+
+  if not AOrgNode.RelaPeg then
+  begin
+    vCur := AddNoPegTreeNode(AOrgNode, AParent);
+    FilterNoPegTreeNode(TtpGatherTreeNode(AOrgNode.FirstChild), vCur);
+  end;
+  FilterNoPegTreeNode(TtpGatherTreeNode(AOrgNode.NextSibling), AParent);
+end;
+
+function TtpBaseGatherData.AddNoPegTreeNode(AOrgNode,
+  AParent: TtpGatherTreeNode): TtpGatherTreeNode;
+begin
+  Result := FNoPegTree.AddNode(AParent);
+  Result.Code := AOrgNode.Code;
+  Result.B_Code := AOrgNode.B_Code;
+  Result.Name := AOrgNode.Name;
+  Result.Units := AOrgNode.Units;
+  Result.Price := AOrgNode.Price;
+  Result.Quantity := AOrgNode.Quantity;
+  Result.TotalPrice := AOrgNode.TotalPrice;
+  Result.DgnQuantity1 := AOrgNode.DgnQuantity1;
+  Result.DgnQuantity2 := AOrgNode.DgnQuantity2;
+end;
+
+procedure TtpBaseGatherData.FilterNoPegTree;
+begin
+  FTree.CheckRelaPeg;
+  FilterNoPegTreeNode(TtpGatherTreeNode(FTree.Root.FirstChild), nil);
+  FNoPegTree.CalculateAllParent;
+  FNoPegData.LoadData(FNoPegTree);
+end;
+
+end.

+ 202 - 0
TenderPartition/tpGatherGcl.pas

@@ -0,0 +1,202 @@
+unit tpGatherGcl;
+
+interface
+
+uses
+  Classes, tpGatherTree;
+
+type
+  TtpGatherGclRela = class
+  private
+    FRelaGcl: TtpGatherTreeNode;
+    FRelaPegXmj: TtpGatherTreeNode;
+  public
+    constructor Create(AGcl, APegXmj: TtpGatherTreeNode);
+
+    property RelaGcl: TtpGatherTreeNode read FRelaGcl;
+    property RelaPegXmj: TtpGatherTreeNode read FRelaPegXmj;
+  end;
+
+  TtpGatherGcl = class
+  private
+    FID: Integer;
+    FRelas: TList;
+
+    FIndexCode: string;
+    FB_Code: string;
+    FName: string;
+    FUnits: string;
+    FPrice: Double;
+
+    FQuantity: Double;
+    FTotalPrice: Double;
+    function GetRela(AIndex: Integer): TtpGatherGclRela;
+    function GetRelaCount: Integer;
+  public
+    constructor Create(AID: Integer; AGcl, APegXmj: TtpGatherTreeNode);
+    destructor Destroy; override;
+
+    procedure GatherNode(AGcl, APegXmj: TtpGatherTreeNode);
+
+    property ID: Integer read FID;
+
+    property IndexCode: string read FIndexCode;
+    property B_Code: string read FB_Code;
+    property Name: string read FName;
+    property Units: string read FUnits;
+    property Price: Double read FPrice;
+
+    property Quantity: Double read FQuantity;
+    property TotalPrice: Double read FTotalPrice;
+
+    property RelaCount: Integer read GetRelaCount;
+    property Rela[AIndex: Integer]: TtpGatherGclRela read GetRela;
+  end;
+
+  TtpGatherGclList = class
+  private
+    FGcls: TList;
+    FNewID: Integer;
+
+    function FindGatherGcl(ANode: TtpGatherTreeNode): TtpGatherGcl;
+    function NewGatherGcl(AGcl, APegXmj: TtpGatherTreeNode): TtpGatherGcl;
+    function GetGcl(AIndex: Integer): TtpGatherGcl;
+    function GetGclCount: Integer;
+  public
+    constructor Create;
+    destructor Destroy; override;
+
+    procedure GatherNode(AGcl, APegXmj: TtpGatherTreeNode);
+
+    property GclCount: Integer read GetGclCount;
+    property Gcl[AIndex: Integer]: TtpGatherGcl read GetGcl;
+  end;
+
+implementation
+
+uses
+  UtilMethods, SysUtils, ZhAPI;
+
+{ TtpGatherGcl }
+
+constructor TtpGatherGcl.Create(AID: Integer; AGcl, APegXmj: TtpGatherTreeNode);
+var
+  vRela: TtpGatherGclRela;
+begin
+  FID := AID;
+  FRelas := TList.Create;
+  vRela := TtpGatherGclRela.Create(AGcl, APegXmj);
+  FRelas.Add(vRela);
+
+  FB_Code := AGcl.B_Code;
+  FIndexCode := B_CodeToIndexCode(FB_Code);
+  FName := AGcl.Name;
+  FUnits := AGcl.Units;
+  FPrice := AGcl.Price;
+
+  FQuantity := AGcl.Quantity;
+  FTotalPrice := AGcl.TotalPrice;
+end;
+
+destructor TtpGatherGcl.Destroy;
+begin
+  ClearObjects(FRelas);
+  FRelas.Free;
+  inherited;
+end;
+
+procedure TtpGatherGcl.GatherNode(AGcl, APegXmj: TtpGatherTreeNode);
+var
+  vRela: TtpGatherGclRela;
+begin
+  vRela := TtpGatherGclRela.Create(AGcl, APegXmj);
+  FRelas.Add(vRela);
+
+  FQuantity := FQuantity + AGcl.Quantity;
+  FTotalPrice := FTotalPrice + AGcl.TotalPrice;
+end;
+
+function TtpGatherGcl.GetRela(AIndex: Integer): TtpGatherGclRela;
+begin
+  Result := TtpGatherGclRela(FRelas.Items[AIndex]);
+end;
+
+function TtpGatherGcl.GetRelaCount: Integer;
+begin
+  Result := FRelas.Count;
+end;
+
+{ TtpGatherGclList }
+
+constructor TtpGatherGclList.Create;
+begin
+  FGcls := TList.Create;
+  FNewID := 0;
+end;
+
+destructor TtpGatherGclList.Destroy;
+begin
+  ClearObjects(FGcls);
+  FGcls.Free;
+  inherited;
+end;
+
+function TtpGatherGclList.FindGatherGcl(
+  ANode: TtpGatherTreeNode): TtpGatherGcl;
+var
+  iGcl: Integer;
+  vGcl: TtpGatherGcl;
+begin
+  Result := nil;
+  for iGcl := 0 to FGcls.Count - 1 do
+  begin
+    vGcl := TtpGatherGcl(FGcls.Items[iGcl]);
+    if SameText(vGcl.B_Code, ANode.B_Code) and
+        SameText(vGcl.Name, ANode.Name) and
+        SameText(vGcl.Units, ANode.Units) and
+        (vGcl.Price - ANode.Price < 0.0001) then
+    begin
+      Result := vGcl;
+      Break;
+    end;
+  end;
+end;
+
+procedure TtpGatherGclList.GatherNode(AGcl, APegXmj: TtpGatherTreeNode);
+var
+  vGcl: TtpGatherGcl;
+begin
+  vGcl := FindGatherGcl(AGcl);
+  if Assigned(vGcl) then
+    vGcl.GatherNode(AGcl, APegXmj)
+  else
+    vGcl := NewGatherGcl(AGcl, APegXmj);
+end;
+
+function TtpGatherGclList.GetGcl(AIndex: Integer): TtpGatherGcl;
+begin
+  Result := TtpGatherGcl(FGcls.Items[AIndex]);
+end;
+
+function TtpGatherGclList.GetGclCount: Integer;
+begin
+  Result := FGcls.Count;
+end;
+
+function TtpGatherGclList.NewGatherGcl(
+  AGcl, APegXmj: TtpGatherTreeNode): TtpGatherGcl;
+begin
+  Result := TtpGatherGcl.Create(FNewID, AGcl, APegXmj);
+  FGcls.Add(Result);
+  Inc(FNewID);
+end;
+
+{ TtpGatherGclRela }
+
+constructor TtpGatherGclRela.Create(AGcl, APegXmj: TtpGatherTreeNode);
+begin
+  FRelaGcl := AGcl;
+  FRelaPegXmj := APegXmj;
+end;
+
+end.

+ 300 - 0
TenderPartition/tpGatherTree.pas

@@ -0,0 +1,300 @@
+unit tpGatherTree;
+// 实际上可以使用mCacheTree中的ReportCacheTree
+// 但此处的树节点更多,使用的清单数据不多,为了便于理解,故重写
+
+interface
+
+uses
+  Classes, CacheTree, mDataRecord, ZhAPI, sdDB, sdIDTree;
+
+type
+  TtpGatherTreeNode = class(TCacheNode)
+  private
+    FCode: string;
+    FB_Code: string;
+    FName: string;
+    FUnits: string;
+    FPrice: Double;
+
+    FQuantity: Double;
+    FTotalPrice: Double;
+    FDgnQuantity1: Double;
+    FDgnQuantity2: Double;
+
+    FRelaPeg: Boolean;
+    FParted: Boolean;
+  public
+    property Code: string read FCode write FCode;
+    property B_Code: string read FB_Code write FB_Code;
+    property Name: string read FName write FName;
+    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 DgnQuantity1: Double read FDgnQuantity1 write FDgnQuantity1;
+    property DgnQuantity2: Double read FDgnQuantity2 write FDgnQuantity2;
+
+    // 节点为桩号/节点的父项为桩号/节点的子项全为桩号
+    property RelaPeg: Boolean read FRelaPeg write FRelaPeg;
+    property Parted: Boolean read FParted write FParted;
+  end;
+
+  TtpGatherTree = class(TCacheTree)
+  private
+    function SamePrice(APrice1, APrice2: Double): Boolean;
+
+    function GetParentParted(ANode: TtpGatherTreeNode): Boolean;
+    procedure CheckNodeParted(ANode: TtpGatherTreeNode);
+
+    function GetParentRelaPeg(ANode: TtpGatherTreeNode): Boolean;
+    procedure CheckNodeRelaPeg(ANode: TtpGatherTreeNode);
+  protected
+    function GetNewNode: TCacheNode; override;
+  public
+    function FindNode(AParent: TtpGatherTreeNode; ARec: TBillsRecord): TtpGatherTreeNode;
+    function FindNextSibling(AParent: TtpGatherTreeNode; ARec: TBillsRecord): TtpGatherTreeNode;
+
+    function AddNode(AParent: TCacheNode; ANextSibling: TCacheNode = nil): TtpGatherTreeNode;
+
+    procedure CalculateAllParent;
+    procedure WriteData(ADataSet: TsdDataSet);
+
+    procedure CheckRelaPeg;
+    procedure CheckParted;
+  end;
+
+implementation
+
+uses SysUtils;
+
+{ TtpGatherTree }
+
+function TtpGatherTree.AddNode(AParent,
+  ANextSibling: TCacheNode): TtpGatherTreeNode;
+begin
+  Result := TtpGatherTreeNode(GetNewNode);
+  if Assigned(ANextSibling) then
+    ANextSibling.InsertPreSibling(Result)
+  else if Assigned(AParent) then
+    AParent.InsertChild(Result)
+  else
+    Root.InsertChild(Result);
+end;
+
+procedure TtpGatherTree.CalculateAllParent;
+
+  function GatherChildren(ANode: TtpGatherTreeNode): Double;
+  var
+    vChild: TtpGatherTreeNode;
+  begin
+    Result := 0;
+    if not Assigned(ANode) then Exit;
+
+    vChild := TtpGatherTreeNode(ANode.FirstChild);
+    while Assigned(vChild) do
+    begin
+      Result := Result + vChild.TotalPrice;
+      vChild := TtpGatherTreeNode(vChild.NextSibling);
+    end;
+  end;
+
+  procedure CalculateParent(ANode: TtpGatherTreeNode);
+  begin
+    if not Assigned(ANode) or not Assigned(ANode.FirstChild) then Exit;
+
+    CalculateParent(TtpGatherTreeNode(ANode.FirstChild));
+    ANode.TotalPrice := GatherChildren(ANode);
+    CalculateParent(TtpGatherTreeNode(ANode.NextSibling));
+  end;
+
+begin
+  CalculateParent(TtpGatherTreeNode(Root.FirstChild));
+end;
+
+procedure TtpGatherTree.CheckNodeParted(ANode: TtpGatherTreeNode);
+begin
+  if not Assigned(ANode) then Exit;
+
+  if Assigned(ANode.FirstChild) then
+  begin
+    CheckNodeParted(TtpGatherTreeNode(ANode.FirstChild));
+    ANode.Parted := GetParentParted(ANode);
+  end;
+
+  CheckNodeParted(TtpGatherTreeNode(ANode.NextSibling));
+end;
+
+procedure TtpGatherTree.CheckNodeRelaPeg(ANode: TtpGatherTreeNode);
+begin
+  if not Assigned(ANode) then Exit;
+
+  if Assigned(ANode.FirstChild) then
+  begin
+    CheckNodeRelaPeg(TtpGatherTreeNode(ANode.FirstChild));
+    ANode.RelaPeg := GetParentRelaPeg(ANode);
+  end;
+
+  CheckNodeRelaPeg(TtpGatherTreeNode(ANode.NextSibling));
+end;
+
+procedure TtpGatherTree.CheckParted;
+begin
+  CheckNodeParted(TtpGatherTreeNode(Root.FirstChild));
+end;
+
+procedure TtpGatherTree.CheckRelaPeg;
+begin
+  CheckNodeRelaPeg(TtpGatherTreeNode(Root.FirstChild));
+end;
+
+function TtpGatherTree.FindNextSibling(AParent: TtpGatherTreeNode;
+  ARec: TBillsRecord): TtpGatherTreeNode;
+var
+  vNode: TtpGatherTreeNode;
+  sCodeID, sCodeID2, sB_CodeID, sB_CodeID2: string;
+begin
+  if Assigned(AParent) then
+    vNode := TtpGatherTreeNode(AParent.FirstChild)
+  else
+    vNode := TtpGatherTreeNode(Root.FirstChild);
+  Result := nil;
+  if (ARec.Code.AsString = '') and (ARec.B_Code.AsString = '') then Exit;
+
+  sCodeID := ConvertDigitCode(ARec.Code.AsString, 3, '-');
+  sB_CodeID := ConvertDigitCode(ARec.B_Code.AsString, 4, '-');
+  while Assigned(vNode) do
+  begin
+    sCodeID2 := ConvertDigitCode(vNode.Code, 3, '-');
+    sB_CodeID2 := ConvertDigitCode(vNode.B_Code, 4, '-');
+    if sCodeID < sCodeID2 then
+    begin
+      Result := vNode;
+      Break;
+    end
+    else if sB_CodeID < sB_CodeID2 then
+    begin
+      Result := vNode;
+      Break;
+    end;
+    vNode := TtpGatherTreeNode(vNode.NextSibling);
+  end;
+end;
+
+function TtpGatherTree.FindNode(AParent: TtpGatherTreeNode; ARec: TBillsRecord): TtpGatherTreeNode;
+var
+  vNode: TtpGatherTreeNode;
+begin
+  if Assigned(AParent) then
+    vNode := TtpGatherTreeNode(AParent.FirstChild)
+  else
+    vNode := TtpGatherTreeNode(Root.FirstChild);
+  while Assigned(vNode) do
+  begin
+    if SameText(vNode.Code, ARec.Code.AsString) and
+        SameText(vNode.B_Code, ARec.B_Code.AsString) and
+        SameText(vNode.Name, ARec.Name.AsString) and
+        SameText(vNode.Units, ARec.Units.AsString) and
+        SamePrice(vNode.Price, ARec.Price.AsFloat) then
+    begin
+      Result := vNode;
+      Break;
+    end;
+    vNode := TtpGatherTreeNode(vNode.NextSibling);
+  end;
+end;
+
+function TtpGatherTree.GetNewNode: TCacheNode;
+begin
+  Result := TtpGatherTreeNode.Create(Self, GetNewNodeID);
+  CacheNodes.Add(Result);
+end;
+
+function TtpGatherTree.GetParentParted(ANode: TtpGatherTreeNode): Boolean;
+var
+  i: Integer;
+  vChild: TtpGatherTreeNode;
+begin
+  if Assigned(ANode.FirstChild) then
+  begin
+    Result := True;
+    vChild := TtpGatherTreeNode(ANode.FirstChild);
+    while Assigned(vChild) and Result do
+    begin
+      Result := Result and vChild.Parted;
+      vChild := TtpGatherTreeNode(vChild.NextSibling);
+    end;
+  end
+  else
+    Result := ANode.Parted;
+end;
+
+function TtpGatherTree.GetParentRelaPeg(ANode: TtpGatherTreeNode): Boolean;
+var
+  i: Integer;
+  vChild: TtpGatherTreeNode;
+begin
+  if Assigned(ANode.FirstChild) then
+  begin
+    Result := True;
+    vChild := TtpGatherTreeNode(ANode.FirstChild);
+    while Assigned(vChild) and Result do
+    begin
+      Result := Result and vChild.RelaPeg;
+      vChild := TtpGatherTreeNode(vChild.NextSibling);
+    end;
+  end
+  else
+    Result := ANode.RelaPeg;
+end;
+
+function TtpGatherTree.SamePrice(APrice1, APrice2: Double): Boolean;
+begin
+  Result := (APrice1 - APrice2) < 0.001;
+end;
+
+procedure TtpGatherTree.WriteData(ADataSet: TsdDataSet);
+
+  procedure BeforeWrite;
+  begin
+    ADataSet.DisableControls;
+    ADataSet.BeginUpdate;
+    ADataSet.DeleteAll;
+  end;
+
+  procedure AfterWrite;
+  begin
+    ADataSet.EndUpdate;
+    ADataSet.EnableControls;
+  end;
+
+var
+  i: Integer;
+  vNode: TtpGatherTreeNode;
+  Rec: TsdDataRecord;
+begin
+  BeforeWrite;
+  try
+    for i := 0 to CacheNodes.Count - 1 do
+    begin
+      vNode := TtpGatherTreeNode(CacheNodes.Items[i]);
+      Rec := ADataSet.Add;
+      Rec.ValueByName('ID').AsInteger := vNode.ID;
+      Rec.ValueByName('ParentID').AsInteger := vNode.ParentID;
+      Rec.ValueByName('NextSiblingID').AsInteger := vNode.NextSiblingID;
+      Rec.ValueByName('Code').AsString := vNode.Code;
+      Rec.ValueByName('B_Code').AsString := vNode.B_Code;
+      Rec.ValueByName('Name').AsString := vNode.Name;
+      Rec.ValueByName('Units').AsString := vNode.Units;
+      Rec.ValueByName('Price').AsFloat := vNode.Price;
+      Rec.ValueByName('Quantity').AsFloat := vNode.Quantity;
+      Rec.ValueByName('TotalPrice').AsFloat := vNode.TotalPrice;
+      Rec.ValueByName('DgnQuantity1').AsFloat := vNode.DgnQuantity1;
+      Rec.ValueByName('DgnQuantity2').AsFloat := vNode.DgnQuantity2;
+    end;
+  finally
+    AfterWrite;
+  end;
+end;
+
+end.

+ 165 - 0
TenderPartition/tpMainData.pas

@@ -0,0 +1,165 @@
+unit tpMainData;
+
+interface
+
+uses
+  Classes, tpBaseGatherData, tpSelectTenderDm, sdIDTree, tpSelectTenderNode,
+  tpPartTender, tpPartTenderSet;
+
+type
+  TtpMainData = class
+  private
+    FHistoryTenders: TList;
+    FTenders: TList;
+    // Memory DataSet -- For Display
+    // Display FTenders
+    FSelectTenderData: TtpSelectTenderData;
+
+    FBaseGatherData: TtpBaseGatherData;
+    FPartTrial: TtpPartTender;
+    FPartTenderSet: TtpPartTenderSet;
+
+    procedure ClearAllHistoryData;
+  public
+    constructor Create;
+    destructor Destroy; override;
+
+    procedure GatherProjects(AProjects: TList);
+    procedure TrialPeg;
+    procedure PricePart;
+    procedure PegPart;
+
+    property Tenders: TList read FTenders;                          
+    property SelectTenderData: TtpSelectTenderData read FSelectTenderData;
+
+    property BaseGatherData: TtpBaseGatherData read FBaseGatherData;
+    property PartTrial: TtpPartTender read FPartTrial;
+    property PartTenderSet: TtpPartTenderSet read FPartTenderSet;
+  end;
+
+implementation
+
+uses
+  ZhAPI, Globals, mPegFilter, tpTrialPegInputFrm, UtilMethods,
+  Math;
+
+{ TtpMainData }
+
+procedure TtpMainData.ClearAllHistoryData;
+begin
+  FTenders.Clear;
+  FPartTrial.Clear;
+end;
+
+constructor TtpMainData.Create;
+begin
+  FHistoryTenders := TList.Create;
+  FTenders := TList.Create;
+  FSelectTenderData := TtpSelectTenderData.Create(nil);
+
+  FBaseGatherData := TtpBaseGatherData.Create;
+  FPartTrial := TtpPartTender.Create;
+  FPartTenderSet := TtpPartTenderSet.Create;
+end;
+
+destructor TtpMainData.Destroy;
+begin
+  FPartTenderSet.Free;
+  FPartTrial.Free;
+  FBaseGatherData.Free;
+
+  FSelectTenderData.Free;
+  ClearObjects(FTenders);
+  FTenders.Free;
+  FHistoryTenders.Free;
+  inherited;
+end;
+
+procedure TtpMainData.GatherProjects(AProjects: TList);
+
+  function SortTenders(AItem1, AItem2: Pointer): Integer;
+  begin
+    Result := TtpSelectTenderNode(AItem1).SerialNo - TtpSelectTenderNode(AItem2).SerialNo;
+  end;
+
+  procedure FilterTenders;
+  var
+    i: Integer;
+    stnNode: TsdIDTreeNode;
+    vTender: TtpSelectTenderNode;
+  begin
+    for i := 0 to AProjects.Count - 1 do
+    begin
+      stnNode := ProjectManager.ProjectsTree.FindNode(Integer(AProjects.Items[i]));
+      if Assigned(stnNode) and (stnNode.Rec.ValueByName('Type').AsInteger = 1) then
+      begin
+        vTender := TtpSelectTenderNode.Create(stnNode);
+        FTenders.Add(vTender);
+        FTenders.Sort(@SortTenders);
+      end;
+    end;
+  end;
+
+  function CheckSameTenders: Boolean;
+  var
+    i: Integer;
+    vOrg, vNew: TtpSelectTenderNode;
+  begin
+    if FHistoryTenders.Count = FTenders.Count then
+    begin
+      Result := True;
+      for i := 0 to FHistoryTenders.Count - 1 do
+      begin
+        vOrg := TtpSelectTenderNode(FHistoryTenders.Items[i]);
+        vNew := TtpSelectTenderNode(FTenders.Items[i]);
+        if vOrg.ID <> vNew.ID then
+        begin
+          Result := False;
+          Break;
+        end;
+      end;
+    end
+    else
+      Result := False;
+  end;
+
+begin
+  ClearAllHistoryData;
+  FilterTenders;
+  if not CheckSameTenders then
+  begin
+    FBaseGatherData.GatherTenders(FTenders);
+    FSelectTenderData.AssignSelectTenders(FTenders);
+    ClearObjects(FHistoryTenders);
+    FHistoryTenders.Assign(FTenders);
+  end;
+end;
+
+procedure TtpMainData.PegPart;
+begin
+  if FBaseGatherData.Pegs.Count > 0 then
+    FPartTenderSet.PegPart(FBaseGatherData.Pegs)
+  else
+    WarningMessage('无桩号数据,无法划分');
+end;
+
+procedure TtpMainData.PricePart;
+begin
+  if FBaseGatherData.Pegs.TotalPrice > 0 then
+    FPartTenderSet.PricePart(FBaseGatherData.Pegs)
+  else
+    WarningMessage('当前可划分的桩号节点金额为0,无法通过金额模式进行划分。');
+end;
+
+procedure TtpMainData.TrialPeg;
+var
+  sPeg: string;
+begin
+  if InputTrialPeg(sPeg) then
+  begin
+    PegFilter.Filter(sPeg);
+    FPartTrial.FilterPegs(PegFilter, BaseGatherData.Pegs);
+  end;
+end;
+
+end.

+ 515 - 0
TenderPartition/tpMainFrm.dfm

@@ -0,0 +1,515 @@
+object tpMainForm: TtpMainForm
+  Left = 462
+  Top = 202
+  Width = 1104
+  Height = 675
+  ActiveControl = zgNoPeg
+  BorderIcons = [biSystemMenu]
+  Caption = #26631#27573#21010#20998
+  Color = clBtnFace
+  Font.Charset = DEFAULT_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -11
+  Font.Name = 'MS Sans Serif'
+  Font.Style = []
+  OldCreateOrder = False
+  Position = poMainFormCenter
+  PixelsPerInch = 96
+  TextHeight = 13
+  object jtsMainDatas: TJimTabSet
+    Left = 0
+    Top = 26
+    Width = 1096
+    Height = 21
+    Align = alTop
+    BackgroundColor = clGradientInactiveCaption
+    Font.Charset = ANSI_CHARSET
+    Font.Color = clWindowText
+    Font.Height = -12
+    Font.Name = #23435#20307
+    Font.Style = []
+    StartMargin = 0
+    SelectedColor = clWhite
+    XPSelectedColor = clWhite
+    XPUnSelectedColor = 15200496
+    Tabs.Strings = (
+      #22522#30784#20449#24687
+      #26729#21495#35797#31639
+      #26631#27573#21010#20998)
+    TabIndex = 0
+    TabPosition = jtpTop
+    TabStyle = tdsNew
+    UnselectedColor = 15200496
+    OnChange = jtsMainDatasChange
+  end
+  object jpsMain: TJimPages
+    Left = 0
+    Top = 47
+    Width = 1096
+    Height = 594
+    ActivePage = jpsMainBaseTender
+    ActivePageIndex = 0
+    Align = alClient
+    Caption = 'jpsMain'
+    object jpsMainBaseTender: TJimPage
+      Left = 0
+      Top = 0
+      Width = 1096
+      Height = 594
+      TabName = 'BaseTender'
+      Caption = 'BaseTender'
+      object labGatherResult: TJimGradLabel
+        Left = 0
+        Top = 574
+        Width = 1096
+        Height = 20
+        Align = alBottom
+        AutoSize = False
+        ColorBegin = clGradientInactiveCaption
+        ColorEnd = clGradientInactiveCaption
+        Caption = ' '#27719#24635#21518#65292#20849#21547#26729#21495#33410#28857'%d'#20010#65292#36215#28857#26729#21495#20026'%s'#65292#32456#28857#26729#21495#20026'%s'
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = [fsBold]
+        ParentFont = False
+        Layout = tlCenter
+      end
+      object sprNoPegData: TSplitter
+        Left = 390
+        Top = 0
+        Height = 574
+      end
+      object pnlNoPegData: TPanel
+        Left = 393
+        Top = 0
+        Width = 703
+        Height = 574
+        Align = alClient
+        BevelOuter = bvNone
+        TabOrder = 0
+        object labNoPegData: TJimGradLabel
+          Left = 0
+          Top = 0
+          Width = 703
+          Height = 20
+          Align = alTop
+          AutoSize = False
+          ColorBegin = clGradientInactiveCaption
+          ColorEnd = clGradientInactiveCaption
+          Caption = ' '#26080#26729#21495#25968#25454
+          Font.Charset = GB2312_CHARSET
+          Font.Color = clWindowText
+          Font.Height = -12
+          Font.Name = #23435#20307
+          Font.Style = [fsBold]
+          ParentFont = False
+          Layout = tlCenter
+        end
+        object zgNoPeg: TZJGrid
+          Left = 0
+          Top = 20
+          Width = 703
+          Height = 554
+          Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection, goShowTreeLine]
+          OptionsEx = []
+          ColCount = 8
+          ShowGridLine = False
+          DefaultColWidth = 73
+          DefaultFixedColWidth = 25
+          Selection.AlphaBlend = False
+          Selection.TransparentColor = False
+          FrozenCol = 0
+          FrozenRow = 0
+          Align = alClient
+        end
+      end
+      object pnlGatherTenders: TPanel
+        Left = 0
+        Top = 0
+        Width = 390
+        Height = 574
+        Align = alLeft
+        BevelOuter = bvNone
+        TabOrder = 1
+        object labGatherTenders: TJimGradLabel
+          Left = 0
+          Top = 0
+          Width = 390
+          Height = 20
+          Align = alTop
+          AutoSize = False
+          ColorBegin = clGradientInactiveCaption
+          ColorEnd = clGradientInactiveCaption
+          Caption = ' '#21442#19982#27719#24635#39033#30446
+          Font.Charset = GB2312_CHARSET
+          Font.Color = clWindowText
+          Font.Height = -12
+          Font.Name = #23435#20307
+          Font.Style = [fsBold]
+          ParentFont = False
+          Layout = tlCenter
+        end
+        object zgSelectTenders: TZJGrid
+          Left = 0
+          Top = 20
+          Width = 401
+          Height = 554
+          Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+          OptionsEx = []
+          ColCount = 4
+          ShowGridLine = False
+          DefaultColWidth = 73
+          DefaultFixedColWidth = 25
+          Selection.AlphaBlend = False
+          Selection.TransparentColor = False
+          FrozenCol = 0
+          FrozenRow = 0
+          Align = alLeft
+        end
+      end
+    end
+    object jpsMainTrial: TJimPage
+      Left = 0
+      Top = 0
+      Width = 1096
+      Height = 594
+      TabName = 'Trial'
+      Caption = 'Result'
+    end
+    object jpsMainPart: TJimPage
+      Left = 0
+      Top = 0
+      Width = 1096
+      Height = 594
+      TabName = 'Part'
+      Caption = 'Part'
+    end
+  end
+  object dxBarManager: TdxBarManager
+    Font.Charset = DEFAULT_CHARSET
+    Font.Color = clWindowText
+    Font.Height = -12
+    Font.Name = #23435#20307
+    Font.Style = []
+    Bars = <
+      item
+        AllowCustomizing = False
+        AllowQuickCustomizing = False
+        Caption = #33756#21333
+        DockedDockingStyle = dsTop
+        DockedLeft = 0
+        DockedTop = 0
+        DockingStyle = dsTop
+        FloatLeft = 484
+        FloatTop = 279
+        FloatClientWidth = 65
+        FloatClientHeight = 92
+        IsMainMenu = True
+        ItemLinks = <
+          item
+            Item = dxsiPart
+            Visible = True
+          end
+          item
+            Item = dxbtnTrial
+            Visible = True
+          end
+          item
+            Item = dxbtnReGather
+            Visible = True
+          end>
+        MultiLine = True
+        Name = #33756#21333
+        OneOnRow = True
+        Row = 0
+        UseOwnFont = False
+        Visible = True
+        WholeRow = True
+      end
+      item
+        BorderStyle = bbsNone
+        Caption = #35828#26126
+        DockedDockingStyle = dsTop
+        DockedLeft = 0
+        DockedTop = 26
+        DockingStyle = dsTop
+        FloatLeft = 724
+        FloatTop = 369
+        FloatClientWidth = 23
+        FloatClientHeight = 22
+        ItemLinks = <>
+        Name = #35828#26126
+        OneOnRow = True
+        Row = 1
+        ShowMark = False
+        UseOwnFont = False
+        Visible = False
+        WholeRow = False
+      end>
+    CanCustomize = False
+    Categories.Strings = (
+      #40664#35748)
+    Categories.ItemsVisibles = (
+      2)
+    Categories.Visibles = (
+      True)
+    PopupMenuLinks = <>
+    Style = bmsOffice11
+    UseSystemFont = True
+    Left = 192
+    Top = 120
+    DockControlHeights = (
+      0
+      0
+      26
+      0)
+    object dxsiPart: TdxBarSubItem
+      Caption = #26631#27573#21010#20998
+      Category = 0
+      Visible = ivAlways
+      ItemLinks = <
+        item
+          Item = dxbtnPartByLength
+          Visible = True
+        end
+        item
+          Item = dxbtnPartByPrice
+          Visible = True
+        end>
+    end
+    object dxbtnTrial: TdxBarButton
+      Caption = #26729#21495#35797#31639
+      Category = 0
+      Visible = ivAlways
+      OnClick = dxbtnTrialClick
+    end
+    object dxbtnPartByLength: TdxBarButton
+      Caption = #36317#31163#27169#24335
+      Category = 0
+      Hint = #36317#31163#27169#24335
+      Visible = ivAlways
+      OnClick = dxbtnPartByLengthClick
+    end
+    object dxbtnPartByPrice: TdxBarButton
+      Caption = #37329#39069#27169#24335
+      Category = 0
+      Hint = #37329#39069#27169#24335
+      Visible = ivAlways
+      OnClick = dxbtnPartByPriceClick
+    end
+    object dxbtnReGather: TdxBarButton
+      Caption = #20999#25442#27719#24635#39033#30446
+      Category = 0
+      Hint = #20999#25442#27719#24635#39033#30446
+      Visible = ivNever
+      OnClick = dxbtnReGatherClick
+    end
+    object dxbtnGatherGclBills: TdxBarButton
+      Caption = #27719#24635#24037#31243#37327#28165#21333
+      Category = 0
+      Hint = #27719#24635#20840#37096#26729#21495#33410#28857#19979#30340#24037#31243#37327#28165#21333
+      Visible = ivAlways
+    end
+  end
+  object saSelectTenders: TsdGridDBA
+    Columns = <
+      item
+        Title.Caption = #26631#27573#21517#31216
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Name'
+        Width = 200
+        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'
+        Width = 80
+        ReadOnly = False
+      end
+      item
+        Title.Caption = #28165#21333#34892#25968
+        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 = 'NodeCount'
+        Width = 60
+        ReadOnly = False
+      end>
+    Grid = zgSelectTenders
+    ExtendRowCount = 3
+    Options = []
+    Left = 192
+    Top = 222
+  end
+  object staNoPeg: TsdGridTreeDBA
+    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 = 120
+        ReadOnly = True
+      end
+      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'
+        Width = 80
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21517#31216
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Name'
+        Width = 200
+        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 = True
+      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 = 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 = #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 = True
+      end>
+    Grid = zgNoPeg
+    ExtendRowCount = 0
+    Options = []
+    AutoExpand = False
+    TreeOptions = []
+    TopLevelBold = True
+    Left = 548
+    Top = 227
+  end
+end

+ 153 - 0
TenderPartition/tpMainFrm.pas

@@ -0,0 +1,153 @@
+unit tpMainFrm;
+
+interface
+
+uses
+  tpMainData, tpPartTenderFme, tpPartTenderSetFme,
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, JimTabs, JimPages, dxBarExtItems, dxBar, ZJGrid, sdGridDBA,
+  ActnList, StdCtrls, JimLabels, sdGridTreeDBA, ExtCtrls;
+
+const
+  sGatherResult = ' 汇总后,共含桩号节点%d个,起点桩号为%s,终点桩号为%s,桩号节点总金额为%s';
+
+type
+  TtpMainForm = class(TForm)
+    jtsMainDatas: TJimTabSet;
+    jpsMain: TJimPages;
+    dxBarManager: TdxBarManager;
+    dxsiPart: TdxBarSubItem;
+    dxbtnTrial: TdxBarButton;
+    dxbtnPartByLength: TdxBarButton;
+    dxbtnPartByPrice: TdxBarButton;
+    dxbtnReGather: TdxBarButton;
+    jpsMainBaseTender: TJimPage;
+    zgSelectTenders: TZJGrid;
+    saSelectTenders: TsdGridDBA;
+    jpsMainTrial: TJimPage;
+    labGatherResult: TJimGradLabel;
+    jpsMainPart: TJimPage;
+    dxbtnGatherGclBills: TdxBarButton;
+    sprNoPegData: TSplitter;
+    pnlNoPegData: TPanel;
+    labNoPegData: TJimGradLabel;
+    zgNoPeg: TZJGrid;
+    staNoPeg: TsdGridTreeDBA;
+    pnlGatherTenders: TPanel;
+    labGatherTenders: TJimGradLabel;
+    procedure jtsMainDatasChange(Sender: TObject; NewTab: Integer;
+      var AllowChange: Boolean);
+    procedure dxbtnTrialClick(Sender: TObject);
+    procedure dxbtnReGatherClick(Sender: TObject);
+    procedure dxbtnPartByPriceClick(Sender: TObject);
+    procedure dxbtnPartByLengthClick(Sender: TObject);
+  private
+    FMainData: TtpMainData;
+
+    FProjects: TList; // ID类型,缓存用户选择,再次选择时加载
+    FTenders: TList; // TtpSelectTenderNode类型,缓存用户选择的标段,汇总时加载部分后期展示数据
+
+    FtpPartTrialFrame: TtpPartTenderFrame;
+    FtpPartTenderSetFrame: TtpPartTenderSetFrame;
+  public
+    constructor Create;
+    destructor Destroy; override;
+
+    function GatherBaseTenders: Boolean;
+  end;
+
+procedure PartTendersModel;
+
+implementation
+
+uses
+  ZhAPI, tpSelectTendersFrm, sdIDTree, Globals, tpSelectTenderNode,
+  mPegFilter, UtilMethods, tpNoPegDm;
+
+procedure PartTendersModel;
+var
+  tpForm: TtpMainForm;
+begin
+  tpForm := TtpMainForm.Create;
+  try
+    if tpForm.GatherBaseTenders then
+      tpForm.ShowModal; 
+  finally
+    tpForm.Free;
+  end;
+end;
+
+{$R *.dfm}
+
+constructor TtpMainForm.Create;
+begin
+  Inherited Create(nil);
+  FMainData := TtpMainData.Create;
+  saSelectTenders.DataView := FMainData.SelectTenderData.sdvTenders;
+  staNoPeg.IDTree := FMainData.BaseGatherData.NoPegData.NoPegTree;
+
+  FtpPartTrialFrame := TtpPartTenderFrame.Create;
+  FtpPartTrialFrame.PartTenderData := FMainData.PartTrial;
+  AlignControl(FtpPartTrialFrame, jpsMainTrial, alClient);
+
+  FtpPartTenderSetFrame := TtpPartTenderSetFrame.Create(FMainData.PartTenderSet);
+  AlignControl(FtpPartTenderSetFrame, jpsMainPart, alClient);
+
+  FProjects := TList.Create;
+end;
+
+destructor TtpMainForm.Destroy;
+begin
+  FtpPartTenderSetFrame.Free;
+  FtpPartTrialFrame.Free;
+  FProjects.Free;
+  FMainData.Free;
+  inherited;
+end;
+
+function TtpMainForm.GatherBaseTenders: Boolean;
+begin
+  Result := False;
+  if SelectTendersToPart(FProjects) then
+  begin
+    FMainData.GatherProjects(FProjects);
+    with FMainData.BaseGatherData.Pegs do
+      labGatherResult.Caption := Format(sGatherResult, [Count, BeginPeg, EndPeg, FormatFloat('##,###,###,###.##', TotalPrice)]);
+    Result := True;
+  end;
+end;
+
+procedure TtpMainForm.jtsMainDatasChange(Sender: TObject; NewTab: Integer;
+  var AllowChange: Boolean);
+begin
+  if (NewTab > -1) and (NewTab < jtsMainDatas.Tabs.Count) then
+    jpsMain.ActivePageIndex := NewTab;
+end;
+
+procedure TtpMainForm.dxbtnTrialClick(Sender: TObject);
+begin
+  FMainData.TrialPeg;
+  FtpPartTrialFrame.RefreshResult;
+end;
+
+procedure TtpMainForm.dxbtnReGatherClick(Sender: TObject);
+begin
+  if QuestMessage('切换汇总项目将清空当前的桩号试算、标段划分结果,是否继续?') then
+    GatherBaseTenders;
+end;
+
+procedure TtpMainForm.dxbtnPartByPriceClick(Sender: TObject);
+begin
+  FMainData.PartTenderSet.PricePart(FMainData.BaseGatherData.Pegs);
+  if jtsMainDatas.TabIndex <> 1 then
+    jtsMainDatas.TabIndex := 1;
+end;
+
+procedure TtpMainForm.dxbtnPartByLengthClick(Sender: TObject);
+begin
+  FMainData.PartTenderSet.PegPart(FMainData.BaseGatherData.Pegs);
+  if jtsMainDatas.TabIndex <> 2 then
+    jtsMainDatas.TabIndex := 2;
+end;
+
+end.

+ 94 - 0
TenderPartition/tpNoPegDm.dfm

@@ -0,0 +1,94 @@
+object tpNoPegData: TtpNoPegData
+  OldCreateOrder = False
+  Left = 650
+  Top = 456
+  Height = 258
+  Width = 215
+  object smpNoPegBills: TsdMemoryProvider
+    Left = 64
+    Top = 24
+  end
+  object sddNoPegBills: TsdDataSet
+    Active = True
+    Provider = smpNoPegBills
+    Left = 64
+    Top = 88
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65080001044E616D650608506172656E744944094669656C644E61
+      6D650608506172656E7449440844617461547970650203084461746153697A65
+      02040549734B6579080F4E65656450726F636573734E616D65080001044E616D
+      65060D4E6578745369626C696E674944094669656C644E616D65060D4E657874
+      5369626C696E6749440844617461547970650203084461746153697A65020405
+      49734B6579080F4E65656450726F636573734E616D65080001044E616D650604
+      436F6465094669656C644E616D650604436F6465084461746154797065020108
+      4461746153697A6502320549734B6579080F4E65656450726F636573734E616D
+      65080001044E616D650606425F436F6465094669656C644E616D650606425F43
+      6F64650844617461547970650201084461746153697A6502320549734B657908
+      0F4E65656450726F636573734E616D65080001044E616D6506044E616D650946
+      69656C644E616D6506044E616D65084461746154797065021808446174615369
+      7A6503C8000549734B6579080F4E65656450726F636573734E616D6508000104
+      4E616D650605556E697473094669656C644E616D650605556E69747308446174
+      61547970650218084461746153697A6502140549734B6579080F4E6565645072
+      6F636573734E616D65080001044E616D6506055072696365094669656C644E61
+      6D65060550726963650844617461547970650206084461746153697A65020805
+      49734B6579080F4E65656450726F636573734E616D65080001044E616D650608
+      5175616E74697479094669656C644E616D6506085175616E7469747908446174
+      61547970650206084461746153697A6502080549734B6579080F4E6565645072
+      6F636573734E616D65080001044E616D65060A546F74616C5072696365094669
+      656C644E616D65060A546F74616C507269636508446174615479706502060844
+      61746153697A6502080549734B6579080F4E65656450726F636573734E616D65
+      080001044E616D65060C44676E5175616E7469747931094669656C644E616D65
+      060C44676E5175616E7469747931084461746154797065020608446174615369
+      7A6502080549734B6579080F4E65656450726F636573734E616D65080001044E
+      616D65060C44676E5175616E7469747932094669656C644E616D65060C44676E
+      5175616E74697479320844617461547970650206084461746153697A65020805
+      49734B6579080F4E65656450726F636573734E616D65080000}
+  end
+  object sdvNoPegBills: TsdDataView
+    Active = True
+    DataSet = sddNoPegBills
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'Code'
+      end
+      item
+        FieldName = 'B_Code'
+      end
+      item
+        FieldName = 'Name'
+      end
+      item
+        FieldName = 'Units'
+      end
+      item
+        FieldName = 'Price'
+      end
+      item
+        FieldName = 'Quantity'
+      end
+      item
+        FieldName = 'TotalPrice'
+      end
+      item
+        FieldName = 'DgnQuantity1'
+      end
+      item
+        FieldName = 'DgnQuantity2'
+      end
+      item
+        FieldName = 'ID'
+      end
+      item
+        FieldName = 'ParentID'
+      end
+      item
+        FieldName = 'NextSiblingID'
+      end>
+    OnGetText = sdvNoPegBillsGetText
+    Left = 64
+    Top = 152
+  end
+end

+ 82 - 0
TenderPartition/tpNoPegDm.pas

@@ -0,0 +1,82 @@
+unit tpNoPegDm;
+
+interface
+
+uses
+  SysUtils, Classes, sdDB, sdProvider, sdIDTree, tpGatherTree;
+
+type
+  TtpNoPegData = class(TDataModule)
+    smpNoPegBills: TsdMemoryProvider;
+    sddNoPegBills: TsdDataSet;
+    sdvNoPegBills: TsdDataView;
+    procedure sdvNoPegBillsGetText(var Text: String;
+      ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
+      DisplayText: Boolean);
+  private
+    FNoPegTree: TsdIDTree;
+  public
+    constructor Create;
+    destructor Destroy; override;
+
+    procedure LoadData(ATree: TtpGatherTree);
+
+    property NoPegTree: TsdIDTree read FNoPegTree;
+  end;
+
+implementation
+
+{$R *.dfm}
+
+{ TtpNoPegData }
+
+constructor TtpNoPegData.Create;
+begin
+  inherited Create(nil);
+  FNoPegTree := TsdIDTree.Create;
+  FNoPegTree.KeyFieldName := 'ID';
+  FNoPegTree.ParentFieldName := 'ParentID';
+  FNoPegTree.NextSiblingFieldName := 'NextSiblingID';
+  FNoPegTree.AutoCreateKeyID := True;
+  FNoPegTree.AutoExpand := True;
+  FNoPegTree.DataView := sdvNoPegBills;
+end;
+
+destructor TtpNoPegData.Destroy;
+begin
+  FNoPegTree.Free;
+  inherited;
+end;
+
+procedure TtpNoPegData.LoadData(ATree: TtpGatherTree);
+begin
+  FNoPegTree.Active := False;
+  try
+    ATree.WriteData(sddNoPegBills);
+  finally
+    FNoPegTree.DataView := nil;
+    FNoPegTree.DataView := sdvNoPegBills;
+  end;
+end;
+
+procedure TtpNoPegData.sdvNoPegBillsGetText(var Text: String;
+  ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
+  DisplayText: Boolean);
+
+  procedure GetDisplayText;
+  begin
+    if (Pos('TotalPrice', AColumn.FieldName) > 0) or
+       (Pos('Quantity', AColumn.FieldName) > 0) or
+       (Pos('Price', AColumn.FieldName) > 0) then
+    begin
+      if AValue.AsFloat = 0 then
+        Text := '';
+    end;
+  end;
+
+begin
+  if DisplayText then
+    GetDisplayText;
+end;
+
+end.

+ 203 - 0
TenderPartition/tpPartTender.pas

@@ -0,0 +1,203 @@
+unit tpPartTender;
+
+interface
+
+uses
+  Classes, tpPeg, mPegFilter, tpPeg_GclDm, tpGatherGcl, tpPegGclGatherDm;
+
+type
+  // According to the OD Peg
+  TtpPartTender = class
+  private
+    FInPegs: TList;
+    FTotalPrice: Double;
+    FRelaPegs: TList;
+    FRelaTotalPrice: Double;
+
+    FBeginPeg: string;
+    FBeginPegNum: Double;
+    FEndPeg: string;
+    FEndPegNum: Double;
+
+    FInPegData: TtpPeg_GclData;
+    FInGclGatherData: TtpPegGclGatherData;
+    FRelaPegData: TtpPeg_GclData;
+
+    procedure ResetPegInfo(APegFilter: TPegFilter); overload;
+
+    function GetPegsTotalPrice(APegs: TList): Double;
+    procedure Calculate;
+    procedure GatherInGclBills;
+
+    procedure ExecuteFilter(APegs: TtpPegList);
+
+    function GetInPeg(AIndex: Integer): TtpPegNode;
+    function GetInPegCount: Integer;
+    function GetRelaPeg(AIndex: Integer): TtpPegNode;
+    function GetRelaPegCount: Integer;
+  public
+    constructor Create;
+    destructor Destroy; override;
+
+    procedure Clear;
+    procedure FilterPegs(APegFilter: TPegFilter; APegs: TtpPegList); overload;
+    procedure FilterPegs(ABeginPegNum, AEndPegNum: Double; APegs: TtpPegList); overload;
+
+    property BeginPeg: string read FBeginPeg;
+    property BeginPegNum: Double read FBeginPegNum;
+    property EndPeg: string read FEndPeg;
+    property EndPegNum: Double read FEndPegNum;
+
+    property InPegCount: Integer read GetInPegCount;
+    property InPeg[AIndex: Integer]: TtpPegNode read GetInPeg;
+    property TotalPrice: Double read FTotalPrice;
+
+    property RelaPegCount: Integer read GetRelaPegCount;
+    property RelaPeg[AIndex: Integer]: TtpPegNode read GetRelaPeg;
+    property RelaTotalPrice: Double read FRelaTotalPrice;
+
+    property InPegData: TtpPeg_GclData read FInPegData;
+    property InGclGatherData: TtpPegGclGatherData read FInGclGatherData;
+    property RelaPegData: TtpPeg_GclData read FRelaPegData;
+  end;
+
+implementation
+
+uses
+  ZhAPI, tpGatherTree, UtilMethods;
+
+{ TtpPartTender }
+
+procedure TtpPartTender.Calculate;
+begin
+  FTotalPrice := GetPegsTotalPrice(FInPegs);
+  FRelaTotalPrice := GetPegsTotalPrice(FRelaPegs);
+end;
+
+procedure TtpPartTender.Clear;
+begin
+  FInPegs.Clear;
+  FRelaPegs.Clear;
+end;
+
+constructor TtpPartTender.Create;
+begin
+  FInPegs := TList.Create;
+  FRelaPegs := TList.Create;
+  FInPegData := TtpPeg_GclData.Create(nil);
+  FInGclGatherData :=TtpPegGclGatherData.Create(nil);
+  FRelaPegData := TtpPeg_GclData.Create(nil);
+end;
+
+destructor TtpPartTender.Destroy;
+begin
+  Clear;
+  FRelaPegData.Free;
+  FInGclGatherData.Free;
+  FInPegData.Free;
+  FRelaPegs.Free;
+  FInPegs.Free;
+  inherited;
+end;
+
+procedure TtpPartTender.FilterPegs(APegFilter: TPegFilter; APegs: TtpPegList);
+begin
+  ResetPegInfo(APegFilter);
+  ExecuteFilter(APegs);
+end;
+
+procedure TtpPartTender.ExecuteFilter(APegs: TtpPegList);
+var
+  iPeg: Integer;
+  vPegNode: TtpPegNode;
+begin
+  for iPeg := 0 to APegs.Count - 1 do
+  begin
+    vPegNode := APegs.Peg[iPeg];
+    if vPegNode.IsPegIn(FBeginPegNum, FEndPegNum) then
+      FInPegs.Add(vPegNode)
+    else if vPegNode.IsPegRela(FBeginPegNum, FEndPegNum) then
+      FRelaPegs.Add(vPegNode);
+  end;
+  Calculate;
+
+  FInPegData.LoadData(FInPegs);
+  FRelaPegData.LoadData(FRelaPegs);
+
+  GatherInGclBills;
+end;
+
+procedure TtpPartTender.FilterPegs(ABeginPegNum, AEndPegNum: Double;
+  APegs: TtpPegList);
+begin
+  Clear;
+  FBeginPegNum := ABeginPegNum;
+  FBeginPeg := Num2Peg(FBeginPegNum);
+  FEndPegNum := AEndPegNum;
+  FEndPeg := Num2Peg(FEndPegNum);
+  ExecuteFilter(APegs);
+end;
+
+procedure TtpPartTender.GatherInGclBills;
+var
+  vGcls: TtpGatherGclList;
+  iPeg, iGcl: Integer;
+  vPeg: TtpPegNode;
+begin
+  vGcls := TtpGatherGclList.Create;
+  try
+    for iPeg := 0 to FInPegs.Count - 1 do
+    begin
+      vPeg := TtpPegNode(FInPegs.Items[iPeg]);
+      for iGcl := 0 to vPeg.RelaGclNodes.Count - 1 do
+        vGcls.GatherNode(TtpGatherTreeNode(vPeg.RelaGclNodes.Items[iGcl]), vPeg.RelaNode);
+    end;
+    FInGclGatherData.LoadGclGatherData(vGcls);
+  finally
+    vGcls.Free;
+  end;
+end;
+
+function TtpPartTender.GetInPeg(AIndex: Integer): TtpPegNode;
+begin
+  Result := TtpPegNode(FInPegs.Items[AIndex]);
+end;
+
+function TtpPartTender.GetInPegCount: Integer;
+begin
+  Result := FInPegs.Count;
+end;
+
+function TtpPartTender.GetPegsTotalPrice(APegs: TList): Double;
+var
+  iPeg: Integer;
+  vPeg: TtpPegNode;
+begin
+  Result := 0;
+  for iPeg := 0 to APegs.Count - 1 do
+  begin
+    vPeg := TtpPegNode(APegs.Items[iPeg]);
+    Result := Result + vPeg.RelaNode.TotalPrice;
+  end;
+end;
+
+function TtpPartTender.GetRelaPeg(AIndex: Integer): TtpPegNode;
+begin
+  Result := TtpPegNode(FRelaPegs.Items[AIndex]);
+end;
+
+function TtpPartTender.GetRelaPegCount: Integer;
+begin
+  Result := FRelaPegs.Count;
+end;
+
+procedure TtpPartTender.ResetPegInfo(APegFilter: TPegFilter);
+begin
+  Clear;
+  FBeginPeg := APegFilter.BeginPeg;
+  FBeginPegNum := APegFilter.BeginPegNum;
+  FEndPeg := APegFilter.EndPeg;
+  FEndPegNum := APegFilter.EndPegNum;
+end;
+
+end.

+ 153 - 0
TenderPartition/tpPartTenderFme.dfm

@@ -0,0 +1,153 @@
+object tpPartTenderFrame: TtpPartTenderFrame
+  Left = 0
+  Top = 0
+  Width = 614
+  Height = 461
+  TabOrder = 0
+  object labResult: TJimGradLabel
+    Left = 0
+    Top = 441
+    Width = 614
+    Height = 20
+    Align = alBottom
+    AutoSize = False
+    ColorBegin = clGradientInactiveCaption
+    ColorEnd = clGradientInactiveCaption
+    Caption = ' '#26729#21495'%s'#30456#20851#28165#21333#35797#31639#32467#26524#65306#33539#22260#20869#28165#21333#24635#37329#39069'%f'#65292#20854#20182#30456#20851#28165#21333#24635#37329#39069'%f'
+    Font.Charset = GB2312_CHARSET
+    Font.Color = clWindowText
+    Font.Height = -12
+    Font.Name = #23435#20307
+    Font.Style = [fsBold]
+    ParentFont = False
+    Layout = tlCenter
+    Visible = False
+  end
+  object pnlResult: TPanel
+    Left = 0
+    Top = 0
+    Width = 614
+    Height = 21
+    Align = alTop
+    BevelOuter = bvNone
+    TabOrder = 0
+    object tbResult: TToolBar
+      Left = 0
+      Top = 0
+      Width = 255
+      Height = 21
+      Align = alLeft
+      AutoSize = True
+      ButtonHeight = 21
+      ButtonWidth = 85
+      Caption = 'tbResult'
+      EdgeBorders = []
+      Flat = True
+      ShowCaptions = True
+      TabOrder = 0
+      object tobtnInPegs: TToolButton
+        Left = 0
+        Top = 0
+        Caption = ' '#33539#22260#20869#26729#21495' '
+        Down = True
+        ImageIndex = 0
+        Style = tbsCheck
+        OnClick = tobtnInPegsClick
+      end
+      object tobtnInGcls: TToolButton
+        Tag = 1
+        Left = 85
+        Top = 0
+        Caption = #33539#22260#20869#28165#21333
+        ImageIndex = 2
+        Style = tbsCheck
+        OnClick = tobtnInPegsClick
+      end
+      object tobtnRelaPegs: TToolButton
+        Tag = 2
+        Left = 170
+        Top = 0
+        Caption = ' '#20854#20182#30456#20851#26729#21495' '
+        ImageIndex = 1
+        Style = tbsCheck
+        OnClick = tobtnInPegsClick
+      end
+    end
+  end
+  object jpsPartTender: TJimPages
+    Left = 0
+    Top = 21
+    Width = 614
+    Height = 420
+    ActivePage = jpsPartTenderInPegs
+    ActivePageIndex = 0
+    Align = alClient
+    Caption = 'jpsPartTender'
+    object jpsPartTenderInPegs: TJimPage
+      Left = 0
+      Top = 0
+      Width = 614
+      Height = 420
+      TabName = 'InPegs'
+      Caption = 'InPegs'
+    end
+    object jpsPartTenderInGcls: TJimPage
+      Left = 0
+      Top = 0
+      Width = 614
+      Height = 420
+      TabName = 'InGcls'
+      Caption = 'InGcls'
+    end
+    object jpsPartTenderRelaPegs: TJimPage
+      Left = 0
+      Top = 0
+      Width = 614
+      Height = 420
+      TabName = 'RelaPegs'
+      Caption = 'RelaPegs'
+    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 = 167
+    Top = 96
+  end
+end

+ 100 - 0
TenderPartition/tpPartTenderFme.pas

@@ -0,0 +1,100 @@
+unit tpPartTenderFme;
+
+interface
+
+uses
+  tpPartTender, tpPeg_GclFme, tpPegGclGatherFme,
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, ComCtrls, ToolWin, ExtCtrls, XPMenu, JimPages, StdCtrls,
+  JimLabels;
+
+const
+  sPartResult = ' 褸뵀%s宮밑헌데桿炬써벎:렀鍋코헌데悧쏜띨%f,페儉宮밑헌데悧쏜띨%f';
+
+type
+  TtpPartTenderFrame = class(TFrame)
+    pnlResult: TPanel;
+    tbResult: TToolBar;
+    tobtnInPegs: TToolButton;
+    tobtnRelaPegs: TToolButton;
+    xpm: TXPMenu;
+    jpsPartTender: TJimPages;
+    jpsPartTenderInPegs: TJimPage;
+    jpsPartTenderRelaPegs: TJimPage;
+    labResult: TJimGradLabel;
+    tobtnInGcls: TToolButton;
+    jpsPartTenderInGcls: TJimPage;
+    procedure tobtnInPegsClick(Sender: TObject);
+  private
+    FPartTenderData: TtpPartTender;
+
+    FInPegFrame: TtpPeg_GclFrame;
+    FInGclGatherFrame: TtpPegGclGatherFrame;
+    FRelaPegFrame: TtpPeg_GclFrame;
+    procedure SetPartTenderData(const Value: TtpPartTender);
+  public
+    constructor Create;
+    destructor Destroy; override;
+
+    procedure RefreshResult;
+
+    property PartTenderData: TtpPartTender read FPartTenderData write SetPartTenderData;
+  end;
+
+implementation
+
+uses
+  UtilMethods;
+
+{$R *.dfm}
+
+{ TtpPartTenderFrame }
+
+constructor TtpPartTenderFrame.Create;
+begin
+  inherited Create(nil);
+  FInPegFrame := TtpPeg_GclFrame.Create(nil);
+  AlignControl(FInPegFrame, jpsPartTenderInPegs, alClient);
+
+  FInGclGatherFrame := TtpPegGclGatherFrame.Create(nil);
+  AlignControl(FInGclGatherFrame, jpsPartTenderInGcls, alClient);
+
+  FRelaPegFrame := TtpPeg_GclFrame.Create(nil);
+  AlignControl(FRelaPegFrame, jpsPartTenderRelaPegs, alClient);
+end;
+
+destructor TtpPartTenderFrame.Destroy;
+begin
+  FRelaPegFrame.Free;
+  FInPegFrame.Free;
+  inherited;
+end;
+
+procedure TtpPartTenderFrame.RefreshResult;
+begin
+  labResult.Caption := Format(sPartResult, [FPartTenderData.BeginPeg+'~'+FPartTenderData.EndPeg,
+      FPartTenderData.TotalPrice, FPartTenderData.RelaTotalPrice]);
+  labResult.Visible := ((FPartTenderData.InPegCount > 0) or (FPartTenderData.RelaPegCount > 0));
+end;
+
+procedure TtpPartTenderFrame.SetPartTenderData(const Value: TtpPartTender);
+begin
+  FPartTenderData := Value;
+  if Assigned(FPartTenderData) then
+  begin
+    FInPegFrame.Peg_GclData := FPartTenderData.InPegData;
+    FInGclGatherFrame.PegGclGatherData := FPartTenderData.InGclGatherData;
+    FRelaPegFrame.Peg_GclData := FPartTenderData.RelaPegData;
+    RefreshResult;
+  end;
+end;
+
+procedure TtpPartTenderFrame.tobtnInPegsClick(Sender: TObject);
+begin
+  tobtnInPegs.Down := tobtnInPegs.Tag = TToolButton(Sender).Tag;
+  tobtnInGcls.Down := tobtnInGcls.Tag = TToolButton(Sender).Tag;
+  tobtnRelaPegs.Down := tobtnRelaPegs.Tag = TToolButton(Sender).Tag;
+  jpsPartTender.ActivePageIndex := TToolButton(Sender).Tag;
+end;
+
+end.

+ 171 - 0
TenderPartition/tpPartTenderSet.pas

@@ -0,0 +1,171 @@
+unit tpPartTenderSet;
+
+interface
+
+uses
+  Classes, tpPartTender, tpPeg, tpPricePartSettingFrm;
+
+type
+  TtpPartTenderSet = class
+  private
+    FPartTenders: TList;
+    FPartPegs: TStringList;
+    FPricePartInfo: TPricePartInfo;
+
+    FSetFrame: TObject;
+
+    function GetEndPricePart(ABegin: Double; APegs: TtpPegList): Double;
+    procedure ExecutePricePart(APegs: TtpPegList);
+
+    procedure ExecutePegPart(APegs: TtpPegList);
+
+    function GetPartTender(AIndex: Integer): TtpPartTender;
+    function GetTenderCount: Integer;
+  public
+    constructor Create;
+    destructor Destroy; override;
+
+    procedure PegPart(APegs: TtpPegList);
+    procedure PricePart(APegs: TtpPegList);
+
+    property TenderCount: Integer read GetTenderCount;
+    property PartTender[AIndex: Integer]: TtpPartTender read GetPartTender;
+    property SetFrame: TObject read FSetFrame write FSetFrame;
+  end;
+
+implementation
+
+uses
+  ZhAPI, mPegFilter, tpPartTenderSetFme, Math, ProgressHintFrm,
+  SysUtils, tpPegPartSettingFrm, Forms, Controls;
+
+{ TtpPartTenderSet }
+
+constructor TtpPartTenderSet.Create;
+begin
+  FPricePartInfo := TPricePartInfo.Create;
+  FPartTenders := TList.Create;
+  FPartPegs := TStringList.Create;
+end;
+
+destructor TtpPartTenderSet.Destroy;
+begin
+  FPartPegs.Free;
+  ClearObjects(FPartTenders);
+  FPartTenders.Free;
+  FPricePartInfo.Free;
+  inherited;
+end;
+
+procedure TtpPartTenderSet.ExecutePegPart(APegs: TtpPegList);
+var
+  i: Integer;
+  vPartTender: TtpPartTender;
+begin
+  Screen.Cursor := crHourGlass;
+  try
+    ClearObjects(FPartTenders);
+    for i := 0 to FPartPegs.Count - 1 do
+    begin
+      PegFilter.Filter(FPartPegs.Strings[i]);
+      vPartTender := TtpPartTender.Create;
+      FPartTenders.Add(vPartTender);
+      vPartTender.FilterPegs(PegFilter, APegs);
+    end;
+    TtpPartTenderSetFrame(FSetFrame).RefreshData;
+  finally
+    Screen.Cursor := crDefault;
+  end;
+end;
+
+procedure TtpPartTenderSet.ExecutePricePart(APegs: TtpPegList);
+var
+  iTender: Integer;
+  fBegin, fEnd: Double;
+  vPartTender: TtpPartTender;
+begin
+  Screen.Cursor := crHourGlass;
+  ShowProgressHint('正在进行标段划分(金额模式)运算...');
+  try
+    ClearObjects(FPartTenders);
+
+    fBegin := APegs.BeginPegNum;
+    fEnd := fBegin;
+    iTender := 1;
+    while fEnd < APegs.EndPegNum do
+    begin
+      UpdateProgressHint(Format('正在划分第%d个标段...', [iTender]));
+      fEnd := GetEndPricePart(fBegin, APegs);
+
+      UpdateProgressHint(Format('正在确认第%d个标段数据...', [iTender]));
+      vPartTender := TtpPartTender.Create;
+      FPartTenders.Add(vPartTender);
+      vPartTender.FilterPegs(fBegin, fEnd, APegs);
+      fBegin := fEnd;
+      Inc(iTender);
+    end;
+    TtpPartTenderSetFrame(FSetFrame).RefreshData;
+  finally
+    CloseProgressHint;
+    Screen.Cursor := crDefault;
+  end;
+end;
+
+function TtpPartTenderSet.GetEndPricePart(ABegin: Double;
+  APegs: TtpPegList): Double;
+var
+  fEnd1, fTotalPrice1: Double;
+  fTotalPrice: Double;
+begin
+  Result := ABegin + FPricePartInfo.MinLength * 1000;
+  if Result < APegs.EndPegNum then
+  begin
+    fTotalPrice := APegs.TrialTotalPrice(ABegin, Result);
+    while (fTotalPrice < FPricePartInfo.PartPrice) and (Result < APegs.EndPegNum) do
+    begin
+      Result := Min(APegs.EndPegNum, Result + FPricePartInfo.MinStep);
+      fTotalPrice := APegs.TrialTotalPrice(ABegin, Result);
+    end;
+
+    if (APegs.EndPegNum - Result) > FPricePartInfo.MinStep then
+    begin
+      fEnd1 := Result - FPricePartInfo.MinStep;
+      fTotalPrice1 := APegs.TrialTotalPrice(ABegin, fEnd1);
+      if Abs(fTotalPrice1 - FPricePartInfo.PartPrice) < Abs(fTotalPrice - FPricePartInfo.PartPrice) then
+        Result := fEnd1;
+    end
+    else
+      Result := APegs.EndPegNum;
+  end
+  else
+    Result := APegs.EndPegNum;
+end;
+
+function TtpPartTenderSet.GetPartTender(AIndex: Integer): TtpPartTender;
+begin
+  if AIndex < FPartTenders.Count then
+    Result := TtpPartTender(FPartTenders.Items[AIndex])
+  else
+    Result := nil;
+end;
+
+function TtpPartTenderSet.GetTenderCount: Integer;
+begin
+  Result := FPartTenders.Count;
+end;
+
+procedure TtpPartTenderSet.PegPart(APegs: TtpPegList);
+begin
+  if FPartPegs.Count = 0 then
+    FPartPegs.Add(APegs.BeginPeg+'~'+APegs.EndPeg);
+  if PegPartSetting(FPartPegs) then
+    ExecutePegPart(APegs);
+end;
+
+procedure TtpPartTenderSet.PricePart(APegs: TtpPegList);
+begin
+  if PricePartSetting(FPricePartInfo) then
+    ExecutePricePart(APegs);
+end;
+
+end.

+ 71 - 0
TenderPartition/tpPartTenderSetFme.dfm

@@ -0,0 +1,71 @@
+object tpPartTenderSetFrame: TtpPartTenderSetFrame
+  Left = 0
+  Top = 0
+  Width = 1100
+  Height = 519
+  TabOrder = 0
+  object sprTenderData: TSplitter
+    Left = 250
+    Top = 0
+    Height = 519
+  end
+  object pnlPartTenders: TPanel
+    Left = 0
+    Top = 0
+    Width = 250
+    Height = 519
+    Align = alLeft
+    BevelOuter = bvNone
+    TabOrder = 0
+    object labGatherTenders: TJimGradLabel
+      Left = 0
+      Top = 0
+      Width = 250
+      Height = 20
+      Align = alTop
+      AutoSize = False
+      ColorBegin = clGradientInactiveCaption
+      ColorEnd = clGradientInactiveCaption
+      Caption = ' '#26631#27573#21010#20998#21015#34920
+      Font.Charset = GB2312_CHARSET
+      Font.Color = clWindowText
+      Font.Height = -12
+      Font.Name = #23435#20307
+      Font.Style = [fsBold]
+      ParentFont = False
+      Layout = tlCenter
+    end
+    object zgPartTendersInfo: TZJGrid
+      Left = 0
+      Top = 20
+      Width = 250
+      Height = 499
+      OptionsEx = []
+      ColCount = 2
+      ShowGridLine = False
+      DefaultColWidth = 190
+      DefaultFixedColWidth = 25
+      Selection.AlphaBlend = False
+      Selection.TransparentColor = False
+      FrozenCol = 0
+      FrozenRow = 0
+      OnCurrentChanged = zgPartTendersInfoCurrentChanged
+      Font.Charset = ANSI_CHARSET
+      Font.Color = clWindowText
+      Font.Height = -12
+      Font.Name = #23435#20307
+      Font.Style = []
+      ParentFont = False
+      Align = alClient
+    end
+  end
+  object pnlCurPartTender: TPanel
+    Left = 253
+    Top = 0
+    Width = 847
+    Height = 519
+    Align = alClient
+    BevelOuter = bvNone
+    TabOrder = 1
+  end
+end

+ 87 - 0
TenderPartition/tpPartTenderSetFme.pas

@@ -0,0 +1,87 @@
+unit tpPartTenderSetFme;
+
+interface
+
+uses
+  tpPartTenderSet, tpPartTenderFme,
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, sdGridDBA, StdCtrls, JimLabels, ZJGrid, ExtCtrls;
+
+type
+  TtpPartTenderSetFrame = class(TFrame)
+    pnlPartTenders: TPanel;
+    zgPartTendersInfo: TZJGrid;
+    labGatherTenders: TJimGradLabel;
+    pnlCurPartTender: TPanel;
+    sprTenderData: TSplitter;
+    procedure zgPartTendersInfoCurrentChanged(Sender: TObject; Col,
+      Row: Integer);
+  private
+    FPartTenderSetData: TtpPartTenderSet;
+    FCurPartTenderFrame: TtpPartTenderFrame;
+
+    procedure AssignTenderInfo;
+  public
+    constructor Create(APartTenderSetData: TtpPartTenderSet);
+    destructor Destroy; override;
+
+    procedure RefreshData;
+  end;
+
+implementation
+
+uses
+  UtilMethods, tpPartTender;
+
+{$R *.dfm}
+
+{ TtpPartTenderSetFrame }
+
+procedure TtpPartTenderSetFrame.AssignTenderInfo;
+var
+  i: Integer;
+  vPartTender: TtpPartTender;
+begin
+  zgPartTendersInfo.RowCount := FPartTenderSetData.TenderCount + 1;
+  for i := 0 to FPartTenderSetData.TenderCount - 1 do
+  begin
+    vPartTender := FPartTenderSetData.PartTender[i];
+    zgPartTendersInfo.Cells[1, i+1].Text := vPartTender.BeginPeg + '~' + vPartTender.EndPeg;
+    zgPartTendersInfo.Cells[1, i+1].Align := gaCenterLeft;
+  end;
+end;
+
+constructor TtpPartTenderSetFrame.Create(
+  APartTenderSetData: TtpPartTenderSet);
+begin
+  inherited Create(nil);
+  zgPartTendersInfo.Cells[1, 0].Text := '±ê¶Î';
+
+  FPartTenderSetData := APartTenderSetData;
+  FPartTenderSetData.SetFrame := Self;
+  FCurPartTenderFrame := TtpPartTenderFrame.Create;
+  AlignControl(FCurPartTenderFrame, pnlCurPartTender, alClient);
+end;
+
+destructor TtpPartTenderSetFrame.Destroy;
+begin
+  FCurPartTenderFrame.Free;
+  inherited;
+end;
+
+procedure TtpPartTenderSetFrame.RefreshData;
+begin
+  AssignTenderInfo;
+  FCurPartTenderFrame.PartTenderData := FPartTenderSetData.PartTender[0];
+end;
+
+procedure TtpPartTenderSetFrame.zgPartTendersInfoCurrentChanged(
+  Sender: TObject; Col, Row: Integer);
+var
+  iTender: Integer;
+begin
+  iTender := zgPartTendersInfo.CurRow - 1;
+  FCurPartTenderFrame.PartTenderData := FPartTenderSetData.PartTender[iTender];
+end;
+
+end.

+ 282 - 0
TenderPartition/tpPeg.pas

@@ -0,0 +1,282 @@
+unit tpPeg;
+
+interface
+
+uses
+  Classes, tpGatherTree, ZhAPI, mPegFilter;
+
+type
+  TtpPegNode = class
+  private
+    FRelaNode: TtpGatherTreeNode;
+
+    FRelaGclNodes: TList;
+
+    FBeginPeg: string;
+    FEndPeg: string;
+    FBeginPegNum: Double;
+    FEndPegNum: Double;
+
+    procedure LoadGclNodes(ANode: TtpGatherTreeNode);
+
+    function GetPeg: string;
+    function GetPegLength: Double;
+  public
+    constructor Create(ANode: TtpGatherTreeNode; APegFilter: TPegFilter);
+    destructor Destroy; override;
+
+    function IsPegIn(ABeginPegNum, AEndPegNum: Double): Boolean;
+    function IsPegRela(ABeginPegNum, AEndPegNum: Double): Boolean;
+    procedure LoadRelaGclNodes;
+
+    property RelaNode: TtpGatherTreeNode read FRelaNode;
+    property RelaGclNodes: TList read FRelaGclNodes;
+
+    property Peg: string read GetPeg;
+    property BeginPeg: string read FBeginPeg;
+    property EndPeg: string read FEndPeg;
+    property BeginPegNum: Double read FBeginPegNum;
+    property EndPegNum: Double read FEndPegNum;
+
+    property PegLength: Double read GetPegLength;
+  end;
+
+  TtpPegList = class
+  private
+    FPegNodes: TList;
+
+    FBeginPegNum: Double;
+    FEndPegNum: Double;
+    FTotalPrice: Double;
+
+    function GetPeg(AIndex: Integer): TtpPegNode;
+    function GetCount: Integer;
+    function GetBeginPeg: string;
+    function GetEndPeg: string;
+  public
+    constructor Create;
+    destructor Destroy; override;
+
+    procedure Clear;
+    procedure SortPegs;
+    procedure SaveDebugData(const AFileName: string);
+
+    procedure AddPegs(APeg: TtpPegNode);
+    procedure LoadRelaGclNodes;
+
+    function TrialTotalPrice(ABeginPegNum, AEndPegNum: Double): Double;
+
+    property Count: Integer read GetCount;
+    property Peg[AIndex: Integer]: TtpPegNode read GetPeg;
+
+    property BeginPegNum: Double read FBeginPegNum;
+    property BeginPeg: string read GetBeginPeg;
+    property EndPegNum: Double read FEndPegNum;
+    property EndPeg: string read GetEndPeg;
+
+    property TotalPrice: Double read FTotalPrice;
+  end;
+
+implementation
+
+uses Math, SysUtils, UtilMethods, CacheTree;
+
+{ TtpPegNode }
+
+constructor TtpPegNode.Create(ANode: TtpGatherTreeNode; APegFilter: TPegFilter);
+begin
+  FRelaNode := ANode;
+  FRelaGclNodes := TList.Create;
+
+  FBeginPeg := APegFilter.BeginPeg;
+  FBeginPegNum := APegFilter.BeginPegNum;
+  if APegFilter.EndPeg = '' then
+  begin
+    FEndPeg := FBeginPeg;
+    FEndPegNum := FBeginPegNum;
+  end
+  else
+  begin
+    FEndPeg := APegFilter.EndPeg;
+    FEndPegNum := APegFilter.EndPegNum;
+  end;
+end;
+
+destructor TtpPegNode.Destroy;
+begin
+  FRelaGclNodes.Free;
+  inherited;
+end;
+
+function TtpPegNode.GetPeg: string;
+begin
+  Result := RelaNode.Name;
+end;
+
+function TtpPegNode.GetPegLength: Double;
+begin
+  Result := FEndPegNum - FBeginPegNum;
+end;
+
+function TtpPegNode.IsPegIn(ABeginPegNum, AEndPegNum: Double): Boolean;
+begin
+  Result := (FBeginPegNum >= ABeginPegNum) and (FEndPegNum <= AEndPegNum);
+end;
+
+function TtpPegNode.IsPegRela(ABeginPegNum, AEndPegNum: Double): Boolean;
+begin
+  Result := ((FBeginPegNum < ABeginPegNum) and (FEndPegNum > ABeginPegNum)) or
+            ((FBeginPegNum < AEndPegNum) and (FEndPegNum > AEndPegNum));
+end;
+
+procedure TtpPegNode.LoadGclNodes(ANode: TtpGatherTreeNode);
+var
+  vChild: TtpGatherTreeNode;
+begin
+  if not Assigned(ANode) then Exit;
+
+  if Assigned(ANode.FirstChild) then
+  begin
+    vChild := TtpGatherTreeNode(ANode.FirstChild);
+    while Assigned(vChild) do
+    begin
+      LoadGclNodes(vChild);
+      vChild := TtpGatherTreeNode(vChild.NextSibling);
+    end;
+  end
+  else if ANode.B_Code <> '' then
+  begin
+    FRelaGclNodes.Add(ANode);
+    ANode.RelaPeg := True;
+  end;
+end;
+
+procedure TtpPegNode.LoadRelaGclNodes;
+begin
+  FRelaGclNodes.Clear;
+  LoadGclNodes(FRelaNode);
+end;
+
+{ TtpPegList }
+
+procedure TtpPegList.Clear;
+begin
+  FTotalPrice := 0;
+  ClearObjects(FPegNodes);
+end;
+
+constructor TtpPegList.Create;
+begin
+  FPegNodes := TList.Create;
+  FBeginPegNum := 0;
+  FEndPegNum := 0;
+  FTotalPrice := 0;
+end;
+
+destructor TtpPegList.Destroy;
+begin
+  Clear;
+  FPegNodes.Free;
+  inherited;
+end;
+
+function TtpPegList.GetPeg(AIndex: Integer): TtpPegNode;
+begin
+  Result := TtpPegNode(FPegNodes.Items[AIndex]);
+end;
+
+function TtpPegList.GetCount: Integer;
+begin
+  Result := FPegNodes.Count;
+end;
+
+procedure TtpPegList.SaveDebugData(const AFileName: string);
+var
+  i: Integer;
+  sgs: TStringList;
+  vPeg: TtpPegNode;
+begin
+  sgs := TStringList.Create;
+  try
+    for i := 0 to Count - 1 do
+    begin
+      vPeg := Peg[i];
+      sgs.Add(Format('×®ºÅ%s: Æðµã: %f ÖÕµã: %f', [vPeg.Peg, vPeg.BeginPegNum, vPeg.EndPegNum]));
+    end;
+  finally
+    sgs.SaveToFile(AFileName);
+    sgs.Free;
+  end;
+end;
+
+procedure TtpPegList.SortPegs;
+
+  function PegCompare(Item1, Item2: Pointer): Integer;
+  var
+    vPeg1, vPeg2: TtpPegNode;
+  begin
+    vPeg1 := TtpPegNode(Item1);
+    vPeg2 := TtpPegNode(Item2);
+    if vPeg1.BeginPegNum > vPeg2.BeginPegNum then
+      Result := 1
+    else if vPeg1.BeginPegNum < vPeg2.BeginPegNum then
+      Result := -1
+    else if vPeg1.PegLength > vPeg2.PegLength then
+      Result := 1
+    else if vPeg1.PegLength < vPeg2.PegLength then
+      Result := -1
+    else
+      Result := 0;
+  end;
+
+begin
+  FPegNodes.Sort(@PegCompare);
+end;
+
+procedure TtpPegList.AddPegs(APeg: TtpPegNode);
+begin
+  FPegNodes.Add(APeg);
+  FBeginPegNum := Min(FBeginPegNum, APeg.BeginPegNum);
+  FEndPegNum := Max(FEndPegNum, APeg.EndPegNum);
+
+  FTotalPrice := FTotalPrice + APeg.RelaNode.TotalPrice;
+end;
+
+procedure TtpPegList.LoadRelaGclNodes;
+var
+  iPeg: Integer;
+  vPeg: TtpPegNode;
+begin
+  for iPeg := 0 to FPegNodes.Count - 1 do
+  begin
+    vPeg := TtpPegNode(FPegNodes.Items[iPeg]);
+    vPeg.LoadRelaGclNodes;
+  end;
+end;
+
+function TtpPegList.GetBeginPeg: string;
+begin
+  Result := Num2Peg(FBeginPegNum);
+end;
+
+function TtpPegList.GetEndPeg: string;
+begin
+  Result := Num2Peg(FEndPegNum);
+end;
+
+function TtpPegList.TrialTotalPrice(ABeginPegNum,
+  AEndPegNum: Double): Double;
+var
+  iPeg: Integer;
+  vPegNode: TtpPegNode;
+begin
+  Result := 0;
+  for iPeg := 0 to FPegNodes.Count - 1 do
+  begin
+    vPegNode := Peg[iPeg];
+    if vPegNode.IsPegIn(ABeginPegNum, AEndPegNum) then
+      Result := Result + vPegNode.RelaNode.TotalPrice;
+  end;
+end;
+
+end.

+ 173 - 0
TenderPartition/tpPegBlock.pas

@@ -0,0 +1,173 @@
+unit tpPegBlock;
+
+interface
+
+uses
+  Classes, tpPeg, Math;
+
+type
+  TtpPegBlock = class
+  private
+    FPegs: TList;
+
+    FBeginPeg: TtpPegNode;
+    FEndPeg: TtpPegNode;
+    FBeginNum: Double;
+    FEndNum: Double;
+
+    FTotalPrice: Double;
+    function GetPeg(AIndex: Integer): TtpPegNode;
+    function GetPegCount: Integer;
+    function GetLength: Double;
+  public
+    constructor Create(APeg: TtpPegNode);
+    destructor Destroy; override;
+
+    procedure AddPeg(APeg: TtpPegNode);
+    function IsRelaPeg(APeg: TtpPegNode; ARange: Double): Boolean;
+
+    property BeginNum: Double read FBeginNum;
+    property EndNum: Double read FEndNum;
+
+    property BeginPeg: TtpPegNode read FBeginPeg;
+    property EndPeg: TtpPegNode read FEndPeg;
+
+    property Length: Double read GetLength;
+    property TotalPrice: Double read FTotalPrice;
+
+    property PegCount: Integer read GetPegCount;
+    property Peg[AIndex: Integer]: TtpPegNode read GetPeg;
+  end;
+
+  TtpPegBlockList = class
+  private
+    FBlocks: TList;
+    function GetBlockCount: Integer;
+    function GetPegBlock(AIndex: Integer): TtpPegBlock;
+  public
+    constructor Create;
+    destructor Destroy; override;
+
+    procedure Clear;
+
+    property BlockCount: Integer read GetBlockCount;
+    property PegBlock[AIndex: Integer]: TtpPegBlock read GetPegBlock;
+  end;
+
+implementation
+
+uses
+  ZhAPI;
+
+{ TtpPegBlock }
+
+procedure TtpPegBlock.AddPeg(APeg: TtpPegNode);
+begin
+  FPegs.Add(APeg);
+  if APeg.BeginPegNum < FBeginNum then
+  begin
+    FBeginNum := APeg.BeginPegNum;
+    FBeginPeg := APeg
+  end;
+  if APeg.EndPegNum > FEndNum then
+  begin
+    FEndNum := APeg.EndPegNum;
+    FEndPeg := APeg;
+  end;
+  FTotalPrice := FTotalPrice + APeg.RelaNode.TotalPrice;
+end;
+
+constructor TtpPegBlock.Create(APeg: TtpPegNode);
+begin
+  FPegs := TList.Create;
+  FPegs.Add(APeg);
+  FBeginNum := APeg.BeginPegNum;
+  FEndNum := APeg.EndPegNum;
+  FBeginPeg := APeg;
+  FEndPeg := APeg;
+  FTotalPrice := APeg.RelaNode.TotalPrice;
+end;
+
+destructor TtpPegBlock.Destroy;
+begin
+  FPegs.Free;
+  inherited;
+end;
+
+function TtpPegBlock.GetLength: Double;
+begin
+  Result := FEndNum - FBeginNum;
+end;
+
+function TtpPegBlock.GetPeg(AIndex: Integer): TtpPegNode;
+begin
+  Result := TtpPegNode(FPegs.Items[AIndex]);
+end;
+
+function TtpPegBlock.GetPegCount: Integer;
+begin
+  Result := FPegs.Count;
+end;
+
+function TtpPegBlock.IsRelaPeg(APeg: TtpPegNode; ARange: Double): Boolean;
+var
+  fRela: Double;
+begin
+  if APeg.PegLength > 0 then
+  begin
+    fRela := 0;
+    if (APeg.BeginPegNum <= FBeginNum) then
+    begin
+      if (APeg.EndPegNum > FBeginNum) and (APeg.EndPegNum < FEndNum) then
+        fRela := APeg.EndPegNum - FBeginNum
+      else if APeg.EndPegNum >= FEndNum then
+        fRela := Length;
+    end
+    else if (APeg.BeginPegNum > FBeginNum) and (APeg.BeginPegNum < FEndNum) then
+    begin
+      if (APeg.EndPegNum > FBeginNum) and (APeg.EndPegNum < FEndNum) then
+        fRela := APeg.EndPegNum - APeg.BeginPegNum
+      else if (APeg.EndPegNum >= FEndNum) then
+        fRela := FEndNum - APeg.BeginPegNum;
+    end
+    else
+      fRela := 0;
+    Result := (fRela <> 0) and (fRela >= Min(Min(Length, APeg.PegLength), ARange));
+  end
+  else if APeg.PegLength = 0 then
+    Result := (APeg.BeginPegNum > FBeginNum) and (APeg.BeginPegNum < FEndNum)
+  else
+    Result := False;
+end;
+
+{ TtpPegBlockList }
+
+procedure TtpPegBlockList.Clear;
+begin
+  ClearObjects(FBlocks);
+  FBlocks.Free;
+end;
+
+constructor TtpPegBlockList.Create;
+begin
+  FBlocks := TList.Create;
+end;
+
+destructor TtpPegBlockList.Destroy;
+begin
+  Clear;
+  FBlocks.Free;
+  inherited;
+end;
+
+function TtpPegBlockList.GetBlockCount: Integer;
+begin
+  Result := FBlocks.Count;
+end;
+
+function TtpPegBlockList.GetPegBlock(AIndex: Integer): TtpPegBlock;
+begin
+  Result := TtpPegBlock(FBlocks.Items[AIndex]);
+end;
+
+end.

+ 131 - 0
TenderPartition/tpPegGclGatherDm.dfm

@@ -0,0 +1,131 @@
+object tpPegGclGatherData: TtpPegGclGatherData
+  OldCreateOrder = False
+  Left = 712
+  Top = 443
+  Height = 268
+  Width = 322
+  object smpGclGather: TsdMemoryProvider
+    Left = 48
+    Top = 24
+  end
+  object sddGclGather: TsdDataSet
+    Active = True
+    Provider = smpGclGather
+    Left = 48
+    Top = 88
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65080001044E616D650609496E646578436F6465094669656C644E
+      616D650609496E646578436F6465084461746154797065021808446174615369
+      7A6502320549734B6579080F4E65656450726F636573734E616D65080001044E
+      616D650606425F436F6465094669656C644E616D650606425F436F6465084461
+      7461547970650201084461746153697A6502320549734B6579080F4E65656450
+      726F636573734E616D65080001044E616D6506044E616D65094669656C644E61
+      6D6506044E616D650844617461547970650218084461746153697A6503C80005
+      49734B6579080F4E65656450726F636573734E616D65080001044E616D650605
+      556E697473094669656C644E616D650605556E69747308446174615479706502
+      18084461746153697A6502140549734B6579080F4E65656450726F636573734E
+      616D65080001044E616D6506055072696365094669656C644E616D6506055072
+      6963650844617461547970650206084461746153697A6502080549734B657908
+      0F4E65656450726F636573734E616D65080001044E616D6506085175616E7469
+      7479094669656C644E616D6506085175616E7469747908446174615479706502
+      06084461746153697A6502080549734B6579080F4E65656450726F636573734E
+      616D65080001044E616D65060A546F74616C5072696365094669656C644E616D
+      65060A546F74616C50726963650844617461547970650206084461746153697A
+      6502080549734B6579080F4E65656450726F636573734E616D65080000}
+  end
+  object sdvGclGather: TsdDataView
+    Active = True
+    DataSet = sddGclGather
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'ID'
+      end
+      item
+        FieldName = 'B_Code'
+      end
+      item
+        FieldName = 'Name'
+      end
+      item
+        FieldName = 'Units'
+      end
+      item
+        FieldName = 'Price'
+      end
+      item
+        FieldName = 'Quantity'
+      end
+      item
+        FieldName = 'TotalPrice'
+      end>
+    OnCurrentChanged = sdvGclGatherCurrentChanged
+    Left = 48
+    Top = 152
+  end
+  object smpGclRela: TsdMemoryProvider
+    Left = 152
+    Top = 24
+  end
+  object sddGclRela: TsdDataSet
+    Active = True
+    Provider = smpGclRela
+    Left = 152
+    Top = 88
+    FieldListData = {
+      0101044E616D65060B44657461696C47636C4944094669656C644E616D65060B
+      44657461696C47636C49440844617461547970650203084461746153697A6502
+      040549734B6579080F4E65656450726F636573734E616D65080001044E616D65
+      060547636C4944094669656C644E616D65060547636C49440844617461547970
+      650203084461746153697A6502040549734B6579080F4E65656450726F636573
+      734E616D65080001044E616D650608506567586D6A4944094669656C644E616D
+      650608506567586D6A49440844617461547970650203084461746153697A6502
+      040549734B6579080F4E65656450726F636573734E616D65080001044E616D65
+      060A506567586D6A436F6465094669656C644E616D65060A506567586D6A436F
+      64650844617461547970650201084461746153697A6502320549734B6579080F
+      4E65656450726F636573734E616D65080001044E616D65060A506567586D6A4E
+      616D65094669656C644E616D65060A506567586D6A4E616D6508446174615479
+      70650218084461746153697A6503C8000549734B6579080F4E65656450726F63
+      6573734E616D65080001044E616D65060B506567586D6A556E69747309466965
+      6C644E616D65060B506567586D6A556E69747308446174615479706502180844
+      61746153697A6502140549734B6579080F4E65656450726F636573734E616D65
+      080001044E616D6506085175616E74697479094669656C644E616D6506085175
+      616E746974790844617461547970650206084461746153697A6502080549734B
+      6579080F4E65656450726F636573734E616D65080001044E616D65060A546F74
+      616C5072696365094669656C644E616D65060A546F74616C5072696365084461
+      7461547970650206084461746153697A6502080549734B6579080F4E65656450
+      726F636573734E616D65080000}
+  end
+  object sdvGclRela: TsdDataView
+    Active = True
+    DataSet = sddGclRela
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'ID'
+      end
+      item
+        FieldName = 'GclBillsID'
+      end
+      item
+        FieldName = 'PegXmjCode'
+      end
+      item
+        FieldName = 'PegXmjName'
+      end
+      item
+        FieldName = 'PegXmjUnits'
+      end
+      item
+        FieldName = 'Quantity'
+      end
+      item
+        FieldName = 'TotalPrice'
+      end>
+    OnFilterRecord = sdvGclRelaFilterRecord
+    Left = 152
+    Top = 152
+  end
+end

+ 124 - 0
TenderPartition/tpPegGclGatherDm.pas

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

+ 262 - 0
TenderPartition/tpPegGclGatherFme.dfm

@@ -0,0 +1,262 @@
+object tpPegGclGatherFrame: TtpPegGclGatherFrame
+  Left = 0
+  Top = 0
+  Width = 685
+  Height = 513
+  TabOrder = 0
+  object sprPeg_Gcl: TSplitter
+    Left = 0
+    Top = 310
+    Width = 685
+    Height = 3
+    Cursor = crVSplit
+    Align = alBottom
+  end
+  object zgGclGather: TZJGrid
+    Left = 0
+    Top = 0
+    Width = 685
+    Height = 310
+    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
+  object zgGclRela: TZJGrid
+    Left = 0
+    Top = 313
+    Width = 685
+    Height = 200
+    Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+    OptionsEx = []
+    ColCount = 6
+    ShowGridLine = False
+    DefaultColWidth = 73
+    DefaultFixedColWidth = 25
+    Selection.AlphaBlend = False
+    Selection.TransparentColor = False
+    FrozenCol = 0
+    FrozenRow = 0
+    Align = alBottom
+  end
+  object saGclGather: 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 = False
+      end
+      item
+        Title.Caption = #21517#31216
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Name'
+        Width = 200
+        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 = True
+      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 = 80
+        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 = 80
+        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'
+        Width = 80
+        ReadOnly = True
+      end>
+    Grid = zgGclGather
+    ExtendRowCount = 0
+    Options = []
+    Left = 120
+    Top = 88
+  end
+  object saGclRela: 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 = 'PegXmjCode'
+        Width = 120
+        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 = 'PegXmjName'
+        Width = 200
+        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 = 'PegXmjUnits'
+        Width = 45
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #25968#37327
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taRightJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Quantity'
+        Width = 80
+        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'
+        Width = 80
+        ReadOnly = True
+      end>
+    Grid = zgGclRela
+    ExtendRowCount = 0
+    Options = []
+    Left = 120
+    Top = 360
+  end
+end

+ 39 - 0
TenderPartition/tpPegGclGatherFme.pas

@@ -0,0 +1,39 @@
+unit tpPegGclGatherFme;
+
+interface
+
+uses
+  tpPegGclGatherDm,
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, ExtCtrls, sdGridDBA, ZJGrid;
+
+type
+  TtpPegGclGatherFrame = class(TFrame)
+    zgGclGather: TZJGrid;
+    saGclGather: TsdGridDBA;
+    sprPeg_Gcl: TSplitter;
+    zgGclRela: TZJGrid;
+    saGclRela: TsdGridDBA;
+  private
+    FPegGclGatherData: TtpPegGclGatherData;
+    procedure SetPegGclGatherData(const Value: TtpPegGclGatherData);
+  public
+    property PegGclGatherData: TtpPegGclGatherData read FPegGclGatherData write SetPegGclGatherData;
+  end;
+
+implementation
+
+{$R *.dfm}
+
+{ TtpPegGclGatherFrame }
+
+procedure TtpPegGclGatherFrame.SetPegGclGatherData(
+  const Value: TtpPegGclGatherData);
+begin
+  FPegGclGatherData := Value;
+
+  saGclGather.DataView := FPegGclGatherData.sdvGclGather;
+  saGclRela.DataView := FPegGclGatherData.sdvGclRela;
+end;
+
+end.

+ 79 - 0
TenderPartition/tpPegPartSettingFrm.dfm

@@ -0,0 +1,79 @@
+object tpPegPartSettingForm: TtpPegPartSettingForm
+  Left = 631
+  Top = 424
+  Width = 392
+  Height = 341
+  Caption = #26631#27573#21010#20998'-'#36317#31163#27169#24335
+  Color = clBtnFace
+  Font.Charset = ANSI_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -12
+  Font.Name = #23435#20307
+  Font.Style = []
+  OldCreateOrder = False
+  DesignSize = (
+    384
+    307)
+  PixelsPerInch = 96
+  TextHeight = 12
+  object lblHint: TLabel
+    Left = 8
+    Top = 32
+    Width = 192
+    Height = 12
+    Caption = #35831#36755#20837'%s'#20043#38388'%d'#20010#26631#27573#30340#32456#28857#26729#21495#65306
+  end
+  object leCount: TLabeledEdit
+    Left = 88
+    Top = 8
+    Width = 121
+    Height = 18
+    Ctl3D = False
+    EditLabel.Width = 78
+    EditLabel.Height = 12
+    EditLabel.Caption = #21010#20998#26631#27573#25968#65306' '
+    LabelPosition = lpLeft
+    ParentCtl3D = False
+    TabOrder = 0
+    OnChange = leCountChange
+    OnKeyPress = leCountKeyPress
+  end
+  object zgTenders: TZJGrid
+    Left = 8
+    Top = 56
+    Width = 369
+    Height = 217
+    OptionsEx = []
+    ColCount = 3
+    ShowGridLine = False
+    DefaultColWidth = 150
+    DefaultFixedColWidth = 25
+    Selection.AlphaBlend = False
+    Selection.TransparentColor = False
+    FrozenCol = 0
+    FrozenRow = 0
+    OnCellTextChanged = zgTendersCellTextChanged
+    OnCellCanEdit = zgTendersCellCanEdit
+    Anchors = [akLeft, akTop, akRight, akBottom]
+  end
+  object btnOk: TButton
+    Left = 239
+    Top = 280
+    Width = 65
+    Height = 21
+    Anchors = [akRight, akBottom]
+    Caption = #30830' '#23450
+    TabOrder = 2
+    OnClick = btnOkClick
+  end
+  object btnCancel: TButton
+    Left = 313
+    Top = 280
+    Width = 65
+    Height = 21
+    Anchors = [akRight, akBottom]
+    Caption = #21462' '#28040
+    ModalResult = 2
+    TabOrder = 3
+  end
+end

+ 185 - 0
TenderPartition/tpPegPartSettingFrm.pas

@@ -0,0 +1,185 @@
+unit tpPegPartSettingFrm;
+
+interface
+
+uses
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, StdCtrls, ZJGrid, ExtCtrls;
+
+type
+  TtpPegPartSettingForm = class(TForm)
+    leCount: TLabeledEdit;
+    zgTenders: TZJGrid;
+    lblHint: TLabel;
+    btnOk: TButton;
+    btnCancel: TButton;
+    procedure leCountKeyPress(Sender: TObject; var Key: Char);
+    procedure leCountChange(Sender: TObject);
+    procedure zgTendersCellCanEdit(Sender: TObject; const ACoord: TPoint;
+      var Allow: Boolean);
+    procedure zgTendersCellTextChanged(Sender: TObject; Col, Row: Integer);
+    procedure btnOkClick(Sender: TObject);
+  private
+    FBeginPeg: string;
+    FEndPeg: string;
+
+    function CheckEmptyPeg: Boolean;
+
+    procedure Init(ACount: Integer);
+    procedure LoadHistoryData(APartPegs: TStringList);
+  public
+    constructor Create(APartPegs: TStringList);
+    destructor Destroy; override;
+
+    procedure AssignResult(APegs: TStringList);
+  end;
+
+function PegPartSetting(APartPegs: TStringList): Boolean;
+
+implementation
+
+uses
+  mPegFilter, UtilMethods;
+
+function PegPartSetting(APartPegs: TStringList): Boolean;
+var
+  SetForm: TtpPegPartSettingForm;
+begin
+  SetForm := TtpPegPartSettingForm.Create(APartPegs);
+  try
+    Result := SetForm.ShowModal = mrOk;
+    if Result then
+      SetForm.AssignResult(APartPegs);
+  finally
+    SetForm.Free;
+  end;
+end;
+
+{$R *.dfm}
+
+procedure TtpPegPartSettingForm.leCountKeyPress(Sender: TObject;
+  var Key: Char);
+begin
+  if not (Key in ['0'..'9', #8, #13]) then
+    Key := #0;
+end;
+
+procedure TtpPegPartSettingForm.leCountChange(Sender: TObject);
+var
+  iCount: Integer;
+begin
+  iCount := StrToIntDef(leCount.Text, 0);
+  if iCount <= 30 then
+  begin
+    if iCount = 1 then
+      lblHint.Caption := '仅划分为1个标段'
+    else
+      lblHint.Caption := Format('请输入%s~%s之间的前%d个标段的终点桩号:', [FBeginPeg, FEndPeg, iCount-1]);
+    Init(iCount);
+  end
+  else
+    WarningMessage('最多仅支持划分为30个标段。');
+end;
+
+procedure TtpPegPartSettingForm.zgTendersCellCanEdit(Sender: TObject;
+  const ACoord: TPoint; var Allow: Boolean);
+begin
+  Allow := (ACoord.X = 2) and (ACoord.Y > 0) and (ACoord.Y < zgTenders.RowCount-1);
+end;
+
+constructor TtpPegPartSettingForm.Create(APartPegs: TStringList);
+begin
+  inherited Create(nil);
+  LoadHistoryData(APartPegs);
+end;
+
+destructor TtpPegPartSettingForm.Destroy;
+begin
+  inherited;
+end;
+
+procedure TtpPegPartSettingForm.Init(ACount: Integer);
+var
+  iRow: Integer;
+begin
+  zgTenders.RowCount := ACount+1;
+  zgTenders.Cells[1, 0].Text := '起点桩号';
+  zgTenders.Cells[2, 0].Text := '终点桩号';
+  zgTenders.Cells[1, 1].Text := FBeginPeg;
+  for iRow := 1 to zgTenders.RowCount - 1 do
+  begin
+    zgTenders.Cells[1, iRow].Color := clSilver;
+    zgTenders.Cells[1, iRow].Align := gaCenterLeft;
+    zgTenders.Cells[2, iRow].Color := clWindow;
+    zgTenders.Cells[2, iRow].Align := gaCenterLeft;
+  end;
+  zgTenders.Cells[2, zgTenders.RowCount-1].Text := FEndPeg;
+  zgTenders.Cells[2, zgTenders.RowCount-1].Color := clSilver;
+end;
+
+procedure TtpPegPartSettingForm.LoadHistoryData(APartPegs: TStringList);
+var
+  iPeg: Integer;
+begin
+  PegFilter.Filter(APartPegs.Strings[0]);
+  FBeginPeg := PegFilter.BeginPeg;
+  if APartPegs.Count > 1 then
+  begin
+    PegFilter.Filter(APartPegs.Strings[APartPegs.Count-1]);
+    FEndPeg := PegFilter.EndPeg;
+  end
+  else
+    FEndPeg := PegFilter.EndPeg;
+
+  leCount.Text := IntToStr(APartPegs.Count);
+
+  if APartPegs.Count = 1 then Exit;
+  for iPeg := 1 to APartPegs.Count - 1 do
+  begin
+    PegFilter.Filter(APartPegs.Strings[iPeg]);
+    zgTenders.Cells[2, iPeg].Text := PegFilter.BeginPeg;
+  end;
+end;
+
+procedure TtpPegPartSettingForm.zgTendersCellTextChanged(Sender: TObject;
+  Col, Row: Integer);
+begin
+  if (Col = 2) and (Row > 0) and (Row < zgTenders.RowCount-1) then
+    zgTenders.Cells[Col-1, Row+1].Text := zgTenders.Cells[Col, Row].Text;
+end;
+
+procedure TtpPegPartSettingForm.AssignResult(APegs: TStringList);
+var
+  iRow: Integer;
+  sPeg: string;
+begin
+  APegs.Clear;
+  for iRow := 1 to zgTenders.RowCount - 1 do
+  begin
+    sPeg := zgTenders.Cells[1, iRow].Text + '~' + zgTenders.Cells[2, iRow].Text;
+    APegs.Add(sPeg);
+  end;
+end;
+
+procedure TtpPegPartSettingForm.btnOkClick(Sender: TObject);
+begin
+  if CheckEmptyPeg then
+    WarningMessage('请填写需要的桩号信息。')
+  else
+    ModalResult := mrOk;
+end;
+
+function TtpPegPartSettingForm.CheckEmptyPeg: Boolean;
+var
+  iRow: Integer;
+begin
+  Result := False;
+  for iRow := 1 to zgTenders.RowCount - 1 do
+  begin
+    Result := (zgTenders.Cells[1, iRow].Text = '') or
+              (zgTenders.Cells[2, iRow].Text = '');
+    if Result then Break;
+  end;
+end;
+
+end.

+ 132 - 0
TenderPartition/tpPeg_GclDm.dfm

@@ -0,0 +1,132 @@
+object tpPeg_GclData: TtpPeg_GclData
+  OldCreateOrder = False
+  Left = 581
+  Top = 368
+  Height = 246
+  Width = 244
+  object smpPeg: TsdMemoryProvider
+    Left = 56
+    Top = 16
+  end
+  object sddPeg: TsdDataSet
+    Active = True
+    Provider = smpPeg
+    Left = 56
+    Top = 80
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65080001044E616D650604436F6465094669656C644E616D650604
+      436F64650844617461547970650201084461746153697A6502320549734B6579
+      080F4E65656450726F636573734E616D65080001044E616D6506044E616D6509
+      4669656C644E616D6506044E616D650844617461547970650218084461746153
+      697A6503C8000549734B6579080F4E65656450726F636573734E616D65080001
+      044E616D650605556E697473094669656C644E616D650605556E697473084461
+      7461547970650218084461746153697A6502140549734B6579080F4E65656450
+      726F636573734E616D65080001044E616D65060A546F74616C50726963650946
+      69656C644E616D65060A546F74616C5072696365084461746154797065020608
+      4461746153697A6502080549734B6579080F4E65656450726F636573734E616D
+      65080001044E616D650608426567696E506567094669656C644E616D65060842
+      6567696E5065670844617461547970650201084461746153697A650232054973
+      4B6579080F4E65656450726F636573734E616D65080001044E616D65060B4265
+      67696E5065674E756D094669656C644E616D65060B426567696E5065674E756D
+      0844617461547970650206084461746153697A6502080549734B6579080F4E65
+      656450726F636573734E616D65080001044E616D650606456E64506567094669
+      656C644E616D650606456E645065670844617461547970650201084461746153
+      697A6502320549734B6579080F4E65656450726F636573734E616D6508000104
+      4E616D650609456E645065674E756D094669656C644E616D650609456E645065
+      674E756D0844617461547970650206084461746153697A6502080549734B6579
+      080F4E65656450726F636573734E616D65080000}
+  end
+  object sdvPeg: TsdDataView
+    Active = True
+    DataSet = sddPeg
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'Code'
+      end
+      item
+        FieldName = 'Name'
+      end
+      item
+        FieldName = 'Units'
+      end
+      item
+        FieldName = 'TotalPrice'
+      end
+      item
+        FieldName = 'BeginPeg'
+      end
+      item
+        FieldName = 'BeginPegNum'
+      end
+      item
+        FieldName = 'EndPeg'
+      end
+      item
+        FieldName = 'EndPegNum'
+      end>
+    OnCurrentChanged = sdvPegCurrentChanged
+    Left = 56
+    Top = 144
+  end
+  object smpGclBills: TsdMemoryProvider
+    Left = 144
+    Top = 17
+  end
+  object sddGclBills: TsdDataSet
+    Active = True
+    Provider = smpGclBills
+    Left = 144
+    Top = 80
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65080001044E616D6506055065674944094669656C644E616D6506
+      0550656749440844617461547970650203084461746153697A6502040549734B
+      6579080F4E65656450726F636573734E616D65080001044E616D650606425F43
+      6F6465094669656C644E616D650606425F436F64650844617461547970650201
+      084461746153697A6502320549734B6579080F4E65656450726F636573734E61
+      6D65080001044E616D6506044E616D65094669656C644E616D6506044E616D65
+      0844617461547970650218084461746153697A6503C8000549734B6579080F4E
+      65656450726F636573734E616D65080001044E616D650605556E697473094669
+      656C644E616D650605556E697473084461746154797065020108446174615369
+      7A6502140549734B6579080F4E65656450726F636573734E616D65080001044E
+      616D6506055072696365094669656C644E616D65060550726963650844617461
+      547970650206084461746153697A6502080549734B6579080F4E65656450726F
+      636573734E616D65080001044E616D6506085175616E74697479094669656C64
+      4E616D6506085175616E74697479084461746154797065020608446174615369
+      7A6502080549734B6579080F4E65656450726F636573734E616D65080001044E
+      616D65060A546F74616C5072696365094669656C644E616D65060A546F74616C
+      50726963650844617461547970650206084461746153697A6502080549734B65
+      79080F4E65656450726F636573734E616D65080000}
+  end
+  object sdvGclBills: TsdDataView
+    Active = True
+    DataSet = sddGclBills
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'B_Code'
+      end
+      item
+        FieldName = 'Name'
+      end
+      item
+        FieldName = 'Units'
+      end
+      item
+        FieldName = 'Price'
+      end
+      item
+        FieldName = 'Quantity'
+      end
+      item
+        FieldName = 'TotalPrice'
+      end>
+    OnFilterRecord = sdvGclBillsFilterRecord
+    Left = 144
+    Top = 144
+  end
+end

+ 131 - 0
TenderPartition/tpPeg_GclDm.pas

@@ -0,0 +1,131 @@
+unit tpPeg_GclDm;
+
+interface
+
+uses
+  SysUtils, Classes, sdDB, sdProvider, tpPeg;
+
+type
+  TtpPeg_GclData = class(TDataModule)
+    smpPeg: TsdMemoryProvider;
+    sddPeg: TsdDataSet;
+    sdvPeg: TsdDataView;
+    smpGclBills: TsdMemoryProvider;
+    sddGclBills: TsdDataSet;
+    sdvGclBills: TsdDataView;
+    procedure sdvGclBillsFilterRecord(ARecord: TsdDataRecord;
+      var Allow: Boolean);
+    procedure sdvPegCurrentChanged(ARecord: TsdDataRecord);
+  private
+  public
+    procedure LoadData(APegs: TList);
+  end;
+
+implementation
+
+uses
+  tpGatherTree;
+
+{$R *.dfm}
+
+{ TtpPeg_GclData }
+
+procedure TtpPeg_GclData.LoadData(APegs: TList);
+
+  procedure BeforeLoadData;
+  begin
+    sddPeg.Active := True;
+    sddPeg.DisableControls;
+    sddPeg.BeginUpdate;
+    sddPeg.DeleteAll;
+
+    sddGclBills.Active := True;
+    sddGclBills.DisableControls;
+    sddGclBills.BeginUpdate;
+    sddGclBills.DeleteAll;
+
+    sdvGclBills.Filtered := False;
+  end;
+
+  procedure AfterLoadData;
+  begin
+    sddPeg.EndUpdate;
+    sddPeg.EnableControls;
+    sddGclBills.EndUpdate;
+    sddGclBills.EnableControls;
+
+    sdvPeg.LocateInControl(sdvPeg.Records[0]);
+    sdvGclBills.Filtered := True;
+  end;
+
+  procedure LoadGclBills(APeg: TtpPegNode);
+  var
+    i: Integer;
+    Rec: TsdDataRecord;
+    vGclNode: TtpGatherTreeNode;
+  begin
+    for i := 0 to APeg.RelaGclNodes.Count - 1 do
+    begin
+      vGclNode := TtpGatherTreeNode(APeg.RelaGclNodes.Items[i]);
+      Rec := sddGclBills.Add;
+      Rec.ValueByName('ID').AsInteger := vGclNode.ID;
+      Rec.ValueByName('PegID').AsInteger := APeg.RelaNode.ID;
+      Rec.ValueByName('B_Code').AsString := vGclNode.B_Code;
+      Rec.ValueByName('Name').AsString := vGclNode.Name;
+      Rec.ValueByName('Units').AsString := vGclNode.Units;
+      Rec.ValueByName('Price').AsFloat := vGclNode.Price;
+      Rec.ValueByName('Quantity').AsFloat := vGclNode.Quantity;
+      Rec.ValueByName('TotalPrice').AsFloat := vGclNode.TotalPrice;
+    end;
+  end;
+
+  procedure LoadPeg(APeg: TtpPegNode);
+  var
+    i: Integer;
+    Rec: TsdDataRecord;
+  begin
+    Rec := sddPeg.Add;
+    Rec.ValueByName('ID').AsInteger := APeg.RelaNode.ID;
+    Rec.ValueByName('Code').AsString := APeg.RelaNode.Code;
+    Rec.ValueByName('Name').AsString := APeg.RelaNode.Name;
+    Rec.ValueByName('Units').AsString := APeg.RelaNode.Units;
+    Rec.ValueByName('TotalPrice').AsFloat := APeg.RelaNode.TotalPrice;
+
+    Rec.ValueByName('BeginPeg').AsString := APeg.BeginPeg;
+    Rec.ValueByName('BeginPegNum').AsFloat := APeg.BeginPegNum;
+    Rec.ValueByName('EndPeg').AsString := APeg.EndPeg;
+    Rec.ValueByName('EndPegNum').AsFloat := APeg.EndPegNum;
+    LoadGclBills(APeg);
+  end;
+
+var
+  i: Integer;
+  vPeg: TtpPegNode;
+begin
+  BeforeLoadData;
+  try
+    for i := 0 to APegs.Count - 1 do
+    begin
+      vPeg := TtpPegNode(APegs.Items[i]);
+      LoadPeg(vPeg);
+    end;
+  finally
+    AfterLoadData;
+  end;
+end;
+
+procedure TtpPeg_GclData.sdvGclBillsFilterRecord(ARecord: TsdDataRecord;
+  var Allow: Boolean);
+begin
+  if Assigned(sdvPeg.Current) then
+    Allow := ARecord.ValueByName('PegID').AsInteger = sdvPeg.Current.ValueByName('ID').AsInteger
+  else
+    Allow := False;
+end;
+
+procedure TtpPeg_GclData.sdvPegCurrentChanged(ARecord: TsdDataRecord);
+begin
+  sdvGclBills.RefreshFilter;
+end;
+
+end.

+ 331 - 0
TenderPartition/tpPeg_GclFme.dfm

@@ -0,0 +1,331 @@
+object tpPeg_GclFrame: TtpPeg_GclFrame
+  Left = 0
+  Top = 0
+  Width = 703
+  Height = 484
+  TabOrder = 0
+  object sprPeg_Gcl: TSplitter
+    Left = 0
+    Top = 281
+    Width = 703
+    Height = 3
+    Cursor = crVSplit
+    Align = alBottom
+  end
+  object zgGclBills: TZJGrid
+    Left = 0
+    Top = 284
+    Width = 703
+    Height = 200
+    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 = alBottom
+  end
+  object zgPeg: TZJGrid
+    Left = 0
+    Top = 0
+    Width = 703
+    Height = 281
+    Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
+    OptionsEx = []
+    ColCount = 9
+    RowCount = 6
+    FixedRowCount = 2
+    ShowGridLine = False
+    DefaultColWidth = 73
+    DefaultFixedColWidth = 25
+    Selection.AlphaBlend = False
+    Selection.TransparentColor = False
+    FrozenCol = 0
+    FrozenRow = 0
+    Align = alClient
+  end
+  object saGclBills: 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'
+        Width = 200
+        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 = True
+      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 = 80
+        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 = 80
+        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'
+        Width = 80
+        ReadOnly = True
+      end>
+    Grid = zgGclBills
+    ExtendRowCount = 0
+    Options = []
+    Left = 120
+    Top = 296
+  end
+  object saPeg: TsdGridDBA
+    Columns = <
+      item
+        Title.Caption = #39033#30446#33410#32534#21495
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 2
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Code'
+        Width = 120
+        ReadOnly = False
+      end
+      item
+        Title.Caption = #21517#31216
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 2
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Name'
+        Width = 200
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #21333#20301
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 2
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Unit'
+        Width = 45
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #37329#39069
+        Title.CaptionAcrossCols = '1'
+        Title.CaptionAcrossRows = 2
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taRightJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'TotalPrice'
+        Width = 80
+        ReadOnly = True
+      end
+      item
+        Title.Caption = #36215#28857'|'#26729#21495
+        Title.CaptionAcrossCols = '2'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'BeginPeg'
+        ReadOnly = False
+      end
+      item
+        Title.Caption = '|'#20540
+        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 = 'BeginPegNum'
+        Width = 60
+        ReadOnly = False
+      end
+      item
+        Title.Caption = #32456#28857'|'#26729#21495
+        Title.CaptionAcrossCols = '2'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'EndPeg'
+        ReadOnly = True
+      end
+      item
+        Title.Caption = '|'#20540
+        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 = 'EndPegNum'
+        Width = 60
+        ReadOnly = True
+      end>
+    Grid = zgPeg
+    ExtendRowCount = 0
+    Options = []
+    Left = 120
+    Top = 88
+  end
+  object dxBarPopupMenu1: TdxBarPopupMenu
+    BarManager = tpMainForm.dxBarManager
+    ItemLinks = <
+      item
+        Item = tpMainForm.dxbtnGatherGclBills
+        Visible = True
+      end>
+    UseOwnFont = False
+    Left = 176
+    Top = 88
+  end
+end

+ 39 - 0
TenderPartition/tpPeg_GclFme.pas

@@ -0,0 +1,39 @@
+unit tpPeg_GclFme;
+
+interface
+
+uses
+  tpPeg_GclDm,
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, ExtCtrls, sdGridDBA, ZJGrid, dxBar;
+
+type
+  TtpPeg_GclFrame = class(TFrame)
+    zgGclBills: TZJGrid;
+    saGclBills: TsdGridDBA;
+    sprPeg_Gcl: TSplitter;
+    zgPeg: TZJGrid;
+    saPeg: TsdGridDBA;
+    dxBarPopupMenu1: TdxBarPopupMenu;
+  private
+    FPeg_GclData: TtpPeg_GclData;
+    procedure SetPeg_GclData(const Value: TtpPeg_GclData);
+  public
+    property Peg_GclData: TtpPeg_GclData read FPeg_GclData write SetPeg_GclData;
+  end;
+
+implementation
+
+{$R *.dfm}
+
+{ TtpPeg_GclFrame }
+
+procedure TtpPeg_GclFrame.SetPeg_GclData(const Value: TtpPeg_GclData);
+begin
+  FPeg_GclData := Value;
+
+  saPeg.DataView := FPeg_GclData.sdvPeg;
+  saGclBills.DataView := FPeg_GclData.sdvGclBills;
+end;
+
+end.

+ 118 - 0
TenderPartition/tpPricePartSettingFrm.dfm

@@ -0,0 +1,118 @@
+object tpPricePartSettingForm: TtpPricePartSettingForm
+  Left = 654
+  Top = 475
+  BorderIcons = [biSystemMenu]
+  BorderStyle = bsSingle
+  Caption = #26631#27573#21010#20998'-'#37329#39069#27169#24335
+  ClientHeight = 101
+  ClientWidth = 393
+  Color = clBtnFace
+  Font.Charset = ANSI_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -12
+  Font.Name = #23435#20307
+  Font.Style = []
+  OldCreateOrder = False
+  DesignSize = (
+    393
+    101)
+  PixelsPerInch = 96
+  TextHeight = 12
+  object lblFormat: TLabel
+    Left = 262
+    Top = 18
+    Width = 108
+    Height = 12
+    Caption = '##,###,###,###.###'
+    Visible = False
+  end
+  object lePartTotalPrice: TLabeledEdit
+    Left = 134
+    Top = 14
+    Width = 121
+    Height = 18
+    Ctl3D = False
+    EditLabel.Width = 120
+    EditLabel.Height = 12
+    EditLabel.Caption = #21333#26631#27573#30446#26631#37329#39069'('#20803')'#65306
+    LabelPosition = lpLeft
+    ParentCtl3D = False
+    TabOrder = 0
+    OnChange = lePartTotalPriceChange
+    OnKeyPress = lePartTotalPriceKeyPress
+  end
+  object btnOk: TButton
+    Left = 239
+    Top = 72
+    Width = 65
+    Height = 21
+    Anchors = [akRight, akBottom]
+    Caption = #30830' '#23450
+    TabOrder = 1
+    OnClick = btnOkClick
+  end
+  object btnCancel: TButton
+    Left = 313
+    Top = 72
+    Width = 65
+    Height = 21
+    Anchors = [akRight, akBottom]
+    Caption = #21462' '#28040
+    ModalResult = 2
+    TabOrder = 2
+  end
+  object leMinLength: TLabeledEdit
+    Left = 134
+    Top = 41
+    Width = 39
+    Height = 18
+    Ctl3D = False
+    EditLabel.Width = 120
+    EditLabel.Height = 12
+    EditLabel.Caption = #21333#26631#27573#26368#30701#38271#24230'(km)'#65306
+    LabelPosition = lpLeft
+    ParentCtl3D = False
+    ParentShowHint = False
+    ShowHint = True
+    TabOrder = 3
+    Text = '5'
+  end
+  object udMinLength: TUpDown
+    Left = 173
+    Top = 41
+    Width = 16
+    Height = 18
+    Associate = leMinLength
+    Max = 50
+    Position = 5
+    TabOrder = 4
+  end
+  object leMinStep: TLabeledEdit
+    Left = 285
+    Top = 42
+    Width = 39
+    Height = 18
+    Ctl3D = False
+    EditLabel.Width = 78
+    EditLabel.Height = 12
+    EditLabel.Caption = #21010#20998#31934#24230'(m)'#65306
+    LabelPosition = lpLeft
+    ParentCtl3D = False
+    ParentShowHint = False
+    ShowHint = True
+    TabOrder = 5
+    Text = '100'
+  end
+  object udMinStep: TUpDown
+    Left = 324
+    Top = 42
+    Width = 16
+    Height = 18
+    Associate = leMinStep
+    Min = 10
+    Max = 1000
+    Increment = 10
+    Position = 100
+    TabOrder = 6
+  end
+end

+ 146 - 0
TenderPartition/tpPricePartSettingFrm.pas

@@ -0,0 +1,146 @@
+unit tpPricePartSettingFrm;
+
+interface
+
+uses
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, ExtCtrls, StdCtrls, ComCtrls;
+
+const
+  sPegIgnoreHint = '各桩号间可能存在重叠,可通过该项设置多少m重叠忽略不计' + #13#10 +
+                   '如果要求重叠桩号划分为1个标段,可设置为0。';
+
+type
+  TPricePartInfo = class
+  private
+    FPartPrice: Double;
+    FMinLength: Integer;
+    FMinStep: Integer;
+  public
+    constructor Create;
+
+    property PartPrice: Double read FPartPrice write FPartPrice;
+    property MinLength: Integer read FMinLength write FMinLength;
+    property MinStep: Integer read FMinStep write FMinStep;
+  end;
+
+  TtpPricePartSettingForm = class(TForm)
+    lePartTotalPrice: TLabeledEdit;
+    lblFormat: TLabel;
+    btnOk: TButton;
+    btnCancel: TButton;
+    leMinLength: TLabeledEdit;
+    udMinLength: TUpDown;
+    leMinStep: TLabeledEdit;
+    udMinStep: TUpDown;
+    procedure btnOkClick(Sender: TObject);
+    procedure lePartTotalPriceChange(Sender: TObject);
+    procedure lePartTotalPriceKeyPress(Sender: TObject; var Key: Char);
+  private
+    function GetPartPrice: Double;
+    function GetMinLength: Integer;
+    function GetMinStep: Integer;
+  public
+    constructor Create(AInfo: TPricePartInfo);
+    destructor Destroy; override;
+
+    property PartPrice: Double read GetPartPrice;
+    property MinLength: Integer read GetMinLength;
+    property MinStep: Integer read GetMinStep;
+  end;
+
+function PricePartSetting(AInfo: TPricePartInfo): Boolean;
+
+implementation
+
+uses
+  UtilMethods;
+
+function PricePartSetting(AInfo: TPricePartInfo): Boolean;
+var
+  SettingForm: TtpPricePartSettingForm;
+begin
+  SettingForm := TtpPricePartSettingForm.Create(AInfo);
+  try
+    Result := SettingForm.ShowModal = mrOk;
+    if Result then
+    begin
+      AInfo.PartPrice := SettingForm.PartPrice;
+      AInfo.MinLength := SettingForm.MinLength;
+      AInfo.MinStep := SettingForm.MinStep;
+    end;
+  finally
+    SettingForm.Free;
+  end;
+end;
+
+{$R *.dfm}
+
+{ TtpPricePartSettingForm }
+
+constructor TtpPricePartSettingForm.Create(AInfo: TPricePartInfo);
+begin
+  inherited Create(nil);
+  if AInfo.PartPrice > 0 then
+    lePartTotalPrice.Text := FloatToStr(AInfo.PartPrice)
+  else
+    lePartTotalPrice.Text := '';
+  udMinLength.Position := AInfo.MinLength;
+  udMinStep.Position := AInfo.MinStep;
+
+  SetWindowLong(lePartTotalPrice.Handle, GWL_STYLE, GetWindowLong(lePartTotalPrice.Handle, GWL_STYLE) or ES_RIGHT);
+  SetWindowLong(leMinLength.Handle, GWL_STYLE, GetWindowLong(leMinLength.Handle, GWL_STYLE) or ES_RIGHT);
+  SetWindowLong(leMinStep.Handle, GWL_STYLE, GetWindowLong(leMinStep.Handle, GWL_STYLE) or ES_RIGHT);
+end;
+
+destructor TtpPricePartSettingForm.Destroy;
+begin
+  inherited;
+end;
+
+function TtpPricePartSettingForm.GetPartPrice: Double;
+begin
+  Result := StrToFloatDef(lePartTotalPrice.Text, 0);
+end;
+
+procedure TtpPricePartSettingForm.btnOkClick(Sender: TObject);
+begin
+  if PartPrice <= 0 then
+    TipMessage('单标段目标金额应大于0。')
+  else
+    ModalResult := mrOk;
+end;
+
+procedure TtpPricePartSettingForm.lePartTotalPriceChange(Sender: TObject);
+begin
+  lblFormat.Visible :=  PartPrice > 0;
+  lblFormat.Caption := FormatFloat('##,###,###,###.##', PartPrice);
+end;
+
+procedure TtpPricePartSettingForm.lePartTotalPriceKeyPress(Sender: TObject;
+  var Key: Char);
+begin
+  if not (Key in ['0'..'9', '.', #8, #13]) then
+    Key := #0;
+end;
+
+function TtpPricePartSettingForm.GetMinLength: Integer;
+begin
+  Result := udMinLength.Position;
+end;
+
+function TtpPricePartSettingForm.GetMinStep: Integer;
+begin
+  Result := udMinStep.Position;
+end;
+
+{ TPricePartInfo }
+
+constructor TPricePartInfo.Create;
+begin
+  FPartPrice := 0;
+  FMinLength := 5;
+  FMinStep := 100;
+end;
+
+end.

+ 49 - 0
TenderPartition/tpSelectTenderDm.dfm

@@ -0,0 +1,49 @@
+object tpSelectTenderData: TtpSelectTenderData
+  OldCreateOrder = False
+  Left = 616
+  Top = 382
+  Height = 220
+  Width = 215
+  object sdmpTenders: TsdMemoryProvider
+    Left = 64
+    Top = 16
+  end
+  object sddTenders: TsdDataSet
+    Active = True
+    Provider = sdmpTenders
+    Left = 64
+    Top = 72
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65080001044E616D6506044E616D65094669656C644E616D650604
+      4E616D650844617461547970650218084461746153697A6503FF000549734B65
+      79080F4E65656450726F636573734E616D65080001044E616D6506094E6F6465
+      436F756E74094669656C644E616D6506094E6F6465436F756E74084461746154
+      7970650203084461746153697A6502040549734B6579080F4E65656450726F63
+      6573734E616D65080001044E616D65060A546F74616C5072696365094669656C
+      644E616D65060A546F74616C5072696365084461746154797065020608446174
+      6153697A6502080549734B6579080F4E65656450726F636573734E616D650800
+      00}
+  end
+  object sdvTenders: TsdDataView
+    Active = True
+    DataSet = sddTenders
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'ID'
+      end
+      item
+        FieldName = 'Name'
+      end
+      item
+        FieldName = 'NodeCount'
+      end
+      item
+        FieldName = 'TotalPrice'
+      end>
+    Left = 64
+    Top = 128
+  end
+end

+ 42 - 0
TenderPartition/tpSelectTenderDm.pas

@@ -0,0 +1,42 @@
+unit tpSelectTenderDm;
+
+interface
+
+uses
+  SysUtils, Classes, sdDB, sdProvider, tpSelectTenderNode;
+
+type
+  TtpSelectTenderData = class(TDataModule)
+    sdmpTenders: TsdMemoryProvider;
+    sddTenders: TsdDataSet;
+    sdvTenders: TsdDataView;
+  private
+  public
+    procedure AssignSelectTenders(ATenders: TList);
+  end;
+
+implementation
+
+{$R *.dfm}
+
+{ TtpSelectTenderData }
+
+procedure TtpSelectTenderData.AssignSelectTenders(ATenders: TList);
+var
+  i: Integer;
+  vTender: TtpSelectTenderNode;
+  Rec: TsdDataRecord;
+begin
+  sddTenders.DeleteAll;
+  for i := 0 to ATenders.Count - 1 do
+  begin
+    vTender := TtpSelectTenderNode(ATenders.Items[i]);
+    Rec := sddTenders.Add;
+    Rec.ValueByName('ID').AsInteger := vTender.ID;
+    Rec.ValueByName('Name').AsString := vTender.Name;
+    Rec.ValueByName('NodeCount').AsInteger := vTender.NodeCount;
+    Rec.ValueByName('TotalPrice').AsFloat := vTender.TotalPrice;
+  end;
+end;
+
+end.

+ 48 - 0
TenderPartition/tpSelectTenderNode.pas

@@ -0,0 +1,48 @@
+unit tpSelectTenderNode;
+
+interface
+
+uses
+  Classes, sdIDTree, sdDB;
+
+type
+  TtpSelectTenderNode = class
+  private
+    FID: Integer;
+    FSerialNo: Integer;
+    FName: string;
+    FFileName: string;
+    FTotalPrice: Double;
+    FNodeCount: Integer;
+  public
+    constructor Create(ANode: TsdIDTreeNode);
+    destructor Destroy; override;
+
+    property ID: Integer read FID;
+    property SerialNo: Integer read FSerialNo;
+    property Name: string read FName;
+    property FileName: string read FFileName;
+    property TotalPrice: Double read FTotalPrice;
+
+    property NodeCount: Integer read FNodeCount write FNodeCount;
+  end;
+
+implementation
+
+{ TtpSelectTenderNode }
+
+constructor TtpSelectTenderNode.Create(ANode: TsdIDTreeNode);
+begin
+  FID := ANode.ID;
+  FSerialNo := ANode.MajorIndex;
+  FName := ANode.Rec.ValueByName('Name').AsString;
+  FFileName := ANode.Rec.ValueByName('FileName').AsString;
+  FTotalPrice := ANode.Rec.ValueByName('DealTotalPrice').AsFloat;
+end;
+
+destructor TtpSelectTenderNode.Destroy;
+begin
+  inherited;
+end;
+
+end.

+ 235 - 0
TenderPartition/tpSelectTendersFrm.dfm

@@ -0,0 +1,235 @@
+object SelectTendersForm: TSelectTendersForm
+  Left = 634
+  Top = 239
+  BorderIcons = [biSystemMenu]
+  BorderStyle = bsSingle
+  Caption = #26631#27573#21010#20998'-'#35774#32622
+  ClientHeight = 391
+  ClientWidth = 598
+  Color = clBtnFace
+  Font.Charset = ANSI_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -12
+  Font.Name = #23435#20307
+  Font.Style = []
+  OldCreateOrder = False
+  DesignSize = (
+    598
+    391)
+  PixelsPerInch = 96
+  TextHeight = 12
+  object lblTenderResult: TLabel
+    Left = 8
+    Top = 355
+    Width = 204
+    Height = 12
+    Caption = #24403#21069#36873#20013#65306' '#26631#27573' %d '#20010#65292#37329#39069#21512#35745' %f'
+  end
+  object btnOk: TButton
+    Left = 455
+    Top = 362
+    Width = 65
+    Height = 21
+    Anchors = [akRight, akBottom]
+    Caption = #30830#23450
+    TabOrder = 0
+    OnClick = btnOkClick
+  end
+  object btnCancel: TButton
+    Left = 528
+    Top = 362
+    Width = 65
+    Height = 21
+    Anchors = [akRight, akBottom]
+    Caption = #21462#28040
+    ModalResult = 2
+    TabOrder = 1
+  end
+  object Panel1: TPanel
+    Left = 4
+    Top = 0
+    Width = 590
+    Height = 348
+    BevelOuter = bvNone
+    Caption = 'pnlTenderSelect'
+    TabOrder = 2
+    object pnlTenderSelectTitle: TPanel
+      Left = 0
+      Top = 0
+      Width = 590
+      Height = 25
+      Align = alTop
+      BevelOuter = bvNone
+      TabOrder = 0
+      object lblTenderSelect: TLabel
+        Left = 2
+        Top = 8
+        Width = 132
+        Height = 12
+        Caption = #35831#21246#36873#38656#32479#19968#21010#20998#30340#26631#27573
+      end
+    end
+    object pnlSelect: TPanel
+      Left = 0
+      Top = 25
+      Width = 308
+      Height = 323
+      Align = alLeft
+      BevelOuter = bvNone
+      TabOrder = 1
+      object zgTenderSelect: TZJGrid
+        Left = 0
+        Top = 19
+        Width = 308
+        Height = 304
+        Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection, goShowTreeLine]
+        OptionsEx = []
+        ColCount = 3
+        RowCount = 2
+        ShowGridLine = False
+        DefaultColWidth = 35
+        DefaultFixedColWidth = 25
+        DefaultFixedRowHeight = 22
+        Selection.AlphaBlend = False
+        Selection.TransparentColor = False
+        FrozenCol = 0
+        FrozenRow = 0
+        OnGetCellText = zgTenderSelectGetCellText
+        OnSetCellText = zgTenderSelectSetCellText
+        OnCellTextChanged = zgTenderSelectCellTextChanged
+        OnDrawCellText = zgTenderSelectDrawCellText
+        OnShowHint = zgTenderSelectShowHint
+        Align = alClient
+      end
+      object pnlSelectTitle: TPanel
+        Left = 0
+        Top = 0
+        Width = 308
+        Height = 19
+        Align = alTop
+        BevelOuter = bvNone
+        TabOrder = 1
+        object lblTenderList: TLabel
+          Left = 3
+          Top = 2
+          Width = 72
+          Height = 12
+          Caption = #21487#36873#39033#30446#21015#34920
+          Font.Charset = ANSI_CHARSET
+          Font.Color = clBlue
+          Font.Height = -12
+          Font.Name = #23435#20307
+          Font.Style = []
+          ParentFont = False
+        end
+      end
+    end
+    object pnlResult: TPanel
+      Left = 311
+      Top = 25
+      Width = 279
+      Height = 323
+      Align = alClient
+      BevelOuter = bvNone
+      TabOrder = 2
+      object zgResult: TZJGrid
+        Left = 0
+        Top = 19
+        Width = 279
+        Height = 304
+        OptionsEx = []
+        ColCount = 2
+        RowCount = 2
+        ShowGridLine = False
+        DefaultColWidth = 225
+        DefaultFixedColWidth = 25
+        DefaultFixedRowHeight = 22
+        Selection.AlphaBlend = False
+        Selection.TransparentColor = False
+        FrozenCol = 0
+        FrozenRow = 0
+        Align = alClient
+      end
+      object pnlResultTitle: TPanel
+        Left = 0
+        Top = 0
+        Width = 279
+        Height = 19
+        Align = alTop
+        BevelOuter = bvNone
+        TabOrder = 1
+        object lblResultList: TLabel
+          Left = 3
+          Top = 2
+          Width = 72
+          Height = 12
+          Caption = #25152#36873#39033#30446#21015#34920
+          Font.Charset = ANSI_CHARSET
+          Font.Color = clBlue
+          Font.Height = -12
+          Font.Name = #23435#20307
+          Font.Style = []
+          ParentFont = False
+        end
+      end
+    end
+    object pnlDivision: TPanel
+      Left = 308
+      Top = 25
+      Width = 3
+      Height = 323
+      Align = alLeft
+      BevelOuter = bvNone
+      TabOrder = 3
+    end
+  end
+  object stdTenderSelect: TsdGridTreeDBA
+    Columns = <
+      item
+        Title.Caption = #36873#25321
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taCenter
+        EditType = sgeCheckBox
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        Width = 30
+        ReadOnly = False
+      end
+      item
+        Title.Caption = #21517#31216
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'Name'
+        Width = 225
+        ReadOnly = False
+      end>
+    Grid = zgTenderSelect
+    ExtendRowCount = 0
+    AutoExpand = False
+    TreeCellCol = 2
+    KeyFieldName = 'ID'
+    ParentFieldName = 'ParentID'
+    NextSiblingFieldName = 'NextSiblingID'
+    TopLevelBold = True
+    Left = 500
+    Top = 193
+  end
+end

+ 354 - 0
TenderPartition/tpSelectTendersFrm.pas

@@ -0,0 +1,354 @@
+unit tpSelectTendersFrm;
+
+interface
+
+uses
+  sdIDTree,
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, StdCtrls, ExtCtrls, ZJGrid, JimPages, ActnList, sdGridDBA,
+  sdGridTreeDBA;
+
+type
+  TSelectTendersForm = class(TForm)
+    btnOk: TButton;
+    btnCancel: TButton;
+    stdTenderSelect: TsdGridTreeDBA;
+    lblTenderResult: TLabel;
+    Panel1: TPanel;
+    pnlTenderSelectTitle: TPanel;
+    lblTenderSelect: TLabel;
+    pnlSelect: TPanel;
+    zgTenderSelect: TZJGrid;
+    pnlSelectTitle: TPanel;
+    lblTenderList: TLabel;
+    pnlResult: TPanel;
+    zgResult: TZJGrid;
+    pnlResultTitle: TPanel;
+    lblResultList: TLabel;
+    pnlDivision: TPanel;
+    procedure zgTenderSelectDrawCellText(ACanvas: TCanvas;
+      const ARect: TRect; const ACoord: TPoint; AGrid: TZJGrid;
+      const Text: String; var ADefaultDraw: Boolean);
+    procedure zgTenderSelectShowHint(var HintStr: String;
+      var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint);
+    procedure zgTenderSelectCellTextChanged(Sender: TObject; Col,
+      Row: Integer);
+    procedure zgTenderSelectSetCellText(Sender: TObject;
+      const ACoord: TPoint; var Value: String; DisplayText: Boolean);
+    procedure zgTenderSelectGetCellText(Sender: TObject;
+      const ACoord: TPoint; var Value: String; DisplayText: Boolean);
+    procedure btnOkClick(Sender: TObject);
+  private
+    FSelects: TList;
+
+    procedure AddRows(ANode: TsdIDTreeNode);
+    procedure RemoveRows(ANode: TsdIDTreeNode);
+
+    procedure InitResultGrid;
+    procedure AssignResultGrid;
+    procedure AssignResult;
+
+    function GetSelectCount: Integer;
+    function GetSelectTotalPrice: Double;
+  public
+    constructor Create(AHistorys: TList);
+    destructor Destroy; override;
+
+    procedure AssignSelectTenders(ATender: TList);
+
+    property SelectCount: Integer read GetSelectCount;
+    property SelectTotalPrice: Double read GetSelectTotalPrice;
+  end;
+
+function SelectTendersToPart(ATenders: TList): Boolean;
+
+implementation
+
+uses
+  Globals, MainFrm, ProjectManagerDm, sdDB, UtilMethods;
+
+function SelectTendersToPart(ATenders: TList): Boolean;
+var
+  vSelectFrm: TSelectTendersForm;
+begin
+  vSelectFrm := TSelectTendersForm.Create(ATenders);
+  try
+    Result := vSelectFrm.ShowModal = mrOk;
+    if Result then
+      vSelectFrm.AssignSelectTenders(ATenders);
+  finally
+    vSelectFrm.Free;
+  end;
+end;
+
+{$R *.dfm}
+
+constructor TSelectTendersForm.Create(AHistorys: TList);
+begin
+  inherited Create(nil);
+  stdTenderSelect.DataView := ProjectManager.sdvProjectsSpare;
+  FSelects := TList.Create;
+  FSelects.Assign(AHistorys);
+  InitResultGrid;
+end;
+
+destructor TSelectTendersForm.Destroy;
+begin
+  FSelects.Free;
+  inherited;
+end;
+
+procedure TSelectTendersForm.zgTenderSelectDrawCellText(ACanvas: TCanvas;
+  const ARect: TRect; const ACoord: TPoint; AGrid: TZJGrid;
+  const Text: String; var ADefaultDraw: Boolean);
+
+  procedure GetBitmap(AImage: TBitmap);
+  begin
+    with stdTenderSelect.IDTree.Items[ACoord.Y - 1] do
+      if Rec.ValueByName('Type').AsInteger = 0 then
+        if Expanded and HasChildren then
+          MainForm.Images.GetBitmap(34, AImage)
+        else
+          MainForm.Images.GetBitmap(34, AImage)
+      else
+        MainForm.Images.GetBitmap(11, AImage);
+  end;
+
+const
+  rIconWidth = 16;
+  rIconHeight = 16;
+var
+  Img: TBitmap;
+  Cell: TZjCell;
+  rImg: TRect;
+begin
+ if (ACoord.X = 2) and (ACoord.Y > zgTenderSelect.FixedRowCount - 1) then
+  begin
+    Cell := zgTenderSelect.Cells[ACoord.X, ACoord.Y];
+    Img := TBitmap.Create;
+    try
+      GetBitmap(Img);
+      case Cell.Align of
+        gaTopLeft, gaTopCenter, gaTopRight:
+          rImg := Rect(ARect.Left + 2, ARect.Top, ARect.Left + rIconWidth, ARect.Top + rIconHeight);
+        gaCenterLeft, gaCenterCenter, gaCenterRight:
+          rImg := Rect(ARect.Left + 2, ARect.Top + (ARect.Bottom - ARect.Top - rIconHeight) div 2, ARect.Left + rIconWidth, ARect.Bottom - (ARect.Bottom - ARect.Top - rIconHeight) div 2);
+        gaBottomLeft, gaBottomCenter, gaBottomRight:
+          rImg := Rect(ARect.Left + 2, ARect.Bottom - rIconHeight, ARect.Left + rIconWidth, ARect.Bottom);
+      end;
+      ACanvas.StretchDraw(rImg, Img);
+      WriteText(ACanvas, Rect(ARect.Left + rIconWidth, ARect.Top, ARect.Right, ARect.Bottom)
+        , 2, 2, Text, Cell.Align, False);
+      ADefaultDraw := False;
+    finally
+      Img.Free;
+    end;
+  end;
+end;
+
+procedure TSelectTendersForm.zgTenderSelectShowHint(var HintStr: String;
+  var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint);
+var
+  vCell: TZjCell;
+  vNode: TsdIDTreeNode;
+  iLevelWidth: Integer;
+  rText: TRect;
+
+  procedure CalcTextRect(var R: TRect);
+  var
+    DC: HDC;
+    iTextHeight: Integer;
+  begin
+    DC := CreateCompatibleDC(0);
+    try
+      SelectObject(DC, vCell.Font.Handle);
+      iTextHeight := DrawText(DC, PChar(vCell.Text), Length(vCell.Text), R, DT_SINGLELINE or DT_VCenter
+        or DT_NOCLIP or DT_CALCRECT);
+    finally
+      DeleteDC(DC);
+    end;
+  end;
+
+begin
+  if ACoord.Y < 1 then Exit;
+
+  vCell := zgTenderSelect.Cells[ACoord.X, ACoord.Y];
+  with HintInfo do
+  begin
+    vNode := stdTenderSelect.IDTree.Items[ACoord.Y - 1];
+    if not Assigned(vNode) then Exit;
+    iLevelWidth := (vNode.Level + 1) * 20 + 16;
+
+    rText := CursorRect;
+    CalcTextRect(rText);
+    if (rText.Right - rText.Left + iLevelWidth > CursorRect.Right - CursorRect.Left) or
+      (rText.Right > ClientWidth) then
+    begin
+      CanShow := True;
+      HintStr := vCell.Text;
+      GetCursorPos(HintPos);
+    end;
+  end;
+end;
+
+procedure TSelectTendersForm.InitResultGrid;
+begin
+  zgResult.ColCount := 2;
+  zgResult.RowCount := 1;
+  zgResult.Cells[1, 0].Text := '所选项目';
+  zgResult.ColWidths[1] := 225;
+end;
+
+procedure TSelectTendersForm.AssignResult;
+const
+  sResult = '共选中标段 %d 个,金额合计 %s 元';
+var
+  sTotalPrice: string;
+begin
+  InitResultGrid;
+  AssignResultGrid;
+  sTotalPrice := FormatFloat('##,###,###,###.##', SelectTotalPrice);
+  lblTenderResult.Caption := Format(sResult, [SelectCount, sTotalPrice]);
+end;
+
+procedure TSelectTendersForm.zgTenderSelectCellTextChanged(Sender: TObject;
+  Col, Row: Integer);
+begin
+  if (Col = 1) then
+    zgTenderSelect.InvalidateCol(1);
+end;
+
+procedure TSelectTendersForm.zgTenderSelectSetCellText(Sender: TObject;
+  const ACoord: TPoint; var Value: String; DisplayText: Boolean);
+var
+  stnNode: TsdIDTreeNode;
+begin
+  if ACoord.X = 1 then
+  begin
+    stnNode := stdTenderSelect.IDTree.Items[ACoord.Y - 1];
+    if Value = 'True' then
+      AddRows(stnNode)
+    else
+      RemoveRows(stnNode);
+    AssignResult;
+  end;
+end;
+
+procedure TSelectTendersForm.AddRows(ANode: TsdIDTreeNode);
+var
+  iChild: Integer;
+begin
+  if not Assigned(ANode) then Exit;
+
+  if FSelects.IndexOf(Pointer(ANode.ID)) = -1 then
+    FSelects.Add(Pointer(ANode.ID));
+
+  if ANode.HasChildren then
+    for iChild := 0 to ANode.ChildCount - 1 do
+      AddRows(ANode.ChildNodes[iChild]);
+end;
+
+procedure TSelectTendersForm.RemoveRows(ANode: TsdIDTreeNode);
+var
+  iChild: Integer;
+begin
+  if not Assigned(ANode) then Exit;
+
+  if FSelects.IndexOf(Pointer(ANode.ID)) > -1 then
+    FSelects.Remove(Pointer(ANode.ID));
+
+  if ANode.HasChildren then
+    for iChild := 0 to ANode.ChildCount - 1 do
+      RemoveRows(ANode.ChildNodes[iChild]);
+end;
+
+procedure TSelectTendersForm.zgTenderSelectGetCellText(Sender: TObject;
+  const ACoord: TPoint; var Value: String; DisplayText: Boolean);
+var
+  stnNode: TsdIDTreeNode;
+begin
+  if ACoord.X = 1 then
+  begin
+    stnNode := stdTenderSelect.IDTree.Items[ACoord.Y - 1];
+    if Assigned(stnNode) and (FSelects.IndexOf(Pointer(stnNode.ID)) > -1) then
+      Value := 'True';
+  end;
+end;
+
+procedure TSelectTendersForm.AssignResultGrid;
+var
+  i, iID: Integer;
+  vNode: TsdIDTreeNode;
+begin
+  for i := 0 to FSelects.Count - 1 do
+  begin
+    iID := Integer(FSelects.Items[i]);
+    vNode := stdTenderSelect.IDTree.FindNode(iID);
+    if vNode.Rec.ValueByName('Type').AsInteger = 1 then
+    begin
+      zgResult.RowCount := zgResult.RowCount + 1;
+      zgResult.Cells[1, zgResult.RowCount - 1].Text := vNode.Rec.ValueByName('Name').AsString;
+      zgResult.Cells[1, zgResult.RowCount - 1].Align := gaCenterLeft;
+      zgResult.Rows[zgResult.RowCount - 1].Data := vNode;
+    end;
+  end;
+end;
+
+function TSelectTendersForm.GetSelectCount: Integer;
+begin
+  Result := zgResult.RowCount - 1;
+end;
+
+function TSelectTendersForm.GetSelectTotalPrice: Double;
+var
+  iRow: Integer;
+  vNode: TsdIDTreeNode;
+begin
+  Result := 0;
+  for iRow := 1 to zgResult.RowCount - 1 do
+  begin
+    vNode := TsdIDTreeNode(zgResult.Rows[iRow].Data);
+    if Assigned(vNode) then
+      Result := Result + vNode.Rec.ValueByName('DealTotalPrice').AsFloat;
+  end;
+end;
+
+procedure TSelectTendersForm.btnOkClick(Sender: TObject);
+
+  function CheckValid(var AMessage: string): Boolean;
+  begin
+    Result := False;
+    if SelectCount = 0 then
+      AMessage := '请勾选需统一划分的标段。'
+    else if SelectTotalPrice <= 0 then
+      AMessage := '当前勾选的标段,合计金额为0,请检查标段数据是否正确。'
+    else
+      Result := True;
+  end;
+
+var
+  iCount: Integer;
+  sMessage: string;
+begin
+  if not CheckValid(sMessage) then
+  begin
+    WarningMessage(sMessage);
+    Exit;
+  end
+  else
+    ModalResult := mrOk;
+end;
+
+procedure TSelectTendersForm.AssignSelectTenders(ATender: TList);
+//var
+  //iRow: Integer;
+begin
+  ATender.Assign(FSelects);
+  //for iRow := 1 to zgResult.RowCount - 1 do
+  //begin
+  //  if Assigned(zgResult.Rows[iRow].Data) then
+  //    ATender.Add(Pointer(TsdIDTreeNode(zgResult.Rows[iRow].Data).ID));
+  //end;
+end;
+
+end.

+ 54 - 0
TenderPartition/tpTrialPegInputFrm.dfm

@@ -0,0 +1,54 @@
+object TrialPegInputForm: TTrialPegInputForm
+  Left = 594
+  Top = 388
+  Width = 340
+  Height = 123
+  Caption = #35797#31639#26729#21495#33539#22260
+  Color = clBtnFace
+  Font.Charset = DEFAULT_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -11
+  Font.Name = 'MS Sans Serif'
+  Font.Style = []
+  OldCreateOrder = False
+  PixelsPerInch = 96
+  TextHeight = 13
+  object lblHint: TLabel
+    Left = 8
+    Top = 8
+    Width = 132
+    Height = 13
+    Caption = #35831#36755#20837#35797#31639#30340#26729#21495#33539#22260#65306
+  end
+  object lePeg: TLabeledEdit
+    Left = 96
+    Top = 32
+    Width = 201
+    Height = 19
+    Ctl3D = False
+    EditLabel.Width = 60
+    EditLabel.Height = 13
+    EditLabel.Caption = #36215#35755#26729#21495#65306
+    LabelPosition = lpLeft
+    ParentCtl3D = False
+    TabOrder = 0
+  end
+  object btnOk: TButton
+    Left = 176
+    Top = 61
+    Width = 65
+    Height = 21
+    Caption = #30830'  '#23450
+    TabOrder = 1
+    OnClick = btnOkClick
+  end
+  object btnCancel: TButton
+    Left = 256
+    Top = 61
+    Width = 65
+    Height = 21
+    Caption = #21462'  '#28040
+    ModalResult = 2
+    TabOrder = 2
+  end
+end

+ 60 - 0
TenderPartition/tpTrialPegInputFrm.pas

@@ -0,0 +1,60 @@
+unit tpTrialPegInputFrm;
+
+interface
+
+uses
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, StdCtrls, ExtCtrls;
+
+type
+  TTrialPegInputForm = class(TForm)
+    lblHint: TLabel;
+    lePeg: TLabeledEdit;
+    btnOk: TButton;
+    btnCancel: TButton;
+    procedure btnOkClick(Sender: TObject);
+  private
+    function GetPeg: string;
+  public
+    property Peg: string read GetPeg;
+  end;
+
+function InputTrialPeg(var APeg: string): Boolean;
+
+implementation
+
+uses
+  UtilMethods, mPegFilter;
+
+function InputTrialPeg(var APeg: string): Boolean;
+var
+  vInputForm: TTrialPegInputForm;
+begin
+  vInputForm := TTrialPegInputForm.Create(nil);
+  try
+    Result := vInputForm.ShowModal = mrOk;
+    if Result then
+      APeg := vInputForm.Peg;
+  finally
+    vInputForm.Free;
+  end;
+end;
+
+{$R *.dfm}
+
+procedure TTrialPegInputForm.btnOkClick(Sender: TObject);
+begin
+  if (lePeg.Text = '') then
+    TipMessage('请输入起点桩号。')
+  else if PegFilter.Filter(lePeg.Text) then
+    ModalResult := mrOk
+  else
+    TipMessage('请按格式“K###+###~K###+###”输入桩号');
+end;
+
+function TTrialPegInputForm.GetPeg: string;
+begin
+  Result := lePeg.Text;
+end;
+
+end.

+ 1 - 0
TenderPartition/说明.txt

@@ -0,0 +1 @@
+该文件夹下所有代码均为智能标段划分使用,严禁其他功能使用该部分代码

+ 4 - 2
Units/DataBaseTables.pas

@@ -328,7 +328,7 @@ const
 
 
   {变更令}
   {变更令}
   SBGL = 'BGL';
   SBGL = 'BGL';
-  tdBGL: array [0..10] of TScFieldDef =(
+  tdBGL: array [0..11] of TScFieldDef =(
     (FieldName: 'ID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
     (FieldName: 'ID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
     // 变更令号
     // 变更令号
     (FieldName: 'Code'; FieldType: ftString; Size: 50; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'Code'; FieldType: ftString; Size: 50; NotNull: False; PrimaryKey: False; ForceUpdate: False),
@@ -349,7 +349,9 @@ const
     // 创建期数
     // 创建期数
     (FieldName: 'CreatePhaseID'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'CreatePhaseID'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 已执行
     // 已执行
-    (FieldName: 'ExecutionRate'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+    (FieldName: 'ExecutionRate'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 变更令类型:一般、较大、重大
+    (FieldName: 'BGLType'; FieldType: ftString; Size: 10; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
   );
 
 
   SBGBills = 'BGBills';
   SBGBills = 'BGBills';

+ 3 - 3
Units/DetailExcelImport.pas

@@ -212,8 +212,8 @@ begin
       vGclNode.Units := sUnits;
       vGclNode.Units := sUnits;
       vGclNode.Quantity := StrToFloatDef(GetCellValue(AXlsFile, FCurRow, FQuantityCol), 0);
       vGclNode.Quantity := StrToFloatDef(GetCellValue(AXlsFile, FCurRow, FQuantityCol), 0);
       vGclNode.Price := fPrice;
       vGclNode.Price := fPrice;
-      vGclNode.DrawingCode := GetCellValue(AXlsFile, FCurRow, FDrawingCol);
-      vGclNode.MemoStr := GetCellValue(AXlsFile, FCurRow, FMemoCol);
+      vGclNode.DrawingCode := Trim(GetCellValue(AXlsFile, FCurRow, FDrawingCol));
+      vGclNode.MemoStr := Trim(GetCellValue(AXlsFile, FCurRow, FMemoCol));
     end
     end
     else
     else
       vGclNode.Quantity := vGclNode.Quantity + StrToFloatDef(GetCellValue(AXlsFile, FCurRow, FQuantityCol), 0);
       vGclNode.Quantity := vGclNode.Quantity + StrToFloatDef(GetCellValue(AXlsFile, FCurRow, FQuantityCol), 0);
@@ -248,7 +248,7 @@ begin
   begin
   begin
     for iCol := 1 to AXlsFile.MaxCol do
     for iCol := 1 to AXlsFile.MaxCol do
     begin
     begin
-      sColName := GetCellValue(AXlsFile, FCurRow, iCol);
+      sColName := Trim(GetCellValue(AXlsFile, FCurRow, iCol));
       if sColName = 'µÚ1²ã' then
       if sColName = 'µÚ1²ã' then
         FXmjLevel1Col := iCol
         FXmjLevel1Col := iCol
       else if sColName = 'µÚ2²ã' then
       else if sColName = 'µÚ2²ã' then

+ 52 - 42
Units/ExcelImport.pas

@@ -19,6 +19,7 @@ type
     procedure Import; virtual; abstract;
     procedure Import; virtual; abstract;
 
 
     function GetCellValue(ASheet: TSpreadSheet; ACol, ARow: Integer): Variant;
     function GetCellValue(ASheet: TSpreadSheet; ACol, ARow: Integer): Variant;
+    function GetCellTrimText(ASheet: TSpreadSheet; ACol, ARow: Integer): string;
   public
   public
     constructor Create(AProjectData: TProjectData);
     constructor Create(AProjectData: TProjectData);
     destructor Destroy; override;
     destructor Destroy; override;
@@ -186,6 +187,12 @@ begin
   inherited;
   inherited;
 end;
 end;
 
 
+function TExcelImport.GetCellTrimText(ASheet: TSpreadSheet; ACol,
+  ARow: Integer): string;
+begin
+  Result := Trim(VarToStrDef(GetCellValue(ASheet, ACol, ARow), ''));
+end;
+
 function TExcelImport.GetCellValue(ASheet: TSpreadSheet;
 function TExcelImport.GetCellValue(ASheet: TSpreadSheet;
   ACol, ARow: Integer): Variant;
   ACol, ARow: Integer): Variant;
 begin
 begin
@@ -278,19 +285,16 @@ var
   Node: TBillsCacheNode;
   Node: TBillsCacheNode;
   vValue: Variant;
   vValue: Variant;
 begin
 begin
-  with ASheet.Cells do
-  begin
-    sLevelCode := VarToStrDef(GetValue(FLevelCol, FCurRow), '');
-    if sLevelCode = '' then Exit;
+  sLevelCode := GetCellTrimText(ASheet, FLevelCol, FCurRow);
+  if sLevelCode = '' then Exit;
 
 
-    iFixedID := StrToInt(VarToStrDef(GetValue(FFixedIDCol, FCurRow), '-1'));
-    Node := FCacheTree.AddNodeByCode(sLevelCode, iFixedID);
-    Node.Code := VarToStrDef(GetValue(FCodeCol, FCurRow), '');
-    Node.B_Code := VarToStrDef(GetValue(FB_CodeCol, FCurRow), '');
-    Node.Name := VarToStrDef(GetValue(FNameCol, FCurRow), '');
-    Node.Units := VarToStrDef(GetValue(FUnitsCol, FCurRow), '');
-    Node.CanDelete := VarToIntDef(GetValue(FCanDeleteCol, FCurRow), 0) = 0;
-  end;
+  iFixedID := StrToIntDef(GetCellTrimText(ASheet, FFixedIDCol, FCurRow), -1);
+  Node := FCacheTree.AddNodeByCode(sLevelCode, iFixedID);
+  Node.Code := GetCellTrimText(ASheet, FCodeCol, FCurRow);
+  Node.B_Code := GetCellTrimText(ASheet, FB_CodeCol, FCurRow);
+  Node.Name := GetCellTrimText(ASheet, FNameCol, FCurRow);
+  Node.Units := GetCellTrimText(ASheet, FUnitsCol, FCurRow);
+  Node.CanDelete := VarToIntDef(GetCellValue(ASheet, FCanDeleteCol, FCurRow), 0) = 0;
 end;
 end;
 
 
 procedure TBillsExcelImport.LoadNodes(ASheet: TSpreadSheet);
 procedure TBillsExcelImport.LoadNodes(ASheet: TSpreadSheet);
@@ -476,10 +480,10 @@ var
   vValue: Variant;
   vValue: Variant;
   iFixedID: Integer;
   iFixedID: Integer;
 begin
 begin
-  sLevelCode := VarToStrDef(GetCellValue(ASheet, FLevelCol, FCurRow), '');
-  sCode := VarToStrDef(GetCellValue(ASheet, FCodeCol, FCurRow), '');
-  sB_Code := VarToStrDef(GetCellValue(ASheet, FB_CodeCol, FCurRow), '');
-  sName := VarToStrDef(GetCellValue(ASheet, FNameCol, FCurRow), '');
+  sLevelCode := GetCellTrimText(ASheet, FLevelCol, FCurRow);
+  sCode := GetCellTrimText(ASheet, FCodeCol, FCurRow);
+  sB_Code := GetCellTrimText(ASheet, FB_CodeCol, FCurRow);
+  sName := GetCellTrimText(ASheet, FNameCol, FCurRow);
 
 
   // 含层次编号时,层次编号为空不导入
   // 含层次编号时,层次编号为空不导入
   // 不含层次编号时,仅导入第一部分,且项目节编号、清单编号均未空时不导入
   // 不含层次编号时,仅导入第一部分,且项目节编号、清单编号均未空时不导入
@@ -523,16 +527,16 @@ begin
       FFixedIDNodes.Add(Node);
       FFixedIDNodes.Add(Node);
   end;
   end;
 
 
-  Node.Code := VarToStrDef(GetCellValue(ASheet, FCodeCol, FCurRow), '');
-  Node.B_Code := VarToStrDef(GetCellValue(ASheet, FB_CodeCol, FCurRow), '');
-  Node.Name := VarToStrDef(GetCellValue(ASheet, FNameCol, FCurRow), '');
-  Node.Units := VarToStrDef(GetCellValue(ASheet, FUnitsCol, FCurRow), '');
+  Node.Code := sCode;
+  Node.B_Code := sB_Code;
+  Node.Name := sName;
+  Node.Units := GetCellTrimText(ASheet, FUnitsCol, FCurRow);
   Node.Price := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FPriceCol, FCurRow), ''), 0);
   Node.Price := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FPriceCol, FCurRow), ''), 0);
   Node.Quantity := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FQuantityCol, FCurRow), ''), 0);
   Node.Quantity := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FQuantityCol, FCurRow), ''), 0);
   Node.DgnQuantity1 := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FDgnQuantity1Col, FCurRow), ''), 0);
   Node.DgnQuantity1 := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FDgnQuantity1Col, FCurRow), ''), 0);
   Node.DgnQuantity2 := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FDgnQuantity2Col, FCurRow), ''), 0);
   Node.DgnQuantity2 := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FDgnQuantity2Col, FCurRow), ''), 0);
-  Node.DrawingCode := VarToStrDef(GetCellValue(ASheet, FDrawingCol, FCurRow), '');
-  Node.MemoStr := VarToStrDef(GetCellValue(ASheet, FMemoCol, FCurRow), '');
+  Node.DrawingCode := GetCellTrimText(ASheet, FDrawingCol, FCurRow);
+  Node.MemoStr := GetCellTrimText(ASheet, FMemoCol, FCurRow);
 end;
 end;
 
 
 procedure TBillsEdtExcelImport.LoadNodes(ASheet: TSpreadSheet);
 procedure TBillsEdtExcelImport.LoadNodes(ASheet: TSpreadSheet);
@@ -598,13 +602,16 @@ end;
 
 
 procedure TBillsPriceExcelImport.BeginImport;
 procedure TBillsPriceExcelImport.BeginImport;
 begin
 begin
+  ShowProgressHint('导入Excel清单单价', 100);
   FProjectData.BillsData.sddBills.BeginUpdate;
   FProjectData.BillsData.sddBills.BeginUpdate;
 end;
 end;
 
 
 procedure TBillsPriceExcelImport.EndImport;
 procedure TBillsPriceExcelImport.EndImport;
 begin
 begin
   FProjectData.BillsData.sddBills.EndUpdate;
   FProjectData.BillsData.sddBills.EndUpdate;
+  UpdateProgressHint('正在计算导入后的数据');
   FProjectData.BillsCompileData.CalculateAll;
   FProjectData.BillsCompileData.CalculateAll;
+  CloseProgressHint;
 end;
 end;
 
 
 procedure TBillsPriceExcelImport.Import;
 procedure TBillsPriceExcelImport.Import;
@@ -634,19 +641,25 @@ procedure TBillsPriceExcelImport.ImportBillsPriceData(ASheet: TSpreadSheet);
   end;
   end;
 
 
 var
 var
+  iPos: Integer;
   sB_Code: string;
   sB_Code: string;
   fPrice: Double;
   fPrice: Double;
 begin
 begin
+  UpdateProgressHint('写入读取的Excel数据');
+  UpdateProgressPosition(0);
   while (FCurRow < ASheet.Cells.UsedRowCount) do
   while (FCurRow < ASheet.Cells.UsedRowCount) do
   begin
   begin
-    sB_Code := VarToStrDef(ASheet.Cells.GetValue(FB_CodeCol, FCurRow), '');
+    sB_Code := GetCellTrimText(ASheet, FB_CodeCol, FCurRow);
     if (sB_Code <> '') and CheckIsBillsCode(sB_Code) then
     if (sB_Code <> '') and CheckIsBillsCode(sB_Code) then
     begin
     begin
       fPrice := StrToFloatDef(VarToStrDef(ASheet.Cells.GetValue(FPriceCol, FCurRow), ''), 0);
       fPrice := StrToFloatDef(VarToStrDef(ASheet.Cells.GetValue(FPriceCol, FCurRow), ''), 0);
       UpdateBillsPrice(sB_Code, fPrice);
       UpdateBillsPrice(sB_Code, fPrice);
     end;
     end;
     Inc(FCurRow);
     Inc(FCurRow);
+    iPos := FCurRow * 100 div ASheet.Cells.UsedRowCount;
+    UpdateProgressPosition(iPos);
   end;
   end;
+  UpdateProgressPosition(100);
 end;
 end;
 
 
 procedure TBillsPriceExcelImport.LoadColumnsFromHead(ASheet: TSpreadSheet);
 procedure TBillsPriceExcelImport.LoadColumnsFromHead(ASheet: TSpreadSheet);
@@ -661,7 +674,7 @@ begin
   begin
   begin
     for iCol := 0 to ASheet.Cells.UsedColCount do
     for iCol := 0 to ASheet.Cells.UsedColCount do
     begin
     begin
-      sColName := VarToStrDef(ASheet.Cells.GetValue(iCol, FCurRow), '');
+      sColName := GetCellTrimText(ASheet, iCol, FCurRow);
       if SameText(sColName, '清单编号') or SameText(sColName, '子目号') then
       if SameText(sColName, '清单编号') or SameText(sColName, '子目号') then
         FB_CodeCol := iCol
         FB_CodeCol := iCol
       else if SameText(sColName, '名称') then
       else if SameText(sColName, '名称') then
@@ -727,7 +740,7 @@ begin
   begin
   begin
     for iCol := 0 to ASheet.Cells.UsedColCount do
     for iCol := 0 to ASheet.Cells.UsedColCount do
     begin
     begin
-      sColName := VarToStrDef(ASheet.Cells.GetValue(iCol, FCurRow), '');
+      sColName := GetCellTrimText(ASheet, iCol, FCurRow);
       if SameText(sColName, '清单编号') or SameText(sColName, '子目号') then
       if SameText(sColName, '清单编号') or SameText(sColName, '子目号') then
         FB_CodeCol := iCol
         FB_CodeCol := iCol
       else if SameText(sColName, '名称') then
       else if SameText(sColName, '名称') then
@@ -771,23 +784,20 @@ var
 begin
 begin
   while (FCurRow < ASheet.Cells.UsedRowCount) do
   while (FCurRow < ASheet.Cells.UsedRowCount) do
   begin
   begin
-    sB_Code := VarToStrDef(ASheet.Cells.GetValue(FB_CodeCol, FCurRow), '');
+    sB_Code := GetCellTrimText(ASheet, FB_CodeCol, FCurRow);
     if (sB_Code <> '') and CheckIsBillsCode(sB_Code) then
     if (sB_Code <> '') and CheckIsBillsCode(sB_Code) then
     begin
     begin
       Rec := FProjectData.DealBillsData.sddDealBills.Add;
       Rec := FProjectData.DealBillsData.sddDealBills.Add;
       Rec.ValueByName('ID').AsInteger := FBillsID;
       Rec.ValueByName('ID').AsInteger := FBillsID;
       Rec.ValueByName('B_Code').AsString := sB_Code;
       Rec.ValueByName('B_Code').AsString := sB_Code;
-      with ASheet.Cells do
-      begin
-        Rec.ValueByName('Name').AsString := VarToStrDef(GetValue(FNameCol, FCurRow), '');
-        Rec.ValueByName('Units').AsString := VarToStrDef(GetValue(FUnitsCol, FCurRow), '');
-        Rec.ValueByName('Price').AsFloat := PriceRoundTo(
-            StrToFloatDef(VarToStrDef(GetValue(FPriceCol, FCurRow), ''), 0));
-        Rec.ValueByName('Quantity').AsFloat := QuantityRoundTo(
-            StrToFloatDef(VarToStrDef(GetValue(FQuantityCol, FCurRow), ''), 0));
-        Rec.ValueByName('TotalPrice').AsFloat := TotalPriceRoundTo(
-            StrToFloatDef(VarToStrDef(GetValue(FTotalPriceCol, FCurRow), ''), 0));
-      end;
+      Rec.ValueByName('Name').AsString := GetCellTrimText(ASheet, FNameCol, FCurRow);
+      Rec.ValueByName('Units').AsString := GetCellTrimText(ASheet, FUnitsCol, FCurRow);
+      Rec.ValueByName('Price').AsFloat := PriceRoundTo(
+          StrToFloatDef(GetCellTrimText(ASheet, FPriceCol, FCurRow), 0));
+      Rec.ValueByName('Quantity').AsFloat := QuantityRoundTo(
+          StrToFloatDef(GetCellTrimText(ASheet, FQuantityCol, FCurRow), 0));
+      Rec.ValueByName('TotalPrice').AsFloat := TotalPriceRoundTo(
+          StrToFloatDef(GetCellTrimText(ASheet, FTotalPriceCol, FCurRow), 0));
       Inc(FBillsID);
       Inc(FBillsID);
     end;
     end;
     Inc(FCurRow);
     Inc(FCurRow);
@@ -869,14 +879,14 @@ var
 begin
 begin
   with ASheet.Cells do
   with ASheet.Cells do
   begin
   begin
-    sB_Code := VarToStrDef(GetValue(FB_CodeCol, FCurRow), '');
-    sName := VarToStrDef(GetValue(FNameCol, FCurRow), '');
+    sB_Code := Trim(VarToStrDef(GetValue(FB_CodeCol, FCurRow), ''));
+    sName := Trim(VarToStrDef(GetValue(FNameCol, FCurRow), ''));
 
 
     Node := FCacheTree.AddNodeByData(sB_Code, sName);
     Node := FCacheTree.AddNodeByData(sB_Code, sName);
 
 
-    Node.B_Code := VarToStrDef(GetValue(FB_CodeCol, FCurRow), '');
-    Node.Name := VarToStrDef(GetValue(FNameCol, FCurRow), '');
-    Node.Units := VarToStrDef(GetValue(FUnitsCol, FCurRow), '');
+    Node.B_Code := sB_Code;
+    Node.Name := sName;
+    Node.Units := Trim(VarToStrDef(GetValue(FUnitsCol, FCurRow), ''));
     Node.Price := StrToFloatDef(VarToStrDef(GetValue(FPriceCol, FCurRow), ''), 0);
     Node.Price := StrToFloatDef(VarToStrDef(GetValue(FPriceCol, FCurRow), ''), 0);
     Node.Quantity := StrToFloatDef(VarToStrDef(GetValue(FQuantityCol, FCurRow), ''), 0);
     Node.Quantity := StrToFloatDef(VarToStrDef(GetValue(FQuantityCol, FCurRow), ''), 0);
   end;
   end;

+ 1 - 1
Units/MCacheTree.pas

@@ -630,7 +630,7 @@ begin
   while Assigned(Node) do
   while Assigned(Node) do
   begin
   begin
     sCodeID2 := ConvertDigitCode(Node.Code, 3, '-');
     sCodeID2 := ConvertDigitCode(Node.Code, 3, '-');
-    sB_CodeID2 := ConvertDigitCode(AB_Code, 4, '-');
+    sB_CodeID2 := ConvertDigitCode(Node.B_Code, 4, '-');
     if sCodeID < sCodeID2 then
     if sCodeID < sCodeID2 then
     begin
     begin
       Result := Node;
       Result := Node;

+ 7 - 7
Units/PhaseProperty.pas

@@ -23,8 +23,8 @@ type
 
 
     procedure SetFinalAudit(const Value: Boolean);
     procedure SetFinalAudit(const Value: Boolean);
     procedure SetAuditCount(const Value: Integer);
     procedure SetAuditCount(const Value: Integer);
-    function GetZJJLCount: Integer;
-    procedure SetZJJLCount(const Value: Integer);
+    function GetZJJLType: Integer;
+    procedure SetZJJLType(const Value: Integer);
   public
   public
     constructor Create(AConnection: TADOConnection);
     constructor Create(AConnection: TADOConnection);
     destructor Destroy; override;
     destructor Destroy; override;
@@ -35,7 +35,7 @@ type
     property AuditCount: Integer read FAuditCount write SetAuditCount;
     property AuditCount: Integer read FAuditCount write SetAuditCount;
     property FinalAudit: Boolean read FFinalAudit write SetFinalAudit;
     property FinalAudit: Boolean read FFinalAudit write SetFinalAudit;
 
 
-    property ZJJLCount: Integer read GetZJJLCount write SetZJJLCount;
+    property ZJJLType: Integer read GetZJJLType write SetZJJLType;
   end;
   end;
 
 
 implementation
 implementation
@@ -98,9 +98,9 @@ begin
   Result := VarToStrDef(vProperty, ADef);
   Result := VarToStrDef(vProperty, ADef);
 end;
 end;
 
 
-function TPhaseProperties.GetZJJLCount: Integer;
+function TPhaseProperties.GetZJJLType: Integer;
 begin
 begin
-  Result := GetIntPropertyDef('ZJJLCount', 0);
+  Result := GetIntPropertyDef('ZJJLType', 0);
 end;
 end;
 
 
 procedure TPhaseProperties.LoadBaseProperties;
 procedure TPhaseProperties.LoadBaseProperties;
@@ -131,9 +131,9 @@ begin
   FPropertyInqurity.Value['FinalAudit'] := FFinalAudit;
   FPropertyInqurity.Value['FinalAudit'] := FFinalAudit;
 end;
 end;
 
 
-procedure TPhaseProperties.SetZJJLCount(const Value: Integer);
+procedure TPhaseProperties.SetZJJLType(const Value: Integer);
 begin
 begin
-  FPropertyInqurity.Value['ZJJLCount'] := Value;
+  FPropertyInqurity.Value['ZJJLType'] := Value;
 end;
 end;
 
 
 end.
 end.

+ 4 - 0
Units/ProjectData.pas

@@ -563,6 +563,7 @@ begin
   FProjectID := -1;
   FProjectID := -1;
   UnZipFile(AFileName, TempPath);
   UnZipFile(AFileName, TempPath);
   FConnection.Open(MainFileName);
   FConnection.Open(MainFileName);
+  UpdateProjectDataBase;
   FProjProperties.Open(FConnection.Connection);
   FProjProperties.Open(FConnection.Connection);
   if ProjProperties.PhaseCount > 0 then
   if ProjProperties.PhaseCount > 0 then
   begin
   begin
@@ -1281,6 +1282,7 @@ begin
   FProjectID := -1;
   FProjectID := -1;
   UnZipFile(AFileName, TempPath);
   UnZipFile(AFileName, TempPath);
   FConnection.Open(MainFileName);
   FConnection.Open(MainFileName);
+  UpdateProjectDataBase;
   FProjProperties.Open(FConnection.Connection);
   FProjProperties.Open(FConnection.Connection);
   FStaffData.Open(FConnection.Connection);
   FStaffData.Open(FConnection.Connection);
 end;
 end;
@@ -1339,6 +1341,7 @@ begin
   FProjectID := -1;
   FProjectID := -1;
   UnZipFile(AFileName, TempPath);
   UnZipFile(AFileName, TempPath);
   FConnection.Open(MainFileName);
   FConnection.Open(MainFileName);
+  UpdateProjectDataBase;
   FProjProperties.Open(FConnection.Connection);
   FProjProperties.Open(FConnection.Connection);
   if ProjProperties.PhaseCount > 0 then
   if ProjProperties.PhaseCount > 0 then
   begin
   begin
@@ -1365,6 +1368,7 @@ begin
   FProjectID := -1;
   FProjectID := -1;
   UnZipFile(AFileName, TempPath);
   UnZipFile(AFileName, TempPath);
   FConnection.Open(MainFileName);
   FConnection.Open(MainFileName);
+  UpdateProjectDataBase;
   FProjProperties.Open(FConnection.Connection);
   FProjProperties.Open(FConnection.Connection);
   if ProjProperties.PhaseCount > 0 then
   if ProjProperties.PhaseCount > 0 then
   begin
   begin

+ 37 - 0
Units/UtilMethods.pas

@@ -61,6 +61,7 @@ type
   {CodeTransform}
   {CodeTransform}
   function B_CodeToIndexCode(const AB_Code: string): string;
   function B_CodeToIndexCode(const AB_Code: string): string;
   function ChinessNum(const ADigitNum: Integer): string;
   function ChinessNum(const ADigitNum: Integer): string;
+  function Num2Peg(ANum: Double): string;
 
 
   {Compare Code}
   {Compare Code}
   //function CompareCodeWithChar(const ACode1, ACode2: string): Integer;
   //function CompareCodeWithChar(const ACode1, ACode2: string): Integer;
@@ -622,6 +623,42 @@ begin
   Result := TransChineseNum(iBai, 2) + TransChineseNum(iShi, 1) + TransChineseNum(iGe, 0);
   Result := TransChineseNum(iBai, 2) + TransChineseNum(iShi, 1) + TransChineseNum(iGe, 0);
 end;
 end;
 
 
+function CheckDigit(ANum: Double): Integer;
+begin
+  if abs(ANum - advRoundTo(ANum, -2)) > 0.0001 then
+    Result := 3
+  else if abs(ANum - advRoundTo(ANum, -1)) > 0.001 then
+    Result := 2
+  else if abs(ANum - AdvRoundTo(ANum, 0)) > 0.01 then
+    Result := 1
+  else
+    Result := 0; 
+end;
+
+function Num2Peg(ANum: Double): string;
+var
+  fMod: Double;
+  iK, iDigit: Integer;
+  sDigit: string;
+begin
+  iK := Trunc(ANum/1000);
+  fMod := Frac(ANum/1000)*1000;
+  iDigit := CheckDigit(fMod);
+  case iDigit of
+    3: sDigit := FormatFloat('000.000', AdvRoundTo(fMod, -3));
+    2: sDigit := FormatFloat('000.00', AdvRoundTo(fMod, -2));
+    1: sDigit := FormatFloat('000.0', AdvRoundTo(fMod, -1));
+    0: sDigit := FormatFloat('000', Trunc(AdvRoundTo(fMod, 0)));
+  end;
+{  case iDigit of
+    3: Result := Format('K%d+%3.3f', [iK, ]);
+    2: Result := Format('K%d+%3.2f', [iK, AdvRoundTo(fMod, -2)]);
+    1: Result := Format('K%d+%3.1f', [iK, AdvRoundTo(fMod, -1)]);
+    0: Result := Format('K%d+%s', [iK, FormatFloat('000', [])]);
+  end;                                                          }
+  Result := Format('K%d+%s', [iK, sDigit]);
+end;
+
 {Tree Relative}
 {Tree Relative}
 
 
 function CreateTree: TZjIDTree;
 function CreateTree: TZjIDTree;

+ 198 - 0
Units/mPegFilter.pas

@@ -0,0 +1,198 @@
+unit mPegFilter;
+
+interface
+
+uses
+  Classes, SysUtils;
+
+type
+  TPegFilter = class
+  private
+    FBeginPeg: string;
+    FBeginPegNum: Double;
+    FEndPeg: string;
+    FEndPegNum: Double;
+
+    function PegFormat(const AStr: string): string;
+    function FilterPeg(const AStr: string; var APeg: string; var ANum: Double; var ABegin, AEnd: Integer): Boolean;
+  public
+    function Filter(const AStr: string): Boolean;
+
+    property BeginPeg: string read FBeginPeg;
+    property BeginPegNum: Double read FBeginPegNum;
+    property EndPeg: string read FEndPeg;
+    property EndPegNum: Double read FEndPegNum;
+  end;
+
+function PegFilter: TPegFilter;
+
+implementation
+
+uses Math;
+
+var
+  FPegFilter: TPegFilter;
+
+function PegFilter: TPegFilter;
+begin
+  if FPegFilter = nil then
+    FPegFilter := TPegFilter.Create;
+  Result := FPegFilter;
+end;
+
+{ TPegFilter }
+
+function TPegFilter.Filter(const AStr: string): Boolean;
+var
+  sPeg: string;
+  iPos, iBegin, iEnd: Integer;
+begin
+  sPeg := PegFormat(AStr);
+  Result := FilterPeg(sPeg, FBeginPeg, FBeginPegNum, iBegin, iEnd);
+  if Result and (sPeg[iEnd+1] = '~') then
+  begin
+    sPeg := StringReplace(sPeg, FBeginPeg, '', []);
+    FilterPeg(sPeg, FEndPeg, FEndPegNum, iBegin, iEnd);
+    if FEndPegNum = 0 then
+    begin
+      FEndPeg := FBeginPeg;
+      FEndPegNum := FBeginPegNum;
+    end
+    else
+      Result := FEndPegNum >= FBeginPegNum;
+  end
+  else
+  begin
+    FEndPeg := '';
+    FEndPegNum := 0;
+  end;
+end;
+
+function TPegFilter.FilterPeg(const AStr: string; var APeg: string;
+  var ANum: Double; var ABegin, AEnd: Integer): Boolean;
+
+  function FilterInt(ABegin: Integer; var AEnd: Integer; var AIntStr: string; var AValue: Integer): Boolean;
+  var
+    iPos, iLength: Integer;
+    sInt: string;
+  begin
+    AIntStr := '';
+    AEnd := ABegin;
+
+    iPos := ABegin;
+    iLength := Length(AStr);
+    while (iPos <= iLength) do
+    begin
+      if AStr[iPos] in ['0'..'9'] then
+      begin
+        AIntStr := AIntStr + AStr[iPos];
+        AEnd := iPos;
+      end
+      else Break;
+      Inc(iPos);
+    end;
+
+    Result := AIntStr <> '';
+    AValue := StrToIntDef(AIntStr, 0);
+  end;
+
+  // ¹ýÂËÒ»¸öСÓÚ1000µÄFloat
+  function FilterFloat(ABegin: Integer; var AEnd: Integer; var AFloatStr: string; var AValue: Double): Boolean;
+  var
+    iPos, iLength, iIntPartLength: Integer;
+    bHasPoint, bAllZero: Boolean;
+  begin
+    AFloatStr := '';
+    AEnd := ABegin;
+
+    iPos := ABegin;
+    iLength := Length(AStr);
+    bHasPoint := False;
+    bAllZero := True;
+    iIntPartLength := 0;
+    while (iPos <= iLength) do
+    begin
+      if AStr[iPos] in ['0'..'9'] then
+      begin
+        AFloatStr := AFloatStr + AStr[iPos];
+        AEnd := iPos;
+        if not bHasPoint then
+          Inc(iIntPartLength);
+
+        bAllZero := bAllZero and (AStr[iPos] = '0');
+      end
+      else if (AStr[iPos] = '.') and (not bHasPoint) then
+      begin
+        AFloatStr := AFloatStr + AStr[iPos];
+        AEnd := iPos;
+        bHasPoint := True;
+      end
+      else Break;
+      Inc(iPos);
+    end;
+
+    if iIntPartLength > 3 then
+    begin
+      AEnd := ABegin + 3 - 1;
+      AFloatStr := Copy(AFloatStr, 1, 3);
+    end;
+
+    AValue := StrToFloatDef(AFloatStr, 0);
+    Result := (AValue <> 0) or (bAllZero and (AEnd > ABegin));
+  end;
+
+var
+  iPos, iLength: Integer;
+  iBeginNum, iEndNum, iPosPuls, iBeginNum2, iEndNum2: Integer;
+  sNum, sNum2: string;
+  iNum: Integer;
+  fNum: Double;
+begin
+  Result := False;
+  APeg := '';
+  ANum := 0;
+  ABegin := -1;
+  AEnd := -1;
+
+  iPos := 1;
+  iLength := Length(AStr);
+  while (iPos <= iLength) and (not Result) do
+  begin
+    if AStr[iPos] = 'k' then
+    begin
+      iBeginNum := iPos + 1;
+      if FilterInt(iBeginNum, iEndNum, sNum, iNum) then
+      begin
+        iPosPuls := iEndNum + 1;
+        if AStr[iPosPuls] = '+' then
+        begin
+          iBeginNum2 := iPosPuls + 1;
+          if FilterFloat(iBeginNum2, iEndNum2, sNum2, fNum) then
+          begin
+            Result := True;
+            APeg := Copy(AStr, iPos, iEndNum2-iPos+1);
+            ANum := iNum * 1000 + fNum;
+            ABegin := iPos;
+            AEnd := iEndNum2;
+          end;
+        end;
+      end
+    end;
+    inc(iPos);
+  end;
+end;
+
+function TPegFilter.PegFormat(const AStr: string): string;
+begin
+  Result := AStr;
+  Result := StringReplace(Result, 'K', 'k', [rfReplaceAll]);
+  Result := StringReplace(Result, '£«', '+', [rfReplaceAll]);
+  Result := StringReplace(Result, '¡«', '~', [rfReplaceAll]);
+  Result := StringReplace(Result, ' ', '', [rfReplaceAll]);
+end;
+
+initialization
+  FPegFilter := nil;
+finalization
+  FPegFilter.Free;
+end.