Browse Source

Merge branch 'master' of http://192.168.1.12:3000/maixinrong/measure

Conflicts:
	Forms/MainFrm.dfm
	Forms/MainFrm.pas
	Frames/ProjectFme.pas
解决冲突
MaiXinRong 9 years ago
parent
commit
82ea5fb78f
100 changed files with 9474 additions and 2229 deletions
  1. 101 49
      DataModules/BillsCompileDm.pas
  2. 4 1
      DataModules/BillsDm.dfm
  3. 5 2
      DataModules/BillsDm.pas
  4. 446 368
      DataModules/BillsGatherDm.dfm
  5. 246 431
      DataModules/BillsGatherDm.pas
  6. 15 0
      DataModules/BillsMeasureDm.dfm
  7. 109 13
      DataModules/BillsMeasureDm.pas
  8. 15 1
      DataModules/DealPaymentDm.dfm
  9. 96 1
      DataModules/DealPaymentDm.pas
  10. 44 0
      DataModules/DetailGLDm.dfm
  11. 368 0
      DataModules/DetailGLDm.pas
  12. 1 0
      DataModules/PhasePayDm.pas
  13. 223 0
      DataModules/PriceMarginBillsDm.dfm
  14. 377 0
      DataModules/PriceMarginBillsDm.pas
  15. 117 0
      DataModules/ProjectGLDm.dfm
  16. 575 0
      DataModules/ProjectGLDm.pas
  17. 27 2
      DataModules/ReportMemoryDm/rmBillsGatherDm.dfm
  18. 9 2
      DataModules/ReportMemoryDm/rmBillsGatherDm.pas
  19. 102 444
      DataModules/ReportMemoryDm/rmGcl_XmjBillsDm.pas
  20. 361 0
      DataModules/ReportMemoryDm/rmHaBaiCustomizedDm.dfm
  21. 1355 0
      DataModules/ReportMemoryDm/rmHaBaiCustomizedDm.pas
  22. 6 0
      DataModules/StageDm.dfm
  23. 217 22
      DataModules/StageDm.pas
  24. 41 0
      Dprs/CSL/Measure_Cloud.cfg
  25. 156 0
      Dprs/CSL/Measure_Cloud.dof
  26. 206 0
      Dprs/CSL/Measure_Cloud.dpr
  27. BIN
      Dprs/CSL/Measure_Cloud.res
  28. 2 2
      Dprs/Pro/Measure.cfg
  29. 14 30
      Dprs/Pro/Measure.dof
  30. 14 1
      Dprs/Pro/Measure.dpr
  31. BIN
      Dprs/Pro/Measure.res
  32. 2 2
      Dprs/Pro/Measure_Cloud.cfg
  33. 11 36
      Dprs/Pro/Measure_Cloud.dof
  34. 14 1
      Dprs/Pro/Measure_Cloud.dpr
  35. BIN
      Dprs/Pro/Measure_Cloud.res
  36. 2 2
      Dprs/Pro/Measure_GuangDong.cfg
  37. 11 31
      Dprs/Pro/Measure_GuangDong.dof
  38. 14 1
      Dprs/Pro/Measure_GuangDong.dpr
  39. BIN
      Dprs/Pro/Measure_GuangDong.res
  40. 2 2
      Dprs/Pro/Measure_GuangDong_Cloud.cfg
  41. 11 39
      Dprs/Pro/Measure_GuangDong_Cloud.dof
  42. 14 1
      Dprs/Pro/Measure_GuangDong_Cloud.dpr
  43. BIN
      Dprs/Pro/Measure_GuangDong_Cloud.res
  44. 2 2
      Dprs/Pro/Measure_GuangDong_TZ.cfg
  45. 6 3
      Dprs/Pro/Measure_GuangDong_TZ.dof
  46. 14 1
      Dprs/Pro/Measure_GuangDong_TZ.dpr
  47. BIN
      Dprs/Pro/Measure_GuangDong_TZ.res
  48. 2 2
      Dprs/Pro/Measure_TZ.cfg
  49. 11 38
      Dprs/Pro/Measure_TZ.dof
  50. 14 1
      Dprs/Pro/Measure_TZ.dpr
  51. BIN
      Dprs/Pro/Measure_TZ.res
  52. 2 2
      Dprs/Trail/Measure.cfg
  53. 2 39
      Dprs/Trail/Measure.dof
  54. 14 1
      Dprs/Trail/Measure.dpr
  55. BIN
      Dprs/Trail/Measure.res
  56. 2 2
      Dprs/Trail/Measure_GuangDong.cfg
  57. 2 41
      Dprs/Trail/Measure_GuangDong.dof
  58. 14 1
      Dprs/Trail/Measure_GuangDong.dpr
  59. BIN
      Dprs/Trail/Measure_GuangDong.res
  60. 6 0
      Forms/BatchInsertBillsFrm.dfm
  61. 1 0
      Forms/BatchInsertBillsFrm.pas
  62. 3 3
      Forms/BatchReplaceBillsFrm.dfm
  63. 252 0
      Forms/DealPayPlanFrm.dfm
  64. 294 0
      Forms/DealPayPlanFrm.pas
  65. 36 22
      Forms/LoginFrm.dfm
  66. 128 53
      Forms/LoginFrm.pas
  67. 29 3
      Forms/MainFrm.dfm
  68. 5 1
      Forms/MainFrm.pas
  69. 11 11
      Forms/ReportsFrm.dfm
  70. 30 2
      Forms/ReportsFrm.pas
  71. 269 0
      Forms/SelectDetailGLsFrm.dfm
  72. 158 0
      Forms/SelectDetailGLsFrm.pas
  73. 1 1
      Frames/BGLFme.dfm
  74. 1 1
      Frames/BillsCompileFme.dfm
  75. 549 236
      Frames/BillsGatherFme.dfm
  76. 51 26
      Frames/BillsGatherFme.pas
  77. 59 2
      Frames/BillsMeasureFme.dfm
  78. 40 14
      Frames/BillsMeasureFme.pas
  79. 3 1
      Frames/DealBillsFme.dfm
  80. 10 0
      Frames/DealPaymentFme.dfm
  81. 79 4
      Frames/DealPaymentFme.pas
  82. 1 1
      Frames/PhaseCompareFme.dfm
  83. 745 0
      Frames/PriceMarginBillsFme.dfm
  84. 190 0
      Frames/PriceMarginBillsFme.pas
  85. 115 0
      Frames/PriceMarginFme.dfm
  86. 82 0
      Frames/PriceMarginFme.pas
  87. 35 8
      Frames/ProjectFme.dfm
  88. 43 13
      Frames/ProjectFme.pas
  89. 291 0
      Frames/ProjectGLFme.dfm
  90. 94 0
      Frames/ProjectGLFme.pas
  91. 3 1
      Frames/SearchFme.dfm
  92. 3 1
      Frames/StandardBillsFme.dfm
  93. 1 1
      TenderPartition/tpBaseGatherData.pas
  94. 1 1
      TenderPartition/tpPartTenderSet.pas
  95. 159 0
      Units/BaseClipboard.pas
  96. 16 121
      Units/BillsClipboard.pas
  97. 3 0
      Units/ConstUnit.pas
  98. 142 6
      Units/DataBaseTables.pas
  99. 117 79
      Units/DetailExcelImport.pas
  100. 0 0
      Units/GclBillsGatherModel.pas

+ 101 - 49
DataModules/BillsCompileDm.pas

@@ -147,18 +147,36 @@ procedure TBillsCompileData.sdvBillsCompileGetText(var Text: String;
   ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
   ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
   DisplayText: Boolean);
   DisplayText: Boolean);
 
 
+  function GetQtyEditText(const AFormulaField: string): Boolean;
+  begin
+
+  end;
+
   procedure GetEditText;
   procedure GetEditText;
   var
   var
     sFormula: string;
     sFormula: string;
+    sFormulaField: string;
   begin
   begin
-    if SameText('OrgQuantity', AColumn.FieldName) then
-      sFormula := ARecord.ValueByName('OrgFormula').AsString
-    else if SameText('MisQuantity', AColumn.FieldName) then
-      sFormula := ARecord.ValueByName('MisFormula').AsString
-    else if SameText('OthQuantity', AColumn.FieldName) then
-      sFormula := ARecord.ValueByName('OthFormula').AsString
-    else
-      sFormula := '';
+    sFormula := '';
+    if ARecord.ValueByName('CalcType').AsInteger = 0 then
+    begin
+      if SameText('OrgQuantity', AColumn.FieldName) then
+        sFormula := ARecord.ValueByName('OrgFormula').AsString
+      else if SameText('MisQuantity', AColumn.FieldName) then
+        sFormula := ARecord.ValueByName('MisFormula').AsString
+      else if SameText('OthQuantity', AColumn.FieldName) then
+        sFormula := ARecord.ValueByName('OthFormula').AsString;
+    end
+    else if ARecord.ValueByName('CalcType').AsInteger = 1 then
+    begin
+      if SameText('OrgTotalPrice', AColumn.FieldName) then
+        sFormula := ARecord.ValueByName('OrgFormula').AsString
+      else if SameText('MisTotalPrice', AColumn.FieldName) then
+        sFormula := ARecord.ValueByName('MisFormula').AsString
+      else if SameText('OthTotalPrice', AColumn.FieldName) then
+        sFormula := ARecord.ValueByName('OthFormula').AsString;
+    end;
+
     if sFormula <> '' then
     if sFormula <> '' then
       Text := sFormula;
       Text := sFormula;
   end;
   end;
@@ -168,7 +186,7 @@ procedure TBillsCompileData.sdvBillsCompileGetText(var Text: String;
     if (Pos('Price', AColumn.FieldName) > 0) or
     if (Pos('Price', AColumn.FieldName) > 0) or
        (Pos('Quantity', AColumn.FieldName) > 0) then
        (Pos('Quantity', AColumn.FieldName) > 0) then
     begin
     begin
-      if Assigned(AValue) and (AValue.AsFloat = 0) then
+      if not Assigned(AValue) or (AValue.AsFloat = 0) then
         Text := '';
         Text := '';
     end;
     end;
   end;
   end;
@@ -276,33 +294,6 @@ end;
 procedure TBillsCompileData.sdvBillsCompileBeforeValueChange(
 procedure TBillsCompileData.sdvBillsCompileBeforeValueChange(
   AValue: TsdValue; const NewValue: Variant; var Allow: Boolean);
   AValue: TsdValue; const NewValue: Variant; var Allow: Boolean);
 begin
 begin
-  // 清单编号和项目节编号不可同时存在
-  if SameText(AValue.FieldName, 'Code') then
-  begin
-    if AValue.Owner.ValueByName('B_Code').AsString <> '' then
-      DataSetErrorMessage(Allow, '已存在清单编号,不可输入项目节编号!');
-  end
-  else if SameText(AValue.FieldName, 'B_Code') then
-  begin
-    if AValue.Owner.ValueByName('Code').AsString <> '' then
-      DataSetErrorMessage(Allow, '已存在项目节编号,不可输入清单编号!');
-  end
-  //
-  else if SameText(AValue.FieldName, 'Price') then
-  begin
-    if AValue.Owner.ValueByName('AddGatherTotalPrice').AsFloat <> 0 then
-      DataSetErrorMessage(Allow, '该清单已经开始计量,不可修改单价!');
-  end
-  // 变更清单不可修改0号台账数据
-  else if SameText(AValue.FieldName, 'OrgQuantity') or
-      SameText(AValue.FieldName, 'MisQuantity') or
-      SameText(AValue.FieldName, 'OthQuantity') then
-  begin
-    if AValue.Owner.ValueByName('IsMeasureAdd').AsBoolean then
-      DataSetErrorMessage(Allow, '变更清单不可填写0号台账数量与金额');
-  end;
-  if not Allow then Exit;
-    
   if SameText(AValue.FieldName, 'OrgQuantity') or
   if SameText(AValue.FieldName, 'OrgQuantity') or
       SameText(AValue.FieldName, 'MisQuantity') or
       SameText(AValue.FieldName, 'MisQuantity') or
       SameText(AValue.FieldName, 'OthQuantity') or
       SameText(AValue.FieldName, 'OthQuantity') or
@@ -558,22 +549,33 @@ procedure TBillsCompileData.sdvBillsCompileSetText(var Text: String;
     Allow := False;
     Allow := False;
   end;
   end;
 
 
-  procedure SetQuantity(const APre: string);
+  procedure SetQuantity(const AFieldName: string);
+  var
+    sPre: string;
   begin
   begin
-    // 0号台账改为三项合计后,不记录输入的公式,但允许公式计算
+    sPre := StringReplace(AFieldName, 'Quantity', '', [rfIgnoreCase, rfReplaceAll]);
     if CheckStringNull(Text) or CheckNumeric(Text) then
     if CheckStringNull(Text) or CheckNumeric(Text) then
       Text := FloatToStr(QuantityRoundTo(StrToFloatDef(Text, 0)))
       Text := FloatToStr(QuantityRoundTo(StrToFloatDef(Text, 0)))
     else
     else
     begin
     begin
-      ARecord.ValueByName(APre + 'Formula').AsString := Text;
+      ARecord.ValueByName(sPre + 'Formula').AsString := Text;
       Text := FloatToStr(QuantityRoundTo(EvaluateExprs(Text)));
       Text := FloatToStr(QuantityRoundTo(EvaluateExprs(Text)));
     end;
     end;
     ARecord.ValueByName('CalcType').AsInteger := 0;
     ARecord.ValueByName('CalcType').AsInteger := 0;
   end;
   end;
 
 
-  procedure SetTotalPrice;
+  procedure SetTotalPrice(const AFieldName: string);
+  var
+    sPre: string;
   begin
   begin
-    Text := FloatToStr(TotalPriceRoundTo(StrToFloatDef(Text, 0)));
+    sPre := StringReplace(AFieldName, 'TotalPrice', '', [rfIgnoreCase, rfReplaceAll]);
+    if CheckStringNull(Text) or CheckNumeric(Text) then
+      Text := FloatToStr(TotalPriceRoundTo(StrToFloatDef(Text, 0)))
+    else
+    begin
+      ARecord.ValueByName(sPre + 'Formula').AsString := Text;
+      Text := FloatToStr(TotalPriceRoundTo(EvaluateExprs(Text)));
+    end;
     ARecord.ValueByName('CalcType').AsInteger := 1;
     ARecord.ValueByName('CalcType').AsInteger := 1;
   end;
   end;
 
 
@@ -585,20 +587,19 @@ procedure TBillsCompileData.sdvBillsCompileSetText(var Text: String;
   procedure SetPrice;
   procedure SetPrice;
   begin
   begin
     Text := FloatToStr(PriceRoundTo(StrToFloatDef(Text, 0)));
     Text := FloatToStr(PriceRoundTo(StrToFloatDef(Text, 0)));
+    ARecord.ValueByName('CalcType').AsInteger := 0;
   end;
   end;
 
 
   procedure DoCurChanged;
   procedure DoCurChanged;
   begin
   begin
-    if SameText(AColumn.FieldName, 'OrgQuantity') then
-      SetQuantity('Org')
-    else if SameText(AColumn.FieldName, 'MisQuantity') then
-      SetQuantity('Mis')
-    else if SameText(AColumn.FieldName, 'OthQuantity') then
-      SetQuantity('Oth')
+    if SameText(AColumn.FieldName, 'OrgQuantity') or
+        SameText(AColumn.FieldName, 'MisQuantity') or
+        SameText(AColumn.FieldName, 'OthQuantity')then
+      SetQuantity(AColumn.FieldName)
     else if SameText(AColumn.FieldName, 'OrgTotalPrice') or
     else if SameText(AColumn.FieldName, 'OrgTotalPrice') or
         SameText(AColumn.FieldName, 'MisTotalPrice') or
         SameText(AColumn.FieldName, 'MisTotalPrice') or
         SameText(AColumn.FieldName, 'OthTotalPrice') then
         SameText(AColumn.FieldName, 'OthTotalPrice') then
-      SetTotalPrice
+      SetTotalPrice(AColumn.FieldName)
     else if Pos('DgnQuantity', AColumn.FieldName) = 1 then
     else if Pos('DgnQuantity', AColumn.FieldName) = 1 then
       SetDgnQuantity
       SetDgnQuantity
     else if SameText(AColumn.FieldName, 'Price') then
     else if SameText(AColumn.FieldName, 'Price') then
@@ -632,6 +633,9 @@ procedure TBillsCompileData.sdvBillsCompileSetText(var Text: String;
     vNode := TBillsIDTreeNode(BillsCompileTree.FindNode(ARecord.ValueByName('ID').AsInteger));
     vNode := TBillsIDTreeNode(BillsCompileTree.FindNode(ARecord.ValueByName('ID').AsInteger));
     iCreatePhase := vNode.Rec.ValueByName('CreatePhaseID').AsInteger;
     iCreatePhase := vNode.Rec.ValueByName('CreatePhaseID').AsInteger;
 
 
+    if vNode.ID = iPriceMarginID then
+      SetTextErrorHint(sBills_PMHint);
+
     if vNode.HasChildren then
     if vNode.HasChildren then
     begin
     begin
       if Text = '' then
       if Text = '' then
@@ -665,6 +669,36 @@ procedure TBillsCompileData.sdvBillsCompileSetText(var Text: String;
       if not Allow then Exit;
       if not Allow then Exit;
     end;
     end;
 
 
+    // 清单编号和项目节编号不可同时存在
+    if SameText(AValue.FieldName, 'Code') then
+    begin
+      if AValue.Owner.ValueByName('B_Code').AsString <> '' then
+        SetTextErrorHint('已存在清单编号,不可输入项目节编号!');
+    end
+    else if SameText(AValue.FieldName, 'B_Code') then
+    begin
+      if AValue.Owner.ValueByName('Code').AsString <> '' then
+        SetTextErrorHint('已存在项目节编号,不可输入清单编号!');
+    end
+    //
+    else if SameText(AValue.FieldName, 'Price') then
+    begin
+      if AValue.Owner.ValueByName('AddGatherTotalPrice').AsFloat <> 0 then
+        SetTextErrorHint('该清单已经开始计量,不可修改单价!');
+    end
+    // 变更清单不可修改0号台账数据
+    else if SameText(AValue.FieldName, 'OrgQuantity') or
+        SameText(AValue.FieldName, 'OrgTotalPrice') or
+        SameText(AValue.FieldName, 'MisQuantity') or
+        SameText(AValue.FieldName, 'MisTotalPrice') or
+        SameText(AValue.FieldName, 'OthQuantity') or
+        SameText(AValue.FieldName, 'OthTotalPrice') then
+    begin
+      if AValue.Owner.ValueByName('IsMeasureAdd').AsBoolean then
+        SetTextErrorHint('变更清单不可填写0号台账数量与金额');
+    end;
+    if not Allow then Exit;
+
     if SameText('Code', AColumn.FieldName) or
     if SameText('Code', AColumn.FieldName) or
        SameText('B_Code', AColumn.FieldName) or
        SameText('B_Code', AColumn.FieldName) or
        SameText('Name', AColumn.FieldName) or
        SameText('Name', AColumn.FieldName) or
@@ -674,10 +708,28 @@ procedure TBillsCompileData.sdvBillsCompileSetText(var Text: String;
         SetTextErrorHint('该清单已经计量,不可修改清单编号');
         SetTextErrorHint('该清单已经计量,不可修改清单编号');
   end;
   end;
 
 
+  function CheckValidData: Boolean;
+  begin
+    Result := (AValue.AsString <> Text);
+    if SameText(AColumn.FieldName, 'OrgQuantity') or
+       SameText(AColumn.FieldName, 'OrgTotalPrice') or
+       SameText(AColumn.FieldName, 'MisQuantity') or
+       SameText(AColumn.FieldName, 'MisTotalPrice') or
+       SameText(AColumn.FieldName, 'OthQuantity') or
+       SameText(AColumn.FieldName, 'OthTotalPrice') or
+       SameText(AColumn.FieldName, 'Price') then
+    begin
+      if (AValue.AsFloat = 0) and (Text = '') then
+        Result := False;
+    end;
+  end;
+
 begin
 begin
   if not Assigned(AValue) then Exit;
   if not Assigned(AValue) then Exit;
   // 修改后数据与原数据相同则不提交
   // 修改后数据与原数据相同则不提交
-  if (AValue.AsString = Text) or ((AValue.AsFloat = 0) and (Text = '')) then Exit;
+  if not CheckValidData then
+    Allow := False;
+  if not Allow then Exit;
 
 
   CheckLockedData;
   CheckLockedData;
   if not Allow then Exit;
   if not Allow then Exit;

+ 4 - 1
DataModules/BillsDm.dfm

@@ -209,6 +209,9 @@ object BillsData: TBillsData
       C8000549734B6579080F4E65656450726F636573734E616D65090001044E616D
       C8000549734B6579080F4E65656450726F636573734E616D65090001044E616D
       65060A4F7468466F726D756C61094669656C644E616D65060A4F7468466F726D
       65060A4F7468466F726D756C61094669656C644E616D65060A4F7468466F726D
       756C610844617461547970650218084461746153697A6503C8000549734B6579
       756C610844617461547970650218084461746153697A6503C8000549734B6579
-      080F4E65656450726F636573734E616D65090000}
+      080F4E65656450726F636573734E616D65090001044E616D650610504D5F4164
+      64546F74616C5072696365094669656C644E616D650610504D5F416464546F74
+      616C50726963650844617461547970650206084461746153697A650208054973
+      4B6579080F4E65656450726F636573734E616D65090000}
   end
   end
 end
 end

+ 5 - 2
DataModules/BillsDm.pas

@@ -132,8 +132,11 @@ begin
     sddBills.AddIndex('idxID', 'ID');
     sddBills.AddIndex('idxID', 'ID');
     
     
   sddBills.FieldByName('OrgQuantity').ValidChars := sddBills.FieldByName('Quantity').ValidChars + ArithmeticCharSet;
   sddBills.FieldByName('OrgQuantity').ValidChars := sddBills.FieldByName('Quantity').ValidChars + ArithmeticCharSet;
-  sddBills.FieldByName('MisQuantity').ValidChars := sddBills.FieldByName('Quantity').ValidChars + ArithmeticCharSet;
-  sddBills.FieldByName('OthQuantity').ValidChars := sddBills.FieldByName('Quantity').ValidChars + ArithmeticCharSet;
+  sddBills.FieldByName('OrgTotalPrice').ValidChars := sddBills.FieldByName('OrgQuantity').ValidChars;
+  sddBills.FieldByName('MisQuantity').ValidChars := sddBills.FieldByName('OrgQuantity').ValidChars;
+  sddBills.FieldByName('MisTotalPrice').ValidChars := sddBills.FieldByName('OrgQuantity').ValidChars;
+  sddBills.FieldByName('OthQuantity').ValidChars := sddBills.FieldByName('OrgQuantity').ValidChars;
+  sddBills.FieldByName('OthTotalPrice').ValidChars := sddBills.FieldByName('OrgQuantity').ValidChars;
 end;
 end;
 
 
 procedure TBillsData.Save;
 procedure TBillsData.Save;

+ 446 - 368
DataModules/BillsGatherDm.dfm

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

+ 246 - 431
DataModules/BillsGatherDm.pas

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

+ 15 - 0
DataModules/BillsMeasureDm.dfm

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

+ 109 - 13
DataModules/BillsMeasureDm.pas

@@ -35,11 +35,13 @@ type
 
 
     procedure CalcAddCompleteRate(ANode: TsdIDTreeNode);
     procedure CalcAddCompleteRate(ANode: TsdIDTreeNode);
     procedure CalcAddDgnPrice(ANode: TsdIDTreeNode);
     procedure CalcAddDgnPrice(ANode: TsdIDTreeNode);
-    procedure UpdateRecordGather(ANode: TsdIDTreeNode; AQuantity, ATotalPrice: Double);
 
 
     function SelectAndUpdateBGL(ABillsID: Integer; ARec: TsdDataRecord;
     function SelectAndUpdateBGL(ABillsID: Integer; ARec: TsdDataRecord;
       ANewValue: Double; const AType: string): Boolean;
       ANewValue: Double; const AType: string): Boolean;
 
 
+    procedure CalculateNode(ANode: TBillsIDTreeNode);            
+    procedure UpdateRecordGather(ANode: TsdIDTreeNode; AQuantity, ATotalPrice: Double);
+
     function GetStageData: TStageData;
     function GetStageData: TStageData;
     procedure SetOnRecChange(const Value: TRecChangeEvent);
     procedure SetOnRecChange(const Value: TRecChangeEvent);
   public
   public
@@ -65,6 +67,8 @@ type
     procedure UpdateRecordDeal(ABillsID: Integer; AQuantity, ATotalPrice: Double);
     procedure UpdateRecordDeal(ABillsID: Integer; AQuantity, ATotalPrice: Double);
     procedure UpdateRecordQc(ABillsID: Integer; AQuantity, ATotalPrice: Double);
     procedure UpdateRecordQc(ABillsID: Integer; AQuantity, ATotalPrice: Double);
     procedure UpdateRecordPc(ABillsID: Integer; AQuantity, ATotalPrice: Double);
     procedure UpdateRecordPc(ABillsID: Integer; AQuantity, ATotalPrice: Double);
+    procedure UpdateRecordPM(ABillsID: Integer; ADiffer: Double);
+    procedure UpdateGather(ABillsID: Integer; ADiffer: Double);
     procedure UpdateBGLInfo(ABillsID: Integer; ARec: TsdDataRecord; const AType: string);
     procedure UpdateBGLInfo(ABillsID: Integer; ARec: TsdDataRecord; const AType: string);
 
 
     property ProjectData: TObject read FProjectData;
     property ProjectData: TObject read FProjectData;
@@ -80,7 +84,7 @@ implementation
 
 
 uses
 uses
   ProjectData, PhaseData, Math, ZhAPI, BillsCommand, BGLSelectFrm,
   ProjectData, PhaseData, Math, ZhAPI, BillsCommand, BGLSelectFrm,
-  BGLDm, UtilMethods, mDataRecord;
+  BGLDm, UtilMethods, mDataRecord, ConstUnit;
 
 
 {$R *.dfm}
 {$R *.dfm}
 
 
@@ -147,6 +151,9 @@ begin
     sdvBillsMeasure.Columns.FindColumn('EndPcTotalPrice').LookupDataSet := StageData.sddStage;
     sdvBillsMeasure.Columns.FindColumn('EndPcTotalPrice').LookupDataSet := StageData.sddStage;
     sdvBillsMeasure.Columns.FindColumn('EndGatherQuantity').LookupDataSet := StageData.sddStage;
     sdvBillsMeasure.Columns.FindColumn('EndGatherQuantity').LookupDataSet := StageData.sddStage;
     sdvBillsMeasure.Columns.FindColumn('EndGatherTotalPrice').LookupDataSet := StageData.sddStage;
     sdvBillsMeasure.Columns.FindColumn('EndGatherTotalPrice').LookupDataSet := StageData.sddStage;
+
+    sdvBillsMeasure.Columns.FindColumn('PM_PreTotalPrice').LookupDataSet := StageData.sddStage;
+    sdvBillsMeasure.Columns.FindColumn('PM_TotalPrice').LookupDataSet := StageData.sddStage;
   end;
   end;
 end;
 end;
 
 
@@ -180,11 +187,8 @@ procedure TBillsMeasureData.sdvBillsMeasureGetText(var Text: String;
   begin
   begin
     with AValue.Owner do
     with AValue.Owner do
     begin
     begin
-      if ValueByName(AQtyType + 'Flag').AsInteger = 2 then
-      begin
-        FFormulaCalc.SetRecordText(ValueByName(AQtyType + 'Formula').AsString);
-        Result := FFormulaCalc.DisplayText;
-      end
+      if ValueByName(AQtyType + 'Formula').AsString <> '' then
+        Result := ValueByName(AQtyType + 'Formula').AsString
       else
       else
         Result := Text;
         Result := Text;
     end;
     end;
@@ -288,6 +292,9 @@ procedure TBillsMeasureData.sdvBillsMeasureSetText(var Text: String;
     vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(GetBillsID));
     vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(GetBillsID));
     iCreatePhase := vNode.Rec.ValueByName('CreatePhaseID').AsInteger;
     iCreatePhase := vNode.Rec.ValueByName('CreatePhaseID').AsInteger;
 
 
+    if vNode.ID = iPriceMarginID then
+      DataSetErrorMessage(Allow, sBills_PMHint);
+
     if SameText('B_Code', AColumn.FieldName) or
     if SameText('B_Code', AColumn.FieldName) or
         SameText('Name', AColumn.FieldName) or
         SameText('Name', AColumn.FieldName) or
         SameText('Units', AColumn.FieldName) then
         SameText('Units', AColumn.FieldName) then
@@ -325,7 +332,8 @@ procedure TBillsMeasureData.sdvBillsMeasureSetText(var Text: String;
       end
       end
       else if SameText('CurDealQuantity', AColumn.FieldName) or
       else if SameText('CurDealQuantity', AColumn.FieldName) or
           SameText('CurQcQuantity', AColumn.FieldName) or
           SameText('CurQcQuantity', AColumn.FieldName) or
-          SameText('CurPcQuantity', AColumn.FieldName) then
+          SameText('CurPcQuantity', AColumn.FieldName) or
+          SameText('Price', AColumn.FieldName) then
       begin
       begin
         if not vNode.CountPriceEnable then
         if not vNode.CountPriceEnable then
           DataSetErrorMessage(Allow, '该清单不可输入数量单价,如需使用数量×单价计算,请先清空所有直接输入的金额!');
           DataSetErrorMessage(Allow, '该清单不可输入数量单价,如需使用数量×单价计算,请先清空所有直接输入的金额!');
@@ -340,6 +348,8 @@ procedure TBillsMeasureData.sdvBillsMeasureSetText(var Text: String;
   end;
   end;
 
 
   procedure SetQuantity(const AField: string);
   procedure SetQuantity(const AField: string);
+  var
+    vNode: TBillsIDTreeNode;
   begin
   begin
     // 变更应选择变更令
     // 变更应选择变更令
     if SameText(AField , 'Qc') or SameText(AField , 'Pc') then
     if SameText(AField , 'Qc') or SameText(AField , 'Pc') then
@@ -358,9 +368,15 @@ procedure TBillsMeasureData.sdvBillsMeasureSetText(var Text: String;
       AValue.Owner.ValueByName(AField + 'Formula').AsString := Text;
       AValue.Owner.ValueByName(AField + 'Formula').AsString := Text;
       Text := FloatToStr(QuantityRoundTo(EvaluateExprs(Text)));
       Text := FloatToStr(QuantityRoundTo(EvaluateExprs(Text)));
     end;
     end;
+    
+    vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(GetBillsID));
+    if vNode.Rec.CalcType.AsInteger <> 0 then
+      vNode.Rec.CalcType.AsInteger := 0;
   end;
   end;
 
 
   procedure SetTotalPrice(const AField: string);
   procedure SetTotalPrice(const AField: string);
+  var
+    vNode: TBillsIDTreeNode;
   begin
   begin
     // 变更应选择变更令
     // 变更应选择变更令
     if SameText(AField , 'Qc') or SameText(AField , 'Pc') then
     if SameText(AField , 'Qc') or SameText(AField , 'Pc') then
@@ -379,6 +395,10 @@ procedure TBillsMeasureData.sdvBillsMeasureSetText(var Text: String;
       AValue.Owner.ValueByName(AField + 'Formula').AsString := Text;
       AValue.Owner.ValueByName(AField + 'Formula').AsString := Text;
       Text := FloatToStr(TotalPriceRoundTo(EvaluateExprs(Text)));
       Text := FloatToStr(TotalPriceRoundTo(EvaluateExprs(Text)));
     end;
     end;
+
+    vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(GetBillsID));
+    if vNode.Rec.CalcType.AsInteger <> 1 then
+      vNode.Rec.CalcType.AsInteger := 1;
   end;
   end;
 
 
   procedure DoCurChanged;
   procedure DoCurChanged;
@@ -403,10 +423,23 @@ procedure TBillsMeasureData.sdvBillsMeasureSetText(var Text: String;
       Text := FloatToStr(PriceRoundTo(StrToFloatDef(Text, 0)));
       Text := FloatToStr(PriceRoundTo(StrToFloatDef(Text, 0)));
   end;
   end;
 
 
+  function CheckValidData: Boolean;
+  begin
+    Result := (AValue.AsString <> Text);
+    if (Pos('Quantity', AColumn.FieldName) > 0) or
+       (Pos('Price', AColumn.FieldName) > 0) then
+    begin
+      if (AValue.AsFloat = 0) and (Text = '') then
+        Result := False;
+    end;
+  end;
+
 begin
 begin
   if not Assigned(AValue) then Exit;
   if not Assigned(AValue) then Exit;
   // 修改后数据与原数据相同则不提交
   // 修改后数据与原数据相同则不提交
-  if (AValue.AsString = Text) or ((AValue.AsFloat = 0) and (Text = '')) then Exit;
+  if not CheckValidData then
+    Allow := False;
+  if not Allow then Exit;
 
 
   CheckLockedData;
   CheckLockedData;
   if not Allow then Exit;
   if not Allow then Exit;
@@ -505,6 +538,10 @@ procedure TBillsMeasureData.sdvBillsMeasureNeedLookupRecord(
     iCreatePhase: Integer;
     iCreatePhase: Integer;
   begin
   begin
     Result := True;
     Result := True;
+
+    if ANode.ID = iPriceMarginID then
+      DataSetErrorMessage(Result, sBills_PMHint);
+
     if ANode.HasChildren then
     if ANode.HasChildren then
     begin
     begin
       if ANewText = '' then
       if ANewText = '' then
@@ -554,8 +591,9 @@ begin
       if HasCardinalNum(ANewText) then
       if HasCardinalNum(ANewText) then
         raise Exception.Create('数量列公式不可输入参数');
         raise Exception.Create('数量列公式不可输入参数');
     NewRec := StageData.AddStageRecord(ARecord.ValueByName('ID').AsInteger);
     NewRec := StageData.AddStageRecord(ARecord.ValueByName('ID').AsInteger);
-    SetNewRecValue(NewRec);
     vNode.StageRec := NewRec;
     vNode.StageRec := NewRec;
+
+    SetNewRecValue(NewRec);
   end;
   end;
 end;
 end;
 
 
@@ -658,14 +696,20 @@ end;
 
 
 procedure TBillsMeasureData.CalculateAll;
 procedure TBillsMeasureData.CalculateAll;
 var
 var
-  Cacl: TBillsCalculate;
+  //Cacl: TBillsCalculate;
+  i: Integer;
 begin
 begin
-  Cacl := TBillsCalculate.Create(Self);
+  if not TProjectData(FProjectData).StageDataReadOnly then
+
+  for i := 0 to BillsMeasureTree.Count - 1 do
+    CalculateNode(TBillsIDTreeNode(BillsMeasureTree.Items[i]));
+
+  {Cacl := TBillsCalculate.Create(Self);
   try
   try
     Cacl.Execute;
     Cacl.Execute;
   finally
   finally
     Cacl.Free;
     Cacl.Free;
-  end;
+  end;}
 end;
 end;
 
 
 procedure TBillsMeasureData.UpdateRecordDeal(ABillsID: Integer; AQuantity,
 procedure TBillsMeasureData.UpdateRecordDeal(ABillsID: Integer; AQuantity,
@@ -907,4 +951,56 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TBillsMeasureData.UpdateRecordPM(ABillsID: Integer;
+  ADiffer: Double);
+var
+  stnNode: TBillsIDTreeNode;
+begin
+  stnNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(ABillsID));
+  if not Assigned(stnNode) then Exit;
+
+  stnNode.Rec.PM_AddTotalPrice.AsFloat := stnNode.Rec.PM_AddTotalPrice.AsFloat + ADiffer;
+  UpdateRecordPM(stnNode.ParentID, ADiffer);
+end;
+
+procedure TBillsMeasureData.CalculateNode(ANode: TBillsIDTreeNode);
+begin
+  if Assigned(ANode.StageRec) then
+  begin
+    if not ANode.HasChildren then
+    begin
+      ANode.Rec.AddDealQuantity.AsFloat := ANode.StageRec.EndDealQuantity.AsFloat;
+
+      ANode.Rec.AddQcQuantity.AsFloat := ANode.StageRec.EndQcQuantity.AsFloat;
+      ANode.Rec.AddQcBGLCode.AsString := ANode.StageRec.EndQcBGLCode.AsString;
+      ANode.Rec.AddQcBGLNum.AsString := ANode.StageRec.EndQcBGLNum.AsString;
+
+      ANode.Rec.AddPcQuantity.AsFloat := ANode.StageRec.EndPcQuantity.AsFloat;
+      ANode.Rec.AddPcBGLCode.AsString := ANode.StageRec.EndPcBGLCode.AsString;
+      ANode.Rec.AddPcBGLNum.AsString := ANode.StageRec.EndPcBGLNum.AsString;
+
+      ANode.Rec.AddGatherQuantity.AsFloat := ANode.StageRec.EndGatherQuantity.AsFloat;
+    end;
+    ANode.Rec.AddDealTotalPrice.AsFloat := ANode.StageRec.EndDealTotalPrice.AsFloat;
+    ANode.Rec.AddQcTotalPrice.AsFloat := ANode.StageRec.EndQcTotalPrice.AsFloat;
+    ANode.Rec.AddPcTotalPrice.AsFloat := ANode.StageRec.EndPcTotalPrice.AsFloat;
+    ANode.Rec.AddGatherTotalPrice.AsFloat := ANode.StageRec.EndGatherTotalPrice.AsFloat;
+
+    ANode.Rec.PM_AddTotalPrice.AsFloat := ANode.StageRec.PM_PreTotalPrice.AsFloat + ANode.StageRec.PM_TotalPrice.AsFloat;
+  end;
+end;
+
+procedure TBillsMeasureData.UpdateGather(ABillsID: Integer;
+  ADiffer: Double);
+var
+  stnNode: TBillsIDTreeNode;
+begin
+  stnNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(ABillsID));
+  if not Assigned(stnNode) then Exit;
+
+  with stnNode.Rec do
+    AddDifferValue(AddGatherTotalPrice, ADiffer);
+  UpdateGather(stnNode.ParentID, ADiffer);
+end;
+
 end.
 end.

+ 15 - 1
DataModules/DealPaymentDm.dfm

@@ -58,7 +58,21 @@ object DealPaymentData: TDealPaymentData
       4E65656450726F636573734E616D65090001044E616D65060D4C6F636B656446
       4E65656450726F636573734E616D65090001044E616D65060D4C6F636B656446
       6F726D756C61094669656C644E616D65060D4C6F636B6564466F726D756C6108
       6F726D756C61094669656C644E616D65060D4C6F636B6564466F726D756C6108
       44617461547970650205084461746153697A6502010549734B6579080F4E6565
       44617461547970650205084461746153697A6502010549734B6579080F4E6565
-      6450726F636573734E616D65090000}
+      6450726F636573734E616D65090001044E616D650608506C616E547970650946
+      69656C644E616D650608506C616E547970650844617461547970650203084461
+      746153697A6502040549734B6579080F4E65656450726F636573734E616D6509
+      0001044E616D65060B506C616E53756254797065094669656C644E616D65060B
+      506C616E537562547970650844617461547970650203084461746153697A6502
+      040549734B6579080F4E65656450726F636573734E616D65090001044E616D65
+      060C506C616E446561646C696E65094669656C644E616D65060C506C616E4465
+      61646C696E650844617461547970650206084461746153697A6502080549734B
+      6579080F4E65656450726F636573734E616D65080001044E616D650609504446
+      6F726D756C61094669656C644E616D6506095044466F726D756C610844617461
+      547970650218084461746153697A6502640549734B6579080F4E65656450726F
+      636573734E616D65090001044E616D65060C4C696E6B53657269616C4E6F0946
+      69656C644E616D65060C4C696E6B53657269616C4E6F08446174615479706502
+      03084461746153697A6502040549734B6579080F4E65656450726F636573734E
+      616D65090000}
   end
   end
   object sdvDealPayment: TsdDataView
   object sdvDealPayment: TsdDataView
     Active = False
     Active = False

+ 96 - 1
DataModules/DealPaymentDm.pas

@@ -49,9 +49,14 @@ type
 
 
     // 扣款项是否已达起扣金额
     // 扣款项是否已达起扣金额
     function CheckStartedPrice(AID: Integer): Boolean;
     function CheckStartedPrice(AID: Integer): Boolean;
+    function CheckReachPlan(ARec: TsdDataRecord): Boolean;
     function GetAllowTotalPrice(AID: Integer; ATotalPrice: Double): Double;
     function GetAllowTotalPrice(AID: Integer; ATotalPrice: Double): Double;
     procedure UpdateTotalPrice(AID: Integer; ATotalPrice: Double);
     procedure UpdateTotalPrice(AID: Integer; ATotalPrice: Double);
 
 
+    function DealPayRecord(const AName: string): TsdDataRecord;
+
+    function PlanStr(ARec: TsdDataRecord): string;
+
     function GetStartedPrice(AID: Integer): Double;
     function GetStartedPrice(AID: Integer): Double;
 
 
     procedure CalcStarted_RangePrice;
     procedure CalcStarted_RangePrice;
@@ -59,6 +64,8 @@ type
     procedure ResetPhaseLink;
     procedure ResetPhaseLink;
     procedure LockedData;
     procedure LockedData;
 
 
+    procedure UpdateLinkSerialNo;
+
     property ProjectData: TObject read FProjectData;
     property ProjectData: TObject read FProjectData;
 
 
     // 扣款项,累计金额合计
     // 扣款项,累计金额合计
@@ -67,6 +74,7 @@ type
     property AddTotalPrice: Double read GetAddTotalPrice;
     property AddTotalPrice: Double read GetAddTotalPrice;
     // 实付
     // 实付
     property PaidTotalPrice: Double read GetPaidTotalPrice;
     property PaidTotalPrice: Double read GetPaidTotalPrice;
+    property PayFormula: TPayFormula read FPayFormula;
   end;
   end;
 
 
 implementation
 implementation
@@ -110,7 +118,10 @@ begin
   Rec := sddDealPayment.FindKey('idxID', AID);
   Rec := sddDealPayment.FindKey('idxID', AID);
   if Rec.ValueByName('RangePrice').AsFloat = 0 then Exit;
   if Rec.ValueByName('RangePrice').AsFloat = 0 then Exit;
   fAllowPrice := Rec.ValueByName('RangePrice').AsFloat - Rec.ValueByName('TotalPrice').AsFloat;
   fAllowPrice := Rec.ValueByName('RangePrice').AsFloat - Rec.ValueByName('TotalPrice').AsFloat;
-  Result := Min(fAllowPrice, ATotalPrice);
+  if not CheckReachPlan(Rec) then
+    Result := Min(fAllowPrice, ATotalPrice)
+  else
+    Result := fAllowPrice;
 end;
 end;
 
 
 function TDealPaymentData.GetNewID: Integer;
 function TDealPaymentData.GetNewID: Integer;
@@ -431,6 +442,12 @@ procedure TDealPaymentData.sdvDealPaymentSetText(var Text: string;
     begin
     begin
       Rec.ValueByName('Formula').AsString := '';
       Rec.ValueByName('Formula').AsString := '';
       AValue.Owner.ValueByName(sFField).AsString := '';
       AValue.Owner.ValueByName(sFField).AsString := '';
+      {AID := ARecord.ValueByName('ID').AsInteger;
+      fTotalPrice := StrToFloatDef(Text, 0) - AValue.AsFloat;
+      if CheckStartedPrice(AID) then
+        Text := FloatToStr(AValue.AsFloat + GetAllowTotalPrice(AID, fTotalPrice))
+      else
+        Text := '';}
     end
     end
     else
     else
     begin
     begin
@@ -637,4 +654,82 @@ begin
   Result := Rec.ValueByName('StartedPrice').AsFloat;
   Result := Rec.ValueByName('StartedPrice').AsFloat;
 end;
 end;
 
 
+function TDealPaymentData.CheckReachPlan(ARec: TsdDataRecord): Boolean;
+var
+  fCurValue, fDeadlineValue: Double;
+begin
+  Result := False;
+  if ARec.ValueByName('PlanType').AsInteger <> 0 then
+  begin
+    if ARec.ValueByName('PlanType').AsInteger = 1 then
+      fCurValue := TProjectData(FProjectData).ProjProperties.PhaseCount
+    else if ARec.ValueByName('PlanSubType').AsInteger = 0 then
+      fCurValue := TProjectData(FProjectData).BillsData.Settlement[4]
+    else if ARec.ValueByName('PlanSubType').AsInteger = 1 then
+      fCurValue := TProjectData(FProjectData).BillsData.Settlement[1]
+    else if ARec.ValueByName('PlanSubType').AsInteger = 2 then
+      fCurValue := TProjectData(FProjectData).BillsData.Settlement[2];
+    fDeadlineValue := ARec.ValueByName('PlanDeadline').AsFloat;
+    Result := fCurValue >= fDeadlineValue;
+  end;
+end;
+
+function TDealPaymentData.PlanStr(ARec: TsdDataRecord): string;
+begin
+  if ARec.ValueByName('PlanType').AsInteger = 0 then
+    Result := '无'
+  else if ARec.ValueByName('PlanType').AsInteger = 1 then
+    Result := Format('计量期数 >= %d', [ARec.ValueByName('PlanDeadline').AsInteger])
+  else if ARec.ValueByName('PlanSubType').AsInteger = 0 then
+    Result := Format('累计完成计量金额 >= %f', [ARec.ValueByName('PlanDeadline').AsFloat])
+  else if ARec.ValueByName('PlanSubType').AsInteger = 1 then
+    Result := Format('累计合同计量金额 >= %f', [ARec.ValueByName('PlanDeadline').AsFloat])
+  else if ARec.ValueByName('PlanSubType').AsInteger = 2 then
+    Result := Format('累计变更计量金额 >= %f', [ARec.ValueByName('PlanDeadline').AsFloat])
+end;
+
+procedure TDealPaymentData.UpdateLinkSerialNo;
+var
+  iPay, iCut, iIndex: Integer;
+  Rec: TsdDataRecord;
+begin
+  iPay := 1;
+  iCut := 1;
+  for iIndex := 0 to sdvDealPayment.RecordCount - 1 do
+  begin
+    Rec := sdvDealPayment.Records[iIndex];
+    if Rec.ValueByName('CalcType').AsInteger = 0 then
+    begin
+      if Rec.ValueByName('IsMinus').AsBoolean then
+      begin
+        Rec.ValueByName('LinkSerialNo').AsInteger := iCut;
+        Inc(iCut);
+      end
+      else
+      begin
+        Rec.ValueByName('LinkSerialNo').AsInteger := iPay;
+        Inc(iPay);
+      end;
+    end;
+  end;
+end;
+
+function TDealPaymentData.DealPayRecord(
+  const AName: string): TsdDataRecord;
+var
+  iRec: Integer;
+  Rec: TsdDataRecord;
+begin
+  Result := nil;
+  for iRec := 0 to sddDealPayment.RecordCount - 1 do
+  begin
+    Rec := sddDealPayment.Records[iRec];
+    if SameText(AName, Rec.ValueByName('Name').AsString) then
+    begin
+      Result := Rec;
+      Break;
+    end;
+  end;
+end;
+
 end.
 end.

+ 44 - 0
DataModules/DetailGLDm.dfm

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

+ 368 - 0
DataModules/DetailGLDm.pas

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

+ 1 - 0
DataModules/PhasePayDm.pas

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

+ 223 - 0
DataModules/PriceMarginBillsDm.dfm

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

+ 377 - 0
DataModules/PriceMarginBillsDm.pas

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

+ 117 - 0
DataModules/ProjectGLDm.dfm

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

+ 575 - 0
DataModules/ProjectGLDm.pas

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

+ 27 - 2
DataModules/ReportMemoryDm/rmBillsGatherDm.dfm

@@ -862,6 +862,19 @@ object rmBillsGatherData: TrmBillsGatherData
       item
       item
         Name = 'ABDgnPrice'
         Name = 'ABDgnPrice'
         DataType = ftFloat
         DataType = ftFloat
+      end
+      item
+        Name = 'FinalDgnQty'
+        DataType = ftString
+        Size = 20
+      end
+      item
+        Name = 'FinalDgnQty1'
+        DataType = ftFloat
+      end
+      item
+        Name = 'FinalDgnQty2'
+        DataType = ftFloat
       end>
       end>
     IndexDefs = <>
     IndexDefs = <>
     Params = <>
     Params = <>
@@ -869,7 +882,7 @@ object rmBillsGatherData: TrmBillsGatherData
     Left = 32
     Left = 32
     Top = 80
     Top = 80
     Data = {
     Data = {
-      B70600009619E0BD010000001800000041000000000003000000B70609586961
+      010700009619E0BD010000001800000044000000000003000000010709586961
       6E67436F64650100490000000100055749445448020002000A00064D75436F64
       6E67436F64650100490000000100055749445448020002000A00064D75436F64
       650100490000000100055749445448020002000A00074A6965436F6465010049
       650100490000000100055749445448020002000A00074A6965436F6465010049
       00000001000557494454480200020014000858694D75436F6465010049000000
       00000001000557494454480200020014000858694D75436F6465010049000000
@@ -922,7 +935,10 @@ object rmBillsGatherData: TrmBillsGatherData
       6E7469747932436F6D7061726533080004000000000006425F436F6465010049
       6E7469747932436F6D7061726533080004000000000006425F436F6465010049
       000000010005574944544802000200320005507269636508000400000000000A
       000000010005574944544802000200320005507269636508000400000000000A
       504444676E507269636508000400000000000B43444444676E50726963650800
       504444676E507269636508000400000000000B43444444676E50726963650800
-      0400000000000A414244676E507269636508000400000000000000}
+      0400000000000A414244676E507269636508000400000000000B46696E616C44
+      676E51747901004900000001000557494454480200020014000C46696E616C44
+      676E5174793108000400000000000C46696E616C44676E517479320800040000
+      0000000000}
     object cdsEstimateBillsXiangCode: TStringField
     object cdsEstimateBillsXiangCode: TStringField
       FieldName = 'XiangCode'
       FieldName = 'XiangCode'
       Size = 10
       Size = 10
@@ -1125,6 +1141,15 @@ object rmBillsGatherData: TrmBillsGatherData
     object cdsEstimateBillsABDgnPrice: TFloatField
     object cdsEstimateBillsABDgnPrice: TFloatField
       FieldName = 'ABDgnPrice'
       FieldName = 'ABDgnPrice'
     end
     end
+    object cdsEstimateBillsFinalDgnQty: TStringField
+      FieldName = 'FinalDgnQty'
+    end
+    object cdsEstimateBillsFinalDgnQty1: TFloatField
+      FieldName = 'FinalDgnQty1'
+    end
+    object cdsEstimateBillsFinalDgnQty2: TFloatField
+      FieldName = 'FinalDgnQty2'
+    end
   end
   end
   object cdsProjectGclBills: TClientDataSet
   object cdsProjectGclBills: TClientDataSet
     Active = True
     Active = True

+ 9 - 2
DataModules/ReportMemoryDm/rmBillsGatherDm.pas

@@ -175,6 +175,9 @@ type
     cdsEstimateBillsPDDgnPrice: TFloatField;
     cdsEstimateBillsPDDgnPrice: TFloatField;
     cdsEstimateBillsCDDDgnPrice: TFloatField;
     cdsEstimateBillsCDDDgnPrice: TFloatField;
     cdsEstimateBillsABDgnPrice: TFloatField;
     cdsEstimateBillsABDgnPrice: TFloatField;
+    cdsEstimateBillsFinalDgnQty: TStringField;
+    cdsEstimateBillsFinalDgnQty1: TFloatField;
+    cdsEstimateBillsFinalDgnQty2: TFloatField;
     // žöË㲿°ä07, 11
     // žöË㲿°ä07, 11
     cdsProjectGclBills: TClientDataSet;
     cdsProjectGclBills: TClientDataSet;
     cdsProjectGclBillsProjectID: TIntegerField;
     cdsProjectGclBillsProjectID: TIntegerField;
@@ -1212,11 +1215,15 @@ begin
   cdsEstimateBillsCDgnQuantity.AsString :=
   cdsEstimateBillsCDgnQuantity.AsString :=
       GetDgnQuantity(cdsEstimateBillsCDgnQuantity1.AsFloat, cdsEstimateBillsCDgnQuantity2.AsFloat);
       GetDgnQuantity(cdsEstimateBillsCDgnQuantity1.AsFloat, cdsEstimateBillsCDgnQuantity2.AsFloat);
   cdsEstimateBillsGatherDgnQuantity1.AsFloat :=
   cdsEstimateBillsGatherDgnQuantity1.AsFloat :=
-      cdsEstimateBillsDealDgnQuantity1.AsFloat + cdsEstimateBillsDealDgnQuantity1.AsFloat;
+      cdsEstimateBillsDealDgnQuantity1.AsFloat + cdsEstimateBillsCDgnQuantity1.AsFloat;
   cdsEstimateBillsGatherDgnQuantity2.AsFloat :=
   cdsEstimateBillsGatherDgnQuantity2.AsFloat :=
-      cdsEstimateBillsDealDgnQuantity2.AsFloat + cdsEstimateBillsDealDgnQuantity2.AsFloat;;
+      cdsEstimateBillsDealDgnQuantity2.AsFloat + cdsEstimateBillsCDgnQuantity2.AsFloat;;
   cdsEstimateBillsGatherDgnQuantity.AsString :=
   cdsEstimateBillsGatherDgnQuantity.AsString :=
       GetDgnQuantity(cdsEstimateBillsGatherDgnQuantity1.AsFloat, cdsEstimateBillsGatherDgnQuantity2.AsFloat);
       GetDgnQuantity(cdsEstimateBillsGatherDgnQuantity1.AsFloat, cdsEstimateBillsGatherDgnQuantity2.AsFloat);
+  cdsEstimateBillsFinalDgnQty1.AsFloat := cdsEstimateBillsDgnQuantity1.AsFloat + cdsEstimateBillsCDgnQuantity1.AsFloat;
+  cdsEstimateBillsFinalDgnQty2.AsFloat := cdsEstimateBillsDgnQuantity2.AsFloat + cdsEstimateBillsCDgnQuantity2.AsFloat;
+  cdsEstimateBillsFinalDgnQty.AsString := GetDgnQuantity(
+      cdsEstimateBillsFinalDgnQty1.AsFloat, cdsEstimateBillsFinalDgnQty2.AsFloat);
 
 
   cdsEstimateBillsPDQuantity.AsFloat := ANode.PDQuantity;
   cdsEstimateBillsPDQuantity.AsFloat := ANode.PDQuantity;
   cdsEstimateBillsPDTotalPrice.AsFloat := ANode.PDTotalPrice;
   cdsEstimateBillsPDTotalPrice.AsFloat := ANode.PDTotalPrice;

+ 102 - 444
DataModules/ReportMemoryDm/rmGcl_XmjBillsDm.pas

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

+ 361 - 0
DataModules/ReportMemoryDm/rmHaBaiCustomizedDm.dfm

@@ -0,0 +1,361 @@
+object rmHaBaiCustomizedData: TrmHaBaiCustomizedData
+  OldCreateOrder = False
+  Left = 723
+  Top = 455
+  Height = 154
+  Width = 339
+  object cdsCustom2: TClientDataSet
+    Active = True
+    Aggregates = <>
+    Params = <>
+    Left = 32
+    Top = 48
+    Data = {
+      E20000009619E0BD010000001800000009000000000003000000E20007436861
+      707465720400010000000000044E616D6501004A000000010005574944544802
+      000200C8000A546F74616C507269636508000400000000000B43546F74616C50
+      7269636508000400000000000B47546F74616C50726963650800040000000000
+      13456E64476174686572546F74616C5072696365080004000000000013507265
+      476174686572546F74616C507269636508000400000000001343757247617468
+      6572546F74616C507269636508000400000000000750657263656E7408000400
+      000000000000}
+    object cdsCustom2Chapter: TIntegerField
+      FieldName = 'Chapter'
+    end
+    object cdsCustom2Name: TWideStringField
+      FieldName = 'Name'
+      Size = 100
+    end
+    object cdsCustom2TotalPrice: TFloatField
+      FieldName = 'TotalPrice'
+    end
+    object cdsCustom2CTotalPrice: TFloatField
+      FieldName = 'CTotalPrice'
+    end
+    object cdsCustom2GTotalPrice: TFloatField
+      FieldName = 'GTotalPrice'
+    end
+    object cdsCustom2EndGatherTotalPrice: TFloatField
+      FieldName = 'EndGatherTotalPrice'
+    end
+    object cdsCustom2PreGatherTotalPrice: TFloatField
+      FieldName = 'PreGatherTotalPrice'
+    end
+    object cdsCustom2CurGatherTotalPrice: TFloatField
+      FieldName = 'CurGatherTotalPrice'
+    end
+    object cdsCustom2Percent: TFloatField
+      FieldName = 'Percent'
+    end
+  end
+  object cdsCustom3: TClientDataSet
+    Active = True
+    Aggregates = <>
+    IndexFieldNames = 'ChapterID;InnerPartID;IndexCode'
+    Params = <>
+    Left = 104
+    Top = 48
+    Data = {
+      900100009619E0BD010000001800000010000000000003000000900109436861
+      70746572494404000100000000000B496E6E6572506172744944040001000000
+      000009496E646578436F64650100490000000100055749445448020002003200
+      06425F436F646501004A0000000100055749445448020002006400044E616D65
+      02004A000000010005574944544802000200900105556E69747301004A000000
+      0100055749445448020002002800055072696365080004000000000008517561
+      6E7469747908000400000000000A546F74616C50726963650800040000000000
+      115072654761746865725175616E746974790800040000000000135072654761
+      74686572546F74616C5072696365080004000000000011456E64476174686572
+      5175616E74697479080004000000000013456E64476174686572546F74616C50
+      726963650800040000000000114375724761746865725175616E746974790800
+      04000000000013437572476174686572546F74616C5072696365080004000000
+      00000750657263656E7408000400000000000000}
+    object cdsCustom3ChapterID: TIntegerField
+      FieldName = 'ChapterID'
+    end
+    object cdsCustom3InnerPartID: TIntegerField
+      FieldName = 'InnerPartID'
+    end
+    object cdsCustom3IndexCode: TStringField
+      FieldName = 'IndexCode'
+      Size = 50
+    end
+    object cdsCustom3B_Code: TWideStringField
+      FieldName = 'B_Code'
+      Size = 50
+    end
+    object cdsCustom3Name: TWideStringField
+      FieldName = 'Name'
+      Size = 200
+    end
+    object cdsCustom3Units: TWideStringField
+      FieldName = 'Units'
+    end
+    object cdsCustom3Price: TFloatField
+      FieldName = 'Price'
+    end
+    object cdsCustom3Quantity: TFloatField
+      FieldName = 'Quantity'
+    end
+    object cdsCustom3TotalPrice: TFloatField
+      FieldName = 'TotalPrice'
+    end
+    object cdsCustom3PreGatherQuantity: TFloatField
+      FieldName = 'PreGatherQuantity'
+    end
+    object cdsCustom3PreGatherTotalPrice: TFloatField
+      FieldName = 'PreGatherTotalPrice'
+    end
+    object cdsCustom3EndGatherQuantity: TFloatField
+      FieldName = 'EndGatherQuantity'
+    end
+    object cdsCustom3EndGatherTotalPrice: TFloatField
+      FieldName = 'EndGatherTotalPrice'
+    end
+    object cdsCustom3CurGatherQuantity: TFloatField
+      FieldName = 'CurGatherQuantity'
+    end
+    object cdsCustom3CurGatherTotalPrice: TFloatField
+      FieldName = 'CurGatherTotalPrice'
+    end
+    object cdsCustom3Percent: TFloatField
+      FieldName = 'Percent'
+    end
+  end
+  object cdsCustom14: TClientDataSet
+    Active = True
+    Aggregates = <>
+    IndexFieldNames = 'IndexCode'
+    Params = <>
+    Left = 176
+    Top = 48
+    Data = {
+      DC0000009619E0BD010000001800000008000000000003000000DC0009496E64
+      6578436F646501004A000000010005574944544802000200640006425F436F64
+      6501004A0000000100055749445448020002006400044E616D6502004A000000
+      010005574944544802000200900105556E69747301004A000000010005574944
+      54480200020028000550726963650800040000000000085175616E7469747908
+      000400000000000A546F74616C507269636508000400000000000F4365727469
+      666963617465436F646501004A00000001000557494454480200020064000000}
+    object cdsCustom14IndexCode: TWideStringField
+      FieldName = 'IndexCode'
+      Size = 50
+    end
+    object cdsCustom14B_Code: TWideStringField
+      FieldName = 'B_Code'
+      Size = 50
+    end
+    object cdsCustom14Name: TWideStringField
+      FieldName = 'Name'
+      Size = 200
+    end
+    object cdsCustom14Units: TWideStringField
+      FieldName = 'Units'
+    end
+    object cdsCustom14Price: TFloatField
+      FieldName = 'Price'
+    end
+    object cdsCustom14Quantity: TFloatField
+      FieldName = 'Quantity'
+    end
+    object cdsCustom14TotalPrice: TFloatField
+      FieldName = 'TotalPrice'
+    end
+    object cdsCustom14CertificateCode: TWideStringField
+      FieldName = 'CertificateCode'
+      Size = 50
+    end
+  end
+  object cdsCustomProj: TClientDataSet
+    Active = True
+    Aggregates = <>
+    FieldDefs = <
+      item
+        Name = 'ProjectID'
+        DataType = ftInteger
+      end
+      item
+        Name = 'ProjectName'
+        DataType = ftWideString
+        Size = 200
+      end
+      item
+        Name = 'ChapterID'
+        DataType = ftInteger
+      end
+      item
+        Name = 'InnerPartID'
+        DataType = ftInteger
+      end
+      item
+        Name = 'IndexCode'
+        DataType = ftWideString
+        Size = 50
+      end
+      item
+        Name = 'B_Code'
+        DataType = ftWideString
+        Size = 50
+      end
+      item
+        Name = 'Name'
+        DataType = ftWideString
+        Size = 200
+      end
+      item
+        Name = 'Units'
+        DataType = ftWideString
+        Size = 20
+      end
+      item
+        Name = 'Price'
+        DataType = ftFloat
+      end
+      item
+        Name = 'Quantity'
+        DataType = ftFloat
+      end
+      item
+        Name = 'TotalPrice'
+        DataType = ftFloat
+      end
+      item
+        Name = 'CurGatherQuantity'
+        DataType = ftFloat
+      end
+      item
+        Name = 'CurGatherTotalPrice'
+        DataType = ftFloat
+      end
+      item
+        Name = 'EndGatherQuantity'
+        DataType = ftFloat
+      end
+      item
+        Name = 'EndGatherTotalPrice'
+        DataType = ftFloat
+      end
+      item
+        Name = 'P_CurGatherQuantity'
+        DataType = ftFloat
+      end
+      item
+        Name = 'P_CurGatherTotalPrice'
+        DataType = ftFloat
+      end
+      item
+        Name = 'P_EndGatherQuantity'
+        DataType = ftFloat
+      end
+      item
+        Name = 'P_EndGatherTotalPrice'
+        DataType = ftFloat
+      end
+      item
+        Name = 'CurPercent'
+        DataType = ftFloat
+      end
+      item
+        Name = 'EndPercent'
+        DataType = ftFloat
+      end
+      item
+        Name = 'SerialNo'
+        DataType = ftInteger
+      end>
+    IndexDefs = <>
+    IndexFieldNames = 'ProjectID;ChapterID;InnerPartID;IndexCode'
+    Params = <>
+    StoreDefs = True
+    Left = 264
+    Top = 48
+    Data = {
+      270200009619E0BD01000000180000001600000000000300000027020950726F
+      6A656374494404000100000000000B50726F6A6563744E616D6502004A000000
+      0100055749445448020002009001094368617074657249440400010000000000
+      0B496E6E6572506172744944040001000000000009496E646578436F64650100
+      4A000000010005574944544802000200640006425F436F646501004A00000001
+      00055749445448020002006400044E616D6502004A0000000100055749445448
+      02000200900105556E69747301004A0000000100055749445448020002002800
+      0550726963650800040000000000085175616E7469747908000400000000000A
+      546F74616C50726963650800040000000000114375724761746865725175616E
+      74697479080004000000000013437572476174686572546F74616C5072696365
+      080004000000000011456E644761746865725175616E74697479080004000000
+      000013456E64476174686572546F74616C507269636508000400000000001350
+      5F4375724761746865725175616E74697479080004000000000015505F437572
+      476174686572546F74616C5072696365080004000000000013505F456E644761
+      746865725175616E74697479080004000000000015505F456E64476174686572
+      546F74616C507269636508000400000000000A43757250657263656E74080004
+      00000000000A456E6450657263656E7408000400000000000853657269616C4E
+      6F04000100000000000000}
+    object cdsCustomProjProjectID: TIntegerField
+      FieldName = 'ProjectID'
+    end
+    object cdsCustomProjProjectName: TWideStringField
+      FieldName = 'ProjectName'
+      Size = 200
+    end
+    object cdsCustomProjChapterID: TIntegerField
+      FieldName = 'ChapterID'
+    end
+    object cdsCustomProjInnerPartID: TIntegerField
+      FieldName = 'InnerPartID'
+    end
+    object cdsCustomProjIndexCode: TWideStringField
+      FieldName = 'IndexCode'
+      Size = 50
+    end
+    object cdsCustomProjB_Code: TWideStringField
+      FieldName = 'B_Code'
+      Size = 50
+    end
+    object cdsCustomProjName: TWideStringField
+      FieldName = 'Name'
+      Size = 200
+    end
+    object cdsCustomProjUnits: TWideStringField
+      FieldName = 'Units'
+    end
+    object cdsCustomProjPrice: TFloatField
+      FieldName = 'Price'
+    end
+    object cdsCustomProjQuantity: TFloatField
+      FieldName = 'Quantity'
+    end
+    object cdsCustomProjTotalPrice: TFloatField
+      FieldName = 'TotalPrice'
+    end
+    object cdsCustomProjCurGatherQuantity: TFloatField
+      FieldName = 'CurGatherQuantity'
+    end
+    object cdsCustomProjCurGatherTotalPrice: TFloatField
+      FieldName = 'CurGatherTotalPrice'
+    end
+    object cdsCustomProjEndGatherQuantity: TFloatField
+      FieldName = 'EndGatherQuantity'
+    end
+    object cdsCustomProjEndGatherTotalPrice: TFloatField
+      FieldName = 'EndGatherTotalPrice'
+    end
+    object cdsCustomProjP_CurGatherQuantity: TFloatField
+      FieldName = 'P_CurGatherQuantity'
+    end
+    object cdsCustomProjP_CurGatherTotalPrice: TFloatField
+      FieldName = 'P_CurGatherTotalPrice'
+    end
+    object cdsCustomProjP_EndGatherQuantity: TFloatField
+      FieldName = 'P_EndGatherQuantity'
+    end
+    object cdsCustomProjP_EndGatherTotalPrice: TFloatField
+      FieldName = 'P_EndGatherTotalPrice'
+    end
+    object cdsCustomProjCurPercent: TFloatField
+      FieldName = 'CurPercent'
+    end
+    object cdsCustomProjEndPercent: TFloatField
+      FieldName = 'EndPercent'
+    end
+    object cdsCustomProjSerialNo: TIntegerField
+      FieldName = 'SerialNo'
+    end
+  end
+end

File diff suppressed because it is too large
+ 1355 - 0
DataModules/ReportMemoryDm/rmHaBaiCustomizedDm.pas


+ 6 - 0
DataModules/StageDm.dfm

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

+ 217 - 22
DataModules/StageDm.pas

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

+ 41 - 0
Dprs/CSL/Measure_Cloud.cfg

@@ -0,0 +1,41 @@
+-$A8
+-$B-
+-$C+
+-$D+
+-$E-
+-$F-
+-$G+
+-$H+
+-$I+
+-$J-
+-$K-
+-$L+
+-$M-
+-$N+
+-$O+
+-$P+
+-$Q-
+-$R-
+-$S-
+-$T-
+-$U-
+-$V+
+-$W-
+-$X+
+-$YD
+-$Z1
+-cg
+-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+-H+
+-W+
+-M
+-$M16384,1048576
+-K$00400000
+-E"C:\Program Files (x86)\李뷘흡숭\셕좆連마 (데샙경+暾경) 1"
+-N"E:\DelphiTemp"
+-LE"c:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LN"c:\program files (x86)\borland\delphi7\Projects\Bpl"
+-D_mCloud;_mEncrypt;_Test
+-w-UNSAFE_TYPE
+-w-UNSAFE_CODE
+-w-UNSAFE_CAST

+ 156 - 0
Dprs/CSL/Measure_Cloud.dof

@@ -0,0 +1,156 @@
+[FileVersion]
+Version=7.0
+[Compiler]
+A=8
+B=0
+C=1
+D=1
+E=0
+F=0
+G=1
+H=1
+I=1
+J=0
+K=0
+L=1
+M=0
+N=1
+O=1
+P=1
+Q=0
+R=0
+S=0
+T=0
+U=0
+V=1
+W=0
+X=1
+Y=1
+Z=1
+ShowHints=1
+ShowWarnings=1
+UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+NamespacePrefix=
+SymbolDeprecated=1
+SymbolLibrary=1
+SymbolPlatform=1
+UnitLibrary=1
+UnitPlatform=1
+UnitDeprecated=1
+HResultCompat=1
+HidingMember=1
+HiddenVirtual=1
+Garbage=1
+BoundsError=1
+ZeroNilCompat=1
+StringConstTruncated=1
+ForLoopVarVarPar=1
+TypedConstVarPar=1
+AsgToTypedConst=1
+CaseLabelRange=1
+ForVariable=1
+ConstructingAbstract=1
+ComparisonFalse=1
+ComparisonTrue=1
+ComparingSignedUnsigned=1
+CombiningSignedUnsigned=1
+UnsupportedConstruct=1
+FileOpen=1
+FileOpenUnitSrc=1
+BadGlobalSymbol=1
+DuplicateConstructorDestructor=1
+InvalidDirective=1
+PackageNoLink=1
+PackageThreadVar=1
+ImplicitImport=1
+HPPEMITIgnored=1
+NoRetVal=1
+UseBeforeDef=1
+ForLoopVarUndef=1
+UnitNameMismatch=1
+NoCFGFileFound=1
+MessageDirective=1
+ImplicitVariants=1
+UnicodeToLocale=1
+LocaleToUnicode=1
+ImagebaseMultiple=1
+SuspiciousTypecast=1
+PrivatePropAccessor=1
+UnsafeType=0
+UnsafeCode=0
+UnsafeCast=0
+[Linker]
+MapFile=0
+OutputObjs=0
+ConsoleApp=1
+DebugInfo=0
+RemoteSymbols=0
+MinStackSize=16384
+MaxStackSize=1048576
+ImageBase=4194304
+ExeDescription=
+[Directories]
+OutputDir=C:\Program Files (x86)\纵横软件\计量支付 (单机版+云版) 1
+UnitOutputDir=E:\DelphiTemp
+PackageDLLOutputDir=
+PackageDCPOutputDir=
+SearchPath=
+Packages=vcl;rtl;vclx;indy;inet;xmlrtl;vclie;inetdbbde;inetdbxpress;dbrtl;dsnap;dsnapcon;vcldb;soaprtl;VclSmp;dbexpress;dbxcds;inetdb;bdertl;vcldbx;webdsnap;websnap;adortl;ibxpress;teeui;teedb;tee;dss;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL;dclOfficeXP;ZjGridD7;DPanel;ExTree;JimComboBoxs;JimTab;PrintComRep;XPMenu_tom;ZjGridFereD7;ZjCommon;SmartDataSet;ZjGridActns
+Conditionals=_mCloud;_mEncrypt;_Test
+DebugSourceDirs=
+UsePackages=0
+[Parameters]
+RunParams=
+HostApplication=
+Launcher=
+UseLauncher=0
+DebugCWD=
+[Language]
+ActiveLang=
+ProjectLang=
+RootDir=D:\Program Files\Borland\Delphi7\Bin\
+[Version Info]
+IncludeVerInfo=1
+AutoIncBuild=1
+MajorVer=3
+MinorVer=1
+Release=3
+Build=1054
+Debug=0
+PreRelease=0
+Special=0
+Private=0
+DLL=0
+Locale=2052
+CodePage=936
+[Version Info Keys]
+CompanyName=珠海纵横创新软件有限公司
+FileDescription=纵横结算决算计量一体化云版
+FileVersion=3.1.3.1054
+InternalName=Measure
+LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
+LegalTrademarks=Measure
+OriginalFilename=
+ProductName=纵横公路工程计量决算一体化软件
+ProductVersion=3
+Comments=
+[HistoryLists\hlConditionals]
+Count=1
+Item0=_mCloud;_mEncrypt;_Test
+[HistoryLists\hlUnitAliases]
+Count=1
+Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+[HistoryLists\hlUnitOutputDirectory]
+Count=2
+Item0=E:\DelphiTemp
+Item1=D:\Dcu
+[HistoryLists\hlOutputDirectorry]
+Count=2
+Item0=C:\Program Files (x86)\纵横软件\计量支付 (单机版+云版) 1
+Item1=C:\Program Files (x86)\纵横软件\纵横结算决算计量一体化软件(云版)
+[HistoryLists\hlBPLOutput]
+Count=1
+Item0=..\Bin
+[HistoryLists\hlDCPOutput]
+Count=1
+Item0=D:\Dcu

+ 206 - 0
Dprs/CSL/Measure_Cloud.dpr

@@ -0,0 +1,206 @@
+program Measure_Cloud;
+
+uses
+  Windows,
+  ShareMem,
+  Forms,
+  Controls,
+  MainFrm in '..\..\Forms\MainFrm.pas' {MainForm},
+  ProjectManagerFme in '..\..\Frames\ProjectManagerFme.pas' {ProjectManagerFrame: TFrame},
+  UtilMethods in '..\..\Units\UtilMethods.pas',
+  ProjectManagerDm in '..\..\DataModules\ProjectManagerDm.pas' {ProjectManagerData: TDataModule},
+  Connections in '..\..\Units\Connections.pas',
+  TransFile in '..\..\Units\TransFile.pas',
+  ZhAPI in '..\..\Units\ZhAPI.pas',
+  CompactDB in '..\..\Units\CompactDB.pas',
+  OpenProjectManager in '..\..\Units\OpenProjectManager.pas',
+  ProjectData in '..\..\Units\ProjectData.pas',
+  UpdateDataBase in '..\..\Units\UpdateDataBase.pas',
+  DataBaseTables in '..\..\Units\DataBaseTables.pas',
+  ConfigDoc in '..\..\Units\ConfigDoc.pas',
+  SupportUnit in '..\..\Units\SupportUnit.pas',
+  StandardLibs in '..\..\Units\StandardLibs.pas',
+  StandardLib in '..\..\Units\StandardLib.pas',
+  NewProjectFrm in '..\..\Forms\NewProjectFrm.pas' {NewProjectForm},
+  ProjectFme in '..\..\Frames\ProjectFme.pas' {ProjectFrame: TFrame},
+  StandardBillsDm in '..\..\DataModules\StandardBillsDm.pas' {StandardBillsData: TDataModule},
+  StandardBillsFme in '..\..\Frames\StandardBillsFme.pas' {StandardBillsFrame: TFrame},
+  StandardLibsFme in '..\..\Frames\StandardLibsFme.pas' {StandardLibsFrame: TFrame},
+  BillsDm in '..\..\DataModules\BillsDm.pas' {BillsData: TDataModule},
+  Globals in '..\..\Units\Globals.pas',
+  StageDm in '..\..\DataModules\StageDm.pas' {StageData: TDataModule},
+  ExcelImport in '..\..\Units\ExcelImport.pas',
+  CacheTree in '..\..\Units\CacheTree.pas',
+  MCacheTree in '..\..\Units\MCacheTree.pas',
+  ProjectPropertiesFrm in '..\..\Forms\ProjectPropertiesFrm.pas' {ProjectPropertiesForm},
+  ProjectProperty in '..\..\Units\ProjectProperty.pas',
+  FormulaCalc in '..\..\Units\FormulaCalc.pas',
+  BillsCommand in '..\..\Units\BillsCommand.pas',
+  PhaseData in '..\..\Units\PhaseData.pas',
+  PhaseProperty in '..\..\Units\PhaseProperty.pas',
+  BillsClipboard in '..\..\Units\BillsClipboard.pas',
+  BillsTree in '..\..\Units\BillsTree.pas',
+  ProjectCommands in '..\..\Units\ProjectCommands.pas',
+  PhaseCompareDm in '..\..\DataModules\PhaseCompareDm.pas' {PhaseCompareData: TDataModule},
+  PhaseCompareFme in '..\..\Frames\PhaseCompareFme.pas' {PhaseCompareFrame: TFrame},
+  OptionFrm in '..\..\Forms\OptionFrm.pas' {OptionForm},
+  DealPaymentDm in '..\..\DataModules\DealPaymentDm.pas' {DealPaymentData: TDataModule},
+  DealPaymentFme in '..\..\Frames\DealPaymentFme.pas' {DealPaymentFrame: TFrame},
+  PhasePayDm in '..\..\DataModules\PhasePayDm.pas' {PhasePayData: TDataModule},
+  ZJJLDm in '..\..\DataModules\ZJJLDm.pas' {ZJJLData: TDataModule},
+  BillsGatherDm in '..\..\DataModules\BillsGatherDm.pas' {BillsGatherData: TDataModule},
+  BillsGatherFme in '..\..\Frames\BillsGatherFme.pas' {BillsGatherFrame: TFrame},
+  LoginFrm in '..\..\Forms\LoginFrm.pas' {LoginFrm},
+  PHPWebDm in '..\..\DataModules\PHPWebDm.pas' {PHPWeb: TDataModule},
+  MD5Unit in '..\..\Units\MD5Unit.pas',
+  ConstUnit in '..\..\Units\ConstUnit.pas',
+  ExportExcel in '..\..\Units\ExportExcel.pas',
+  mEncryptEditions in '..\..\Encrypt\mEncryptEditions.pas',
+  mEncryptUnit in '..\..\Encrypt\mEncryptUnit.pas',
+  CryptUtils in '..\..\Encrypt\CryptUtils.pas',
+  EncryptDog in '..\..\Encrypt\EncryptDog.pas',
+  mEncryptPWD in '..\..\Encrypt\mEncryptPWD.pas',
+  mEncryptTypes in '..\..\Encrypt\mEncryptTypes.pas',
+  mR1Encrypt in '..\..\Encrypt\mR1Encrypt.pas',
+  mS4Utils in '..\..\Encrypt\mS4Utils.pas',
+  mSNSEncrypt in '..\..\Encrypt\mSNSEncrypt.pas',
+  Rockey1 in '..\..\Encrypt\Rockey1.pas',
+  mConnectEncrypt in '..\..\Encrypt\NetClient\mConnectEncrypt.pas',
+  FindUserFrm in '..\..\Forms\FindUserFrm.pas' {FindUserForm},
+  CslJson in '..\..\Units\CslJson.pas',
+  OrderCheckerFme in '..\..\Frames\OrderCheckerFme.pas' {OrderCheckerFrame: TFrame},
+  CheckerFme in '..\..\Frames\CheckerFme.pas' {CheckerFrame: TFrame},
+  WebNewTenderFrm in '..\..\Forms\WebNewTenderFrm.pas' {WebNewTenderForm},
+  ScFileArchiver in '..\..\Encrypt\ScFileArchiver.pas',
+  SearchDm in '..\..\DataModules\SearchDm.pas' {SearchData: TDataModule},
+  DealBillsDm in '..\..\DataModules\DealBillsDm.pas' {DealBillsData: TDataModule},
+  BGLDm in '..\..\DataModules\BGLDm.pas' {BGLData: TDataModule},
+  StaffDm in '..\..\DataModules\StaffDm.pas' {StaffData: TDataModule},
+  BillsCompileDm in '..\..\DataModules\BillsCompileDm.pas' {BillsCompileData: TDataModule},
+  BillsMeasureDm in '..\..\DataModules\BillsMeasureDm.pas' {BillsMeasureData: TDataModule},
+  ReportManager in '..\..\Units\ReportManager.pas',
+  BGLSelectFrm in '..\..\Forms\BGLSelectFrm.pas' {BGLSelectForm},
+  BillsCompileFme in '..\..\Frames\BillsCompileFme.pas' {BillsCompileFrame: TFrame},
+  BillsMeasureFme in '..\..\Frames\BillsMeasureFme.pas' {BillsMeasureFrame: TFrame},
+  BatchReplaceBillsFrm in '..\..\Forms\BatchReplaceBillsFrm.pas' {BatchReplaceBillsForm},
+  ZJJLFme in '..\..\Frames\ZJJLFme.pas' {ZJJLFrame: TFrame},
+  BGLFme in '..\..\Frames\BGLFme.pas' {BGLFrame: TFrame},
+  MergeTextFrm in '..\..\Forms\MergeTextFrm.pas' {MergeTextForm},
+  ReportsFrm in '..\..\Forms\ReportsFrm.pas' {ReportsForm},
+  ReportAdjustFrm in '..\..\Forms\ReportAdjustFrm.pas' {ReportAdjustForm},
+  SearchFme in '..\..\Frames\SearchFme.pas' {SearchFrame: TFrame},
+  AuthFrm in '..\..\Forms\AuthFrm.pas' {AuthorizeForm},
+  AboutFrm in '..\..\Forms\AboutFrm.pas' {AboutForm},
+  ImportExcelHintFrm in '..\..\Forms\ImportExcelHintFrm.pas' {ImportExcelHintForm},
+  PasswordInputFrm in '..\..\Forms\PasswordInputFrm.pas' {PasswordInputForm},
+  BatchInsertBillsFrm in '..\..\Forms\BatchInsertBillsFrm.pas' {BatchInsertBillsForm},
+  MainDataListDm in '..\..\DataModules\MainDataListDm.pas' {MainListData: TDataModule},
+  mProgressFrm in '..\..\Forms\mProgressFrm.pas' {mProgress},
+  rmGclBillsBGDm in '..\..\DataModules\ReportMemoryDm\rmGclBillsBGDm.pas' {rmGclBillsBGData: TDataModule},
+  rmGclBillsCompareDm in '..\..\DataModules\ReportMemoryDm\rmGclBillsCompareDm.pas' {rmGclBillsCompareData: TDataModule},
+  rmBGLExecutionDm in '..\..\DataModules\ReportMemoryDm\rmBGLExecutionDm.pas' {rmBGLExecutionData: TDataModule},
+  rmBillsGatherDm in '..\..\DataModules\ReportMemoryDm\rmBillsGatherDm.pas' {rmBillsGatherData: TDataModule},
+  rmFxBillsAddDm in '..\..\DataModules\ReportMemoryDm\rmFxBillsAddDm.pas' {rmFxBillsAddData: TDataModule},
+  rmFxBillsCompareDm in '..\..\DataModules\ReportMemoryDm\rmFxBillsCompareDm.pas' {rmFxBillsCompareData: TDataModule},
+  rmGclBillsAddDm in '..\..\DataModules\ReportMemoryDm\rmGclBillsAddDm.pas' {rmGclBillsAddData: TDataModule},
+  rmGridHeaderDm in '..\..\DataModules\ReportMemoryDm\rmGridHeaderDm.pas' {rmGridHeaderData: TDataModule},
+  rmCacheData in '..\..\DataModules\ReportMemoryDm\rmCacheData.pas',
+  rmSelectProjectFrm in '..\..\Forms\rmSelectProjectFrm.pas' {ProjectSelectForm},
+  ConditionalDefines in '..\..\Units\ConditionalDefines.pas',
+  ProgressHintFrm in '..\..\Forms\ProgressHintFrm.pas' {ProgressHintForm},
+  CheckAndClearFrm in '..\..\Forms\CheckAndClearFrm.pas' {CheckAndClearForm},
+  rmGclBillsAuditCompareDm in '..\..\DataModules\ReportMemoryDm\rmGclBillsAuditCompareDm.pas' {rmGclBillsAuditCompareData: TDataModule},
+  rmTestFrm in '..\..\DataModules\ReportMemoryDm\rmTestFrm.pas' {rmTestForm},
+  DealBillsFrm in '..\..\Forms\DealBillsFrm.pas' {DealBillsForm},
+  TenderBackupFrm in '..\..\Forms\TenderBackupFrm.pas' {TenderBackupForm},
+  TenderBackupDm in '..\..\DataModules\TenderBackupDm.pas' {TenderBackupData: TDataModule},
+  BillsBookmarkDm in '..\..\DataModules\BillsBookmarkDm.pas' {BillsBookmarkData: TDataModule},
+  BookmarkFme in '..\..\Frames\BookmarkFme.pas' {BookmarkFrame: TFrame},
+  rmDealInfosDm in '..\..\DataModules\ReportMemoryDm\rmDealInfosDm.pas' {rmDealInfosData: TDataModule},
+  rmXmjBGLDetailDm in '..\..\DataModules\ReportMemoryDm\rmXmjBGLDetailDm.pas' {rmXmjBGLDetailData: TDataModule},
+  WelcomeFrm in '..\..\Forms\WelcomeFrm.pas' {WelcomeForm},
+  rmOtherReport1Dm in '..\..\DataModules\ReportMemoryDm\rmOtherReport1Dm.pas' {rmOtherReport1Data: TDataModule},
+  CheckerMemoFrm in '..\..\Forms\CheckerMemoFrm.pas' {CheckerMemoForm},
+  CslHint in '..\..\Units\CslHint.pas',
+  IPFrm in '..\..\Forms\IPFrm.pas' {IPForm},
+  TenderBackupManager in '..\..\Units\TenderBackupManager.pas',
+  UpFileManageUnit in '..\..\Units\UpFileManageUnit.pas',
+  UpFileFrame in '..\..\Forms\UpFileFrame.pas',
+  UpFileManageFrame in '..\..\Forms\UpFileManageFrame.pas',
+  SheetSelectFrm in '..\..\Forms\SheetSelectFrm.pas' {SheetSelectForm},
+  ReportInteractInfo in '..\..\Units\ReportInteractInfo.pas',
+  Checker in '..\..\Units\Checker.pas',
+  AuditSelectFrm in '..\..\Forms\ReportInteractFrms\AuditSelectFrm.pas' {AuditSelctForm},
+  DealBillsFme in '..\..\Frames\DealBillsFme.pas' {DealBillsFrame: TFrame},
+  rmGclBillsPlaneDm in '..\..\DataModules\ReportMemoryDm\rmGclBillsPlaneDm.pas' {rmGclBillsPlaneData: TDataModule},
+  StageCompareDm in '..\..\DataModules\StageCompareDm.pas' {StageCompareData: TDataModule},
+  mDataRecord in '..\..\Units\mDataRecord.pas',
+  BGLClipboard in '..\..\Units\BGLClipboard.pas',
+  rmMentalCustomized1Dm in '..\..\DataModules\ReportMemoryDm\rmMentalCustomized1Dm.pas' {rmMentalCustomized1Data: TDataModule},
+  rmGcl_XmjBillsDm in '..\..\DataModules\ReportMemoryDm\rmGcl_XmjBillsDm.pas' {rmGcl_XmjBillsData: TDataModule},
+  rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
+  CalcDecimal in '..\..\Units\CalcDecimal.pas',
+  BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
+  DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm},
+  mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm};
+
+{$R *.res}
+
+var
+  Mutex: THandle;
+  IPForm: TIPForm;
+
+begin
+  Mutex := CreateMutex(nil, True, G_AppHandleName);
+
+  if GetLastError = ERROR_ALREADY_EXISTS then
+    Application.MessageBox('程序正在运行, 请勿重复打开该软件!', '系统提示', MB_OK + MB_ICONINFORMATION)
+  else
+  begin
+    Application.CreateHandle;
+    Application.Initialize;
+    Application.Title := '纵横公路工程结算决算计量一体化软件云版';
+    {$IFDEF _mCloud}
+      IPForm := TIPForm.Create(nil);
+      try
+        if not IPForm.HasIP then
+        begin
+          IPForm.ShowModal;
+          if IPForm.ModalResult <> mrOK then
+          begin
+            Application.Terminate;
+            Exit;
+          end;
+        end;
+      finally
+        IPForm.Free;
+      end;
+
+      if not LoginForm then
+      begin
+        Application.Terminate;
+        Exit;
+      end;
+    {$ENDIF}
+
+    if CheckDogExists then
+    begin
+      Application.CreateForm(TMainForm, MainForm);
+  Application.CreateForm(TProgressProForm, ProgressProForm);
+  end;
+    Application.Run;
+  end;
+
+  ReleaseMutex(Mutex);
+end.

BIN
Dprs/CSL/Measure_Cloud.res


+ 2 - 2
Dprs/Pro/Measure.cfg

@@ -33,8 +33,8 @@
 -K$00400000
 -K$00400000
 -E"D:\SmartCostExe\Measure"
 -E"D:\SmartCostExe\Measure"
 -N"..\..\Dcus"
 -N"..\..\Dcus"
--LE"d:\program files (x86)\borland\delphi7\Projects\Bpl"
--LN"d:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LE"c:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LN"c:\program files (x86)\borland\delphi7\Projects\Bpl"
 -D_mEncrypt;
 -D_mEncrypt;
 -w-UNSAFE_TYPE
 -w-UNSAFE_TYPE
 -w-UNSAFE_CODE
 -w-UNSAFE_CODE

+ 14 - 30
Dprs/Pro/Measure.dof

@@ -114,8 +114,8 @@ IncludeVerInfo=1
 AutoIncBuild=1
 AutoIncBuild=1
 MajorVer=3
 MajorVer=3
 MinorVer=1
 MinorVer=1
-Release=3
-Build=1053
+Release=5
+Build=203
 Debug=0
 Debug=0
 PreRelease=0
 PreRelease=0
 Special=0
 Special=0
@@ -126,41 +126,25 @@ CodePage=936
 [Version Info Keys]
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化专业版
 FileDescription=纵横结算决算计量一体化专业版
-FileVersion=3.1.3.1053
-InternalName=Measure
-LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
-LegalTrademarks=Measure
+FileVersion=3.1.5.203
+InternalName=
+LegalCopyright=
+LegalTrademarks=
 OriginalFilename=
 OriginalFilename=
-ProductName=纵横公路工程计量决算一体化软件
-ProductVersion=3
-Comments=
+ProductName=
+ProductVersion=1.0.0.0
+[Excluded Packages]
+C:\Program Files (x86)\Borland\Delphi7\Lib\3F\Developer Express Inc\ExpressEditors Library 5\Delphi 7\Bin\dclcxEditorsVCLD7.bpl=ExpressEditors Library 5 (VCL Edition) by Developer Express Inc.
+C:\Program Files (x86)\Borland\Delphi7\Lib\3F\Developer Express Inc\ExpressEditors Library 5\Delphi 7\Bin\dclcxExtEditorsVCLD7.bpl=ExpressExtendedEditors Library 5 (VCL Edition) by Developer Express Inc.
 [HistoryLists\hlConditionals]
 [HistoryLists\hlConditionals]
-Count=10
+Count=1
 Item0=_mEncrypt;
 Item0=_mEncrypt;
-Item1=_mEncrypt;cplPrint;cplOutputToExcelRange
-Item2=cplPrint;_mEncrypt;cplPrint;cplOutputToExcelRange
-Item3=cplPrint;_mEncrypt;cplPrint
-Item4=cplPrint;_mEncrypt
-Item5=cplPrint;
-Item6=cplPrint;_mEncrypt;
-Item7=cplPrint;mEncrypt;
-Item8=cplPrint
-Item9=cplPrint;cplOutputToExcelRange;
 [HistoryLists\hlUnitAliases]
 [HistoryLists\hlUnitAliases]
 Count=1
 Count=1
 Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
 Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
 [HistoryLists\hlUnitOutputDirectory]
 [HistoryLists\hlUnitOutputDirectory]
-Count=2
+Count=1
 Item0=..\..\Dcus
 Item0=..\..\Dcus
-Item1=..\Dcus
 [HistoryLists\hlOutputDirectorry]
 [HistoryLists\hlOutputDirectorry]
-Count=9
+Count=1
 Item0=D:\SmartCostExe\Measure
 Item0=D:\SmartCostExe\Measure
-Item1=E:\SmartCostExe\Measure
-Item2=D:\Program Files (x86)\纵横软件\纵横计量决算一体化软件(专业版4)
-Item3=D:\Program Files (x86)\纵横软件\纵横计量决算一体化软件(专业版)
-Item4=D:\Program Files (x86)\纵横软件\纵横计量决算一体化软件(专业版2)
-Item5=D:\Program Files (x86)\纵横软件\纵横公路工程计量支付(专业版)
-Item6=D:\Program Files\纵横软件\Environment
-Item7=..\..\Environment
-Item8=..\Dcus

+ 14 - 1
Dprs/Pro/Measure.dpr

@@ -137,7 +137,19 @@ uses
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
-  DetailExcelImport in '..\..\Units\DetailExcelImport.pas';
+  DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
+  mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm},
+  BaseClipboard in '..\..\Units\BaseClipboard.pas';
 
 
 {$R *.res}
 {$R *.res}
 
 
@@ -158,6 +170,7 @@ begin
     begin
     begin
       HideWelcome;
       HideWelcome;
       Application.CreateForm(TMainForm, MainForm);
       Application.CreateForm(TMainForm, MainForm);
+  Application.CreateForm(TProgressProForm, ProgressProForm);
   end
   end
     else  HideWelcome;
     else  HideWelcome;
     Application.Run;
     Application.Run;

BIN
Dprs/Pro/Measure.res


+ 2 - 2
Dprs/Pro/Measure_Cloud.cfg

@@ -33,8 +33,8 @@
 -K$00400000
 -K$00400000
 -E"D:\SmartCostExe\Measure"
 -E"D:\SmartCostExe\Measure"
 -N"..\..\Dcus"
 -N"..\..\Dcus"
--LE"d:\program files (x86)\borland\delphi7\Projects\Bpl"
--LN"d:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LE"c:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LN"c:\program files (x86)\borland\delphi7\Projects\Bpl"
 -D_mCloud;_mEncrypt;
 -D_mCloud;_mEncrypt;
 -w-UNSAFE_TYPE
 -w-UNSAFE_TYPE
 -w-UNSAFE_CODE
 -w-UNSAFE_CODE

+ 11 - 36
Dprs/Pro/Measure_Cloud.dof

@@ -114,8 +114,8 @@ IncludeVerInfo=1
 AutoIncBuild=1
 AutoIncBuild=1
 MajorVer=3
 MajorVer=3
 MinorVer=1
 MinorVer=1
-Release=3
-Build=1053
+Release=5
+Build=203
 Debug=0
 Debug=0
 PreRelease=0
 PreRelease=0
 Special=0
 Special=0
@@ -126,38 +126,13 @@ CodePage=936
 [Version Info Keys]
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化云版
 FileDescription=纵横结算决算计量一体化云版
-FileVersion=3.1.3.1053
-InternalName=Measure
-LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
-LegalTrademarks=Measure
+FileVersion=3.1.5.203
+InternalName=
+LegalCopyright=
+LegalTrademarks=
 OriginalFilename=
 OriginalFilename=
-ProductName=纵横公路工程计量决算一体化软件
-ProductVersion=3
-Comments=
-[HistoryLists\hlConditionals]
-Count=5
-Item0=_mCloud;_mEncrypt;
-Item1=_OnLine;_mEncrypt;
-Item2=_OnLine;_mEncrypt;cplPrint;cplOutputToExcelRange
-Item3=_OnLine;cplPrint;cplOutputToExcelRange
-Item4=_OnLine;cplPrint;_mEncrypt;cplPrint;cplOutputToExcelRange
-[HistoryLists\hlUnitAliases]
-Count=1
-Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-[HistoryLists\hlUnitOutputDirectory]
-Count=3
-Item0=..\..\Dcus
-Item1=E:\DelphiTemp
-Item2=D:\Dcu
-[HistoryLists\hlOutputDirectorry]
-Count=4
-Item0=D:\SmartCostExe\Measure
-Item1=E:\SmartCostExe\Measure
-Item2=D:\Program Files (x86)\纵横软件\纵横计量决算一体化软件(云版)
-Item3=D:\Program Files (x86)\纵横软件\纵横计量决算一体化软件(专业版)
-[HistoryLists\hlBPLOutput]
-Count=1
-Item0=..\Bin
-[HistoryLists\hlDCPOutput]
-Count=1
-Item0=D:\Dcu
+ProductName=
+ProductVersion=1.0.0.0
+[Excluded Packages]
+C:\Program Files (x86)\Borland\Delphi7\Lib\3F\Developer Express Inc\ExpressEditors Library 5\Delphi 7\Bin\dclcxEditorsVCLD7.bpl=ExpressEditors Library 5 (VCL Edition) by Developer Express Inc.
+C:\Program Files (x86)\Borland\Delphi7\Lib\3F\Developer Express Inc\ExpressEditors Library 5\Delphi 7\Bin\dclcxExtEditorsVCLD7.bpl=ExpressExtendedEditors Library 5 (VCL Edition) by Developer Express Inc.

+ 14 - 1
Dprs/Pro/Measure_Cloud.dpr

@@ -141,7 +141,19 @@ uses
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
-  DetailExcelImport in '..\..\Units\DetailExcelImport.pas';
+  DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
+  mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm},
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm},
+  BaseClipboard in '..\..\Units\BaseClipboard.pas';
 
 
 {$R *.res}
 {$R *.res}
 
 
@@ -185,6 +197,7 @@ begin
     if CheckDogExists then
     if CheckDogExists then
     begin
     begin
       Application.CreateForm(TMainForm, MainForm);
       Application.CreateForm(TMainForm, MainForm);
+  Application.CreateForm(TProgressProForm, ProgressProForm);
   end;
   end;
     Application.Run;
     Application.Run;
   end;
   end;

BIN
Dprs/Pro/Measure_Cloud.res


+ 2 - 2
Dprs/Pro/Measure_GuangDong.cfg

@@ -33,8 +33,8 @@
 -K$00400000
 -K$00400000
 -E"D:\SmartCostExe\Measure"
 -E"D:\SmartCostExe\Measure"
 -N"..\..\Dcus"
 -N"..\..\Dcus"
--LE"d:\program files (x86)\borland\delphi7\Projects\Bpl"
--LN"d:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LE"c:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LN"c:\program files (x86)\borland\delphi7\Projects\Bpl"
 -D_mEncrypt;_mGuangDong
 -D_mEncrypt;_mGuangDong
 -w-UNSAFE_TYPE
 -w-UNSAFE_TYPE
 -w-UNSAFE_CODE
 -w-UNSAFE_CODE

+ 11 - 31
Dprs/Pro/Measure_GuangDong.dof

@@ -114,8 +114,8 @@ IncludeVerInfo=1
 AutoIncBuild=1
 AutoIncBuild=1
 MajorVer=3
 MajorVer=3
 MinorVer=1
 MinorVer=1
-Release=3
-Build=1053
+Release=5
+Build=203
 Debug=0
 Debug=0
 PreRelease=0
 PreRelease=0
 Special=0
 Special=0
@@ -126,33 +126,13 @@ CodePage=936
 [Version Info Keys]
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化广东专业版
 FileDescription=纵横结算决算计量一体化广东专业版
-FileVersion=3.1.3.1053
-InternalName=Measure
-LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
-LegalTrademarks=Measure
+FileVersion=3.1.5.203
+InternalName=
+LegalCopyright=
+LegalTrademarks=
 OriginalFilename=
 OriginalFilename=
-ProductName=纵横公路工程计量决算一体化软件
-ProductVersion=3
-Comments=
-[HistoryLists\hlConditionals]
-Count=1
-Item0=_mEncrypt;_mGuangDong
-[HistoryLists\hlUnitAliases]
-Count=1
-Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-[HistoryLists\hlUnitOutputDirectory]
-Count=3
-Item0=..\..\Dcus
-Item1=..\Dcus
-Item2=D:\Dcu
-[HistoryLists\hlOutputDirectorry]
-Count=3
-Item0=D:\SmartCostExe\Measure
-Item1=E:\SmartCostExe\Measure
-Item2=D:\Program Files (x86)\纵横软件\纵横计量决算一体化软件(广东专业版)
-[HistoryLists\hlBPLOutput]
-Count=1
-Item0=..\Bin
-[HistoryLists\hlDCPOutput]
-Count=1
-Item0=D:\Dcu
+ProductName=
+ProductVersion=1.0.0.0
+[Excluded Packages]
+C:\Program Files (x86)\Borland\Delphi7\Lib\3F\Developer Express Inc\ExpressEditors Library 5\Delphi 7\Bin\dclcxEditorsVCLD7.bpl=ExpressEditors Library 5 (VCL Edition) by Developer Express Inc.
+C:\Program Files (x86)\Borland\Delphi7\Lib\3F\Developer Express Inc\ExpressEditors Library 5\Delphi 7\Bin\dclcxExtEditorsVCLD7.bpl=ExpressExtendedEditors Library 5 (VCL Edition) by Developer Express Inc.

+ 14 - 1
Dprs/Pro/Measure_GuangDong.dpr

@@ -136,8 +136,20 @@ uses
   rmGcl_XmjBillsDm in '..\..\DataModules\ReportMemoryDm\rmGcl_XmjBillsDm.pas' {rmGcl_XmjBillsData: TDataModule},
   rmGcl_XmjBillsDm in '..\..\DataModules\ReportMemoryDm\rmGcl_XmjBillsDm.pas' {rmGcl_XmjBillsData: TDataModule},
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
+  DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
+  mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm},
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
-  DetailExcelImport in '..\..\Units\DetailExcelImport.pas';
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
 
 
 {$R *.res}
 {$R *.res}
 
 
@@ -157,6 +169,7 @@ begin
     begin
     begin
       HideWelcome;
       HideWelcome;
       Application.CreateForm(TMainForm, MainForm);
       Application.CreateForm(TMainForm, MainForm);
+  Application.CreateForm(TProgressProForm, ProgressProForm);
   end
   end
     else  HideWelcome;
     else  HideWelcome;
     Application.Run;
     Application.Run;

BIN
Dprs/Pro/Measure_GuangDong.res


+ 2 - 2
Dprs/Pro/Measure_GuangDong_Cloud.cfg

@@ -33,8 +33,8 @@
 -K$00400000
 -K$00400000
 -E"D:\SmartCostExe\Measure"
 -E"D:\SmartCostExe\Measure"
 -N"..\..\Dcus"
 -N"..\..\Dcus"
--LE"d:\program files (x86)\borland\delphi7\Projects\Bpl"
--LN"d:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LE"c:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LN"c:\program files (x86)\borland\delphi7\Projects\Bpl"
 -D_mCloud;_mEncrypt;_mGuangDong
 -D_mCloud;_mEncrypt;_mGuangDong
 -w-UNSAFE_TYPE
 -w-UNSAFE_TYPE
 -w-UNSAFE_CODE
 -w-UNSAFE_CODE

+ 11 - 39
Dprs/Pro/Measure_GuangDong_Cloud.dof

@@ -114,8 +114,8 @@ IncludeVerInfo=1
 AutoIncBuild=1
 AutoIncBuild=1
 MajorVer=3
 MajorVer=3
 MinorVer=1
 MinorVer=1
-Release=3
-Build=1053
+Release=5
+Build=203
 Debug=0
 Debug=0
 PreRelease=0
 PreRelease=0
 Special=0
 Special=0
@@ -126,41 +126,13 @@ CodePage=936
 [Version Info Keys]
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化广东云版
 FileDescription=纵横结算决算计量一体化广东云版
-FileVersion=3.1.3.1053
-InternalName=Measure
-LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
-LegalTrademarks=Measure
+FileVersion=3.1.5.203
+InternalName=
+LegalCopyright=
+LegalTrademarks=
 OriginalFilename=
 OriginalFilename=
-ProductName=纵横公路工程计量决算一体化软件
-ProductVersion=3
-Comments=
-[HistoryLists\hlConditionals]
-Count=8
-Item0=_mCloud;_mEncrypt;_mGuangDong
-Item1=_mCloud;_mEncrypt;_mGuangDong;_Test
-Item2=_mCloud;_mEncrypt;_mGuangDong;_mTest
-Item3=_mCloud;_mEncrypt;_mGuangDong;
-Item4=_OnLine;_mEncrypt;_mGuangDong;cplPrint;cplOutputToExcelRange
-Item5=_OnLine;_mEncrypt;cplPrint;cplOutputToExcelRange
-Item6=_OnLine;cplPrint;cplOutputToExcelRange
-Item7=_OnLine;cplPrint;_mEncrypt;cplPrint;cplOutputToExcelRange
-[HistoryLists\hlUnitAliases]
-Count=1
-Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-[HistoryLists\hlUnitOutputDirectory]
-Count=3
-Item0=..\..\Dcus
-Item1=E:\DelphiTemp
-Item2=D:\Dcu
-[HistoryLists\hlOutputDirectorry]
-Count=4
-Item0=D:\SmartCostExe\Measure
-Item1=E:\SmartCostExe\Measure
-Item2=D:\Program Files (x86)\纵横软件\纵横计量决算一体化软件(广东云版)15审核人
-Item3=D:\Program Files (x86)\纵横软件\纵横计量决算一体化软件(专业版)
-[HistoryLists\hlBPLOutput]
-Count=1
-Item0=..\Bin
-[HistoryLists\hlDCPOutput]
-Count=1
-Item0=D:\Dcu
+ProductName=
+ProductVersion=1.0.0.0
+[Excluded Packages]
+C:\Program Files (x86)\Borland\Delphi7\Lib\3F\Developer Express Inc\ExpressEditors Library 5\Delphi 7\Bin\dclcxEditorsVCLD7.bpl=ExpressEditors Library 5 (VCL Edition) by Developer Express Inc.
+C:\Program Files (x86)\Borland\Delphi7\Lib\3F\Developer Express Inc\ExpressEditors Library 5\Delphi 7\Bin\dclcxExtEditorsVCLD7.bpl=ExpressExtendedEditors Library 5 (VCL Edition) by Developer Express Inc.

+ 14 - 1
Dprs/Pro/Measure_GuangDong_Cloud.dpr

@@ -141,7 +141,19 @@ uses
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
-  DetailExcelImport in '..\..\Units\DetailExcelImport.pas';
+  DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
+  mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm},
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
 
 
 {$R *.res}
 {$R *.res}
 
 
@@ -187,6 +199,7 @@ begin
     if CheckDogExists then
     if CheckDogExists then
     begin
     begin
       Application.CreateForm(TMainForm, MainForm);
       Application.CreateForm(TMainForm, MainForm);
+  Application.CreateForm(TProgressProForm, ProgressProForm);
   end;
   end;
     Application.Run;
     Application.Run;
   end;
   end;

BIN
Dprs/Pro/Measure_GuangDong_Cloud.res


+ 2 - 2
Dprs/Pro/Measure_GuangDong_TZ.cfg

@@ -33,8 +33,8 @@
 -K$00400000
 -K$00400000
 -E"D:\SmartCostExe\Measure"
 -E"D:\SmartCostExe\Measure"
 -N"..\..\Dcus"
 -N"..\..\Dcus"
--LE"d:\program files (x86)\borland\delphi7\Projects\Bpl"
--LN"d:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LE"c:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LN"c:\program files (x86)\borland\delphi7\Projects\Bpl"
 -w-UNSAFE_TYPE
 -w-UNSAFE_TYPE
 -w-UNSAFE_CODE
 -w-UNSAFE_CODE
 -w-UNSAFE_CAST
 -w-UNSAFE_CAST

+ 6 - 3
Dprs/Pro/Measure_GuangDong_TZ.dof

@@ -114,8 +114,8 @@ IncludeVerInfo=1
 AutoIncBuild=0
 AutoIncBuild=0
 MajorVer=3
 MajorVer=3
 MinorVer=1
 MinorVer=1
-Release=3
-Build=1050
+Release=5
+Build=202
 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.3.1050
+FileVersion=3.1.5.202
 InternalName=
 InternalName=
 LegalCopyright=
 LegalCopyright=
 LegalTrademarks=
 LegalTrademarks=
@@ -134,6 +134,9 @@ OriginalFilename=
 ProductName=
 ProductName=
 ProductVersion=1.0.0.0
 ProductVersion=1.0.0.0
 Comments=
 Comments=
+[Excluded Packages]
+C:\Program Files (x86)\Borland\Delphi7\Lib\3F\Developer Express Inc\ExpressEditors Library 5\Delphi 7\Bin\dclcxEditorsVCLD7.bpl=ExpressEditors Library 5 (VCL Edition) by Developer Express Inc.
+C:\Program Files (x86)\Borland\Delphi7\Lib\3F\Developer Express Inc\ExpressEditors Library 5\Delphi 7\Bin\dclcxExtEditorsVCLD7.bpl=ExpressExtendedEditors Library 5 (VCL Edition) by Developer Express Inc.
 [HistoryLists\hlUnitAliases]
 [HistoryLists\hlUnitAliases]
 Count=1
 Count=1
 Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
 Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;

+ 14 - 1
Dprs/Pro/Measure_GuangDong_TZ.dpr

@@ -136,8 +136,20 @@ uses
   rmGcl_XmjBillsDm in '..\..\DataModules\ReportMemoryDm\rmGcl_XmjBillsDm.pas' {rmGcl_XmjBillsData: TDataModule},
   rmGcl_XmjBillsDm in '..\..\DataModules\ReportMemoryDm\rmGcl_XmjBillsDm.pas' {rmGcl_XmjBillsData: TDataModule},
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
+  DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
+  mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm},
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
-  DetailExcelImport in '..\..\Units\DetailExcelImport.pas';
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
 
 
 {$R *.res}
 {$R *.res}
 
 
@@ -157,6 +169,7 @@ begin
     if CheckDogExists then
     if CheckDogExists then
     begin
     begin
       Application.CreateForm(TMainForm, MainForm);
       Application.CreateForm(TMainForm, MainForm);
+  Application.CreateForm(TProgressProForm, ProgressProForm);
   end;
   end;
     Application.Run;
     Application.Run;
   end;
   end;

BIN
Dprs/Pro/Measure_GuangDong_TZ.res


+ 2 - 2
Dprs/Pro/Measure_TZ.cfg

@@ -33,8 +33,8 @@
 -K$00400000
 -K$00400000
 -E"D:\SmartCostExe\Measure"
 -E"D:\SmartCostExe\Measure"
 -N"..\..\Dcus"
 -N"..\..\Dcus"
--LE"d:\program files (x86)\borland\delphi7\Projects\Bpl"
--LN"d:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LE"c:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LN"c:\program files (x86)\borland\delphi7\Projects\Bpl"
 -D_mEncrypt;_mcompile;
 -D_mEncrypt;_mcompile;
 -w-UNSAFE_TYPE
 -w-UNSAFE_TYPE
 -w-UNSAFE_CODE
 -w-UNSAFE_CODE

+ 11 - 38
Dprs/Pro/Measure_TZ.dof

@@ -114,8 +114,8 @@ IncludeVerInfo=1
 AutoIncBuild=1
 AutoIncBuild=1
 MajorVer=3
 MajorVer=3
 MinorVer=1
 MinorVer=1
-Release=3
-Build=1051
+Release=5
+Build=203
 Debug=0
 Debug=0
 PreRelease=0
 PreRelease=0
 Special=0
 Special=0
@@ -126,40 +126,13 @@ CodePage=936
 [Version Info Keys]
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横0号台账专业版
 FileDescription=纵横0号台账专业版
-FileVersion=3.1.3.1051
-InternalName=Measure
-LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
-LegalTrademarks=Measure
+FileVersion=3.1.5.203
+InternalName=
+LegalCopyright=
+LegalTrademarks=
 OriginalFilename=
 OriginalFilename=
-ProductName=纵横公路工程0号台账软件
-ProductVersion=1
-Comments=
-[HistoryLists\hlConditionals]
-Count=11
-Item0=_mEncrypt;_mcompile;
-Item1=_mEncrypt;_mcompile;cplPrint;cplOutputToExcelRange
-Item2=_mEncrypt;cplPrint;cplOutputToExcelRange
-Item3=cplPrint;_mEncrypt;cplPrint;cplOutputToExcelRange
-Item4=cplPrint;_mEncrypt;cplPrint
-Item5=cplPrint;_mEncrypt
-Item6=cplPrint;
-Item7=cplPrint;_mEncrypt;
-Item8=cplPrint;mEncrypt;
-Item9=cplPrint
-Item10=cplPrint;cplOutputToExcelRange;
-[HistoryLists\hlUnitAliases]
-Count=1
-Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-[HistoryLists\hlUnitOutputDirectory]
-Count=2
-Item0=..\..\Dcus
-Item1=..\Dcus
-[HistoryLists\hlOutputDirectorry]
-Count=7
-Item0=D:\SmartCostExe\Measure
-Item1=E:\SmartCostExe\Measure
-Item2=D:\Program Files (x86)\纵横软件\纵横计量决算一体化软件(专业版)
-Item3=D:\Program Files (x86)\纵横软件\纵横公路工程计量支付(专业版)
-Item4=D:\Program Files\纵横软件\Environment
-Item5=..\..\Environment
-Item6=..\Dcus
+ProductName=
+ProductVersion=1.0.0.0
+[Excluded Packages]
+C:\Program Files (x86)\Borland\Delphi7\Lib\3F\Developer Express Inc\ExpressEditors Library 5\Delphi 7\Bin\dclcxEditorsVCLD7.bpl=ExpressEditors Library 5 (VCL Edition) by Developer Express Inc.
+C:\Program Files (x86)\Borland\Delphi7\Lib\3F\Developer Express Inc\ExpressEditors Library 5\Delphi 7\Bin\dclcxExtEditorsVCLD7.bpl=ExpressExtendedEditors Library 5 (VCL Edition) by Developer Express Inc.

+ 14 - 1
Dprs/Pro/Measure_TZ.dpr

@@ -136,8 +136,20 @@ uses
   rmGcl_XmjBillsDm in '..\..\DataModules\ReportMemoryDm\rmGcl_XmjBillsDm.pas' {rmGcl_XmjBillsData: TDataModule},
   rmGcl_XmjBillsDm in '..\..\DataModules\ReportMemoryDm\rmGcl_XmjBillsDm.pas' {rmGcl_XmjBillsData: TDataModule},
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
+  DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
+  mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm},
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
-  DetailExcelImport in '..\..\Units\DetailExcelImport.pas';
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
 
 
 {$R *.res}
 {$R *.res}
 
 
@@ -158,6 +170,7 @@ begin
     if CheckDogExists then
     if CheckDogExists then
     begin
     begin
       Application.CreateForm(TMainForm, MainForm);
       Application.CreateForm(TMainForm, MainForm);
+  Application.CreateForm(TProgressProForm, ProgressProForm);
   end;
   end;
     Application.Run;
     Application.Run;
   end;
   end;

BIN
Dprs/Pro/Measure_TZ.res


+ 2 - 2
Dprs/Trail/Measure.cfg

@@ -33,8 +33,8 @@
 -K$00400000
 -K$00400000
 -E"D:\SmartCostExe\MeasureTrail"
 -E"D:\SmartCostExe\MeasureTrail"
 -N"..\..\Dcus"
 -N"..\..\Dcus"
--LE"d:\program files (x86)\borland\delphi7\Projects\Bpl"
--LN"d:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LE"c:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LN"c:\program files (x86)\borland\delphi7\Projects\Bpl"
 -w-UNSAFE_TYPE
 -w-UNSAFE_TYPE
 -w-UNSAFE_CODE
 -w-UNSAFE_CODE
 -w-UNSAFE_CAST
 -w-UNSAFE_CAST

+ 2 - 39
Dprs/Trail/Measure.dof

@@ -115,7 +115,7 @@ AutoIncBuild=1
 MajorVer=3
 MajorVer=3
 MinorVer=1
 MinorVer=1
 Release=3
 Release=3
-Build=1051
+Build=3013
 Debug=0
 Debug=0
 PreRelease=0
 PreRelease=0
 Special=0
 Special=0
@@ -126,41 +126,4 @@ CodePage=936
 [Version Info Keys]
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化专业版
 FileDescription=纵横结算决算计量一体化专业版
-FileVersion=3.1.3.1051
-InternalName=Measure
-LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
-LegalTrademarks=Measure
-OriginalFilename=
-ProductName=纵横公路工程计量决算一体化软件
-ProductVersion=3
-Comments=
-[HistoryLists\hlConditionals]
-Count=9
-Item0=_mEncrypt;cplPrint;cplOutputToExcelRange
-Item1=cplPrint;_mEncrypt;cplPrint;cplOutputToExcelRange
-Item2=cplPrint;_mEncrypt;cplPrint
-Item3=cplPrint;_mEncrypt
-Item4=cplPrint;
-Item5=cplPrint;_mEncrypt;
-Item6=cplPrint;mEncrypt;
-Item7=cplPrint
-Item8=cplPrint;cplOutputToExcelRange;
-[HistoryLists\hlUnitAliases]
-Count=1
-Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-[HistoryLists\hlUnitOutputDirectory]
-Count=2
-Item0=..\..\Dcus
-Item1=..\Dcus
-[HistoryLists\hlOutputDirectorry]
-Count=10
-Item0=D:\SmartCostExe\MeasureTrail
-Item1=E:\SmartCostExe\MeasureTrail
-Item2=E:\SmartCostExe\Measure
-Item3=D:\Program Files (x86)\纵横软件\纵横计量决算一体化软件(广东专业版)
-Item4=D:\Program Files (x86)\纵横软件\纵横计量决算一体化软件(专业版)
-Item5=D:\Program Files (x86)\纵横软件\纵横计量决算一体化软件(专业版2)
-Item6=D:\Program Files (x86)\纵横软件\纵横公路工程计量支付(专业版)
-Item7=D:\Program Files\纵横软件\Environment
-Item8=..\..\Environment
-Item9=..\Dcus
+FileVersion=3.1.3.3013

+ 14 - 1
Dprs/Trail/Measure.dpr

@@ -136,8 +136,20 @@ uses
   rmGcl_XmjBillsDm in '..\..\DataModules\ReportMemoryDm\rmGcl_XmjBillsDm.pas' {rmGcl_XmjBillsData: TDataModule},
   rmGcl_XmjBillsDm in '..\..\DataModules\ReportMemoryDm\rmGcl_XmjBillsDm.pas' {rmGcl_XmjBillsData: TDataModule},
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
+  DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
+  mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm},
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
-  DetailExcelImport in '..\..\Units\DetailExcelImport.pas';
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
 
 
 {$R *.res}
 {$R *.res}
 
 
@@ -157,6 +169,7 @@ begin
     begin
     begin
       HideWelcome;
       HideWelcome;
       Application.CreateForm(TMainForm, MainForm);
       Application.CreateForm(TMainForm, MainForm);
+  Application.CreateForm(TProgressProForm, ProgressProForm);
   end
   end
     else  HideWelcome;
     else  HideWelcome;
     Application.Run;
     Application.Run;

BIN
Dprs/Trail/Measure.res


+ 2 - 2
Dprs/Trail/Measure_GuangDong.cfg

@@ -33,8 +33,8 @@
 -K$00400000
 -K$00400000
 -E"D:\SmartCostExe\MeasureTrail"
 -E"D:\SmartCostExe\MeasureTrail"
 -N"..\..\Dcus"
 -N"..\..\Dcus"
--LE"d:\program files (x86)\borland\delphi7\Projects\Bpl"
--LN"d:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LE"c:\program files (x86)\borland\delphi7\Projects\Bpl"
+-LN"c:\program files (x86)\borland\delphi7\Projects\Bpl"
 -D_mGuangDong
 -D_mGuangDong
 -w-UNSAFE_TYPE
 -w-UNSAFE_TYPE
 -w-UNSAFE_CODE
 -w-UNSAFE_CODE

+ 2 - 41
Dprs/Trail/Measure_GuangDong.dof

@@ -115,7 +115,7 @@ AutoIncBuild=1
 MajorVer=3
 MajorVer=3
 MinorVer=1
 MinorVer=1
 Release=3
 Release=3
-Build=1051
+Build=3013
 Debug=0
 Debug=0
 PreRelease=0
 PreRelease=0
 Special=0
 Special=0
@@ -126,43 +126,4 @@ CodePage=936
 [Version Info Keys]
 [Version Info Keys]
 CompanyName=珠海纵横创新软件有限公司
 CompanyName=珠海纵横创新软件有限公司
 FileDescription=纵横结算决算计量一体化广东学习版
 FileDescription=纵横结算决算计量一体化广东学习版
-FileVersion=3.1.3.1051
-InternalName=Measure
-LegalCopyright=版权所有(C) 珠海纵横创新软件有限公司 2003-2014。保留所有权利。
-LegalTrademarks=Measure
-OriginalFilename=
-ProductName=纵横公路工程计量决算一体化软件
-ProductVersion=3
-Comments=
-[HistoryLists\hlConditionals]
-Count=12
-Item0=_mGuangDong
-Item1=_mEncrypt;_mGuangDong
-Item2=_mEncrypt;_mGuangDong;cplPrint;cplOutputToExcelRange
-Item3=_mEncrypt;cplPrint;cplOutputToExcelRange
-Item4=cplPrint;_mEncrypt;cplPrint;cplOutputToExcelRange
-Item5=cplPrint;_mEncrypt;cplPrint
-Item6=cplPrint;_mEncrypt
-Item7=cplPrint;
-Item8=cplPrint;_mEncrypt;
-Item9=cplPrint;mEncrypt;
-Item10=cplPrint
-Item11=cplPrint;cplOutputToExcelRange;
-[HistoryLists\hlUnitAliases]
-Count=1
-Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-[HistoryLists\hlUnitOutputDirectory]
-Count=2
-Item0=..\..\Dcus
-Item1=..\Dcus
-[HistoryLists\hlOutputDirectorry]
-Count=9
-Item0=D:\SmartCostExe\MeasureTrail
-Item1=E:\SmartCostExe\MeasureTrail
-Item2=E:\SmartCostExe\Measure
-Item3=D:\Program Files (x86)\纵横软件\纵横计量决算一体化软件(专业版)
-Item4=D:\Program Files (x86)\纵横软件\纵横计量决算一体化软件(专业版2)
-Item5=D:\Program Files (x86)\纵横软件\纵横公路工程计量支付(专业版)
-Item6=D:\Program Files\纵横软件\Environment
-Item7=..\..\Environment
-Item8=..\Dcus
+FileVersion=3.1.3.3013

+ 14 - 1
Dprs/Trail/Measure_GuangDong.dpr

@@ -136,8 +136,20 @@ uses
   rmGcl_XmjBillsDm in '..\..\DataModules\ReportMemoryDm\rmGcl_XmjBillsDm.pas' {rmGcl_XmjBillsData: TDataModule},
   rmGcl_XmjBillsDm in '..\..\DataModules\ReportMemoryDm\rmGcl_XmjBillsDm.pas' {rmGcl_XmjBillsData: TDataModule},
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   rmCustomized2Dm in '..\..\DataModules\ReportMemoryDm\rmCustomized2Dm.pas' {rmCustomized2Data: TDataModule},
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
   CalcDecimal in '..\..\Units\CalcDecimal.pas',
+  DetailExcelImport in '..\..\Units\DetailExcelImport.pas',
+  mProgressProFrm in '..\..\Forms\mProgressProFrm.pas' {ProgressProForm},
+  BaseClipboard in '..\..\Units\BaseClipboard.pas',
+  PriceMarginBillsDm in '..\..\DataModules\PriceMarginBillsDm.pas' {PriceMarginBillsData: TDataModule},
+  ProjectGLDm in '..\..\DataModules\ProjectGLDm.pas' {ProjectGLData: TDataModule},
+  GclBillsGatherModel in '..\..\Units\GclBillsGatherModel.pas',
+  DetailGLDm in '..\..\DataModules\DetailGLDm.pas' {DetailGLData: TDataModule},
+  rmHaBaiCustomizedDm in '..\..\DataModules\ReportMemoryDm\rmHaBaiCustomizedDm.pas' {rmHaBaiCustomizedData: TDataModule},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
   BillsPasteSelectFrm in '..\..\Forms\BillsPasteSelectFrm.pas' {BillsPasteSelectForm},
-  DetailExcelImport in '..\..\Units\DetailExcelImport.pas';
+  PriceMarginBillsFme in '..\..\Frames\PriceMarginBillsFme.pas' {PriceMarginBillsFrame: TFrame},
+  PriceMarginFme in '..\..\Frames\PriceMarginFme.pas' {PriceMarginFrame: TFrame},
+  ProjectGLFme in '..\..\Frames\ProjectGLFme.pas' {ProjectGLFrame: TFrame},
+  SelectDetailGLsFrm in '..\..\Forms\SelectDetailGLsFrm.pas' {SelectDetailGLsForm},
+  DealPayPlanFrm in '..\..\Forms\DealPayPlanFrm.pas' {DealPayPlanForm};
 
 
 {$R *.res}
 {$R *.res}
 
 
@@ -157,6 +169,7 @@ begin
     begin
     begin
       HideWelcome;
       HideWelcome;
       Application.CreateForm(TMainForm, MainForm);
       Application.CreateForm(TMainForm, MainForm);
+  Application.CreateForm(TProgressProForm, ProgressProForm);
   end
   end
     else  HideWelcome;
     else  HideWelcome;
     Application.Run;
     Application.Run;

BIN
Dprs/Trail/Measure_GuangDong.res


+ 6 - 0
Forms/BatchInsertBillsFrm.dfm

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

+ 1 - 0
Forms/BatchInsertBillsFrm.pas

@@ -338,6 +338,7 @@ begin
       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 := gaCenterLeft;
+      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;
     end;
     end;

+ 3 - 3
Forms/BatchReplaceBillsFrm.dfm

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

+ 252 - 0
Forms/DealPayPlanFrm.dfm

@@ -0,0 +1,252 @@
+object DealPayPlanForm: TDealPayPlanForm
+  Left = 593
+  Top = 331
+  Width = 411
+  Height = 290
+  Caption = #35774#32622#35745#25552#26399#38480
+  Color = clBtnFace
+  Font.Charset = ANSI_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -12
+  Font.Name = #23435#20307
+  Font.Style = []
+  OldCreateOrder = False
+  DesignSize = (
+    403
+    256)
+  PixelsPerInch = 96
+  TextHeight = 12
+  object lblTitle: TLabel
+    Left = 10
+    Top = 9
+    Width = 96
+    Height = 12
+    Caption = #35831#35774#32622#20184'('#25187')'#27454#39033
+  end
+  object lblDealPayName: TLabel
+    Left = 112
+    Top = 8
+    Width = 18
+    Height = 12
+    Caption = 'XXX'
+    Font.Charset = ANSI_CHARSET
+    Font.Color = clBlue
+    Font.Height = -12
+    Font.Name = #23435#20307
+    Font.Style = []
+    ParentFont = False
+  end
+  object lblTitle2: TLabel
+    Left = 136
+    Top = 8
+    Width = 60
+    Height = 12
+    Caption = #30340#35745#25552#26399#38480
+  end
+  object lblPlanType: TLabel
+    Left = 12
+    Top = 30
+    Width = 72
+    Height = 12
+    Caption = #38480#21046#27169#24335#20026#65306
+  end
+  object lblResultPre: TLabel
+    Left = 11
+    Top = 175
+    Width = 48
+    Height = 12
+    Anchors = [akRight, akBottom]
+    Caption = #35774#32622#20026#65306
+  end
+  object lblResult: TLabel
+    Left = 35
+    Top = 192
+    Width = 78
+    Height = 12
+    Anchors = [akRight, akBottom]
+    Caption = 'XX>YY('#20844#24335')'#26102
+    Font.Charset = ANSI_CHARSET
+    Font.Color = clRed
+    Font.Height = -12
+    Font.Name = #23435#20307
+    Font.Style = []
+    ParentFont = False
+  end
+  object lblResultPost: TLabel
+    Left = 34
+    Top = 209
+    Width = 258
+    Height = 12
+    Anchors = [akRight, akBottom]
+    Caption = #24403#26399#37329#39069#30452#25509#35745#37327#33267'('#25187#27454#38480#39069' - '#25130#27490#19978#26399#37329#39069')'
+  end
+  object btnOk: TButton
+    Left = 248
+    Top = 229
+    Width = 70
+    Height = 21
+    Anchors = [akRight, akBottom]
+    Caption = #30830#23450
+    TabOrder = 5
+    OnClick = btnOkClick
+  end
+  object btnCancel: TButton
+    Left = 325
+    Top = 229
+    Width = 70
+    Height = 21
+    Anchors = [akRight, akBottom]
+    Caption = #21462#28040
+    ModalResult = 2
+    TabOrder = 6
+  end
+  object rbIsPlanPhase: TRadioButton
+    Tag = 1
+    Left = 127
+    Top = 28
+    Width = 73
+    Height = 17
+    Caption = #35745#37327#26399#25968
+    TabOrder = 1
+    OnClick = rbIsPlanNonClick
+  end
+  object rbIsPlanPrice: TRadioButton
+    Tag = 2
+    Left = 206
+    Top = 28
+    Width = 73
+    Height = 17
+    Caption = #35745#37327#37329#39069
+    TabOrder = 2
+    OnClick = rbIsPlanNonClick
+  end
+  object gbPhase: TGroupBox
+    Left = 9
+    Top = 48
+    Width = 385
+    Height = 47
+    Caption = #35745#37327#26399#25968#27169#24335
+    Enabled = False
+    Font.Charset = ANSI_CHARSET
+    Font.Color = clGray
+    Font.Height = -12
+    Font.Name = #23435#20307
+    Font.Style = []
+    ParentFont = False
+    TabOrder = 3
+    object leDeadlinePhase: TLabeledEdit
+      Left = 78
+      Top = 19
+      Width = 129
+      Height = 18
+      Ctl3D = False
+      EditLabel.Width = 66
+      EditLabel.Height = 12
+      EditLabel.Caption = #38480#21046#37329#39069#65306' '
+      LabelPosition = lpLeft
+      ParentCtl3D = False
+      TabOrder = 0
+      Text = '2'
+      OnChange = leDeadlinePhaseChange
+      OnKeyPress = leDeadlinePhaseKeyPress
+    end
+    object udDeadlinePhase: TUpDown
+      Left = 207
+      Top = 19
+      Width = 16
+      Height = 18
+      Associate = leDeadlinePhase
+      Min = 2
+      Max = 50
+      Position = 2
+      TabOrder = 1
+      OnClick = udDeadlinePhaseClick
+    end
+  end
+  object gbPrice: TGroupBox
+    Left = 10
+    Top = 103
+    Width = 385
+    Height = 65
+    Caption = #35745#37327#37329#39069#27169#24335
+    Enabled = False
+    Font.Charset = ANSI_CHARSET
+    Font.Color = clGray
+    Font.Height = -12
+    Font.Name = #23435#20307
+    Font.Style = []
+    ParentFont = False
+    TabOrder = 4
+    object lblEquar: TLabel
+      Left = 232
+      Top = 43
+      Width = 6
+      Height = 12
+      Caption = '='
+    end
+    object lblPriceDeadline: TLabel
+      Left = 244
+      Top = 43
+      Width = 6
+      Height = 12
+      Caption = '0'
+    end
+    object rbAddGatherTotalPrice: TRadioButton
+      Left = 8
+      Top = 18
+      Width = 118
+      Height = 17
+      Caption = #32047#35745#23436#25104#35745#37327#37329#39069
+      Checked = True
+      TabOrder = 0
+      TabStop = True
+      OnClick = rbAddGatherTotalPriceClick
+    end
+    object rbAddDealTotalPrice: TRadioButton
+      Tag = 1
+      Left = 136
+      Top = 18
+      Width = 118
+      Height = 17
+      Caption = #32047#35745#21512#21516#35745#37327#37329#39069
+      TabOrder = 1
+      OnClick = rbAddGatherTotalPriceClick
+    end
+    object rbAddQCTotalPrice: TRadioButton
+      Tag = 2
+      Left = 263
+      Top = 18
+      Width = 118
+      Height = 17
+      Caption = #32047#35745#21464#26356#35745#37327#37329#39069
+      TabOrder = 2
+      OnClick = rbAddGatherTotalPriceClick
+    end
+    object lePDFormula: TLabeledEdit
+      Left = 80
+      Top = 40
+      Width = 145
+      Height = 18
+      Ctl3D = False
+      EditLabel.Width = 66
+      EditLabel.Height = 12
+      EditLabel.Caption = #38480#21046#37329#39069#65306' '
+      LabelPosition = lpLeft
+      ParentCtl3D = False
+      TabOrder = 3
+      OnExit = lePDFormulaExit
+      OnKeyPress = leDeadlinePhaseKeyPress
+    end
+  end
+  object rbIsPlanNon: TRadioButton
+    Left = 86
+    Top = 28
+    Width = 40
+    Height = 17
+    Caption = #26080
+    Checked = True
+    TabOrder = 0
+    TabStop = True
+    OnClick = rbIsPlanNonClick
+  end
+end

+ 294 - 0
Forms/DealPayPlanFrm.pas

@@ -0,0 +1,294 @@
+unit DealPayPlanFrm;
+
+interface
+
+uses
+  sdDB,
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, StdCtrls, ExtCtrls, ComCtrls, JimPages;
+
+type
+  TDealPayPlanForm = class(TForm)
+    lblTitle: TLabel;
+    lblDealPayName: TLabel;
+    lblTitle2: TLabel;
+    btnOk: TButton;
+    btnCancel: TButton;
+    lblPlanType: TLabel;
+    rbIsPlanPhase: TRadioButton;
+    rbIsPlanPrice: TRadioButton;
+    lblResultPre: TLabel;
+    lblResult: TLabel;
+    lblResultPost: TLabel;
+    gbPhase: TGroupBox;
+    leDeadlinePhase: TLabeledEdit;
+    udDeadlinePhase: TUpDown;
+    gbPrice: TGroupBox;
+    rbAddGatherTotalPrice: TRadioButton;
+    rbAddDealTotalPrice: TRadioButton;
+    rbAddQCTotalPrice: TRadioButton;
+    lePDFormula: TLabeledEdit;
+    rbIsPlanNon: TRadioButton;
+    lblEquar: TLabel;
+    lblPriceDeadline: TLabel;
+    procedure btnOkClick(Sender: TObject);
+    procedure rbIsPlanNonClick(Sender: TObject);
+    procedure rbAddGatherTotalPriceClick(Sender: TObject);
+    procedure udDeadlinePhaseClick(Sender: TObject; Button: TUDBtnType);
+    procedure leDeadlinePhaseKeyPress(Sender: TObject; var Key: Char);
+    procedure leDeadlinePhaseChange(Sender: TObject);
+    procedure lePDFormulaExit(Sender: TObject);
+  private
+    FDealPayRec: TsdDataRecord;
+    FProjectData: TObject;
+
+    FPlanType: Integer;
+    FPlanSubType: Integer;
+
+    //FFormulaSet: t
+
+    procedure InitForm;
+
+    procedure AssignResult;
+
+    procedure SetPlanType(const Value: Integer);
+    procedure SetPlanSubType(const Value: Integer);
+    function GetPhaseDeadline: Integer;
+    procedure SetPhaseDeadline(const Value: Integer);
+    function GetPriceDeadline: Double;
+    procedure SetPriceDeadline(const Value: Double);
+    function GetPDFormula: string;
+    procedure SetPDFormula(const Value: string);
+    function GetLimitPrice: Double;
+    function GetPlanSubTypeName: string;
+  public
+    constructor Create(ADealPayRec: TsdDataRecord; AProjectData: TObject);
+    destructor Destroy; override;
+
+    procedure SavePlanInfos;
+
+    property PlanType: Integer read FPlanType write SetPlanType;
+    property PlanSubType: Integer read FPlanSubType write SetPlanSubType;
+    property PlanSubTypeName: string read GetPlanSubTypeName;
+    property PhaseDeadline: Integer read GetPhaseDeadline write SetPhaseDeadline;
+    property PriceDeadline: Double read GetPriceDeadline write SetPriceDeadline;
+    property PDFormula: string read GetPDFormula write SetPDFormula;
+    property LimitPrice: Double read GetLimitPrice;
+  end;
+
+implementation
+
+uses
+  UtilMethods, ProjectData, BillsDm, DealPaymentDm, ZhAPI;
+
+{$R *.dfm}
+
+{ TDealPayPlanForm }
+
+constructor TDealPayPlanForm.Create(ADealPayRec: TsdDataRecord; AProjectData: TObject);
+begin
+  inherited Create(nil);
+  FDealPayRec := ADealPayRec;
+  FProjectData := AProjectData;
+  InitForm;
+end;
+
+destructor TDealPayPlanForm.Destroy;
+begin
+  inherited;
+end;
+
+procedure TDealPayPlanForm.InitForm;
+begin
+  lblDealPayName.Caption := FDealPayRec.ValueByName('Name').AsString;
+  lblTitle2.Left := lblDealPayName.Left + lblDealPayName.Width + 6;
+  PlanType := FDealPayRec.ValueByName('PlanType').AsInteger;
+  if PlanType = 1 then
+    PhaseDeadline := FDealPayRec.ValueByName('PlanDeadline').AsInteger
+  else if PlanType = 2 then
+  begin
+    PlanSubType := FDealPayRec.ValueByName('PlanSubType').AsInteger;
+    PriceDeadline := FDealPayRec.ValueByName('PlanDeadline').AsFloat;
+    PDFormula := FDealPayRec.ValueByName('PDFormula').AsString;
+  end;
+end;
+
+procedure TDealPayPlanForm.SavePlanInfos;
+begin
+  FDealPayRec.ValueByName('PlanType').AsInteger := PlanType;
+  if PlanType = 0 then
+  begin
+    FDealPayRec.ValueByName('PlanSubType').AsInteger := 0;
+    FDealPayRec.ValueByName('PlanDeadline').AsFloat := 0;
+    FDealPayRec.ValueByName('PDFormula').AsString := '';
+  end
+  else if PlanType = 1 then
+  begin
+    FDealPayRec.ValueByName('PlanSubType').AsInteger := 0;
+    FDealPayRec.ValueByName('PlanDeadline').AsInteger := PhaseDeadline;
+    FDealPayRec.ValueByName('PDFormula').AsString := '';
+  end
+  else
+  begin
+    FDealPayRec.ValueByName('PlanSubType').AsInteger := PlanSubType;
+    FDealPayRec.ValueByName('PlanDeadline').AsFloat := PriceDeadline;
+    FDealPayRec.ValueByName('PDFormula').AsString := PDFormula;
+  end;
+end;
+
+procedure TDealPayPlanForm.SetPriceDeadline(const Value: Double);
+begin
+  lblPriceDeadline.Caption := FloatToStr(Value);
+end;
+
+procedure TDealPayPlanForm.SetPlanSubType(const Value: Integer);
+begin
+  FPlanSubType := Value;
+  rbAddGatherTotalPrice.Checked := FPlanSubType = 0;
+  rbAddDealTotalPrice.Checked := FPlanSubType = 1;
+  rbAddQCTotalPrice.Checked := FPlanSubType = 2;
+  AssignResult;
+end;
+
+procedure TDealPayPlanForm.SetPlanType(const Value: Integer);
+begin
+  FPlanType := Value;
+  rbIsPlanNon.Checked := FPlanType = 0;
+  rbIsPlanPhase.Checked := FPlanType = 1;
+  rbIsPlanPrice.Checked := FPlanType = 2;
+  gbPhase.Enabled := rbIsPlanPhase.Checked;
+  if gbPhase.Enabled then
+    gbPhase.Font.Color := clBlack
+  else
+    gbPhase.Font.Color := clGray;
+  gbPrice.Enabled := rbIsPlanPrice.Checked;
+  if gbPrice.Enabled then
+    gbPrice.Font.Color := clBlack
+  else
+    gbPrice.Font.Color := clGray;
+  AssignResult;
+end;
+
+procedure TDealPayPlanForm.SetPhaseDeadline(const Value: Integer);
+begin
+  udDeadlinePhase.Position := Value;
+end;
+
+procedure TDealPayPlanForm.btnOkClick(Sender: TObject);
+begin
+  if (PlanType = 2) and (PriceDeadline < LimitPrice) then
+    ErrorMessage(Format('当前“%s”已计量至%f,限制金额应大于该值!', [PlanSubTypeName, LimitPrice]))
+  else
+    ModalResult := mrOk;
+end;
+
+function TDealPayPlanForm.GetPhaseDeadline: Integer;
+begin
+  Result := udDeadlinePhase.Position;
+end;
+
+function TDealPayPlanForm.GetPriceDeadline: Double;
+begin
+  Result := StrToFloat(lblPriceDeadline.Caption);
+end;
+
+function TDealPayPlanForm.GetPDFormula: string;
+begin
+  Result := lePDFormula.Text;
+end;
+
+procedure TDealPayPlanForm.SetPDFormula(const Value: string);
+begin
+  lePDFormula.Text := Value;
+end;
+
+function TDealPayPlanForm.GetLimitPrice: Double;
+begin
+  with TProjectData(FProjectData).BillsData do
+  begin
+    case PlanSubType of
+      0: Result := Settlement[4];
+      1: Result := Settlement[1];
+      2: Result := Settlement[2] + Settlement[3];
+    end;
+  end;
+end;
+
+procedure TDealPayPlanForm.rbIsPlanNonClick(Sender: TObject);
+begin
+  if PlanType <> TRadioButton(Sender).Tag then
+    PlanType := TRadioButton(Sender).Tag;
+end;
+
+procedure TDealPayPlanForm.rbAddGatherTotalPriceClick(Sender: TObject);
+begin
+  if PlanSubType <> TRadioButton(Sender).Tag then
+    PlanSubType := TRadioButton(Sender).Tag;
+end;
+
+procedure TDealPayPlanForm.AssignResult;
+
+  procedure CalcPriceDeadline;
+  begin
+    if CheckStringNull(PDFormula) then
+      PriceDeadline := 0
+    else if CheckNumeric(PDFormula) then
+      PriceDeadline := StrToFloatDef(PDFormula, 0)
+    else if Pos('bqwc', PDFormula) > 0 then
+    begin
+      ErrorMessage('不可使用“本期完成计量”计算基数!');
+      PriceDeadline := 0;
+    end
+    else
+      PriceDeadline := TProjectData(FProjectData).DealPaymentData.PayFormula.Calculate(PDFormula);
+  end;
+
+  function GetResult: String;
+  begin
+    case PlanType of
+      0: Result := '无';
+      1: Result := Format('当 计量期数 > %d 时,', [PhaseDeadline]);
+      2: Result := Format('当 %s > %f 时', [PlanSubTypeName, PriceDeadline]);
+    end;
+  end;
+
+begin
+  if PlanType = 2 then
+    CalcPriceDeadline;
+  lblResult.Caption := GetResult;
+  lblResultPost.Visible := PlanType <> 0;
+end;
+
+function TDealPayPlanForm.GetPlanSubTypeName: string;
+begin
+  case PlanSubType of
+    0: Result := '累计完成计量金额';
+    1: Result := '累计合同计量金额';
+    2: Result := '累计变更计量金额';
+  end;
+end;
+
+procedure TDealPayPlanForm.udDeadlinePhaseClick(Sender: TObject;
+  Button: TUDBtnType);
+begin
+  AssignResult;
+end;
+
+procedure TDealPayPlanForm.leDeadlinePhaseKeyPress(Sender: TObject;
+  var Key: Char);
+begin
+  if Key = #13 then
+    btnOk.SetFocus;
+end;
+
+procedure TDealPayPlanForm.leDeadlinePhaseChange(Sender: TObject);
+begin
+  AssignResult;
+end;
+
+procedure TDealPayPlanForm.lePDFormulaExit(Sender: TObject);
+begin
+  AssignResult;
+end;
+
+end.

+ 36 - 22
Forms/LoginFrm.dfm

@@ -1,6 +1,7 @@
 object LoginFrm: TLoginFrm
 object LoginFrm: TLoginFrm
   Left = 241
   Left = 241
   Top = 165
   Top = 165
+  ActiveControl = cbUser
   AutoSize = True
   AutoSize = True
   BorderIcons = [biSystemMenu]
   BorderIcons = [biSystemMenu]
   BorderStyle = bsNone
   BorderStyle = bsNone
@@ -16,6 +17,7 @@ object LoginFrm: TLoginFrm
   OldCreateOrder = False
   OldCreateOrder = False
   Position = poScreenCenter
   Position = poScreenCenter
   OnCreate = FormCreate
   OnCreate = FormCreate
+  OnDestroy = FormDestroy
   PixelsPerInch = 96
   PixelsPerInch = 96
   TextHeight = 12
   TextHeight = 12
   object imgBG: TImage
   object imgBG: TImage
@@ -31310,25 +31312,6 @@ object LoginFrm: TLoginFrm
     ShowHint = True
     ShowHint = True
     OnMouseDown = shpPWMouseDown
     OnMouseDown = shpPWMouseDown
   end
   end
-  object edtUser: TEdit
-    Left = 705
-    Top = 87
-    Width = 248
-    Height = 24
-    BorderStyle = bsNone
-    Ctl3D = True
-    Font.Charset = DEFAULT_CHARSET
-    Font.Color = 6710886
-    Font.Height = -16
-    Font.Name = #24494#36719#38597#40657
-    Font.Style = []
-    ImeName = #20013#25991' ('#31616#20307') - '#25628#29399#25340#38899#36755#20837#27861
-    ParentCtl3D = False
-    ParentFont = False
-    TabOrder = 0
-    OnClick = edtUserClick
-    OnKeyDown = edtUserKeyDown
-  end
   object edtPW: TEdit
   object edtPW: TEdit
     Left = 705
     Left = 705
     Top = 137
     Top = 137
@@ -31345,7 +31328,7 @@ object LoginFrm: TLoginFrm
     ParentCtl3D = False
     ParentCtl3D = False
     ParentFont = False
     ParentFont = False
     PasswordChar = '*'
     PasswordChar = '*'
-    TabOrder = 1
+    TabOrder = 0
     OnKeyDown = edtPWKeyDown
     OnKeyDown = edtPWKeyDown
   end
   end
   object btnLogin: TCslButton
   object btnLogin: TCslButton
@@ -35747,7 +35730,7 @@ object LoginFrm: TLoginFrm
     Top = 0
     Top = 0
     Width = 614
     Width = 614
     Height = 334
     Height = 334
-    TabOrder = 4
+    TabOrder = 3
     ControlData = {
     ControlData = {
       4C000000753F0000852200000000000000000000000000000000000000000000
       4C000000753F0000852200000000000000000000000000000000000000000000
       000000004C000000000000000000000001000000E0D057007335CF11AE690800
       000000004C000000000000000000000001000000E0D057007335CF11AE690800
@@ -35762,7 +35745,7 @@ object LoginFrm: TLoginFrm
     Height = 158
     Height = 158
     BevelOuter = bvNone
     BevelOuter = bvNone
     Color = clWhite
     Color = clWhite
-    TabOrder = 5
+    TabOrder = 4
     object lblLocalHelp: TCslLabel
     object lblLocalHelp: TCslLabel
       Left = 104
       Left = 104
       Top = 104
       Top = 104
@@ -40142,4 +40125,35 @@ object LoginFrm: TLoginFrm
       OnClick = btnLoginClick
       OnClick = btnLoginClick
     end
     end
   end
   end
+  object cbUser: TcxComboBox
+    Left = 705
+    Top = 85
+    Width = 254
+    Height = 29
+    ParentFont = False
+    PopupMenu = pmLogin
+    Properties.Alignment.Vert = taVCenter
+    Style.BorderStyle = ebsNone
+    Style.Font.Charset = DEFAULT_CHARSET
+    Style.Font.Color = clWindowText
+    Style.Font.Height = -16
+    Style.Font.Name = #24494#36719#38597#40657
+    Style.Font.Style = []
+    Style.Shadow = False
+    Style.ButtonStyle = btsHotFlat
+    StyleFocused.BorderStyle = ebsNone
+    StyleHot.BorderStyle = ebsNone
+    TabOrder = 5
+    OnClick = cbUserClick
+    OnKeyDown = cbUserKeyDown
+  end
+  object pmLogin: TPopupMenu
+    AutoHotkeys = maManual
+    Left = 848
+    Top = 40
+    object nClearAccount: TMenuItem
+      Caption = #28165#31354#24080#25143#20449#24687
+      OnClick = nClearAccountClick
+    end
+  end
 end
 end

+ 128 - 53
Forms/LoginFrm.pas

@@ -17,12 +17,11 @@ uses
   cxTextEdit, cxButtons, cxControls, cxEdit,
   cxTextEdit, cxButtons, cxControls, cxEdit,
   cxMaskEdit, cxDropDownEdit, HookEdit, cxContainer, XPMenu, cslLabel,
   cxMaskEdit, cxDropDownEdit, HookEdit, cxContainer, XPMenu, cslLabel,
   IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
   IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
-  CslButton, OleCtrls, SHDocVw;
+  CslButton, OleCtrls, SHDocVw, DB, ADODB, Menus;
   
   
 
 
 type
 type
   TLoginFrm = class(TForm)
   TLoginFrm = class(TForm)
-    edtUser: TEdit;
     edtPW: TEdit;
     edtPW: TEdit;
     lblForgetPW: TcslLabel;
     lblForgetPW: TcslLabel;
     lblVer: TLabel;
     lblVer: TLabel;
@@ -38,21 +37,30 @@ type
     btnLocalLogin: TCslButton;
     btnLocalLogin: TCslButton;
     lblLocalHelp: TCslLabel;
     lblLocalHelp: TCslLabel;
     lblLocalServer: TCslLabel;
     lblLocalServer: TCslLabel;
+    cbUser: TcxComboBox;
+    pmLogin: TPopupMenu;
+    nClearAccount: TMenuItem;
     procedure edtPWKeyDown(Sender: TObject; var Key: Word;
     procedure edtPWKeyDown(Sender: TObject; var Key: Word;
       Shift: TShiftState);
       Shift: TShiftState);
     procedure FormCreate(Sender: TObject);
     procedure FormCreate(Sender: TObject);
     procedure btnLoginClick(Sender: TObject);
     procedure btnLoginClick(Sender: TObject);
-    procedure edtUserKeyDown(Sender: TObject; var Key: Word;
-      Shift: TShiftState);
     procedure img1Click(Sender: TObject);
     procedure img1Click(Sender: TObject);
     procedure shpAccountMouseDown(Sender: TObject; Button: TMouseButton;
     procedure shpAccountMouseDown(Sender: TObject; Button: TMouseButton;
       Shift: TShiftState; X, Y: Integer);
       Shift: TShiftState; X, Y: Integer);
     procedure shpPWMouseDown(Sender: TObject; Button: TMouseButton;
     procedure shpPWMouseDown(Sender: TObject; Button: TMouseButton;
       Shift: TShiftState; X, Y: Integer);
       Shift: TShiftState; X, Y: Integer);
     procedure btnCloseClick(Sender: TObject);
     procedure btnCloseClick(Sender: TObject);
-    procedure edtUserClick(Sender: TObject);
+    procedure FormDestroy(Sender: TObject);
+    procedure cbUserKeyDown(Sender: TObject; var Key: Word;
+      Shift: TShiftState);
+    procedure cbUserClick(Sender: TObject);
+    procedure nClearAccountClick(Sender: TObject);
   private
   private
     { Private declarations }
     { Private declarations }
+    FUsersCon: TADOConnection;
+    FUsersQry: TADOQuery;
+    procedure ReadCloudUser;
+    procedure WriteCloudUser;
   public
   public
     { Public declarations }
     { Public declarations }
   end;
   end;
@@ -77,6 +85,7 @@ begin
     if Form.ShowModal = mrOK then
     if Form.ShowModal = mrOK then
     begin
     begin
       Result := True;
       Result := True;
+      Form.WriteCloudUser;
     end;
     end;
   finally
   finally
     Form.Free;
     Form.Free;
@@ -134,6 +143,8 @@ begin
   lblVer.Caption := G_ProductName + ' ' + ScGetVersion;
   lblVer.Caption := G_ProductName + ' ' + ScGetVersion;
 //  lblVer.Left := lblProductName.Left + lblProductName.Width + 7;
 //  lblVer.Left := lblProductName.Left + lblProductName.Width + 7;
 
 
+  ReadCloudUser;
+
   SL := TStringList.Create;
   SL := TStringList.Create;
   try
   try
     SL.Clear;
     SL.Clear;
@@ -150,7 +161,7 @@ end;
 procedure TLoginFrm.btnLoginClick(Sender: TObject);
 procedure TLoginFrm.btnLoginClick(Sender: TObject);
 var sInfo, sURL, sCheckCode, sMD5PW: string;
 var sInfo, sURL, sCheckCode, sMD5PW: string;
 begin
 begin
-  case PHPWeb.Login(edtUser.Text, edtPW.Text, sInfo, sCheckCode) of
+  case PHPWeb.Login(cbUser.Text, edtPW.Text, sInfo, sCheckCode) of
     ltCon:
     ltCon:
     begin
     begin
       if Trim(sInfo) <> '' then
       if Trim(sInfo) <> '' then
@@ -171,7 +182,7 @@ begin
     begin
     begin
       // 无法对PHP返回的字符串进行排版。这里使用Delphi自身的字符串。
       // 无法对PHP返回的字符串进行排版。这里使用Delphi自身的字符串。
       sInfo := '尊敬的用户:' + #13#13 +
       sInfo := '尊敬的用户:' + #13#13 +
-               '系统检测出您是通过SmartCost旧版本程序注册了本帐户(' + Trim(edtUser.Text) +
+               '系统检测出您是通过SmartCost旧版本程序注册了本帐户(' + Trim(cbUser.Text) +
                '),因系统升级,为保障您的帐户安全和更好的为您服务,' + #13#13 +
                '),因系统升级,为保障您的帐户安全和更好的为您服务,' + #13#13 +
                '我们需要对您的邮箱进行有效性验证,并需要您重置该帐户的密码以保证您的帐号在新程序上能够正常使用。' + #13#13 +
                '我们需要对您的邮箱进行有效性验证,并需要您重置该帐户的密码以保证您的帐号在新程序上能够正常使用。' + #13#13 +
                '请点击“确定”按钮打开密码重置页面。';
                '请点击“确定”按钮打开密码重置页面。';
@@ -198,7 +209,7 @@ begin
       try
       try
         sMD5PW := GetMD5(edtPW.Text);
         sMD5PW := GetMD5(edtPW.Text);
         sURL := Format('%s?Account=%s&Pwd=%s', [ConfigInfo.WebLoginURL,
         sURL := Format('%s?Account=%s&Pwd=%s', [ConfigInfo.WebLoginURL,
-          edtUser.Text, sMD5PW]);
+          cbUser.Text, sMD5PW]);
         ShellExecute(Application.Handle, 'open', PChar(sURL), nil, nil, SW_SHOWNORMAL);
         ShellExecute(Application.Handle, 'open', PChar(sURL), nil, nil, SW_SHOWNORMAL);
       finally
       finally
         Screen.Cursor := crDefault;
         Screen.Cursor := crDefault;
@@ -213,16 +224,6 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TLoginFrm.edtUserKeyDown(Sender: TObject; var Key: Word;
-  Shift: TShiftState);
-begin
-  if Key = VK_Return then
-  begin
-    edtPW.SetFocus;
-    edtPW.SelectAll;
-  end;
-end;
-
 procedure TLoginFrm.img1Click(Sender: TObject);
 procedure TLoginFrm.img1Click(Sender: TObject);
 begin
 begin
   Close;
   Close;
@@ -231,7 +232,7 @@ end;
 procedure TLoginFrm.shpAccountMouseDown(Sender: TObject; Button: TMouseButton;
 procedure TLoginFrm.shpAccountMouseDown(Sender: TObject; Button: TMouseButton;
   Shift: TShiftState; X, Y: Integer);
   Shift: TShiftState; X, Y: Integer);
 begin
 begin
-  edtUser.SetFocus;
+  cbUser.SetFocus;
 end;
 end;
 
 
 procedure TLoginFrm.shpPWMouseDown(Sender: TObject; Button: TMouseButton;
 procedure TLoginFrm.shpPWMouseDown(Sender: TObject; Button: TMouseButton;
@@ -245,46 +246,120 @@ begin
   Close;
   Close;
 end;
 end;
 
 
-procedure TLoginFrm.edtUserClick(Sender: TObject);
-// For Test Quickly. chenshilong, 2015-09-30
-const
-  AccArr: array[1..11, 1..3] of string = (
-    ('1', '2636698008@qq.com', 'smartcost3850887'), // 纵横销售演示服务器
-    ('2', '1971614655@qq.com', '357134933..'),
-    ('3', '1835082984@qq.com', '123456'),
-    ('4', '2417587264@qq.com', 'koukou0708'),
-    ('5', '2609827960@qq.com', 'missling'),
-    ('6', '1240621850@qq.com', '87654321'),
-    ('7', '1014149875@qq.com', 'zhbwoai'),
-    ('8', '1525739553@qq.com', '123456'),
-    ('9', '1391010261@qq.com', 'missling'),
-    ('10', '916960227@qq.com', '123456'),
-    ('11', '916960227@qq.com', '12345678') // 测试服务器
-  );
+procedure TLoginFrm.FormDestroy(Sender: TObject);
+begin
+  FUsersCon.Close;
+  FUsersCon.Free;
+  FUsersQry.Free;
+end;
 
 
-var
-  i: Integer;
-  bEx: Boolean;
+procedure TLoginFrm.ReadCloudUser;
+var s: string;
 begin
 begin
-  if G_IsTest then
+  FUsersCon := TADOConnection.Create(nil);
+  FUsersCon.LoginPrompt := False;
+  s := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=CloudUser.dat;Persist Security Info=False';
+  FUsersCon.ConnectionString := s;
+  FUsersQry := TADOQuery.Create(nil);
+  FUsersQry.Connection := FUsersCon;
+  FUsersQry.SQL.Text := 'Select Top 15 * From Users Order by LoginTimes Desc';
+  FUsersQry.Open;
+  cbUser.Properties.Items.Clear;
+  if FUsersQry.RecordCount > 0 then
   begin
   begin
-    bEx := False;
-    for i := Low(AccArr) to High(AccArr) do
+    FUsersQry.First;
+    while not FUsersQry.Eof do
     begin
     begin
-      if AccArr[i, 1] = edtUser.Text then
-      begin
-        edtUser.Text := AccArr[i, 2];
-        edtPW.Text := AccArr[i, 3];
-        bEx := True;
-        Break;
-      end;
-    end;
-    if not bEx then
-    begin
-      edtUser.Clear;
-      edtPW.Clear;
+      cbUser.Properties.Items.Add(FUsersQry.FieldByName('Account').AsString);
+      FUsersQry.Next;
     end;
     end;
   end;
   end;
+  FUsersQry.Close;
+end;
+
+procedure TLoginFrm.WriteCloudUser;
+begin
+  FUsersQry.Close;
+  FUsersQry.SQL.Text := Format('Select * From Users where UserID = %d', [PHPWeb.UserID]);
+  FUsersQry.Open;
+  if FUsersQry.RecordCount > 0 then
+  begin
+    FUsersQry.Close;
+    FUsersQry.SQL.Text := Format('Update Users Set LoginTimes=LoginTimes+1 where UserID = %d', [PHPWeb.UserID]);
+    FUsersQry.ExecSQL;
+  end
+  else
+  begin
+    FUsersQry.Close;
+    FUsersQry.SQL.Text := Format('Insert into Users(UserID,Account,RealName,LoginTimes) Values(%d,''%s'',''%s'',1)',
+      [PHPWeb.UserID, PHPWeb.Account, PHPWeb.RealName]);
+    FUsersQry.ExecSQL;
+  end;
+  FUsersQry.Close;
+end;
+
+procedure TLoginFrm.cbUserKeyDown(Sender: TObject; var Key: Word;
+  Shift: TShiftState);
+begin
+  if Key = VK_Return then
+  begin
+    edtPW.SetFocus;
+    edtPW.SelectAll;
+  end;
+end;
+
+procedure TLoginFrm.cbUserClick(Sender: TObject);
+// For Test Quickly. chenshilong, 2015-09-30
+//const
+//  AccArr: array[1..11, 1..3] of string = (
+//    ('1', '2636698008@qq.com', 'smartcost3850887'), // 纵横销售演示服务器
+//    ('2', '1971614655@qq.com', '357134933..'),
+//    ('3', '1835082984@qq.com', '123456'),
+//    ('4', '2417587264@qq.com', 'koukou0708'),
+//    ('5', '2609827960@qq.com', 'missling'),
+//    ('6', '1240621850@qq.com', '87654321'),
+//    ('7', '1014149875@qq.com', 'zhbwoai'),
+//    ('8', '1525739553@qq.com', '123456'),
+//    ('9', '1391010261@qq.com', 'missling'),
+//    ('10', '916960227@qq.com', '123456'),
+//    ('11', '916960227@qq.com', '12345678') // 测试服务器
+//  );
+//
+//var
+//  i: Integer;
+//  bEx: Boolean;
+begin
+//  if G_IsTest then
+//  begin
+//    bEx := False;
+//    for i := Low(AccArr) to High(AccArr) do
+//    begin
+//      if AccArr[i, 1] = cbUser.Text then
+//      begin
+//        cbUser.Text := AccArr[i, 2];
+//        edtPW.Text := AccArr[i, 3];
+//        bEx := True;
+//        Break;
+//      end;
+//    end;
+//    if not bEx then
+//    begin
+//      cbUser.Clear;
+//      edtPW.Clear;
+//    end;
+//  end;
+end;
+
+procedure TLoginFrm.nClearAccountClick(Sender: TObject);
+begin
+  if Application.MessageBox('确定要清空所有记录的帐户信息吗?', '询问', MB_YESNO + MB_ICONQUESTION) = ID_No then
+    Exit;
+
+  FUsersQry.Close;
+  FUsersQry.SQL.Text := 'Delete * From Users';
+  FUsersQry.ExecSQL;
+  FUsersQry.Close;
+  cbUser.Properties.Items.Clear;
 end;
 end;
 
 
 end.
 end.

+ 29 - 3
Forms/MainFrm.dfm

@@ -966,6 +966,18 @@ object MainForm: TMainForm
       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
       Visible = ivAlways
     end
     end
+    object dxbtnSetDealPayPlan: TdxBarButton
+      Caption = #35774#32622#35745#25552#26399#38480
+      Category = 0
+      Hint = #35774#32622#35745#25552#26399#38480
+      Visible = ivAlways
+    end
+    object dxbtnAddDetailGLs: TdxBarButton
+      Caption = #26032#22686#35843#24046#24037#26009
+      Category = 0
+      Hint = #26032#22686#35843#24046#24037#26009
+      Visible = ivAlways
+    end
     object dxbtnAllPeg: TdxBarButton
     object dxbtnAllPeg: TdxBarButton
       Caption = #21482#26174#31034#26729#21495'('#39033#30446#33410')'
       Caption = #21482#26174#31034#26729#21495'('#39033#30446#33410')'
       Category = 0
       Category = 0
@@ -989,12 +1001,26 @@ object MainForm: TMainForm
       Visible = ivAlways
       Visible = ivAlways
       OnClick = dxbtnTenderPartitionClick
       OnClick = dxbtnTenderPartitionClick
     end
     end
-    object dxbtnSetDealPayPlan: TdxBarButton
-      Caption = #35774#32622#35745#25552#26399#38480
+    object dxbtnCopyDetailGls: TdxBarButton
+      Caption = #22797#21046#35843#24046#24037#26009
       Category = 0
       Category = 0
-      Hint = #35774#32622#35745#25552#26399#38480
+      Hint = #22797#21046#35843#24046#24037#26009
+      Visible = ivAlways
+      ImageIndex = 4
+    end
+    object dxbtnApplyToSameBills: TdxBarButton
+      Caption = #24212#29992#35843#24046#24037#26009#33267#30456#21516#28165#21333
+      Category = 0
+      Hint = #24212#29992#35843#24046#24037#26009#33267#30456#21516#28165#21333
       Visible = ivAlways
       Visible = ivAlways
     end
     end
+    object dxbtnCalculatePriceMargin: TdxBarButton
+      Caption = #20215#24046#35745#31639
+      Category = 0
+      Hint = #20215#24046#35745#31639
+      Visible = ivAlways
+      ImageIndex = 15
+    end
   end
   end
   object Images: TImageList
   object Images: TImageList
     DrawingStyle = dsTransparent
     DrawingStyle = dsTransparent

+ 5 - 1
Forms/MainFrm.pas

@@ -147,6 +147,10 @@ type
     dxsiData: TdxBarSubItem;
     dxsiData: TdxBarSubItem;
     dxbtnTenderPartition: TdxBarButton;
     dxbtnTenderPartition: TdxBarButton;
     dxbtnSetDealPayPlan: TdxBarButton;
     dxbtnSetDealPayPlan: TdxBarButton;
+    dxbtnAddDetailGLs: TdxBarButton;
+    dxbtnCopyDetailGls: TdxBarButton;
+    dxbtnApplyToSameBills: TdxBarButton;
+    dxbtnCalculatePriceMargin: 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;
@@ -224,7 +228,7 @@ implementation
 uses
 uses
   ProjectProperty, ConstUnit, PHPWebDm, Math, ShellAPI,
   ProjectProperty, ConstUnit, PHPWebDm, Math, ShellAPI,
   FindUserFrm, ImportExcelHintFrm, ConfigDoc, ExportExcel,
   FindUserFrm, ImportExcelHintFrm, ConfigDoc, ExportExcel,
-  ProjectCommands, BillsCompileDm, tpModel, tpMainFrm;
+  ProjectCommands, BillsCompileDm, tpMainFrm;
 
 
 {$R *.dfm}
 {$R *.dfm}
 {$R MeasureIcons.RES}
 {$R MeasureIcons.RES}

+ 11 - 11
Forms/ReportsFrm.dfm

@@ -61,7 +61,7 @@ object ReportsForm: TReportsForm
     Width = 223
     Width = 223
     Height = 25
     Height = 25
     BevelInner = bvLowered
     BevelInner = bvLowered
-    TabOrder = 4
+    TabOrder = 3
     object chkExcelMode: TCheckBox
     object chkExcelMode: TCheckBox
       Left = 6
       Left = 6
       Top = 4
       Top = 4
@@ -83,23 +83,23 @@ object ReportsForm: TReportsForm
   end
   end
   object pnlReports: TPanel
   object pnlReports: TPanel
     Left = 0
     Left = 0
-    Top = 76
+    Top = 81
     Width = 1107
     Width = 1107
-    Height = 430
+    Height = 425
     Align = alClient
     Align = alClient
     BevelOuter = bvNone
     BevelOuter = bvNone
     TabOrder = 6
     TabOrder = 6
     object sprReportPreview: TSplitter
     object sprReportPreview: TSplitter
       Left = 211
       Left = 211
       Top = 0
       Top = 0
-      Height = 430
+      Height = 425
       AutoSnap = False
       AutoSnap = False
     end
     end
     object pnlReportsList: TPanel
     object pnlReportsList: TPanel
       Left = 0
       Left = 0
       Top = 0
       Top = 0
       Width = 211
       Width = 211
-      Height = 430
+      Height = 425
       Align = alLeft
       Align = alLeft
       BevelOuter = bvNone
       BevelOuter = bvNone
       TabOrder = 0
       TabOrder = 0
@@ -107,7 +107,7 @@ object ReportsForm: TReportsForm
         Left = 0
         Left = 0
         Top = 35
         Top = 35
         Width = 211
         Width = 211
-        Height = 395
+        Height = 390
         Align = alClient
         Align = alClient
         Font.Charset = DEFAULT_CHARSET
         Font.Charset = DEFAULT_CHARSET
         Font.Color = clWindowText
         Font.Color = clWindowText
@@ -194,7 +194,7 @@ object ReportsForm: TReportsForm
       Left = 214
       Left = 214
       Top = 0
       Top = 0
       Width = 893
       Width = 893
-      Height = 430
+      Height = 425
       HorzScrollBar.Increment = 48
       HorzScrollBar.Increment = 48
       HorzScrollBar.Tracking = True
       HorzScrollBar.Tracking = True
       VertScrollBar.Increment = 32
       VertScrollBar.Increment = 32
@@ -217,7 +217,7 @@ object ReportsForm: TReportsForm
     Font.Charset = DEFAULT_CHARSET
     Font.Charset = DEFAULT_CHARSET
     Font.Color = clWindowText
     Font.Color = clWindowText
     Font.Height = -12
     Font.Height = -12
-    Font.Name = #23435#20307
+    Font.Name = #24494#36719#38597#40657
     Font.Style = []
     Font.Style = []
     Bars = <
     Bars = <
       item
       item
@@ -314,7 +314,7 @@ object ReportsForm: TReportsForm
         Caption = #33539#22260#36755#20986
         Caption = #33539#22260#36755#20986
         DockedDockingStyle = dsTop
         DockedDockingStyle = dsTop
         DockedLeft = 0
         DockedLeft = 0
-        DockedTop = 47
+        DockedTop = 52
         DockingStyle = dsTop
         DockingStyle = dsTop
         FloatLeft = 602
         FloatLeft = 602
         FloatTop = 414
         FloatTop = 414
@@ -344,7 +344,7 @@ object ReportsForm: TReportsForm
         Caption = #25253#34920#36873#39033
         Caption = #25253#34920#36873#39033
         DockedDockingStyle = dsTop
         DockedDockingStyle = dsTop
         DockedLeft = 308
         DockedLeft = 308
-        DockedTop = 47
+        DockedTop = 52
         DockingStyle = dsTop
         DockingStyle = dsTop
         FloatLeft = 484
         FloatLeft = 484
         FloatTop = 279
         FloatTop = 279
@@ -389,7 +389,7 @@ object ReportsForm: TReportsForm
     DockControlHeights = (
     DockControlHeights = (
       0
       0
       0
       0
-      76
+      81
       0)
       0)
     object xlbPrint: TdxBarLargeButton
     object xlbPrint: TdxBarLargeButton
       Caption = #25171#21360
       Caption = #25171#21360

+ 30 - 2
Forms/ReportsFrm.pas

@@ -164,7 +164,7 @@ implementation
 
 
 uses
 uses
   UtilMethods, Math, DirectPrintUnit, Globals, ZhAPI, ReportAdjustFrm,
   UtilMethods, Math, DirectPrintUnit, Globals, ZhAPI, ReportAdjustFrm,
-  Contnrs, mEncryptUnit, Printers;
+  Contnrs, mEncryptUnit, Printers, WinSpool;
 
 
 {$R *.dfm}
 {$R *.dfm}
 
 
@@ -180,6 +180,7 @@ begin
     ReportsForm.ShowModal;
     ReportsForm.ShowModal;
   finally
   finally
     ReportsForm.Free;
     ReportsForm.Free;
+    AProjectData.ClearReportCacheData;
   end;
   end;
 end;
 end;
 
 
@@ -1268,10 +1269,37 @@ end;
 procedure TReportsForm.PrintReport(ATemplateNode: TTemplateNode;
 procedure TReportsForm.PrintReport(ATemplateNode: TTemplateNode;
   isPDF, isExcel: boolean; ExcelOutputName, TemplateFileName: string);
   isPDF, isExcel: boolean; ExcelOutputName, TemplateFileName: string);
 
 
+  function CheckPrinterReady: Boolean;
+  var
+    PrinterHD: THandle;
+    NoJobs: Word;
+    s: LongWord;
+    Job_Info: Array[0..10] of Job_INFO_1;
+    cbNeeded: Cardinal;
+    cReturned: Cardinal;
+    ret: LongBool;
+  begin
+    if OpenPrinter(PChar(Printer.Printers[Printer.PrinterIndex]), PrinterHD, 0) then
+    begin
+      s := SizeOf(Job_Info);
+      cbNeeded := 0;
+      cReturned := 0;
+      NoJobs := 10;
+      ret := ENumJobs(PrinterHD, 0, NoJobs, 1, @Job_Info, s, cbNeeded, cReturned);
+      Result := not((cReturned > 0) and (Job_Info[0].TotalPages > 0));
+    end
+    else
+      Result := True;
+  end;
+
   procedure PrintTemplet;
   procedure PrintTemplet;
   begin
   begin
     if isPDF then
     if isPDF then
-      PreviewComXML.PrintPDFAll
+    begin
+      PreviewComXML.PrintPDFAll;
+      while not CheckPrinterReady do
+        Sleep(1000);
+    end
     else if not isExcel then
     else if not isExcel then
       PreviewComXML.PrintAll(1)
       PreviewComXML.PrintAll(1)
     else
     else

+ 269 - 0
Forms/SelectDetailGLsFrm.dfm

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

+ 158 - 0
Forms/SelectDetailGLsFrm.pas

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

+ 1 - 1
Frames/BGLFme.dfm

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

+ 1 - 1
Frames/BillsCompileFme.dfm

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

+ 549 - 236
Frames/BillsGatherFme.dfm

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

+ 51 - 26
Frames/BillsGatherFme.pas

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

+ 59 - 2
Frames/BillsMeasureFme.dfm

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

+ 40 - 14
Frames/BillsMeasureFme.pas

@@ -56,13 +56,15 @@ type
     FShowBGLCode: Boolean;
     FShowBGLCode: Boolean;
     FShowDesignQuantity: Boolean;
     FShowDesignQuantity: Boolean;
     FShowAddField: Boolean; // For Inner Test
     FShowAddField: Boolean; // For Inner Test
+    FShowPMField: Boolean; // For Inner Test
     FOnAfterSetBookmark: TBookmarkRefreshEvent;
     FOnAfterSetBookmark: TBookmarkRefreshEvent;
     FShowAlias: Boolean;
     FShowAlias: Boolean;
 
 
     function CheckExprsColumn: Boolean;
     function CheckExprsColumn: Boolean;
 
 
     procedure SetColumnVisible(const AColumn: string; AVisible: Boolean);
     procedure SetColumnVisible(const AColumn: string; AVisible: Boolean);
-    procedure SetAddFieldVisiblie(AValue: Boolean);
+    procedure SetAddFieldVisible(AValue: Boolean);
+    procedure SetPMFieldVisible(AValue: Boolean);
 
 
     procedure LoadDealProperty(ARec: TsdDataRecord);
     procedure LoadDealProperty(ARec: TsdDataRecord);
 
 
@@ -185,20 +187,20 @@ end;
 procedure TBillsMeasureFrame.zgBillsMeasureCellGetColor(Sender: TObject; ACoord: TPoint;
 procedure TBillsMeasureFrame.zgBillsMeasureCellGetColor(Sender: TObject; ACoord: TPoint;
   var AColor: TColor);
   var AColor: TColor);
 var
 var
-  stnNode: TsdIDTreeNode;
+  stnNode: TBillsIDTreeNode;
   iCreatePhaseID: Integer;
   iCreatePhaseID: Integer;
   StageRec: TsdDataRecord;
   StageRec: TsdDataRecord;
-  fQtyDiffer: Double;
+  fDiffer: Double;
 begin
 begin
   AColor := clWindow;
   AColor := clWindow;
   if ACoord.Y > stdBillsMeasure.IDTree.Count + 1 then Exit;
   if ACoord.Y > stdBillsMeasure.IDTree.Count + 1 then Exit;
-  stnNode := stdBillsMeasure.IDTree.Items[ACoord.Y - 2];
+  stnNode := TBillsIDTreeNode(stdBillsMeasure.IDTree.Items[ACoord.Y - 2]);
   if not Assigned(stnNode) then Exit;
   if not Assigned(stnNode) then Exit;
-  iCreatePhaseID := stnNode.Rec.ValueByName('CreatePhaseID').AsInteger;
+  iCreatePhaseID := stnNode.Rec.CreatePhaseID.AsInteger;
   // 根据层次底色不同
   // 根据层次底色不同
   if stnNode.ParentID = 1 then
   if stnNode.ParentID = 1 then
     AColor := $00FBCAC4
     AColor := $00FBCAC4
-  else if (stnNode.Rec.ValueByName('B_Code').AsString = '') and (stnNode.Level > 0) then
+  else if (stnNode.Rec.B_Code.AsString = '') and (stnNode.Level > 0) then
     AColor := $00F9E8DF;
     AColor := $00F9E8DF;
   // 书签
   // 书签
   if TProjectData(FBillsMeasureData.ProjectData).ProjProperties.PhaseCount > 0 then
   if TProjectData(FBillsMeasureData.ProjectData).ProjProperties.PhaseCount > 0 then
@@ -221,10 +223,14 @@ begin
   if not stnNode.HasChildren then
   if not stnNode.HasChildren then
   begin
   begin
     with stnNode.Rec do
     with stnNode.Rec do
-      fQtyDiffer := QuantityRoundTo(
-          ValueByName('AddDealQuantity').AsFloat - ValueByName('Quantity').AsFloat);
-    if fQtyDiffer > 0 then
-      AColor := $00646AFE;
+    begin
+      if CalcType.AsInteger = 0 then
+        fDiffer := QuantityRoundTo(AddDealQuantity.AsFloat - Quantity.AsFloat)
+      else
+        fDiffer := TotalPriceRoundTo(AddDealTotalPrice.AsFloat - TotalPrice.AsFloat);
+      if fDiffer > 0 then
+        AColor := $00646AFE;
+    end;
   end;
   end;
 end;
 end;
 
 
@@ -339,15 +345,20 @@ procedure TBillsMeasureFrame.zgBillsMeasureCellButtonClick(Sender: TObject;
   end;
   end;
 
 
 var
 var
-  stnCurNode: TsdIDTreeNode;
+  stnCurNode: TBillsIDTreeNode;
   sType, sField: string;
   sType, sField: string;
 begin
 begin
-  stnCurNode := stdBillsMeasure.IDTree.Selected;
+  stnCurNode := TBillsIDTreeNode(stdBillsMeasure.IDTree.Selected);
   if stnCurNode.HasChildren then Exit;
   if stnCurNode.HasChildren then Exit;
   with TProjectData(FBillsMeasureData.ProjectData) do
   with TProjectData(FBillsMeasureData.ProjectData) do
     if PhaseData.StageDataReadOnly then Exit;
     if PhaseData.StageDataReadOnly then Exit;
   GetTypeAndField(sType, sField);
   GetTypeAndField(sType, sField);
   if (sType = '') or (sField = '') then Exit;
   if (sType = '') or (sField = '') then Exit;
+  if stnCurNode.Rec.CalcType.AsInteger = 1 then
+  begin
+    WarningMessage('该清单不可输入数量单价,如需使用数量×单价计算,请先清空所有直接输入的金额!');
+    Exit;
+  end;
   SelectAndUpdateBGL(sType, sField, stnCurNode);
   SelectAndUpdateBGL(sType, sField, stnCurNode);
 end;
 end;
 
 
@@ -375,7 +386,7 @@ begin
   stdBillsMeasure.Column('AddDgnPrice').Visible := FShowDesignQuantity;
   stdBillsMeasure.Column('AddDgnPrice').Visible := FShowDesignQuantity;
 end;
 end;
 
 
-procedure TBillsMeasureFrame.SetAddFieldVisiblie(AValue: Boolean);
+procedure TBillsMeasureFrame.SetAddFieldVisible(AValue: Boolean);
 begin
 begin
   FShowAddField := AValue;
   FShowAddField := AValue;
   stdBillsMeasure.Column('AddDealQuantity').Visible := AValue;
   stdBillsMeasure.Column('AddDealQuantity').Visible := AValue;
@@ -395,7 +406,7 @@ begin
   if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
   if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
       and (Key in [65, 97]) // 'a', 'A'
       and (Key in [65, 97]) // 'a', 'A'
       and (zgBillsMeasure.CurCol = 4) then
       and (zgBillsMeasure.CurCol = 4) then
-    SetAddFieldVisiblie(not FShowAddField);
+    SetAddFieldVisible(not FShowAddField);
 
 
   if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
   if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
       and (Key in [80, 112]) // 'p', 'P' - Parent
       and (Key in [80, 112]) // 'p', 'P' - Parent
@@ -406,6 +417,13 @@ begin
   end;
   end;
 
 
   if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
   if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
+      and (Key in [77, 109]) // 'm', 'M' - PriceMargin
+      and (zgBillsMeasure.CurCol = 5) then
+  begin
+    SetPMFieldVisible(not FShowPMField);
+  end;
+
+  if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
       and (Key in [67, 99]) then // 'c', 'C'
       and (Key in [67, 99]) then // 'c', 'C'
     actnCalculateAll.Execute;
     actnCalculateAll.Execute;
 end;
 end;
@@ -629,4 +647,12 @@ begin
     stdBillsMeasure.Options := stdBillsMeasure.Options - [aoAllowInsert];
     stdBillsMeasure.Options := stdBillsMeasure.Options - [aoAllowInsert];
 end;
 end;
 
 
+procedure TBillsMeasureFrame.SetPMFieldVisible(AValue: Boolean);
+begin
+  FShowAddField := AValue;
+  stdBillsMeasure.Column('PM_PreTotalPrice').Visible := AValue;
+  stdBillsMeasure.Column('PM_TotalPrice').Visible := AValue;
+  stdBillsMeasure.Column('PM_AddTotalPrice').Visible := AValue;
+end;
+
 end.
 end.

+ 3 - 1
Frames/DealBillsFme.dfm

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

+ 10 - 0
Frames/DealPaymentFme.dfm

@@ -119,6 +119,7 @@ object DealPaymentFrame: TDealPaymentFrame
       FrozenRow = 0
       FrozenRow = 0
       OnCurrentChanged = zgDealPaymentCurrentChanged
       OnCurrentChanged = zgDealPaymentCurrentChanged
       OnCanEditAcceptKey = zgDealPaymentCanEditAcceptKey
       OnCanEditAcceptKey = zgDealPaymentCanEditAcceptKey
+      OnShowHint = zgDealPaymentShowHint
       OnCellGetColor = zgDealPaymentCellGetColor
       OnCellGetColor = zgDealPaymentCellGetColor
       OnMouseDown = zgDealPaymentMouseDown
       OnMouseDown = zgDealPaymentMouseDown
       Align = alClient
       Align = alClient
@@ -305,6 +306,10 @@ object DealPaymentFrame: TDealPaymentFrame
         BeginGroup = True
         BeginGroup = True
         Item = MainForm.dxbtnCalculatePhasePay
         Item = MainForm.dxbtnCalculatePhasePay
         Visible = True
         Visible = True
+      end
+      item
+        Item = MainForm.dxbtnSetDealPayPlan
+        Visible = True
       end>
       end>
     UseOwnFont = False
     UseOwnFont = False
     OnPopup = dxpmDealPaymentPopup
     OnPopup = dxpmDealPaymentPopup
@@ -321,5 +326,10 @@ object DealPaymentFrame: TDealPaymentFrame
       OnExecute = actnCalculatePhasePayExecute
       OnExecute = actnCalculatePhasePayExecute
       OnUpdate = actnCalculatePhasePayUpdate
       OnUpdate = actnCalculatePhasePayUpdate
     end
     end
+    object actnSetDealPayPlan: TAction
+      Caption = #35774#32622#35745#25552#26399#38480
+      Hint = #36798#21040#26465#20214#26102#65292#21363#21051#35745#37327#33267#20184'('#25187')'#27454#38480#39069
+      OnExecute = actnSetDealPayPlanExecute
+    end
   end
   end
 end
 end

+ 79 - 4
Frames/DealPaymentFme.pas

@@ -23,6 +23,7 @@ type
     dxpmDealPayment: TdxBarPopupMenu;
     dxpmDealPayment: TdxBarPopupMenu;
     actnDealPayment: TActionList;
     actnDealPayment: TActionList;
     actnCalculatePhasePay: TAction;
     actnCalculatePhasePay: TAction;
+    actnSetDealPayPlan: TAction;
     procedure zgParameterCellCanEdit(Sender: TObject; const ACoord: TPoint;
     procedure zgParameterCellCanEdit(Sender: TObject; const ACoord: TPoint;
       var Allow: Boolean);
       var Allow: Boolean);
     procedure imgHelpClick(Sender: TObject);
     procedure imgHelpClick(Sender: TObject);
@@ -41,6 +42,9 @@ type
     procedure laEdtExprsKeyPress(Sender: TObject; var Key: Char);
     procedure laEdtExprsKeyPress(Sender: TObject; var Key: Char);
     procedure zgDealPaymentCanEditAcceptKey(var AKey: Char;
     procedure zgDealPaymentCanEditAcceptKey(var AKey: Char;
       var Accept: Boolean);
       var Accept: Boolean);
+    procedure actnSetDealPayPlanExecute(Sender: TObject);
+    procedure zgDealPaymentShowHint(var HintStr: String;
+      var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint);
   private
   private
     FDealPaymentData: TDealPaymentData;
     FDealPaymentData: TDealPaymentData;
 
 
@@ -64,7 +68,7 @@ type
 implementation
 implementation
 
 
 uses
 uses
-  MainFrm, UtilMethods, ProjectData, PhaseData;
+  MainFrm, UtilMethods, ProjectData, PhaseData, DealPayPlanFrm;
 
 
 {$R *.dfm}
 {$R *.dfm}
 
 
@@ -138,7 +142,9 @@ procedure TDealPaymentFrame.laEdtExprsKeyDown(Sender: TObject;
   var Key: Word; Shift: TShiftState);
   var Key: Word; Shift: TShiftState);
 begin
 begin
   if Key = VK_Return then
   if Key = VK_Return then
-    zgDealPayment.SetFocus;
+    zgDealPayment.SetFocus
+  else if (ssCtrl in Shift) and (Key in [67, 99]) then
+    laEdtExprs.CopyToClipboard;
 end;
 end;
 
 
 function TDealPaymentFrame.CheckColHasFormula(ACol: Integer): Boolean;
 function TDealPaymentFrame.CheckColHasFormula(ACol: Integer): Boolean;
@@ -151,6 +157,7 @@ end;
 procedure TDealPaymentFrame.dxpmDealPaymentPopup(Sender: TObject);
 procedure TDealPaymentFrame.dxpmDealPaymentPopup(Sender: TObject);
 begin
 begin
   SetDxBtnAction(actnCalculatePhasePay, MainForm.dxbtnCalculatePhasePay);
   SetDxBtnAction(actnCalculatePhasePay, MainForm.dxbtnCalculatePhasePay);
+  SetDxBtnAction(actnSetDealPayPlan, MainForm.dxbtnSetDealPayPlan);
 end;
 end;
 
 
 procedure TDealPaymentFrame.actnCalculatePhasePayExecute(Sender: TObject);
 procedure TDealPaymentFrame.actnCalculatePhasePayExecute(Sender: TObject);
@@ -230,12 +237,12 @@ procedure TDealPaymentFrame.laEdtExprsKeyPress(Sender: TObject;
 begin
 begin
   if CheckCurTotalPriceCol(zgDealPayment.CurCol) then
   if CheckCurTotalPriceCol(zgDealPayment.CurCol) then
   begin
   begin
-    if not((Key in ArithmeticCharSet) or (Key in ExprsBaseCharSet) or (Key = #8)) then
+    if not((Key in ArithmeticCharSet) or (Key in ExprsBaseCharSet) or (Key in [#8, #17])) then
       Key := #0;
       Key := #0;
   end
   end
   else if CheckLimitPriceCol(zgDealPayment.CurCol) then
   else if CheckLimitPriceCol(zgDealPayment.CurCol) then
   begin
   begin
-    if not((Key in ArithmeticCharSet) or (Key in ExprsExceptCharSet) or (Key = #8)) then
+    if not((Key in ArithmeticCharSet) or (Key in ExprsExceptCharSet) or (Key in [#8, #17])) then
       Key := #0;
       Key := #0;
   end
   end
   else
   else
@@ -297,4 +304,72 @@ begin
             (ACol - 1 = sdDealPayment.VisibleCol('RangePrice'));
             (ACol - 1 = sdDealPayment.VisibleCol('RangePrice'));
 end;
 end;
 
 
+procedure TDealPaymentFrame.actnSetDealPayPlanExecute(Sender: TObject);
+
+  function CheckCanPlan(ARec: TsdDataRecord): Boolean;
+  begin
+    Result := True;
+    if ARec.ValueByName('CalcType').AsInteger <> 0 then
+    begin
+      ErrorMessage('本期应付,本期实付不可设置计提期限。');
+      Result := False;
+    end
+    else if ARec.ValueByName('RangePrice').AsFloat = 0 then
+    begin
+      ErrorMessage('计提期限用于达到条件时,即刻计量至付(扣)款限额,应先设置付(扣)款限额。');
+      Result := False;
+    end
+    else if ARec.ValueByName('Locked').AsBoolean then
+    begin
+      if ARec.ValueByName('PlanType').AsInteger = 0 then
+        ErrorMessage('该支付(扣款)项被锁定,不可修改!')
+      else
+        TipMessage(Format('该支付(扣款)项已设置计提期限为:%s', [FDealPaymentData.PlanStr(ARec)]) + #13#10 + '且该项已被锁定,不可修改!');
+      Result := False;
+    end;
+  end;
+
+var
+  Rec: TsdDataRecord;
+  PlanForm: TDealPayPlanForm;
+begin
+  Rec := sdDealPayment.DataView.Current;
+  if CheckCanPlan(Rec) then
+  begin
+    PlanForm := TDealPayPlanForm.Create(Rec, FDealPaymentData.ProjectData);
+    try
+      if PlanForm.ShowModal = mrOk then
+        PlanForm.SavePlanInfos;
+    finally
+      PlanForm.Free;
+    end;
+  end;
+end;
+
+procedure TDealPaymentFrame.zgDealPaymentShowHint(var HintStr: String;
+  var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint);
+var
+  Rec: TsdDataRecord;
+begin
+  // 用户鼠标点击移动至本期金额时,提示是否含计提限额
+  if (ACoord.X = 3) and (ACoord.Y > 0) and (ACoord.Y <= zgDealPayment.RowCount - 3) then
+  begin  
+    Rec := sdDealPayment.DataView.Records[ACoord.Y - 1];
+    if Assigned(Rec) and (Rec.ValueByName('Formula').AsString <> '') then
+    begin
+      if (Rec.ValueByName('PlanType').AsInteger <> 0) then
+      begin
+        CanShow := True;
+        HintStr := Format('计提期限为(%s)', [FDealPaymentData.PlanStr(Rec)]);
+      end;
+      if (zgDealPayment.Cells[ACoord.X, ACoord.Y].Text <> '') and FDealPaymentData.CheckReachPlan(Rec) then
+      begin
+        CanShow := True;
+        HintStr := '已达到计提期限,使用公式计算的当期金额须一次性计提至限额' + #13#10 +
+            Format('计提期限为(%s)', [FDealPaymentData.PlanStr(Rec)]);
+      end;
+    end;
+  end;
+end;
+
 end.
 end.

+ 1 - 1
Frames/PhaseCompareFme.dfm

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

+ 745 - 0
Frames/PriceMarginBillsFme.dfm

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

+ 190 - 0
Frames/PriceMarginBillsFme.pas

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

+ 115 - 0
Frames/PriceMarginFme.dfm

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

+ 82 - 0
Frames/PriceMarginFme.pas

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

+ 35 - 8
Frames/ProjectFme.dfm

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

+ 43 - 13
Frames/ProjectFme.pas

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

+ 291 - 0
Frames/ProjectGLFme.dfm

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

+ 94 - 0
Frames/ProjectGLFme.pas

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

+ 3 - 1
Frames/SearchFme.dfm

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

+ 3 - 1
Frames/StandardBillsFme.dfm

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

+ 1 - 1
TenderPartition/tpBaseGatherData.pas

@@ -37,7 +37,7 @@ type
 implementation
 implementation
 
 
 uses
 uses
-  ProgressHintFrm, mPegFilter, Globals, UtilMethods, Forms;
+  ProgressHintFrm, mPegFilter, Globals, UtilMethods, Forms, Controls;
 
 
 { TtpBaseGatherData }
 { TtpBaseGatherData }
 
 

+ 1 - 1
TenderPartition/tpPartTenderSet.pas

@@ -37,7 +37,7 @@ implementation
 
 
 uses
 uses
   ZhAPI, mPegFilter, tpPartTenderSetFme, Math, ProgressHintFrm,
   ZhAPI, mPegFilter, tpPartTenderSetFme, Math, ProgressHintFrm,
-  SysUtils, tpPegPartSettingFrm, Forms;
+  SysUtils, tpPegPartSettingFrm, Forms, Controls;
 
 
 { TtpPartTenderSet }
 { TtpPartTenderSet }
 
 

+ 159 - 0
Units/BaseClipboard.pas

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

+ 16 - 121
Units/BillsClipboard.pas

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

+ 3 - 0
Units/ConstUnit.pas

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

+ 142 - 6
Units/DataBaseTables.pas

@@ -103,7 +103,7 @@ const
 
 
   {清单数据 -- 台账编辑界面}
   {清单数据 -- 台账编辑界面}
   SBills = 'Bills';
   SBills = 'Bills';
-  tdBills: array [0..80] of TScFieldDef =(
+  tdBills: array [0..83] 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: 'ParentID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'ParentID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'NextSiblingID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'NextSiblingID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: False; ForceUpdate: False),
@@ -270,12 +270,19 @@ const
     // 经济指标
     // 经济指标
     (FieldName: 'DgnPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'DgnPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 累计经济指标
     // 累计经济指标
-    (FieldName: 'AddDgnPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+    (FieldName: 'AddDgnPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    {------------------- Begin reports -----------------------}
+    // 签约清单数量
+    (FieldName: 'GclDealQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 签约清单金额
+    (FieldName: 'GclDealTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    {------------------ End Reports --------------------------}
+    (FieldName: 'PM_AddTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
   );
 
 
   {合同支付}
   {合同支付}
   SDealPayment = 'DealPayment';
   SDealPayment = 'DealPayment';
-  tdDealPayment: array [0..14] of TScFieldDef =(
+  tdDealPayment: array [0..19] 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: 'Name'; FieldType: ftString; Size: 200; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'Name'; FieldType: ftString; Size: 200; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 计算类型
     // 计算类型
@@ -297,6 +304,14 @@ const
     (FieldName: 'RangePrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'RangePrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 限额 -- 公式
     // 限额 -- 公式
     (FieldName: 'RFormula'; FieldType: ftString; Size: 100; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'RFormula'; FieldType: ftString; Size: 100; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 计提期限 -- 方式 0:无 1:计量期数 2:计量金额
+    (FieldName: 'PlanType'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 计提期限 -- 子方式(计量金额)  0:累计完成计量金额 1: 累计合同计量金额 2: 累计变更计量金额
+    (FieldName: 'PlanSubType'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 计提期限 -- 截止限定
+    (FieldName: 'PlanDeadline'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 计提期限 -- 截止限定 -- 计算公式
+    (FieldName: 'PDFormula'; FieldType: ftString; Size: 100; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 锁定
     // 锁定
     (FieldName: 'Locked'; FieldType: ftBoolean; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'Locked'; FieldType: ftBoolean; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 创建期数
     // 创建期数
@@ -306,7 +321,9 @@ const
     // 预定义
     // 预定义
     (FieldName: 'PreDefined'; FieldType: ftBoolean; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'PreDefined'; FieldType: ftBoolean; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 锁定公式
     // 锁定公式
-    (FieldName: 'LockedFormula'; FieldType: ftBoolean; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+    (FieldName: 'LockedFormula'; FieldType: ftBoolean; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 支付扣款项拼接ID -- 报表专用
+    (FieldName: 'LinkSerialNo'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
   );
 
 
   {变更令}
   {变更令}
@@ -392,6 +409,121 @@ const
     (FieldName: 'TotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
     (FieldName: 'TotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
   );
 
 
+  {调差工料}
+  SProjectGL = 'ProjectGL';
+  tdProjectGL: array [0..16] of TScFieldDef =(
+    (FieldName: 'ID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 工料机编号
+    (FieldName: 'Code'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 名称
+    (FieldName: 'Name'; FieldType: ftString; Size: 200; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 单位
+    (FieldName: 'Units'; FieldType: ftString; Size: 20; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 规格
+    (FieldName: 'Specs'; FieldType: ftString; Size: 200; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 基准价
+    (FieldName: 'BasePrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 风险幅度
+    (FieldName: 'RiskRange'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 锁定期号: 取值范围0~50, 0表示未锁定, 1~50表示在第1~50期锁定
+    (FieldName: 'LockedPhaseID'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 创建期号: 取值范围0~50(台账编制, 1期~50期)
+    (FieldName: 'CreatePhaseID'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    {--------------------Begin 当期缓存数据----------------------}
+    // 信息价
+    (FieldName: 'InfoPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 信息价时间
+    (FieldName: 'InfoDate'; FieldType: ftString; Size: 20; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 价差
+    (FieldName: 'DeltaPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 有效价差
+    (FieldName: 'ValidDeltaPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 -- 调差数量
+    (FieldName: 'PM_PreQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 -- 调差金额
+    (FieldName: 'PM_PreTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 当前阶段 -- 调差数量
+    (FieldName: 'PM_Quantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 当期阶段 -- 调差金额
+    (FieldName: 'PM_TotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+    {--------------------End 当期缓存数据----------------------}
+  );
+
+  {调差工料--价格信息及计算}
+  SGLPrice = 'GLPrice';
+  tdGLPrice: array [0..39] of TScFieldDef =(
+    // 工料ID
+    (FieldName: 'GLID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 期号
+    (FieldName: 'PhaseID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 信息价
+    (FieldName: 'InfoPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 信息价--时间
+    (FieldName: 'InfoDate'; FieldType: ftString; Size: 20; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 价差
+    (FieldName: 'DeltaPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 有效价差
+    (FieldName: 'ValidDeltaPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期
+    (FieldName: 'PM_PreQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_PreTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 -- 原报
+    (FieldName: 'PM_Quantity0'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice0'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 -- 1审~14审
+    (FieldName: 'PM_Quantity1'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice1'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity2'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice2'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity3'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice3'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity4'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice4'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity5'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice5'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity6'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice6'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity7'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice7'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity8'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice8'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity9'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice9'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity10'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice10'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity11'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice11'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity12'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice12'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity13'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice13'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_Quantity14'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice14'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 -- 终审数据(当前文件中最后一人的数据)-- 数据缓存
+    (FieldName: 'PM_Quantity_F'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'PM_TotalPrice_F'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+  );
+
+  {清单使用的工料}
+  SDetailGL = 'DetailGL';
+  tdDetailGL: array [0..7] of TScFieldDef =(
+    (FieldName: 'ID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 清单ID
+    (FieldName: 'BillsID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: False; ForceUpdate: False),
+    // 工料ID
+    (FieldName: 'GLID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: False; ForceUpdate: False),
+    // 工料机编号
+    (FieldName: 'Code'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 消耗量
+    (FieldName: 'Quantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 创建期号
+    (FieldName: 'CreatePhaseID'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 最新一期最新一阶段的清单计量信息 -- 数据缓存
+    (FieldName: 'LastBillsQuantity'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 锁定期号
+    (FieldName: 'LockedPhaseID'; FieldType: ftInteger; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+  );
+
   {各期总数据 -- 为更新项目管理而储存的缓存数据}
   {各期总数据 -- 为更新项目管理而储存的缓存数据}
   SMainDataList = 'MainDataList';
   SMainDataList = 'MainDataList';
   tdMainDataList: array [0..15] of TScFieldDef =(
   tdMainDataList: array [0..15] of TScFieldDef =(
@@ -438,7 +570,7 @@ const
   // ......
   // ......
   SRefer = 'Refer';
   SRefer = 'Refer';
   SAudit = 'Audit';
   SAudit = 'Audit';
-  tdRefer_Audit: array [0..44] of TScFieldDef = (
+  tdRefer_Audit: array [0..46] of TScFieldDef = (
     (FieldName: 'BillsID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
     (FieldName: 'BillsID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
     //------------------   本期合同计量  ----------------
     //------------------   本期合同计量  ----------------
     // 数量
     // 数量
@@ -542,7 +674,11 @@ const
     // 附件 暂时不用,用台帐的
     // 附件 暂时不用,用台帐的
 //    (FieldName: 'HasAttachment'; FieldType: ftBoolean; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
 //    (FieldName: 'HasAttachment'; FieldType: ftBoolean; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 书签批注
     // 书签批注
-    (FieldName: 'MarkMemo'; FieldType: ftString; Size: 255; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+    (FieldName: 'MarkMemo'; FieldType: ftString; Size: 255; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期材料调差
+    (FieldName: 'PM_PreTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期材料调差
+    (FieldName: 'PM_TotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
   );
 
 
   // 计量期合同支付
   // 计量期合同支付

+ 117 - 79
Units/DetailExcelImport.pas

@@ -304,28 +304,31 @@ var
   iEndRow: Integer;
   iEndRow: Integer;
 begin
 begin
   sName := Trim(GetCellValue(AXlsFile, FCurRow, FXmjLevel1Col));
   sName := Trim(GetCellValue(AXlsFile, FCurRow, FXmjLevel1Col));
-  if sName = '' then Exit;
-
-  vXmj := FCacheTree.FindXmjChild(nil, '', sName);
-  if not Assigned(vXmj) then
-  begin
-    vXmj := FCacheTree.AddNode(nil);
-    vXmj.Name := sName;
-  end;
-
   with AXlsFile.CellMergedBounds[FCurRow, FXmjLevel1Col] do
   with AXlsFile.CellMergedBounds[FCurRow, FXmjLevel1Col] do
     iEndRow := FCurRow + Bottom - Top;
     iEndRow := FCurRow + Bottom - Top;
 
 
-  if FXmjLevel2Col <> -1 then
+  if sName <> '' then
   begin
   begin
-    while FCurRow <= iEndRow do
-      LoadXmjLevel2(AXlsFile, vXmj);
+    vXmj := FCacheTree.FindXmjChild(nil, '', sName);
+    if not Assigned(vXmj) then
+    begin
+      vXmj := FCacheTree.AddNode(nil);
+      vXmj.Name := sName;
+    end;
+
+    if FXmjLevel2Col <> -1 then
+    begin
+      while FCurRow <= iEndRow do
+        LoadXmjLevel2(AXlsFile, vXmj);
+    end
+    else
+    begin
+      while FCurRow <= iEndRow do
+        LoadBillsNode(AXlsFile, vXmj);
+    end;
   end
   end
   else
   else
-  begin
-    while FCurRow <= iEndRow do
-      LoadBillsNode(AXlsFile, vXmj);
-  end;
+    Inc(FCurRow);
 end;
 end;
 
 
 procedure TPlaneFxBillsExcelImport.LoadXmjLevel2(AXlsFile: TXLSFile;
 procedure TPlaneFxBillsExcelImport.LoadXmjLevel2(AXlsFile: TXLSFile;
@@ -336,22 +339,29 @@ var
   iEndRow: Integer;
   iEndRow: Integer;
 begin
 begin
   sName := Trim(GetCellValue(AXlsFile, FCurRow, FXmjLevel2Col));
   sName := Trim(GetCellValue(AXlsFile, FCurRow, FXmjLevel2Col));
-  if sName = '' then Exit;
-
-  vXmj := FCacheTree.FindXmjChild(AParent, '', sName);
-  if not Assigned(vXmj) then
-  begin
-    vXmj := FCacheTree.AddNode(AParent);
-    vXmj.Name := sName;
-  end;
-
   with AXlsFile.CellMergedBounds[FCurRow, FXmjLevel2Col] do
   with AXlsFile.CellMergedBounds[FCurRow, FXmjLevel2Col] do
     iEndRow := FCurRow + Bottom - Top;
     iEndRow := FCurRow + Bottom - Top;
 
 
-  if FXmjLevel3Col <> -1 then
+  if sName <> '' then
   begin
   begin
-    while FCurRow <= iEndRow do
-      LoadXmjLevel3(AXlsFile, vXmj);
+    vXmj := FCacheTree.FindXmjChild(AParent, '', sName);
+    if not Assigned(vXmj) then
+    begin
+      vXmj := FCacheTree.AddNode(AParent);
+      vXmj.Name := sName;
+    end;
+
+
+    if FXmjLevel3Col <> -1 then
+    begin
+      while FCurRow <= iEndRow do
+        LoadXmjLevel3(AXlsFile, vXmj);
+    end
+    else
+    begin
+      while FCurRow <= iEndRow do
+        LoadBillsNode(AXlsFile, vXmj);
+    end;
   end
   end
   else
   else
   begin
   begin
@@ -368,27 +378,33 @@ var
   iEndRow: Integer;
   iEndRow: Integer;
 begin
 begin
   sName := Trim(GetCellValue(AXlsFile, FCurRow, FXmjLevel3Col));
   sName := Trim(GetCellValue(AXlsFile, FCurRow, FXmjLevel3Col));
-  if sName = '' then Exit;
-
-  vXmj := FCacheTree.FindXmjChild(AParent, '', sName);
-  if not Assigned(vXmj) then
-  begin
-    vXmj := FCacheTree.AddNode(AParent);
-    vXmj.Name := sName;
-  end;
-
   with AXlsFile.CellMergedBounds[FCurRow, FXmjLevel3Col] do
   with AXlsFile.CellMergedBounds[FCurRow, FXmjLevel3Col] do
     iEndRow := FCurRow + Bottom - Top;
     iEndRow := FCurRow + Bottom - Top;
 
 
-  if FXmjLevel4Col <> -1 then
+  if sName <> '' then
   begin
   begin
-    while FCurRow <= iEndRow do
-      LoadXmjLevel4(AXlsFile, vXmj);
+    vXmj := FCacheTree.FindXmjChild(AParent, '', sName);
+    if not Assigned(vXmj) then
+    begin
+      vXmj := FCacheTree.AddNode(AParent);
+      vXmj.Name := sName;
+    end;
+
+    if FXmjLevel4Col <> -1 then
+    begin
+      while FCurRow <= iEndRow do
+        LoadXmjLevel4(AXlsFile, vXmj);
+    end
+    else
+    begin
+      while FCurRow <= iEndRow do
+        LoadBillsNode(AXlsFile, vXmj);
+    end;
   end
   end
   else
   else
   begin
   begin
     while FCurRow <= iEndRow do
     while FCurRow <= iEndRow do
-      LoadBillsNode(AXlsFile, vXmj);
+      LoadBillsNode(AXlsFile, AParent);
   end;
   end;
 end;
 end;
 
 
@@ -400,27 +416,33 @@ var
   iEndRow: Integer;
   iEndRow: Integer;
 begin
 begin
   sName := Trim(GetCellValue(AXlsFile, FCurRow, FXmjLevel4Col));
   sName := Trim(GetCellValue(AXlsFile, FCurRow, FXmjLevel4Col));
-  if sName = '' then Exit;
-
-  vXmj := FCacheTree.FindXmjChild(AParent, '', sName);
-  if not Assigned(vXmj) then
-  begin
-    vXmj := FCacheTree.AddNode(AParent);
-    vXmj.Name := sName;
-  end;
-
   with AXlsFile.CellMergedBounds[FCurRow, FXmjLevel4Col] do
   with AXlsFile.CellMergedBounds[FCurRow, FXmjLevel4Col] do
     iEndRow := FCurRow + Bottom - Top;
     iEndRow := FCurRow + Bottom - Top;
 
 
-  if FXmjLevel5Col <> -1 then
+  if sName <> '' then
   begin
   begin
-    while FCurRow <= iEndRow do
-      LoadXmjLevel5(AXlsFile, vXmj);
+    vXmj := FCacheTree.FindXmjChild(AParent, '', sName);
+    if not Assigned(vXmj) then
+    begin
+      vXmj := FCacheTree.AddNode(AParent);
+      vXmj.Name := sName;
+    end;
+
+    if FXmjLevel5Col <> -1 then
+    begin
+      while FCurRow <= iEndRow do
+        LoadXmjLevel5(AXlsFile, vXmj);
+    end
+    else
+    begin
+      while FCurRow <= iEndRow do
+        LoadBillsNode(AXlsFile, vXmj);
+    end;
   end
   end
   else
   else
   begin
   begin
     while FCurRow <= iEndRow do
     while FCurRow <= iEndRow do
-      LoadBillsNode(AXlsFile, vXmj);
+      LoadBillsNode(AXlsFile, AParent);
   end;
   end;
 end;
 end;
 
 
@@ -432,27 +454,33 @@ var
   iEndRow: Integer;
   iEndRow: Integer;
 begin
 begin
   sName := Trim(GetCellValue(AXlsFile, FCurRow, FXmjLevel5Col));
   sName := Trim(GetCellValue(AXlsFile, FCurRow, FXmjLevel5Col));
-  if sName = '' then Exit;
-
-  vXmj := FCacheTree.FindXmjChild(AParent, '', sName);
-  if not Assigned(vXmj) then
-  begin
-    vXmj := FCacheTree.AddNode(AParent);
-    vXmj.Name := sName;
-  end;
-
   with AXlsFile.CellMergedBounds[FCurRow, FXmjLevel5Col] do
   with AXlsFile.CellMergedBounds[FCurRow, FXmjLevel5Col] do
     iEndRow := FCurRow + Bottom - Top;
     iEndRow := FCurRow + Bottom - Top;
 
 
-  if FXmjLevel6Col <> -1 then
+  if sName <> '' then
   begin
   begin
-    while FCurRow <= iEndRow do
-      LoadXmjLevel6(AXlsFile, vXmj);
+    vXmj := FCacheTree.FindXmjChild(AParent, '', sName);
+    if not Assigned(vXmj) then
+    begin
+      vXmj := FCacheTree.AddNode(AParent);
+      vXmj.Name := sName;
+    end;
+
+    if FXmjLevel6Col <> -1 then
+    begin
+      while FCurRow <= iEndRow do
+        LoadXmjLevel6(AXlsFile, vXmj);
+    end
+    else
+    begin
+      while FCurRow <= iEndRow do
+        LoadBillsNode(AXlsFile, vXmj);
+    end;
   end
   end
   else
   else
   begin
   begin
     while FCurRow <= iEndRow do
     while FCurRow <= iEndRow do
-      LoadBillsNode(AXlsFile, vXmj);
+      LoadBillsNode(AXlsFile, AParent);
   end;
   end;
 end;
 end;
 
 
@@ -464,27 +492,34 @@ var
   iEndRow: Integer;
   iEndRow: Integer;
 begin
 begin
   sName := Trim(GetCellValue(AXlsFile, FCurRow, FXmjLevel6Col));
   sName := Trim(GetCellValue(AXlsFile, FCurRow, FXmjLevel6Col));
-  if sName = '' then Exit;
-
-  vXmj := FCacheTree.FindXmjChild(AParent, '', sName);
-  if not Assigned(vXmj) then
-  begin
-    vXmj := FCacheTree.AddNode(AParent);
-    vXmj.Name := sName;
-  end;
 
 
   with AXlsFile.CellMergedBounds[FCurRow, FXmjLevel6Col] do
   with AXlsFile.CellMergedBounds[FCurRow, FXmjLevel6Col] do
     iEndRow := FCurRow + Bottom - Top;
     iEndRow := FCurRow + Bottom - Top;
 
 
-  if FXmjLevel7Col <> -1 then
+  if sName <> '' then
   begin
   begin
-    while FCurRow <= iEndRow do
-      LoadXmjLevel7(AXlsFile, vXmj);
+    vXmj := FCacheTree.FindXmjChild(AParent, '', sName);
+    if not Assigned(vXmj) then
+    begin
+      vXmj := FCacheTree.AddNode(AParent);
+      vXmj.Name := sName;
+    end;
+
+    if FXmjLevel7Col <> -1 then
+    begin
+      while FCurRow <= iEndRow do
+        LoadXmjLevel7(AXlsFile, vXmj);
+    end
+    else
+    begin
+      while FCurRow <= iEndRow do
+        LoadBillsNode(AXlsFile, vXmj);
+    end;
   end
   end
   else
   else
   begin
   begin
     while FCurRow <= iEndRow do
     while FCurRow <= iEndRow do
-      LoadBillsNode(AXlsFile, vXmj);
+      LoadBillsNode(AXlsFile, AParent);
   end;
   end;
 end;
 end;
 
 
@@ -551,6 +586,9 @@ begin
   Rec.ValueByName('OrgQuantity').AsFloat := QuantityRoundTo(ANode.Quantity);
   Rec.ValueByName('OrgQuantity').AsFloat := QuantityRoundTo(ANode.Quantity);
   Rec.ValueByName('DrawingCode').AsString := ANode.DrawingCode;
   Rec.ValueByName('DrawingCode').AsString := ANode.DrawingCode;
   Rec.ValueByName('MemoStr').AsString := ANode.MemoStr;
   Rec.ValueByName('MemoStr').AsString := ANode.MemoStr;
+  // 解锁前,新增清单为变更清单,解锁后,新增清单为0号台账清单
+  if FProjectData.ProjProperties.PhaseCount > 0 then
+    Rec.ValueByName('IsMeasureAdd').AsBoolean := not FProjectData.CanUnlockInfo;
 end;
 end;
 
 
 procedure TPlaneFxBillsExcelImport.BeginImport;
 procedure TPlaneFxBillsExcelImport.BeginImport;

+ 0 - 0
Units/GclBillsGatherModel.pas


Some files were not shown because too many files changed in this diff