Exemplo n.º 1
0
 private void GetTargets(ITreeNode targetData, ref ShopCatNode targetShopCatNode, ref TreeNodes targetCollection)
 {
     if (targetData == null)
     {
         var shopRoot = treeShop.DataSource as TreeNodes;
         targetCollection = shopRoot;
     }
     else if (targetData is ShopCatNode)
     {
         targetShopCatNode = targetData as ShopCatNode;
         targetCollection = targetShopCatNode.Childs;
     }
     else if (targetData is ShopProdNode)
     {
         targetShopCatNode = (targetData as ShopProdNode).Parent as ShopCatNode;
         targetCollection = targetShopCatNode.Childs;
     }
 }
Exemplo n.º 2
0
        private void DropSupNode(SupNode supNode, ShopCatNode parentShopCatNode, TreeNodes targetCollection)
        {
            List<ShopCategory> newShopCategories = supNode.Base.CreateShopCategories(parentShopCatNode.Base);

            context.SaveChanges();

            targetCollection.Clear();
            foreach (var newShopCategory in newShopCategories)
            {
                var newShopCatNode = new ShopCatNode(newShopCategory, parentShopCatNode);
                targetCollection.Add(newShopCatNode);
            }
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
0
        private void DropSupCatNode(ITreeNode sourceData, ShopCatNode parentShopCatNode, TreeNodes targetCollection)
        {
            var supCatNode = sourceData as SupCatNode;
            var parentShopCat = parentShopCatNode == null ? null : parentShopCatNode.Base;

            bool mergeCategories = false;
            if (parentShopCatNode != null)
            {
                mergeCategories = MessageBox.Show("Да - Слить, Нет - Добавить?", "Слияние", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
            }

            var newShopCategory = supCatNode.Base.CreateShopCategory(parentShopCat, mergeCategories);
            context.SaveChanges();

            var newShopCatNode = new ShopCatNode(newShopCategory, parentShopCatNode);
            targetCollection.Add(newShopCatNode);
        }
Exemplo n.º 6
0
        private void DropShopCatNode(ShopCatNode sourceCatNode, ShopCatNode targetCatNode, TreeNodes targetCollection)
        {
            var sourceShopCat = sourceCatNode.Base;
            var targetShopCat = targetCatNode == null ? null : targetCatNode.Base;

            bool mergeCategories = false;
            if (targetCatNode != null)
            {
                mergeCategories = MessageBox.Show("Да - Слить, Нет - Добавить?", "Слияние", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
            }

            if (mergeCategories)
                sourceShopCat.Merge(targetShopCat);

            else
                sourceShopCat.Move(targetShopCat);

            context.SaveChanges();

            var rootTreeNodes = treeShop.DataSource as TreeNodes;
            TreeNodes sourceContainer = sourceCatNode.Parent == null ? rootTreeNodes : sourceCatNode.Parent.Childs;
            sourceContainer.Remove(sourceCatNode);

            if (mergeCategories) return;

            targetCollection.Add(sourceCatNode);
            sourceCatNode.Parent = targetCatNode;
        }
Exemplo n.º 7
0
        private void CreateShopCatNode(TreeListNode parent)
        {
            ITreeNode data = GetData(parent);
            ShopCatNode parentShopCatNode = null;
            if (data is ShopProdNode)
            {
                parentShopCatNode = (data as ShopProdNode).Parent as ShopCatNode;
            }
            else
            {
                parentShopCatNode = data as ShopCatNode;
            }

            ShopCategory parentShopCat = parentShopCatNode.Base;

            var shopCategory = new ShopCategory(parentShopCat);
            shopCategory.Title = "Новая категория";
            context.SaveChanges();

            var shopCatNode = new ShopCatNode(shopCategory, parentShopCatNode);
            parentShopCatNode.Childs.Add(shopCatNode);

            parent.TreeList.RefreshDataSource();

            foreach (TreeListNode treeListNode in parent.Nodes)
            {
                ShopCatNode neighbourCat = GetData(treeListNode) as ShopCatNode;
                if (neighbourCat == null) continue;
                if (neighbourCat.Base.Id != shopCategory.Id) continue;

                var treeList = treeListNode.TreeList;
                treeList.MakeNodeVisible(treeListNode);
                treeListNode.TreeList.FocusedNode = treeListNode;
                //treeListNode.TreeList.SetFocusedNode(treeListNode);
                treeListNode.TreeList.ShowEditor();
                break;
            }
        }
Exemplo n.º 8
0
        private void BuildShopTree()
        {
            var shopCats = context.ShopCategorySet.Where(c => c.Parent == null).ToList();
            var shopNodes = new TreeNodes();

            foreach (var s in shopCats)
            {
                var supNode = new ShopCatNode(s, null);
                shopNodes.Add(supNode);
            }

            treeShop.DataSource = shopNodes;
            treeShop.Refresh();
            if (treeSuppliers.Nodes.Count > 0)
            {
                treeSuppliers.Nodes[0].Expanded = true;
            }
        }
Exemplo n.º 9
0
 public ShopProdNode(ShopProduct @base, ShopCatNode shopCatNode)
 {
     Base = @base;
     Parent = shopCatNode;
 }
Exemplo n.º 10
0
 public ShopCatNode(ShopCategory @base, ShopCatNode parentShopCatNode)
 {
     Base = @base;
     Parent = parentShopCatNode;
 }