Ver código fonte

复制整块粘贴时,选择节点为最底层数量单价不为0的节点,子项应不可选

MaiXinRong 9 anos atrás
pai
commit
e17698e738
2 arquivos alterados com 21 adições e 3 exclusões
  1. 12 2
      Forms/BillsPasteSelectFrm.pas
  2. 9 1
      Frames/BillsCompileFme.pas

+ 12 - 2
Forms/BillsPasteSelectFrm.pas

@@ -17,12 +17,15 @@ type
     Label1: TLabel;
     procedure btnOkClick(Sender: TObject);
   private
+    FCanBeChild: Boolean;
     function GetPos: Integer;
+    procedure SetCanBeChild(const Value: Boolean);
   public
     property Pos: Integer read GetPos;
+    property CanBeChild: Boolean read FCanBeChild write SetCanBeChild;
   end;
 
-  function SelectBillsPasteType(var APos: Integer): Boolean;
+  function SelectBillsPasteType(var APos: Integer; ACanBeChild: Boolean): Boolean;
 
 implementation
 
@@ -31,12 +34,13 @@ uses
 
 {$R *.dfm}
 
-function SelectBillsPasteType(var APos: Integer): Boolean;
+function SelectBillsPasteType(var APos: Integer; ACanBeChild: Boolean): Boolean;
 var
   SelectForm: TBillsPasteSelectForm;
 begin
   SelectForm := TBillsPasteSelectForm.Create(nil);
   try
+    SelectForm.CanBeChild := ACanBeChild;
     Result := SelectForm.ShowModal = mrOk;
     if Result then
       APos := SelectForm.Pos;
@@ -67,4 +71,10 @@ begin
     ModalResult := mrOk;
 end;
 
+procedure TBillsPasteSelectForm.SetCanBeChild(const Value: Boolean);
+begin
+  FCanBeChild := Value;
+  rbChild.Enabled := FCanBeChild;
+end;
+
 end.

+ 9 - 1
Frames/BillsCompileFme.pas

@@ -135,11 +135,19 @@ end;
 
 procedure TBillsCompileFrame.PasteBillsBlock(ANode: TsdIDTreeNode;
   ABounds: TRect);
+
+  function CanHasChild: Boolean;
+  begin
+    Result := True;
+    if not ANode.HasChildren then
+      Result := ANode.Rec.ValueByName('Quantity').AsFloat = 0;
+  end;
+
 var
   Clipboard: TBillsClipboard;
   iPos: Integer;
 begin
-  if SelectBillsPasteType(iPos) then
+  if SelectBillsPasteType(iPos, CanHasChild) then
   begin
     if iPos = -1 then Exit;