Пример #1
0
        //private void InternationalDropNodes(TreeListNode sourceNode, TreeListNode targetNode)
        //{
        //    try
        //    {
        //        var sourceData = GetData(sourceNode);
        //        var targetData = GetData(targetNode);
        //        ShopCatNode targetShopCatNode = null;
        //        TreeNodes targetCollection = null;
        //        GetTargets(targetData, ref targetShopCatNode, ref targetCollection);
        //        if (sourceData is SupNode)
        //        {
        //            DropSupNode(sourceData as SupNode, targetShopCatNode, targetCollection);
        //        }
        //        else if (sourceData is SupCatNode)
        //        {
        //            DropSupCatNode(sourceData as SupCatNode, targetShopCatNode, targetCollection);
        //        }
        //        else if (sourceData is SupProdNode)
        //        {
        //            DropSupProdNode(sourceData as SupProdNode, targetShopCatNode, targetCollection);
        //        }
        //        treeShop.RefreshDataSource();
        //    }
        //    catch (Exception ex)
        //    {
        //        throw;
        //    }
        //}
        private void DropSupProdNode(SupProdNode supProdNode, ShopCatNode parentShopCatNode, TreeNodes targetCollection)
        {
            if (parentShopCatNode == null) return;

            var newShopProd = supProdNode.Base.CreateShopProduct(parentShopCatNode.Base);
            context.SaveChanges();
            var newShopProdNode = new ShopProdNode(newShopProd, parentShopCatNode);
            targetCollection.Add(newShopProdNode);
        }
Пример #2
0
        private void DropShopProdNode(ShopProdNode shopProdNode, ShopCatNode targetShopCatNode, TreeNodes targetCollection)
        {
            if (targetShopCatNode == null) return;

            shopProdNode.Base.Move(targetShopCatNode.Base);
            context.SaveChanges();

            shopProdNode.Parent.Childs.Remove(shopProdNode);
            targetCollection.Add(shopProdNode);
            shopProdNode.Parent = targetShopCatNode;
        }