| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod CanDragAndDropStockingPointNodes ( | 
|   Unit dpfocusedunit, | 
|   output String feedback_o, | 
|   StockingPoint_MPs stockingpoints | 
| ) as Boolean | 
| { | 
|   Description: | 
|   [* | 
|     If current supply chain view is displaying all root unit, dragging and dropping of resource nodes should not be allowed (Resource nodes are unit nodes that has parent) | 
|     control / shift key is to prevent collision with other drag and drop. | 
|   *] | 
|   TextBody: | 
|   [* | 
|     feedback_o := ''; | 
|      | 
|     /* | 
|     Count how many number of selected stocking points which do not belong to any unit | 
|     If there are none, (e.g. all stocking points belong to a unit), proceed with the next check | 
|     If there are some. (e.g. still have some stocking points belong to a unit), drag and drop should not be allowed. | 
|     If all of them do not belong to any unit, drag and drop is only allowed in root level. | 
|     */ | 
|      | 
|     nullsp := counter( stockingpoints, Elements, sp, isnull( sp.Unit() ) ); | 
|      | 
|     if( nullsp = 0 ) | 
|     { | 
|       // Check whether the selected stocking points belong to the units of same level | 
|       if( stockingpoints.Size() > 0 and exists( stockingpoints, Elements, sp, | 
|                                                 sp.Unit() <> stockingpoints.Element( 0 ).Unit() ) ) | 
|       { | 
|         feedback_o := Translations::MP_SupplyChainView_CanDragAndDropStockingPointNodes_DifferentLevel(); | 
|       } | 
|      | 
|       else | 
|       { | 
|         level := stockingpoints.Element( 0 ).Unit().Level() + 1; //+ 1 because stocking point belongs to that unit. | 
|         parentname := guard( stockingpoints.Element( 0 ).Unit().Name(), '' ); | 
|      | 
|         if( not isnull( dpfocusedunit )  ) | 
|         { | 
|           //e.g. Units dragged is level 3, current focusedunit is level 1 | 
|           if( dpfocusedunit.Level() + 1 <> level or parentname <> dpfocusedunit.Name() ) | 
|           { | 
|             feedback_o := Translations::MP_SupplyChainView_CanDragAndDropStockingPointNodes_DrillTowards( parentname ); | 
|           } | 
|         } | 
|         else | 
|         { | 
|             feedback_o := Translations::MP_SupplyChainView_CanDragAndDropStockingPointNodes_DrillTowards( parentname ); | 
|         } | 
|       } | 
|     } | 
|      | 
|     else if( nullsp < stockingpoints.Size() ) | 
|     { | 
|       feedback_o := Translations::MP_SupplyChainView_CanDragAndDropStockingPointNodes_DifferentLevel(); | 
|     } | 
|      | 
|     else if( nullsp = stockingpoints.Size() and not isnull( dpfocusedunit ) ) | 
|     { | 
|       feedback_o := Translations::MP_SupplyChainView_CanDragAndDropStockingPointNodes_DrillTowardsRootLevel(); | 
|     } | 
|      | 
|     return feedback_o = ''; | 
|   *] | 
| } |