Sfoglia il codice sorgente

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

builder 8 anni fa
parent
commit
70e5927656

+ 99 - 0
DataModules/OtherMeasurePhaseDm.dfm

@@ -0,0 +1,99 @@
+object OtherMeasurePhaseData: TOtherMeasurePhaseData
+  OldCreateOrder = False
+  Left = 367
+  Top = 303
+  Height = 267
+  Width = 215
+  object sdpPhase: TsdADOProvider
+    TableName = 'OtherMeasurePhase'
+    Left = 56
+    Top = 32
+  end
+  object sddPhase: TsdDataSet
+    Active = False
+    Provider = sdpPhase
+    AfterValueChanged = sddPhaseAfterValueChanged
+    OnGetRecordClass = sddPhaseGetRecordClass
+    Left = 56
+    Top = 96
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D650909507265636973696F6E02000453697A6502000001044E616D
+      65060853657269616C4E6F094669656C644E616D65060853657269616C4E6F08
+      44617461547970650203084461746153697A6502040549734B6579080F4E6565
+      6450726F636573734E616D650909507265636973696F6E02000453697A650200
+      0001044E616D650604436F6465094669656C644E616D650604436F6465084461
+      7461547970650218084461746153697A6502320549734B6579080F4E65656450
+      726F636573734E616D650909507265636973696F6E02000453697A6502000001
+      044E616D6506044E616D65094669656C644E616D6506044E616D650844617461
+      547970650218084461746153697A6503FF000549734B6579080F4E6565645072
+      6F636573734E616D650909507265636973696F6E02000453697A650200000104
+      4E616D6506054D54797065094669656C644E616D6506054D5479706508446174
+      61547970650218084461746153697A6502320549734B6579080F4E6565645072
+      6F636573734E616D650909507265636973696F6E02000453697A650200000104
+      4E616D65060A546F74616C5072696365094669656C644E616D65060A546F7461
+      6C50726963650844617461547970650206084461746153697A6502080549734B
+      6579080F4E65656450726F636573734E616D650909507265636973696F6E0200
+      0453697A6502000001044E616D6506074D656D6F537472094669656C644E616D
+      6506074D656D6F5374720844617461547970650218084461746153697A650203
+      0549734B6579080F4E65656450726F636573734E616D65090950726563697369
+      6F6E02000453697A6502000001044E616D65060D437265617465506861736549
+      44094669656C644E616D65060D43726561746550686173654944084461746154
+      7970650203084461746153697A6502040549734B6579080F4E65656450726F63
+      6573734E616D650909507265636973696F6E02000453697A6502000001044E61
+      6D65060D437572546F74616C5072696365094669656C644E616D65060D437572
+      546F74616C50726963650844617461547970650206084461746153697A650208
+      0549734B6579080F4E65656450726F636573734E616D65090950726563697369
+      6F6E02000453697A6502000001044E616D65060D507265546F74616C50726963
+      65094669656C644E616D65060D507265546F74616C5072696365084461746154
+      7970650206084461746153697A6502080549734B6579080F4E65656450726F63
+      6573734E616D650909507265636973696F6E02000453697A6502000001044E61
+      6D65060D456E64546F74616C5072696365094669656C644E616D65060D456E64
+      546F74616C50726963650844617461547970650206084461746153697A650208
+      0549734B6579080F4E65656450726F636573734E616D65090950726563697369
+      6F6E02000453697A6502000001044E616D65060D416464546F74616C50726963
+      65094669656C644E616D65060D416464546F74616C5072696365084461746154
+      7970650206084461746153697A6502080549734B6579080F4E65656450726F63
+      6573734E616D650909507265636973696F6E02000453697A6502000000}
+  end
+  object sdvPhase: TsdDataView
+    Active = False
+    DataSet = sddPhase
+    Filtered = False
+    Columns = <
+      item
+        FieldName = 'Code'
+      end
+      item
+        FieldName = 'Name'
+      end
+      item
+        FieldName = 'MType'
+      end
+      item
+        FieldName = 'TotalPrice'
+      end
+      item
+        FieldName = 'MemoStr'
+      end
+      item
+        FieldName = 'CreatePhaseID'
+      end
+      item
+        FieldName = 'CurTotalPrice'
+      end
+      item
+        FieldName = 'PreTotalPrice'
+      end
+      item
+        FieldName = 'EndTotalPrice'
+      end
+      item
+        FieldName = 'AddTotalPrice'
+      end>
+    BeforeAddRecord = sdvPhaseBeforeAddRecord
+    Left = 56
+    Top = 160
+  end
+end

+ 219 - 0
DataModules/OtherMeasurePhaseDm.pas

@@ -0,0 +1,219 @@
+unit OtherMeasurePhaseDm;
+
+interface
+
+uses
+  SysUtils, Classes, sdDB, sdProvider, ADODB, OMPhaseRecord;
+
+type
+  TOtherMeasurePhaseData = class(TDataModule)
+    sdpPhase: TsdADOProvider;
+    sddPhase: TsdDataSet;
+    sdvPhase: TsdDataView;
+    procedure sdvPhaseBeforeAddRecord(ARecord: TsdDataRecord;
+      var Allow: Boolean);
+    procedure sdvPhaseAfterValueChanged(AValue: TsdValue);
+    procedure sddPhaseGetRecordClass(var ARecordClass: TsdRecordClass);
+    procedure sddPhaseAfterValueChanged(AValue: TsdValue);
+  private
+    FProjectData: TObject;
+
+    function GetNewID: Integer;
+    function GetNewSerialNo: Integer;
+
+    procedure SaveDetailData;
+
+    procedure BeforeBatchOperation;
+    procedure AfterBatchOperation;
+  public
+    constructor Create(AProjectData: TObject);
+    destructor Destroy; override;
+
+    procedure Open(AConnection: TADOConnection);
+    procedure Save;
+
+    procedure LoadCurStageData;
+  end;
+
+implementation
+
+uses
+  ProjectData, UtilMethods, Math;
+
+{$R *.dfm}
+
+{ TOtherMeasurePhaseData }
+
+procedure TOtherMeasurePhaseData.AfterBatchOperation;
+begin
+  sddPhase.EndUpdate;
+  sddPhase.EnableControls;
+  sddPhase.AfterValueChanged := sddPhaseAfterValueChanged;
+end;
+
+procedure TOtherMeasurePhaseData.BeforeBatchOperation;
+begin
+  sddPhase.AfterValueChanged := nil;
+  sddPhase.DisableControls;
+  sddPhase.BeginUpdate;
+end;
+
+constructor TOtherMeasurePhaseData.Create(AProjectData: TObject);
+begin
+  inherited Create(nil);
+  FProjectData := AProjectData;
+end;
+
+destructor TOtherMeasurePhaseData.Destroy;
+begin
+  inherited;
+end;
+
+function TOtherMeasurePhaseData.GetNewID: Integer;
+var
+  idx: TsdIndex;
+begin
+  idx := sddPhase.FindIndex('idxID');
+  if idx.RecordCount > 0 then
+    Result := idx.Records[idx.RecordCount - 1].ValueByName('ID').AsInteger + 1
+  else
+    Result := 1;
+end;
+
+function TOtherMeasurePhaseData.GetNewSerialNo: Integer;
+var
+  idx: TsdIndex;
+begin
+  idx := sddPhase.FindIndex('idxSerial');
+  if idx.RecordCount > 0 then
+    Result := idx.Records[idx.RecordCount - 1].ValueByName('SerialNo').AsInteger + 1
+  else
+    Result := 1;
+end;
+
+procedure TOtherMeasurePhaseData.LoadCurStageData;
+
+  procedure LoadData;
+  const
+    sSelectSql = 'Select * From OMPhaseDetail Where (PhaseID = %d) and (StageID = %d)';
+  var
+    vQuery: TADOQuery;
+    i: Integer;
+    Rec: TOMPhaseRecord;
+  begin
+    try
+      with TProjectData(FProjectData) do
+        vQuery := QueryData(sdpPhase.Connection, Format(sSelectSql, [PhaseIndex, StageIndex]));
+      for i := 0 to sddPhase.RecordCount - 1 do
+      begin
+        Rec := TOMPhaseRecord(sddPhase.Records[i]);
+        if vQuery.Locate('ID', Rec.ValueByName('ID').AsInteger, []) then
+        begin
+          Rec.PreTotalPrice.AsFloat := vQuery.FieldByName('PreTotalPrice').AsFloat;
+          Rec.CurTotalPrice.AsFloat := vQuery.FieldByName('CurTotalPrice').AsFloat;
+          Rec.EndTotalPrice.AsFloat := vQuery.FieldByName('EndTotalPrice').AsFloat;
+        end
+        else
+        begin
+          Rec.PreTotalPrice.AsFloat := 0;
+          Rec.CurTotalPrice.AsFloat := 0;
+          Rec.EndTotalPrice.AsFloat := 0;
+        end;
+      end;
+    finally
+      vQuery.Free;
+    end;
+  end;
+
+begin
+  BeforeBatchOperation;
+  try
+    LoadData;
+  finally
+    AfterBatchOperation;
+  end;
+end;
+
+procedure TOtherMeasurePhaseData.Open(AConnection: TADOConnection);
+begin
+  sdpPhase.Connection := AConnection;
+  sddPhase.Open;
+  if not Assigned(sddPhase.FindIndex('idxID')) then
+    sddPhase.AddIndex('idxID', 'ID');
+  if not Assigned(sddPhase.FindIndex('idxSerial')) then
+    sddPhase.AddIndex('idxSerial', 'SerialNo');
+  sdvPhase.Open;
+  sdvPhase.IndexName := 'idxSerial';
+
+  LoadCurStageData;
+end;
+
+procedure TOtherMeasurePhaseData.Save;
+begin
+  sddPhase.Save;
+  if not TProjectData(FProjectData).StageDataReadOnly then
+    SaveDetailData;
+end;
+
+procedure TOtherMeasurePhaseData.SaveDetailData;
+const
+  sDeleteSql = 'Delete From OMPhaseDetail where (PhaseID = %d) and (StageID = %d)';
+  sInsertSql = 'Insert Into OMPhaseDetail' +
+               '  Select ID, %d As PhaseID, %d As StageID, PreTotalPrice, CurTotalPrice, EndTotalPrice' +
+               '    From OtherMeasurePhase';
+var
+  iPhase, iStage: Integer;
+  vQuery: TADOQuery;
+begin
+  if TProjectData(FProjectData).StageDataReadOnly then Exit;
+
+  iPhase := TProjectData(FProjectData).PhaseIndex;
+  iStage := TProjectData(FProjectData).StageIndex;
+
+  ExecuteSql(sdpPhase.Connection, Format(sDeleteSql, [iPhase, iStage]));
+  ExecuteSql(sdpPhase.Connection, Format(sInsertSql, [iPhase, iStage]));
+
+  ExecuteSql(sdpPhase.Connection, Format(sDeleteSql, [iPhase, -1]));
+  ExecuteSql(sdpPhase.Connection, Format(sInsertSql, [iPhase, -1]));
+end;
+
+procedure TOtherMeasurePhaseData.sdvPhaseBeforeAddRecord(
+  ARecord: TsdDataRecord; var Allow: Boolean);
+begin
+  ARecord.ValueByName('ID').AsInteger := GetNewID;
+  ARecord.ValueByName('SerialNo').AsInteger := GetNewSerialNo;
+  ARecord.ValueByName('CreatePhaseID').AsInteger := TProjectData(FProjectData).PhaseIndex;
+end;
+
+procedure TOtherMeasurePhaseData.sdvPhaseAfterValueChanged(
+  AValue: TsdValue);
+var
+  Rec: TOMPhaseRecord;
+begin
+  if SameText(AValue.FieldName, 'CurTotalPrice') then
+  begin
+    Rec := TOMPhaseRecord(AValue.Owner);
+    Rec.SetFloatValue(Rec.EndTotalPrice, TotalPriceRoundTo(Rec.CurTotalPrice.AsFloat + Rec.PreTotalPrice.AsFloat));
+  end;
+end;
+
+procedure TOtherMeasurePhaseData.sddPhaseGetRecordClass(
+  var ARecordClass: TsdRecordClass);
+begin
+  ARecordClass := TOMPhaseRecord;
+end;
+
+procedure TOtherMeasurePhaseData.sddPhaseAfterValueChanged(
+  AValue: TsdValue);
+var
+  Rec: TOMPhaseRecord;
+begin
+  if SameText(AValue.FieldName, 'CurTotalPrice') then
+  begin
+    Rec := TOMPhaseRecord(AValue.Owner);
+    Rec.SetFloatValue(Rec.EndTotalPrice, TotalPriceRoundTo(Rec.CurTotalPrice.AsFloat + Rec.PreTotalPrice.AsFloat));
+    Rec.SetFloatValue(Rec.AddTotalPrice, Rec.EndTotalPrice.AsFloat);
+  end;
+end;
+
+end.

+ 4 - 19
DataModules/ProjectGLDm.pas

@@ -47,7 +47,6 @@ type
     procedure CalculatePALRela(ARec: TProjectGLRecord);
     procedure CalculatePALRelas;
 
-    procedure ExecuteSql(const ASql: string);
     procedure SaveGLPrice;
     procedure SavePM_CurData;
 
@@ -214,13 +213,13 @@ var
 begin
   iPhaseID := TProjectData(FProjectData).ProjProperties.PhaseCount;
   sSql := Format(sDeleteSql, [iPhaseID]);
-  ExecuteSql(sSql);
+  ExecuteSql(sdpProjectGL.Connection, sSql);
 
   sSql := Format(sInsertSql, [iPhaseID]);
-  ExecuteSql(sSql);
+  ExecuteSql(sdpProjectGL.Connection, sSql);
 
   sSql := Format(sUpdateSql, [iPhaseID]);
-  ExecuteSql(sSql);
+  ExecuteSql(sdpProjectGL.Connection, sSql);
 end;
 
 procedure TProjectGLData.sddProjectGLAfterAddRecord(
@@ -305,20 +304,6 @@ begin
   RefreshGatherData;
 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;
@@ -431,7 +416,7 @@ begin
   iStageIndex := TProjectData(FProjectData).PhaseData.StageIndex;
   iPhaseCount := TProjectData(FProjectData).ProjProperties.PhaseCount;
   sSql := Format(sUpdateSql, [iStageIndex, iStageIndex, iStageIndex, iStageIndex, iStageIndex, iStageIndex, iPhaseCount]);
-  ExecuteSql(sSql);
+  ExecuteSql(sdpProjectGL.Connection, sSql);
 end;
 
 procedure TProjectGLData.CalculateGL_PM(AGLID: Integer);

+ 2 - 0
Forms/BGLSelectFrm.pas

@@ -104,6 +104,8 @@ end;
 procedure TBGLSelectForm.Init(AOrgBGL: TBGLSelectInfo;
   ProjectData: TObject; ABGNum: Double);
 begin
+  ClientHeight := 281;
+  ClientWidth := 475;
   FProjectData := ProjectData;
   with TProjectData(FProjectData).BillsMeasureData.BillsMeasureTree do
     FGclCode := Selected.Rec.ValueByName('B_Code').AsString;

+ 3 - 0
Forms/BatchInsertBillsFrm.pas

@@ -147,6 +147,9 @@ end;
 procedure TBatchInsertBillsForm.Init(ABillsCompileData: TBillsCompileData;
   AInsertType: TInsertType);
 begin
+  ClientHeight := 382;
+  ClientWidth := 779;
+
   FBillsCompileData := ABillsCompileData;
   sgdDealBills.DataView := TProjectData(ABillsCompileData.ProjectData).DealBillsData.sdvDealBills;
   FInsertType := AInsertType;

+ 6 - 6
Forms/BatchReplaceBillsFrm.dfm

@@ -1,7 +1,7 @@
 object BatchReplaceBillsForm: TBatchReplaceBillsForm
   Left = 494
   Top = 295
-  Width = 392
+  Width = 383
   Height = 249
   Caption = #25209#37327#26367#25442#28165#21333#25968#25454
   Color = clBtnFace
@@ -16,8 +16,8 @@ object BatchReplaceBillsForm: TBatchReplaceBillsForm
   object pnlBills: TPanel
     Left = 0
     Top = 92
-    Width = 384
-    Height = 93
+    Width = 375
+    Height = 96
     Align = alClient
     BevelOuter = bvNone
     TabOrder = 0
@@ -62,8 +62,8 @@ object BatchReplaceBillsForm: TBatchReplaceBillsForm
   end
   object pnlOther: TPanel
     Left = 0
-    Top = 185
-    Width = 384
+    Top = 188
+    Width = 375
     Height = 30
     Align = alBottom
     BevelOuter = bvNone
@@ -90,7 +90,7 @@ object BatchReplaceBillsForm: TBatchReplaceBillsForm
   object pnlOrgBills: TPanel
     Left = 0
     Top = 0
-    Width = 384
+    Width = 375
     Height = 92
     Align = alTop
     BevelOuter = bvNone

+ 3 - 0
Forms/BatchReplaceBillsFrm.pas

@@ -95,6 +95,9 @@ end;
 
 procedure TBatchReplaceBillsForm.Init(ARec: TsdDataRecord);
 begin
+  ClientHeight := 218;
+  ClientWidth := 375;
+
   InitGrid(zgOrgBills, ARec);
   InitGrid(zgBills, ARec);
 end;

+ 1 - 1
Forms/DealPayPlanFrm.dfm

@@ -13,7 +13,7 @@ object DealPayPlanForm: TDealPayPlanForm
   OldCreateOrder = False
   DesignSize = (
     403
-    256)
+    259)
   PixelsPerInch = 96
   TextHeight = 12
   object lblTitle: TLabel

+ 3 - 0
Forms/DealPayPlanFrm.pas

@@ -100,6 +100,9 @@ end;
 
 procedure TDealPayPlanForm.InitForm;
 begin
+  ClientHeight := 259;
+  ClientWidth := 403;
+
   lblDealPayName.Caption := FDealPayRec.ValueByName('Name').AsString;
   lblTitle2.Left := lblDealPayName.Left + lblDealPayName.Width + 6;
   PlanType := FDealPayRec.ValueByName('PlanType').AsInteger;

+ 12 - 12
Forms/MainFrm.dfm

@@ -21,7 +21,7 @@ object MainForm: TMainForm
   object jtsProjects: TJimTabSet
     Left = 0
     Top = 49
-    Width = 734
+    Width = 742
     Height = 21
     Align = alTop
     BackgroundColor = clGradientInactiveCaption
@@ -45,8 +45,8 @@ object MainForm: TMainForm
   end
   object dxStatusBar: TdxStatusBar
     Left = 0
-    Top = 480
-    Width = 734
+    Top = 487
+    Width = 742
     Height = 20
     Panels = <
       item
@@ -78,12 +78,12 @@ object MainForm: TMainForm
     object dxStatusBarContainer2: TdxStatusBarContainerControl
       Left = 604
       Top = 2
-      Width = 128
+      Width = 136
       Height = 16
       object ProgressBar: TProgressBar
         Left = 0
         Top = 0
-        Width = 128
+        Width = 136
         Height = 16
         Align = alClient
         Max = 200
@@ -94,8 +94,8 @@ object MainForm: TMainForm
   object jpsMain: TJimPages
     Left = 0
     Top = 70
-    Width = 734
-    Height = 410
+    Width = 742
+    Height = 417
     ActivePage = jpsMainProjectsManager
     ActivePageIndex = 0
     Align = alClient
@@ -103,8 +103,8 @@ object MainForm: TMainForm
     object jpsMainProjectsManager: TJimPage
       Left = 0
       Top = 0
-      Width = 734
-      Height = 410
+      Width = 742
+      Height = 417
       TabName = 'ProjectsManager'
       Caption = 'ProjsMgr'
       object pnlUser: TPanel
@@ -201,8 +201,8 @@ object MainForm: TMainForm
     object jpsMainProjects: TJimPage
       Left = 0
       Top = 0
-      Width = 734
-      Height = 410
+      Width = 742
+      Height = 417
       TabName = 'Projects'
       Caption = 'Projects'
       object jpsProjects: TJimPages
@@ -220,7 +220,7 @@ object MainForm: TMainForm
     Font.Charset = DEFAULT_CHARSET
     Font.Color = clWindowText
     Font.Height = -12
-    Font.Name = #24494#36719#38597#40657
+    Font.Name = 'Microsoft YaHei UI'
     Font.Style = []
     Bars = <
       item

+ 0 - 1
Forms/MainFrm.pas

@@ -235,7 +235,6 @@ var
 implementation
 
 uses
-
   ProjectProperty, ConstUnit, PHPWebDm, Math, ShellAPI,
   FindUserFrm, ImportExcelHintFrm, ConfigDoc, ExportExcel,
   ProjectCommands, BillsCompileDm, tpMainFrm,

+ 56 - 28
Frames/ProjectFme.dfm

@@ -2,7 +2,7 @@ object ProjectFrame: TProjectFrame
   Left = 0
   Top = 0
   Width = 1169
-  Height = 438
+  Height = 528
   Font.Charset = ANSI_CHARSET
   Font.Color = clWindowText
   Font.Height = -12
@@ -14,14 +14,14 @@ object ProjectFrame: TProjectFrame
     Left = 0
     Top = 0
     Width = 65
-    Height = 438
+    Height = 528
     Align = alLeft
     TabOrder = 0
     object dxsbViewControl: TdxSideBar
       Left = 1
       Top = 1
       Width = 63
-      Height = 436
+      Height = 526
       Align = alClient
       BkGround.BeginColor = clInactiveCaption
       BkGround.EndColor = clGradientInactiveCaption
@@ -86,14 +86,23 @@ object ProjectFrame: TProjectFrame
               Tag = 4
             end
             item
+              Caption = #20854#20182#21488#36134
+              Index = 5
+              IsDefault = False
+              LargeImage = 7
+              SmallImage = 7
+              StoredItem = dxsbsViewControlItem8
+              Tag = 5
+            end
+            item
               Caption = #25253#34920
               Hint = #25253#34920
-              Index = 5
+              Index = 6
               IsDefault = False
               LargeImage = 6
               SmallImage = 6
               StoredItem = xbiReport
-              Tag = 5
+              Tag = 6
             end>
         end>
       ActiveGroupIndex = 0
@@ -116,13 +125,13 @@ object ProjectFrame: TProjectFrame
     Left = 65
     Top = 0
     Width = 1104
-    Height = 438
+    Height = 528
     Align = alClient
     TabOrder = 1
     object sprAssistant: TSplitter
       Left = 904
       Top = 22
-      Height = 415
+      Height = 505
       Align = alRight
       Color = clBtnFace
       ParentColor = False
@@ -2725,7 +2734,7 @@ object ProjectFrame: TProjectFrame
       Left = 907
       Top = 22
       Width = 196
-      Height = 415
+      Height = 505
       ActivePage = jpsAssistantBGL
       ActivePageIndex = 4
       Align = alRight
@@ -2735,7 +2744,7 @@ object ProjectFrame: TProjectFrame
         Left = 0
         Top = 0
         Width = 196
-        Height = 415
+        Height = 505
         TabName = 'StandardBills'
         Caption = 'StandardBills'
       end
@@ -2743,7 +2752,7 @@ object ProjectFrame: TProjectFrame
         Left = 0
         Top = 0
         Width = 196
-        Height = 415
+        Height = 505
         TabName = 'DealPayment'
         Caption = 'BlockLib'
       end
@@ -2751,7 +2760,7 @@ object ProjectFrame: TProjectFrame
         Left = 0
         Top = 0
         Width = 196
-        Height = 415
+        Height = 505
         TabName = 'Search'
         Caption = 'Seach'
       end
@@ -2759,7 +2768,7 @@ object ProjectFrame: TProjectFrame
         Left = 0
         Top = 0
         Width = 196
-        Height = 415
+        Height = 505
         TabName = 'ZJJL'
         Caption = 'ZJJL'
       end
@@ -2767,7 +2776,7 @@ object ProjectFrame: TProjectFrame
         Left = 0
         Top = 0
         Width = 196
-        Height = 415
+        Height = 505
         TabName = 'BGL'
         Caption = 'BGL'
       end
@@ -2775,7 +2784,7 @@ object ProjectFrame: TProjectFrame
         Left = 0
         Top = 0
         Width = 196
-        Height = 415
+        Height = 505
         TabName = 'Checker'
         Caption = 'Checker'
       end
@@ -2783,7 +2792,7 @@ object ProjectFrame: TProjectFrame
         Left = 0
         Top = 0
         Width = 196
-        Height = 415
+        Height = 505
         TabName = 'Bookmark'
         Caption = 'Bookmark'
       end
@@ -2791,7 +2800,7 @@ object ProjectFrame: TProjectFrame
         Left = 0
         Top = 0
         Width = 196
-        Height = 415
+        Height = 505
         TabName = 'UpFile'
         Caption = 'UpFile'
       end
@@ -2799,7 +2808,7 @@ object ProjectFrame: TProjectFrame
         Left = 0
         Top = 0
         Width = 196
-        Height = 415
+        Height = 505
         TabName = 'DealBills'
         Caption = 'DealBills'
       end
@@ -2808,7 +2817,7 @@ object ProjectFrame: TProjectFrame
       Left = 1
       Top = 22
       Width = 903
-      Height = 415
+      Height = 505
       ActivePage = jpsMainBillsCompile
       ActivePageIndex = 0
       Align = alClient
@@ -2818,7 +2827,7 @@ object ProjectFrame: TProjectFrame
         Left = 0
         Top = 0
         Width = 903
-        Height = 415
+        Height = 505
         TabName = 'BillsCompile'
         Caption = 'BillsCompile'
       end
@@ -2827,7 +2836,7 @@ object ProjectFrame: TProjectFrame
         Left = 0
         Top = 0
         Width = 903
-        Height = 415
+        Height = 505
         TabName = 'BillsMeasure'
         Caption = 'Bills'
       end
@@ -2836,7 +2845,7 @@ object ProjectFrame: TProjectFrame
         Left = 0
         Top = 0
         Width = 903
-        Height = 415
+        Height = 505
         TabName = 'BillsGather'
         Caption = 'PhaseCompare'
       end
@@ -2845,7 +2854,7 @@ object ProjectFrame: TProjectFrame
         Left = 0
         Top = 0
         Width = 903
-        Height = 415
+        Height = 505
         TabName = 'PriceMargin'
         Caption = 'PriceMargin'
       end
@@ -2854,10 +2863,19 @@ object ProjectFrame: TProjectFrame
         Left = 0
         Top = 0
         Width = 903
-        Height = 415
+        Height = 505
         TabName = 'StageCompare'
         Caption = 'StageCompare'
       end
+      object jpsMainOtherMeasure: TJimPage
+        Tag = -1
+        Left = 0
+        Top = 0
+        Width = 903
+        Height = 505
+        TabName = 'OtherMeasure'
+        Caption = 'OtherMeasure'
+      end
     end
   end
   object xpm: TXPMenu
@@ -3127,9 +3145,10 @@ object ProjectFrame: TProjectFrame
       #21488#36134#20998#35299
       #35745#37327#21488#36134
       #28165#21333#27719#24635
-      #23457#26680#27604#36739
       #26448#26009#35843#24046
+      #23457#26680#27604#36739
       #24418#35937#36827#24230
+      #20854#20182#21488#36134
       #25253#34920)
     DefaultLargeImage = -1
     DefaultSmallImage = -1
@@ -3157,7 +3176,7 @@ object ProjectFrame: TProjectFrame
     object xbiStageCompare: TdxStoredSideItem
       Tag = 4
       Caption = #23457#26680#27604#36739
-      Category = 3
+      Category = 4
       Enabled = True
       Hint = #23457#26680#27604#36739
       LargeImage = 3
@@ -3173,9 +3192,9 @@ object ProjectFrame: TProjectFrame
       SmallImage = 5
     end
     object xbiReport: TdxStoredSideItem
-      Tag = 5
+      Tag = 6
       Caption = #25253#34920
-      Category = 6
+      Category = 7
       Enabled = True
       Hint = #25253#34920
       LargeImage = 6
@@ -3192,11 +3211,20 @@ object ProjectFrame: TProjectFrame
     object xbiPriceMargin: TdxStoredSideItem
       Tag = 3
       Caption = #26448#26009#35843#24046
-      Category = 4
+      Category = 3
       Enabled = True
       LargeImage = 4
       SmallImage = 4
     end
+    object dxsbsViewControlItem8: TdxStoredSideItem
+      Tag = 5
+      Caption = #20854#20182#21488#36134
+      Category = 6
+      Enabled = True
+      Hint = #20854#20182#21488#36134
+      LargeImage = 7
+      SmallImage = 7
+    end
   end
   object ilstLarge: TImageList
     Height = 32

+ 19 - 6
Frames/ProjectFme.pas

@@ -6,7 +6,7 @@ uses
   BillsCompileFme, BillsMeasureFme, PhaseCompareFme, DealPaymentFme,
   BillsGatherFme, ZJJLFme, BGLFme, ReportsFrm, SearchFme, BookmarkFme,
   ProjectData, UtilMethods, Globals, mEncryptEditions, DealBillsFme,
-  PriceMarginFme,
+  PriceMarginFme, OtherMeasureFme,
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, ImgList, XPMenu, Buttons, ComCtrls, ToolWin, ExtCtrls, JimPages,
   StdCtrls, JimCombos, dxsbar, ActnList, dxBar, OrderCheckerFme, CheckerFme,
@@ -81,6 +81,8 @@ type
     actnAllPeg: TAction;
     jpsMainPriceMargin: TJimPage;
     xbiPriceMargin: TdxStoredSideItem;
+    dxsbsViewControlItem8: TdxStoredSideItem;
+    jpsMainOtherMeasure: TJimPage;
     procedure tobtnStandardBillsClick(Sender: TObject);
     procedure jcbPhaseChanged(Sender: TObject);
     procedure sbtnExpendClick(Sender: TObject);
@@ -107,6 +109,8 @@ type
     FBillsGatherFrame: TBillsGatherFrame;
     FPriceMarginFrame: TPriceMarginFrame;
     FPhaseCompareFrame: TPhaseCompareFrame;
+    FOtherMeasureFrame: TOtherMeasureFrame;
+
     FCheckerFrame: TCheckerFrame;
 
     FDealPaymentFrame: TDealPaymentFrame;
@@ -180,6 +184,7 @@ type
     property BillsMeasureFrame: TBillsMeasureFrame read FBillsMeasureFrame;
     property BillsGatherFrame: TBillsGatherFrame read FBillsGatherFrame;
     property PriceMarginFrame: TPriceMarginFrame read FPriceMarginFrame;
+    property OtherMeasureFrame: TOtherMeasureFrame read FOtherMeasureFrame;
 
     property CheckerFrame: TCheckerFrame read FCheckerFrame;
     property UpFileManageView: TUpFileManageView read FUpFileManageView write SetUpFileManageView;
@@ -256,6 +261,7 @@ destructor TProjectFrame.Destroy;
 begin
   FBookmarkFrame.Free;
   FZJJLFrame.Free;
+  FOtherMeasureFrame.Free;
   FBillsGatherFrame.Free;
   FDealPaymentFrame.Free;
   FBillsCompileFrame.Free;
@@ -532,7 +538,7 @@ procedure TProjectFrame.dxsbViewControlItemClick(Sender: TObject;
     BeforeChangeView;
     case Item.Tag of
       0, 2: jpsMain.ActivePageIndex := Item.Tag;
-      1, 3: if CheckMeasureEdition then jpsMain.ActivePageIndex := Item.Tag;
+      1, 3, 5: if CheckMeasureEdition then jpsMain.ActivePageIndex := Item.Tag;
     end;
     AfterChangeView;
   end;
@@ -600,10 +606,10 @@ begin
   bCloseCompare := (Item.Tag in [0..3]) and (jpsMain.ActivePageIndex = 4);
 
   case Item.Tag of
-    0..2: ChangeView;
+    0..2, 5: ChangeView;
     3: DisplayPriceMargin;
     4: DisplayCompare;
-    5: DisplayReports;
+    6: DisplayReports;
   end;
 
   if bCloseCompare then
@@ -1152,10 +1158,16 @@ begin
   CreateBillsFrame;
   UpdateSysProgress(130, '正在解析数据');
   CreateDealPaymentFrame;
-  UpdateSysProgress(140, '正在解析数据');
+  UpdateSysProgress(135, '正在解析数据');
   CreateBillsGatherFrame;
+  UpdateSysProgress(140, '正在解析数据');
+  CreatePriceMarginFrame;                
+  UpdateSysProgress(145, '正在解析数据');
+
+  FOtherMeasureFrame := TOtherMeasureFrame.Create(FProjectData);
+  AlignControl(FOtherMeasureFrame, jpsMainOtherMeasure, alClient);
   UpdateSysProgress(150, '正在解析数据');
-  CreatePriceMarginFrame;
+
 
   FZJJLFrame := TZJJLFrame.Create(Self, FProjectData.PhaseData.ZJJLData);
   FZJJLFrame.DataReadOnly := FProjectData.PhaseData.StageDataReadOnly;
@@ -1393,6 +1405,7 @@ begin
   FBillsMeasureFrame.RefreshPhase_Stage;
   FDealPaymentFrame.RefreshPhase_Stage;
   FPriceMarginFrame.ResetViewControl;
+  FOtherMeasureFrame.ResetViewControl;
 end;
 
 procedure TProjectFrame.ExpandCurPhase;

+ 1 - 1
Units/Connections.pas

@@ -8,7 +8,7 @@ uses
 const
   ProductName = 'Measure';
   EmptyFileVersion = '1.0.0.0';
-  FileVersion = '1.0.1.6';
+  FileVersion = '1.0.1.7';
   EncryptVersion = 'Auto1.0';
   SAdoConnectStr = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;' +
                    'User ID=Admin;Password='''';Persist Security Info=True';

+ 63 - 4
Units/DataBaseTables.pas

@@ -691,12 +691,71 @@ const
     (FieldName: 'PrePhasePay'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
 
+  {其他台账 -- 全额计量}
+  SOtherMeasureOnce = 'OtherMeasureOnce';
+  tdOtherMeasureOnce: array [0..7] of TScFieldDef = (
+    (FieldName: 'ID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 排序
+    (FieldName: 'SerialNo'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 编号
+    (FieldName: 'Code'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 名称
+    (FieldName: 'Name'; FieldType: ftString; Size: 200; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 台账类型
+    (FieldName: 'MType'; FieldType: ftString; Size: 20; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 金额
+    (FieldName: 'TotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 备注
+    (FieldName: 'MemoStr'; FieldType: ftString; Size: 255; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 创建日期
+    (FieldName: 'CreatePhaseID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+  );
+
+  {其他台账 -- 分期计量}
+  SOtherMeasurePhase = 'OtherMeasurePhase';
+  tdOtherMeasurePhase: array [0..11] of TScFieldDef =(
+    (FieldName: 'ID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 排序
+    (FieldName: 'SerialNo'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 编号
+    (FieldName: 'Code'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 名称
+    (FieldName: 'Name'; FieldType: ftString; Size: 200; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 台账类型
+    (FieldName: 'MType'; FieldType: ftString; Size: 20; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 台账金额
+    (FieldName: 'TotalPrice'; FieldType: ftString; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 备注
+    (FieldName: 'MemoStr'; FieldType: ftString; Size: 255; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 创建日期
+    (FieldName: 'CreatePhaseID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 以下为根据期数缓存DetailMeasure中数据
+    // 本期计量
+    (FieldName: 'CurTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期计量
+    (FieldName: 'PreTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止本期计量
+    (FieldName: 'EndTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 累计计量
+    (FieldName: 'AddTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+  );
+
+  SOMPhaseDetail = 'OMPhaseDetail';
+  tdOMPhaseDetail: array [0..5] of TScFieldDef =(
+    (FieldName: 'ID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    (FieldName: 'PhaseID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    (FieldName: 'StageID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    (FieldName: 'PreTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'CurTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'EndTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+  );
+
   {PhaseData}
 
-  // Refer  :原报
-  // Audit1 :1审
-  // Audit2 :2审
-  // Audit3 :3审
+  // Refer  : 原报
+  // Audit1 : 1审
+  // Audit2 : 2审
+  // Audit3 : 3审
   // ......
   SRefer = 'Refer';
   SAudit = 'Audit';

+ 71 - 0
Units/DataRecord/OMPhaseRecord.pas

@@ -0,0 +1,71 @@
+unit OMPhaseRecord;
+
+interface
+
+uses
+  sdDB, mDataRecord;
+
+type
+  TOMPhaseRecord = class(TMeasureBaseRecord)
+  private
+    FID: TsdValue;
+    FSerialNo: TsdValue;
+
+    FName: TsdValue;
+    FMType: TsdValue;
+    FTotalPrice: TsdValue;
+    FMemoStr: TsdValue;
+
+    FCreatePhaseID: TsdValue;
+    FCreateStageID: TsdValue;
+
+    FCurTotalPrice: TsdValue;
+    FPreTotalPrice: TsdValue;
+    FEndTotalPrice: TsdValue;
+    FAddTotalPrice: TsdValue;
+  protected
+    procedure DoAfterAddFields; override;
+  public
+    property ID: TsdValue read FID;
+    property SerialNo: TsdValue read FSerialNo;
+
+    property Name: TsdValue read FName;
+    property MType: TsdValue read FMType;
+    property TotalPrice: TsdValue read FTotalPrice;
+    property MemoStr: TsdValue read FMemoStr;
+
+    property CreatePhaseID: TsdValue read FCreatePhaseID;
+    property CreateStageID: TsdValue read FCreateStageID;
+
+    property CurTotalPrice: TsdValue read FCurTotalPrice;
+    property PreTotalPrice: TsdValue read FPreTotalPrice;
+    property EndTotalPrice: TsdValue read FEndTotalPrice;
+    property AddTotalPrice: TsdValue read FAddTotalPrice;
+  end;
+
+implementation
+
+{ TOMPhaseRecord }
+
+procedure TOMPhaseRecord.DoAfterAddFields;
+begin
+  inherited;
+  FID := ValueByName('ID');
+  FSerialNo := ValueByName('SerialNo');
+
+  FName := ValueByName('Name');
+  FMType := ValueByName('MType');
+  FTotalPrice := ValueByName('TotalPrice');
+  FMemoStr := ValueByName('MemoStr');
+
+  FCreatePhaseID := ValueByName('CreatePhaseID');
+  FCreateStageID := ValueByName('CreateStageID');
+
+  FCurTotalPrice := ValueByName('CurTotalPrice');
+  FPreTotalPrice := ValueByName('PreTotalPrice');
+  FEndTotalPrice := ValueByName('EndTotalPrice');
+
+  FAddTotalPrice := ValueByName('AddTotalPrice');
+end;
+
+end.

+ 1 - 18
Units/PhaseData.pas

@@ -29,8 +29,6 @@ type
 
     procedure UpdatePhaseDataBase;
 
-    procedure ExecuteSql(const ASql: string);
-
     procedure CopyPreStageData;
 
     procedure CheckAuditCount;
@@ -311,22 +309,7 @@ begin
   sPre := StageTableName[FPhaseProperty.AuditCount-1];
   sCur := StageTableName[FPhaseProperty.AuditCount];
   sSql := Format(sCopySql, [sCur, sPre]);
-  ExecuteSql(sSql);
-end;
-
-procedure TPhaseData.ExecuteSql(const ASql: string);
-var
-  FQuery: TADOQuery;
-begin
-  FQuery := TADOQuery.Create(nil);
-  try
-    FQuery.Connection := FConnection.Connection;
-    FQuery.SQL.Clear;
-    FQuery.SQL.Add(ASql);
-    FQuery.ExecSQL;
-  finally
-    FQuery.Free;
-  end;
+  ExecuteSql(FConnection.Connection, sSql);
 end;
 
 procedure TPhaseData.SimpleOpen2(const AProjectName: string);

+ 84 - 1
Units/ProjectData.pas

@@ -7,7 +7,7 @@ uses
   PhaseCompareDm, DealPaymentDm, SearchDm, DealBillsDm, MainDataListDm,
   BillsGatherDm, BGLDm, StaffDm, BillsCompileDm, BillsMeasureDm,
   BillsBookmarkDm, UpFileManageUnit, ProjectGLDm, PriceMarginBillsDm,
-  DetailGLDm,
+  DetailGLDm, OtherMeasureOnceDm, OtherMeasurePhaseDm,
   Classes, SysUtils, ADODB, sdDB, Checker;
 
 type
@@ -46,6 +46,9 @@ type
     FDetailGLData: TDetailGLData;
     FPriceMarginBillsData: TPriceMarginBillsData;
 
+    FOtherMeasureOnceData: TOtherMeasureOnceData;
+    FOtherMeasurePhaseData: TOtherMeasurePhaseData;
+
     FCanUnlockInfo: Boolean;
 
     FWebID: Integer;
@@ -128,6 +131,8 @@ type
     procedure OpenForReport2(const AFileName: string);
     {OpenForReport3: OpenForReport2的基础上打开最后一个审核人数据,打开BillsMeasureTree不打开BillsCompileTree,链接BillsMeasureTree跟StageData}
     procedure OpenForReport3(const AFileName: string);
+    {OpenForGather: BillsData, BillsMeasureTree, DealPaymentData, BGLData, PhaseData(根据PhaseIndex指定打开)}
+    procedure OpenForGather(const AFileName: string; APhaseIndex: Integer = -1);
     //-----------------------  End ---后台打开 ------------------------
 
     procedure SaveDebugFile(const AFileName: string);
@@ -209,6 +214,9 @@ type
     property DetailGLData: TDetailGLData read FDetailGLData;
     property PriceMarginBillsData: TPriceMarginBillsData read FPriceMarginBillsData;
 
+    property OtherMeasureOnceData: TOtherMeasureOnceData read FOtherMeasureOnceData;
+    property OtherMeasurePhaseData: TOtherMeasurePhaseData read FOtherMeasurePhaseData;
+
     // 台账、合同支付
     property AllowInsert: Boolean read GetAllowInsert;
     property BaseDataReadOnly: Boolean read GetBaseDataReadOnly;
@@ -289,6 +297,8 @@ begin
   FProjectGLData := TProjectGLData.Create(Self);
   FDetailGLData := TDetailGLData.Create(Self);
   FPriceMarginBillsData := TPriceMarginBillsData.Create(Self);
+  FOtherMeasureOnceData := TOtherMeasureOnceData.Create(Self);
+  FOtherMeasurePhaseData := TOtherMeasurePhaseData.Create(Self);
   FAttachmentData := TUpFiles.Create;
   FPhaseIndex := 0;
 end;
@@ -309,6 +319,8 @@ destructor TProjectData.Destroy;
 begin
   try
     FCheckers.Free;
+    FOtherMeasurePhaseData.Free;
+    FOtherMeasureOnceData.Free;
     FPriceMarginBillsData.Free;
     FDetailGLData.Free;
     FProjectGLData.Free;
@@ -449,6 +461,9 @@ begin
 
   //FBillsGatherData.RefreshBills;
   FMainListData.Open(FConnection.Connection);
+  UpdateSysProgress(190, '正在读取数据');
+  FOtherMeasureOnceData.Open(FConnection.Connection);
+  FOtherMeasurePhaseData.Open(FConnection.Connection);
   UpdateSysProgress(200, '就绪');
 
   if _IsDebugView then
@@ -493,6 +508,10 @@ begin
     FBillsCompileData.ReLockBaseData;
     UpdateSysProgress(110, '正在保存数据');
     FBillsData.Save;
+    UpdateSysProgress(165, '正在保存数据');
+
+    FOtherMeasureOnceData.Save;
+    FOtherMeasurePhaseData.Save;
     UpdateSysProgress(170, '正在保存数据');
 
     FProjProperties.AuditCompany := FStaffData.FinalStaffCompany;
@@ -552,6 +571,8 @@ var
 begin
   SaveLastestPhaseMainData;
   FProjectGLData.Save;
+  FOtherMeasurePhaseData.Save;
+
   iOrgPhaseIndex := FPhaseIndex;
   FPhaseIndex := Value;
   ProjProperties.PhaseIndex := FPhaseIndex;
@@ -562,6 +583,8 @@ begin
   FProjectGLData.LoadCurPhaseInfoPrice;
   FProjectGLData.LoadStagePM_CalcData;
   FProjectGLData.RefreshGatherData;
+  // 须保存其他台账--分期计量数据
+  FOtherMeasurePhaseData.LoadCurStageData;
   //BillsGatherData.RefreshBills;
 end;
 
@@ -657,6 +680,17 @@ procedure TProjectData.UpdatePhaseData;
     ExecuteSql(sSql);
   end;
 
+  procedure UpdateOMPhaseDetailData;
+  const
+    sUpdateSql = 'Insert Into OMPhaseDetail (ID, PhaseID, StageID,' +
+                 '    PreTotalPrice, CurTotalPrice, EndTotalPrice)' +
+                 '  Select ID, %d, %d, PreTotalPrice, CurTotalPrice, EndTotalPrice' +
+                 '  From OMPhaseDetail Where (PhaseID = %d) and (StageID = -1)';
+  begin
+    if (ProjProperties.PhaseCount > 0) and (ProjProperties.AuditStatus > 0) then
+      ExecuteSql(Format(sUpdateSql, [FPhaseIndex, FProjProperties.AuditStatus, FPhaseIndex]));
+  end;
+
 var
   iPhase: Integer;
 begin
@@ -667,6 +701,7 @@ begin
     PhaseData.CreateNewAuditData;
     StaffData.UpdateDataForNewAudit;
     UpdateGLPriceData;
+    UpdateOMPhaseDetailData;
   end;
 end;
 
@@ -1737,12 +1772,21 @@ procedure TProjectData.ResetFloatDigitView;
     FBGLData.cdsBGBillsViewUsedQuantity.DisplayFormat := FProjProperties.QuantityFormat;
   end;
 
+  procedure SetOtherMeasureDigit;
+  begin
+    with FOtherMeasureOnceData.sdvOnce do
+    begin
+      Columns.FindColumn('TotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
+    end;
+  end;
+
 begin
   SetBillsCompileDigit;
   SetBillsMeasureDigit;
   SetDealPaymentDigit;
   SetBillsGatherDigit;
   SetBGLDigit;
+  SetOtherMeasureDigit;
 end;
 
 function TProjectData.GetStageDataReadOnly: Boolean;
@@ -1866,12 +1910,25 @@ procedure TProjectData.CopyPreData;
       ExecuteSql(Format(sCopySql, [FProjProperties.PhaseCount, FProjProperties.PhaseCount - 1]));
   end;
 
+  procedure CopyPreOMPhaseDetail;
+  const
+    sCopySql = 'Insert Into OMPhaseDetail (ID, PhaseID, StageID,' +
+               '    PreTotalPrice, CurTotalPrice, EndTotalPrice)' +
+               '  Select ID, %d, 0, PreTotalPrice + CurTotalPrice, 0, PreTotalPrice + CurTotalPrice' +
+               '  From OMPhaseDetail Where (PhaseID = %d) and (StageID = -1)';
+  begin
+    if FProjProperties.PhaseCount > 1 then
+      ExecuteSql(Format(sCopySql, [FProjProperties.PhaseCount, FProjProperties.PhaseCount - 1]));
+  end;
+
 begin
   CopyPreGLPrice;
+  CopyPreOMPhaseDetail;
   PhaseData.CopyPreData;
   ProjectGLData.LoadCurPhaseInfoPrice;
   ProjectGLData.LoadStagePM_CalcData;
   FProjectGLData.RefreshGatherData;
+  FOtherMeasurePhaseData.LoadCurStageData;
   BillsMeasureData.ResetTreeNodeStageRec;
 end;
 
@@ -1883,8 +1940,10 @@ end;
 procedure TProjectData.SetStageIndex(const Value: Integer);
 begin
   FProjectGLData.Save;
+  FOtherMeasurePhaseData.Save;
   FPhaseData.StageIndex := Value;
   FProjectGLData.LoadStagePM_CalcData;
+  FOtherMeasurePhaseData.LoadCurStageData;
 end;
 
 procedure TProjectData.ClearReportCacheData;
@@ -1955,4 +2014,28 @@ begin
     Result := False;
 end;
 
+procedure TProjectData.OpenForGather(const AFileName: string;
+  APhaseIndex: Integer = -1);
+begin
+  FProjectID := -1;
+  UnZipFile(AFileName, TempPath);
+  FConnection.Open(MainFileName);
+  UpdateProjectDataBase;
+  FProjProperties.Open(FConnection.Connection);
+  UpdateOldData;
+  FBillsData.Open(FConnection.Connection);
+  FBillsCompileData.Open;
+  FDealPaymentData.Open(FConnection.Connection);
+  FBGLData.Open(FConnection.Connection);
+  if ProjProperties.PhaseCount > 0 then
+  begin
+    if (APhaseIndex <= ProjProperties.PhaseCount) and (APhaseIndex > 0) then
+      FPhaseIndex := APhaseIndex
+    else
+      FPhaseIndex := ProjProperties.PhaseCount;
+    FPhaseData.SimpleOpen2(Format('%sPhase%d.dat', [TempPath, FPhaseIndex]));
+  end;
+  FBillsMeasureData.ResetTreeNodeStageRec;
+end;
+
 end.

+ 3 - 0
Units/UpdateDataBase.pas

@@ -98,6 +98,9 @@ begin
     Updater.AddTableDef(SProjectGL, @tdProjectGL, Length(tdProjectGL), False, False);
     Updater.AddTableDef(SGLPrice, @tdGLPrice, Length(tdGLPrice), False, False);
     Updater.AddTableDef(SDetailGL, @tdDetailGL, Length(tdDetailGL), False, False);
+    Updater.AddTableDef(SOtherMeasureOnce, @tdOtherMeasureOnce, Length(tdOtherMeasureOnce), False, False);
+    Updater.AddTableDef(SOtherMeasurePhase, @tdOtherMeasurePhase, Length(tdOtherMeasurePhase), False, False);
+    Updater.AddTableDef(SOMPhaseDetail, @tdOMPhaseDetail, Length(tdOMPhaseDetail), False, False);
     Updater.ExcuteUpdate;
   finally
     Updater.Free;

+ 27 - 2
Units/UtilMethods.pas

@@ -4,8 +4,8 @@ interface
 
 uses
   Controls, ZhAPI, ActnList, ZjIDTree, DB, ZjGridDBA, ZjGrid, Windows, Messages,
-  sdDB, VCLZip, VCLUnZip, Dialogs, Forms, ShlObj, Classes, StrUtils, Math;
-  
+  sdDB, VCLZip, VCLUnZip, Dialogs, Forms, ShlObj, Classes, StrUtils, Math, ADODB;
+
 type
   TBookmarkRefreshEvent = procedure (AExpandFrame: Boolean) of object;
 
@@ -21,6 +21,8 @@ type
 
   {DataBase Rela}
   function GetsdDataSetNewID(ADataSet: TsdDataSet; const AIndex: string): Integer;
+  procedure ExecuteSql(AConnection: TADOConnection; const ASql: string);
+  function QueryData(AConnection: TADOConnection; const ASql: string): TADOQuery;
 
   {Message}
   procedure WarningMessage(const AMsg: string; AHandle: THandle = 0);
@@ -181,6 +183,29 @@ begin
     Result := 1;
 end;
 
+procedure ExecuteSql(AConnection: TADOConnection; const ASql: string);
+var
+  vQuery: TADOQuery;
+begin
+  vQuery := TADOQuery.Create(nil);
+  try
+    vQuery.Connection := AConnection;
+    vQuery.SQL.Add(ASql);
+    vQuery.ExecSQL;
+  finally
+    vQuery.Free;
+  end;
+end;
+
+function QueryData(AConnection: TADOConnection; const ASql: string): TADOQuery;
+begin
+  Result := TADOQuery.Create(nil);
+  Result.Connection := AConnection;
+  Result.SQL.Clear;
+  Result.SQL.Add(ASql);
+  Result.Open;
+end;
+
 {Message}
 
 function GetValidHandle(AHandle: THandle = 0): THandle;