Browse Source

新增计量汇总列,不允许父子项同时勾选

MaiXinRong 7 years ago
parent
commit
fe9e769e49

+ 4 - 1
DataModules/BillsDm.dfm

@@ -268,6 +268,9 @@ object BillsData: TBillsData
       6F76616C436F6465094669656C644E616D65060C417070726F76616C436F6465
       0844617461547970650218084461746153697A6502320549734B6579080F4E65
       656450726F636573734E616D650909507265636973696F6E02000453697A6502
-      000000}
+      000001044E616D65060C49734761746865725A4A4A4C094669656C644E616D65
+      060C49734761746865725A4A4A4C084461746154797065020508446174615369
+      7A6502010549734B6579080F4E65656450726F636573734E616D650909507265
+      636973696F6E02000453697A6502000000}
   end
 end

+ 4 - 0
DataModules/BillsMeasureDm.dfm

@@ -223,8 +223,12 @@ object BillsMeasureData: TBillsMeasureData
       end
       item
         FieldName = 'ApprovalCode'
+      end
+      item
+        FieldName = 'IsGatherZJJL'
       end>
     AfterAddRecord = sdvBillsMeasureAfterAddRecord
+    BeforeValueChange = sdvBillsMeasureBeforeValueChange
     AfterValueChanged = sdvBillsMeasureAfterValueChanged
     AfterClose = sdvBillsMeasureAfterClose
     AfterOpen = sdvBillsMeasureAfterOpen

+ 88 - 1
DataModules/BillsMeasureDm.pas

@@ -24,6 +24,8 @@ type
     procedure sdvBillsMeasureAfterClose(Sender: TObject);
     procedure sdvBillsMeasureAfterValueChanged(AValue: TsdValue);
     procedure sdvBillsMeasureCurrentChanged(ARecord: TsdDataRecord);
+    procedure sdvBillsMeasureBeforeValueChange(AValue: TsdValue;
+      const NewValue: Variant; var Allow: Boolean);
   private
     FProjectData: TObject;
     FBillsData: TBillsData;
@@ -434,7 +436,7 @@ begin
   if not CheckValidData then
     Allow := False;
   if not Allow then Exit;
-  
+
   vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(GetBillsID));
 
   CheckLockedData;
@@ -1085,4 +1087,89 @@ begin
     Result := ANode;
 end;
 
+procedure TBillsMeasureData.sdvBillsMeasureBeforeValueChange(
+  AValue: TsdValue; const NewValue: Variant; var Allow: Boolean);
+
+   function CheckParentExist(ANode: TBillsIDTreeNode): Boolean;
+   var
+     vParent: TBillsIDTreeNode;
+   begin
+     Result := False;
+     vParent := TBillsIDTreeNode(ANode.Parent);
+     while Assigned(vParent) and not Result do
+     begin
+       if vParent.Rec.IsGatherZJJL.AsBoolean then
+         Result := True;
+       vParent := TBillsIDTreeNode(vParent.Parent);
+     end;
+   end;
+
+   procedure CancelParentCheck(ANode: TBillsIDTreeNode);
+   var
+     vParent: TBillsIDTreeNode;
+   begin
+     vParent := TBillsIDTreeNode(ANode.Parent);
+     while Assigned(vParent) do
+     begin
+       if vParent.Rec.IsGatherZJJL.AsBoolean then
+         vParent.Rec.IsGatherZJJL.AsBoolean := False;
+       vParent := TBillsIDTreeNode(vParent.Parent);
+     end;
+   end;
+
+   function CheckChildrenExist(ANode: TBillsIDTreeNode): Boolean;
+   var
+     iChild: Integer;
+     vChild: TBillsIDTreeNode;
+   begin
+     Result := False;
+     for iChild := 0 to ANode.ChildCount - 1 do
+     begin
+       vChild := TBillsIDTreeNode(ANode.ChildNodes[iChild]);
+       if vChild.Rec.IsGatherZJJL.AsBoolean or CheckChildrenExist(vChild) then
+       begin
+         Result := True;
+         Break;
+       end;
+     end;
+   end;
+
+   procedure CancelChildrenCheck(ANode: TBillsIDTreeNode);
+   var
+     iChild: Integer;
+     vChild: TBillsIDTreeNode;
+   begin
+     for iChild := 0 to ANode.ChildCount - 1 do
+     begin
+       vChild := TBillsIDTreeNode(ANode.ChildNodes[iChild]);
+       if vChild.Rec.IsGatherZJJL.AsBoolean then
+         vChild.Rec.IsGatherZJJL.AsBoolean := False
+       else
+         CancelChildrenCheck(vChild);
+     end;
+   end;
+
+var
+  vNode: TBillsIDTreeNode;
+begin
+  vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(AValue.Owner.ValueByName('ID').AsInteger));
+  if SameText(AValue.FieldName, 'IsGatherZJJL') and NewValue then
+  begin
+    if CheckParentExist(vNode) then
+    begin
+      if QuestMessage('父项已勾选,继续将取消父项勾选。') then
+        CancelParentCheck(vNode)
+      else
+        Allow := False;
+    end
+    else if CheckChildrenExist(vNode) then
+    begin
+      if QuestMessage('子项已勾选,继续将取消子项勾选。') then
+        CancelChildrenCheck(vNode)
+      else
+        Allow := False;
+    end;
+  end;
+end;
+
 end.

+ 22 - 1
Frames/BillsMeasureFme.dfm

@@ -53,7 +53,7 @@ object BillsMeasureFrame: TBillsMeasureFrame
       Height = 269
       Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection, goShowTreeLine]
       OptionsEx = []
-      ColCount = 36
+      ColCount = 37
       RowCount = 6
       FixedRowCount = 2
       ShowGridLine = False
@@ -130,6 +130,26 @@ object BillsMeasureFrame: TBillsMeasureFrame
   object stdBillsMeasure: TsdGridTreeDBA
     Columns = <
       item
+        Title.Caption = #35745#37327#27719#24635
+        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
+        EditType = sgeCheckBox
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'IsGatherZJJL'
+        Width = 35
+        ReadOnly = False
+      end
+      item
         Title.Caption = #39033#30446#33410#32534#21495
         Title.CaptionAcrossCols = '1'
         Title.CaptionAcrossRows = 2
@@ -1038,6 +1058,7 @@ object BillsMeasureFrame: TBillsMeasureFrame
     Grid = zgBillsMeasure
     ExtendRowCount = 3
     AutoExpand = False
+    TreeCellCol = 2
     KeyFieldName = 'ID'
     ParentFieldName = 'ParentID'
     NextSiblingFieldName = 'NextSiblingID'

+ 1 - 1
Units/Connections.pas

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

+ 4 - 2
Units/DataBaseTables.pas

@@ -107,7 +107,7 @@ const
 
   {清单数据 -- 台账编辑界面}
   SBills = 'Bills';
-  tdBills: array [0..87] of TScFieldDef =(
+  tdBills: array [0..88] of TScFieldDef =(
     (FieldName: 'ID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
     (FieldName: 'ParentID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: False; ForceUpdate: False),
     (FieldName: 'NextSiblingID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: False; ForceUpdate: False),
@@ -289,7 +289,9 @@ const
     {------------------ End Reports --------------------------}
     (FieldName: 'PM_AddTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 批复编号
-    (FieldName: 'ApprovalCode'; FieldType: ftString; Size: 50; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+    (FieldName: 'ApprovalCode'; FieldType: ftString; Size: 50; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 计量汇总,生成中间计量时,是否汇总其下所有工程量清单
+    (FieldName: 'IsGatherZJJL'; FieldType: ftBoolean; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
 
   {合同支付}

+ 3 - 0
Units/mDataRecord.pas

@@ -76,6 +76,7 @@ type
     FLockedNewPrice: TsdValue;
     FCreatePhaseID: TsdValue;
     FIsMeasureAdd: TsdValue;
+    FIsGatherZJJL: TsdValue;
 
     FPeg: TsdValue;
     FDrawingCode: TsdValue;
@@ -167,6 +168,7 @@ type
     property LockedNewPrice: TsdValue read FLockedNewPrice;
     property CreatePhaseID: TsdValue read FCreatePhaseID;
     property IsMeasureAdd: TsdValue read FIsMeasureAdd;
+    property IsGatherZJJL: TsdValue read FIsGatherZJJL;
 
     property Peg: TsdValue read FPeg;
     property DrawingCode: TsdValue read FDrawingCode;
@@ -562,6 +564,7 @@ begin
   FLockedNewPrice := ValueByName('LockedNewPrice');
   FCreatePhaseID := ValueByName('CreatePhaseID');
   FIsMeasureAdd := ValueByName('IsMeasureAdd');
+  FIsGatherZJJL := ValueByName('IsGatherZJJL');
 
   FPeg := ValueByName('Peg');
   FDrawingCode := ValueByName('DrawingCode');