예제 #1
0
        private void supprimerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ListToDisplay.SelectedItems.Count == 1)
            {
                if (treeView1.SelectedNode.Name == "Familles" || treeView1.SelectedNode.Name == "Articles" || treeView1.SelectedNode.Name == "Marques")
                {
                    if (treeView1.SelectedNode.Name == "Articles")
                    {
                        ArticlesDao.DeleteById(ListToDisplay.SelectedItems[0].Name);
                    }
                    else if (treeView1.SelectedNode.Name == "Familles")
                    {
                        FamillesDao.DeleteById(int.Parse(ListToDisplay.SelectedItems[0].Name));
                    }
                    else
                    {
                        MarquesDao.DeleteById(int.Parse(ListToDisplay.SelectedItems[0].Name));
                    }
                }
                else
                {
                    switch (treeView1.SelectedNode.Parent.Name)
                    {
                    case "Familles":
                        SousFamillesDao.DeleteById(int.Parse(ListToDisplay.SelectedItems[0].Name));
                        break;

                    case "Marques":
                        ArticlesDao.DeleteById(ListToDisplay.SelectedItems[0].Name);
                        break;

                    default:
                        ArticlesDao.DeleteById(ListToDisplay.SelectedItems[0].Name);
                        break;
                    }
                }
            }
        }