Переглянути джерело

中间计量,相信信息,添加显示本期计量数据

MaiXinRong 7 роки тому
батько
коміт
8c92a6c9a7
3 змінених файлів з 58 додано та 6 видалено
  1. 1 1
      DataModules/ZJJLDm.dfm
  2. 30 0
      DataModules/ZJJLDm.pas
  3. 27 5
      Frames/ZJJLFme.pas

+ 1 - 1
DataModules/ZJJLDm.dfm

@@ -3,7 +3,7 @@ object ZJJLData: TZJJLData
   Left = 704
   Top = 204
   Height = 241
-  Width = 281
+  Width = 283
   object sdpZJJL: TsdADOProvider
     TableName = 'ZJJL'
     Left = 42

+ 30 - 0
DataModules/ZJJLDm.pas

@@ -111,6 +111,8 @@ type
     function GetInfoRecByB_Code(ABillsID: Integer): TZJJLInfoRec;
     function GetInfoRec(ABillsID, AType: Integer): TZJJLInfoRec;
 
+    function GetZJJLCalcData(ARec: TsdDataRecord; const AFileName: string): Double;
+
     procedure LocateBills;
     function FindZJJLRecord(ABillsID: Integer): TsdDataRecord;
 
@@ -167,6 +169,7 @@ begin
 
   sdpZJJLDetail.Connection := AConnection;
   sddZJJLDetail.Open;
+  sddZJJLDetail.AddIndex('idxID', 'ID');
 
   CheckZjjlVerison;
 end;
@@ -453,6 +456,10 @@ begin
   Rec.ValueByName('UnitName').AsString := GetFieldValue('UnitName', vInfoRec.UnitName);
   Rec.ValueByName('DrawingCode').AsString := GetFieldValue('DrawingCode', vInfoRec.DrawingCode);
 
+  Rec := sddZJJLDetail.Add;
+  Rec.ValueByName('ID').AsInteger := FNewID;
+  Rec.ValueByName('BillsID').AsInteger := ANode.ID;
+
   Inc(FNewID);
 end;
 
@@ -933,4 +940,27 @@ begin
     FRefreshDetailGrid;
 end;
 
+function TZJJLData.GetZJJLCalcData(ARec: TsdDataRecord;
+  const AFileName: string): Double;
+var
+  vIdx: TsdIndex;
+  iBegin, iEnd, i: Integer;
+  vRec, vStageRec: TsdDataRecord;
+begin
+  Result := 0;
+  vIdx := sddZJJLDetail.FindIndex('idxID');
+  iBegin := vIdx.FindKeyIndex(ARec.ValueByName('ID').AsInteger);
+  iEnd := vIdx.FindKeyLastIndex(ARec.ValueByName('ID').AsInteger);
+  if iBegin <> -1 then
+  begin
+    for i := iBegin to iEnd do
+    begin
+      vRec := vIdx.Records[i];
+      vStageRec := TPhaseData(FPhaseData).StageData.StageRecord(vRec.ValueByName('BillsID').AsInteger);
+      if Assigned(vStageRec) then
+        Result := QuantityRoundTo(Result + vStageRec.ValueByName(AFileName).AsFloat);
+    end;
+  end;
+end;
+
 end.

+ 27 - 5
Frames/ZJJLFme.pas

@@ -9,12 +9,12 @@ uses
   ToolWin, ActnList, ZjGridDBA, ZJGrid, dxBar, sdGridDBA, sdDB;
 
 type
-  TRowIndex = (riBGLCode, riPegName, riBeginPeg, riEndPeg, riFBFXName, riUnitName, riDrawingCode,
+  TRowIndex = (riCurGatherMeasure, riBGLCode, riPegName, riBeginPeg, riEndPeg, riFBFXName, riUnitName, riDrawingCode,
     riFormulaMemoTitle, riFormulaMemoValue, riRelaFileTitle, riRelaFileValue);
 const
-  RowFields: array [TRowIndex] of string = ('BGLCode', 'PegName', 'BeginPeg', 'EndPeg', 'FBFXName', 'UnitName', 'DrawingCode',
+  RowFields: array [TRowIndex] of string = ('', 'BGLCode', 'PegName', 'BeginPeg', 'EndPeg', 'FBFXName', 'UnitName', 'DrawingCode',
     '', 'FormulaMemo', '', 'RelaFile');
-  RowFormats: array [TRowIndex] of string = ('变更令号:', '部位:', '起始桩号:', '终止桩号:', '分部分项工程:', '计量单元:', '图号:',
+  RowFormats: array [TRowIndex] of string = ('本期计量%s:%s', '变更令号:', '部位:', '起始桩号:', '终止桩号:', '分部分项工程:', '计量单元:', '图号:',
     '计算式说明:', '', '计算草图几何尺寸:', '');
 type
   TZJJLFrame = class(TFrame)
@@ -93,6 +93,7 @@ uses
 constructor TZJJLFrame.Create(AParent: TFrame; AZJJLData: TZJJLData);
 begin
   inherited Create(AParent);
+  zgDetailInfo.RowCount := Integer(riRelaFileValue) + 1;
   ResetFrameLink(AZJJLData);
   if TPhaseData(FZJJLData.PhaseData).Active then
   begin
@@ -266,8 +267,29 @@ procedure TZJJLFrame.zgDetailInfoGetCellText(Sender: TObject;
       Result := GetDefaultValue(Rec, RowFields[ARow]);
   end;
 
+  function GetFloatStr(ANum: Double): string;
+  begin
+    if ANum = 0 then
+      Result := ''
+    else
+      Result := FloatToStr(ANum);
+  end;
+
+  function GetCurGatherMeasure: string;
+  var
+    Rec: TsdDataRecord;
+  begin
+    Rec := saZJJL.DataView.Current;
+    if Rec.ValueByName('Type').AsInteger = Integer(ztFx) then
+      Result := Format(RowFormats[riCurGatherMeasure], ['金额', GetFloatStr(FZJJLData.GetZJJLCalcData(Rec, 'GatherTotalPrice'))])
+    else
+      Result := Format(RowFormats[riCurGatherMeasure], ['数量', GetFloatStr(FZJJLData.GetZJJLCalcData(Rec, 'GatherQuantity'))]);
+  end;
+
 begin
-  if (ACoord.Y >= 0) and (ACoord.Y <= 10) then
+  if (ACoord.Y = Integer(riCurGatherMeasure)) then
+    Value := GetCurGatherMeasure
+  else if (ACoord.Y > Integer(riCurGatherMeasure)) and (ACoord.Y <= Integer(riRelaFileValue)) then
     Value := GetText(TRowIndex(ACoord.Y));
 end;
 
@@ -280,7 +302,7 @@ begin
     zgDetailInfo[0, iRowIndex].Align := gaTopLeft;
   zgDetailInfo.RowHeights[Integer(riFormulaMemoValue)] := 57;
   zgDetailInfo.Cells[0, Integer(riFormulaMemoValue)].Align := gaTopLeft;
-  zgDetailInfo.RowHeights[Integer(riRelaFileValue)] := 57;              
+  zgDetailInfo.RowHeights[Integer(riRelaFileValue)] := 57;
   zgDetailInfo.Cells[0, Integer(riRelaFileValue)].Align := gaTopLeft;
 end;