Exemplo n.º 1
0
 private void updateButton_Click(object sender, EventArgs e)
 {
     if (ObjetComboBox.Text != "")
     {
         if (typeObjet == "Article")
         {
             FormModifArticle formModifArticle = new FormModifArticle(magasin, (ObjetComboBox.SelectedItem as dynamic).Value, formMain);
             formModifArticle.ShowDialog();
             Close();
         }
         else if (typeObjet == "Sous-Famille")
         {
             FormModifSousFamille formModifSousFamille = new FormModifSousFamille(magasin, (ObjetComboBox.SelectedItem as dynamic).Value, formMain);
             formModifSousFamille.ShowDialog();
             Close();
         }
         else if (typeObjet == "Famille")
         {
             FormModifFamille formModifFamille = new FormModifFamille(magasin, (ObjetComboBox.SelectedItem as dynamic).Value, formMain);
             formModifFamille.ShowDialog();
             Close();
         }
         else if (typeObjet == "Marque")
         {
             FormModifMarque formModifMarque = new FormModifMarque(magasin, (ObjetComboBox.SelectedItem as dynamic).Value, formMain);
             formModifMarque.ShowDialog();
             Close();
         }
         else
         {
             MessageBox.Show("Veuillez selectionner un objet à modifier avant d'appuyer sur le bouton Modifier", "Erreur Gestionnaire Modifier", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Veuillez selectionner un objet à modifier avant d'appuyer sur le bouton Modifier", "Erreur Gestionnaire Modifier", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 2
0
        /**
         * Update an element (article, family, subfamily, brand)
         **/
        private void updateObject()
        {
            // get selected node of treeview
            String selectedNodeText = treeView1.SelectedNode.Text;

            //Console.WriteLine("selectedNodeText:"+ selectedNodeText);

            // get selected item
            ListView.SelectedListViewItemCollection itemSelected = this.listView.SelectedItems;

            // action on item
            switch (selectedNodeText)
            {
            case "Articles":
                foreach (ListViewItem item in itemSelected)
                {
                    Article article = listView.SelectedItems[0].Tag as Article;
                    if (article != null)
                    {
                        Console.WriteLine("update article " + article.RefArticle + " : " + article.Description);
                        refreshStatusStrip("Modification de l'article " + article.RefArticle + " : " + article.Description + ".");
                        FormModifArticle formUpdateArticle = new FormModifArticle(magasin, article.RefArticle, this);
                        formUpdateArticle.ShowDialog();
                    }
                }
                break;

            case "Familles":
                foreach (ListViewItem item in itemSelected)
                {
                    Famille family = listView.SelectedItems[0].Tag as Famille;
                    if (family != null)
                    {
                        Console.WriteLine("update family " + family.RefFamille + ": " + family.Nom);
                        refreshStatusStrip("Modification de  la famille " + family.RefFamille + ": " + family.Nom + ".");
                        FormModifFamille formUpdateFamily = new FormModifFamille(magasin, family, this);
                        formUpdateFamily.ShowDialog();
                    }
                }
                break;

            case "Sous familles":
                foreach (ListViewItem item in itemSelected)
                {
                    SousFamille subFamily = listView.SelectedItems[0].Tag as SousFamille;
                    if (subFamily != null)
                    {
                        Console.WriteLine("update subfamily " + subFamily.RefSousFamille + ": " + subFamily.Nom);
                        refreshStatusStrip("Modification de la sous-famille " + subFamily.RefSousFamille + ": " + subFamily.Nom + ".");
                        FormModifSousFamille formUpdateSubFamily = new FormModifSousFamille(magasin, subFamily, this);
                        formUpdateSubFamily.ShowDialog();
                    }
                }
                break;

            case "Marques":
                foreach (ListViewItem item in itemSelected)
                {
                    Marque brand = listView.SelectedItems[0].Tag as Marque;
                    if (brand != null)
                    {
                        Console.WriteLine("update brand " + brand.RefMarque + ": " + brand.Nom);
                        refreshStatusStrip("Modification de la marque " + brand.RefMarque + ": " + brand.Nom + ".");
                        FormModifMarque formUpdateBrand = new FormModifMarque(magasin, brand, this);
                        formUpdateBrand.ShowDialog();
                    }
                }
                break;
            }
        }