Beispiel #1
0
        /// <summary>
        /// Создать новую категорию(клик).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void createNewCategory_Click(object sender, EventArgs e)
        {
            var selectedNode = (StorageNode)storageTree.SelectedNode;
            var ccvDialog    = new CategoryCreationView(selectedNode);

            ccvDialog.ShowDialog();
            var result = ccvDialog.Result;

            if (result != null)
            {
                Cathegory cathegory = new Cathegory(result.Text);
                result.Cathegory = cathegory;
                if (selectedNode != null)
                {
                    selectedNode.Cathegory.Cathegories.Add(cathegory);
                    selectedNode.Nodes.Add(result);
                }
                else
                {
                    Storage.Cathegories.Add(cathegory);
                    storageTree.Nodes.Add(result);
                }
                Utils.CreateCategoryInPath(result);
            }
        }
Beispiel #2
0
 public void RecursiveProducts(ref List <Product> result, Cathegory cathegory, int curDepth)
 {
     if (curDepth <= 0)
     {
         return;
     }
     result.AddRange(cathegory.Products);
     foreach (Cathegory c in cathegory.Cathegories)
     {
         RecursiveProducts(ref result, c, curDepth - 1);
     }
 }