Ejemplo n.º 1
0
        private void buttonAddNewCategory_Click(object sender, EventArgs e)
        {
            FAddChildCategory facc = new FAddChildCategory();
            if (facc.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string dirName =  facc.NameDirectory;
                if (facc.IsCreateDirectoryFromParent)
                {
                    if (nodeCategory.Directory == "") { MessageBox.Show("Error Creation Directory "); return; };

                        try {
                            Directory.CreateDirectory(DirUtil.JoinDirAndFile(nodeCategory.Directory, facc.NameCategory));
                            dirName = DirUtil.JoinDirAndFile(nodeCategory.Directory, facc.NameCategory);
                        } catch(Exception exp) { MessageBox.Show("Error Creation Directory "+exp.Message); return; }
                }
                nodeCategory.AddCategory(facc.NameCategory,dirName);
                nodeCategory.Save();
            }
        }
Ejemplo n.º 2
0
        private void buttonAddChildCategory_Click(object sender, EventArgs e)
        {
            FAddChildCategory facc = new FAddChildCategory();
            if (facc.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (treeView1.SelectedNode.GetType().Name == "NodeCategory")
                {
                    string dirName = facc.NameDirectory;
                    NodeCategory nodeParent = (NodeCategory) treeView1.SelectedNode;
                    if (nodeParent.Directory == "") { MessageBox.Show("Error Creation Directory "); return; };

                        try {
                           Directory.CreateDirectory(DirUtil.JoinDirAndFile(nodeParent.Directory , facc.NameCategory));
                           dirName = DirUtil.JoinDirAndFile(nodeParent.Directory, facc.NameCategory);
                        } catch(Exception exp) { MessageBox.Show("Error Creation Directory "+exp.Message); return; }
                    tabControl1.SelectedIndex = 0;
                    NodeCategory node = (NodeCategory) treeView1.SelectedNode;
                    node.AddCategory(facc.NameCategory,dirName);
                }
            }
        }