Esempio n. 1
0
        public List <CategorieProduit> getAllCategorieProduitByFamille(FamilleProduit famille)
        {
            List <CategorieProduit> listCategorie = null;

            listCategorie = transition.getAllCategorieProduitBy("id_famille_produit=" + famille.Id);
            return(listCategorie);
        }
Esempio n. 2
0
 private void ComboBoxFamille_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (ComboBoxFamille.SelectedIndex >= 0)
     {
         FamilleProduit selectedFamille = listFamille[ComboBoxFamille.SelectedIndex];
         listCategorie = ProduitController.getAllCategorieProduitByFamille(selectedFamille);
     }
 }
Esempio n. 3
0
 private void ComboBoxFamille_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (ComboBoxFamille.SelectedIndex >= 0)
     {
         FamilleProduit selectedFamille = ProduitController.getAllFamilleProduit()[ComboBoxFamille.SelectedIndex];
         ComboBoxCategorie.ItemsSource = ProduitController.getAllCategorieProduitByFamille(selectedFamille);
     }
 }
 private void comboBoxFamilleProduit_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (comboBoxFamilleProduit.SelectedIndex >= 0)
     {
         FamilleProduit selectedFamilleProduit = listFamilleProduit[comboBoxFamilleProduit.SelectedIndex];
         listCategorieProduit = controller.getCategorieProduitByFamille(selectedFamilleProduit);
         listProduits         = controller.getProduitByFamille(selectedFamilleProduit);
     }
 }
Esempio n. 5
0
        public int addFamilleProduit(FamilleProduit famille)
        {
            string        query         = "INSERT INTO famille_produit('nom') VALUES(";
            StringBuilder stringBuilder = new StringBuilder(query);

            stringBuilder.Append("'" + famille.Nom.Replace("'", "''") + "'" + ")");

            int res = sqliteAccess.ExecuteComandWOReturn(stringBuilder.ToString());

            return(res);
        }
Esempio n. 6
0
        public List <Produit> getProduitByFamille(FamilleProduit selectedFamilleProduit)
        {
            List <Produit>          res           = new List <Produit>();
            List <CategorieProduit> listCategorie = transition.getAllCategorieProduitBy("id_famille_produit=" + selectedFamilleProduit.Id);

            foreach (CategorieProduit categorie in listCategorie)
            {
                List <Produit> currentRes = getProduitByCategorie(categorie);
                res.AddRange(currentRes);
            }
            return(res);
        }
 private void DataGrid_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Delete || e.Key == Key.Back)
     {
         if (MessageBox.Show("Etes vous sûr de supprimer cet élement ?", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             FamilleProduit selectedFamille = DataGrid.SelectedItem as FamilleProduit;
             int            res             = produitController.supprimerFamilleProduit(selectedFamille);
             if (res == 1)
             {
                 MessageBox.Show("L'élement a été supprimé", "Informations");
                 listFamilleProduit = produitController.getAllFamilleProduit();
             }
             else
             {
                 MessageBox.Show("Echec de la supression", "Informations");
             }
         }
     }
 }
Esempio n. 8
0
        public List <CategorieProduit> getAllCategorieProduitBy(string whereClause)
        {
            List <CategorieProduit> listeCategorieProduit = new List <CategorieProduit>();
            string query = "SELECT * FROM categorie_produit";

            if (whereClause != null && whereClause != "")
            {
                query += " WHERE " + whereClause;
            }

            SQLiteDataReader dataReader = sqliteAccess.ExecuteCommandWReturn(query);

            while (dataReader.Read())
            {
                int            idProduit = int.Parse(dataReader["id"].ToString());
                string         string_id = dataReader["id_famille_produit"].ToString();
                FamilleProduit famille;
                if (string_id != null && string_id != "")
                {
                    int id_famille_produit            = int.Parse(dataReader["id_famille_produit"].ToString());
                    List <FamilleProduit> listFamille = getAllFamilleProduitBy("id=" + id_famille_produit);
                    if (listFamille.Count > 0)
                    {
                        famille = listFamille[0];
                    }
                    else
                    {
                        famille = new FamilleProduit("Inconnue");
                    }
                }
                else
                {
                    famille = new FamilleProduit("Inconnue");
                }

                listeCategorieProduit.Add(new CategorieProduit(idProduit, dataReader["nom"].ToString(), famille));
            }

            return(listeCategorieProduit);
        }
Esempio n. 9
0
        private CategorieProduit creerCategorieFromView()
        {
            CategorieProduit res = null;

            if (comboBox_famille.SelectedIndex < 0)
            {
                return(null);
            }
            FamilleProduit famille = listFamille[comboBox_famille.SelectedIndex];

            if (famille != null)
            {
                try
                {
                    res = new CategorieProduit(textBoxNom.Text, famille);
                }
                catch
                {
                }
            }
            return(res);
        }
Esempio n. 10
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            FamilleProduit familleToAdd = creerFamilleFromView();

            if (familleToAdd != null)
            {
                int res = produitController.addFamilleProduit(familleToAdd);
                if (res == 1)
                {
                    MessageBox.Show("La catégorie a été rajouté");
                    textBoxNom.Text = "";
                }
                else
                {
                    MessageBox.Show("Problème interne, la catégorie n'a pas été rajoutée");
                }
            }
            else
            {
                MessageBox.Show("Veuillez vérifier que les informations sont correctes (Bon format de date par exemple)");
            }
        }
Esempio n. 11
0
        public int supprimerFamilleProduit(FamilleProduit famille)
        {
            int res = transition.deleteFamilleProduitBy("id=" + famille.Id);

            return(res);
        }
Esempio n. 12
0
        public int addFamilleProduit(FamilleProduit famille)
        {
            int res = transition.addFamilleProduit(famille);

            return(res);
        }
Esempio n. 13
0
        public List <CategorieProduit> getCategorieProduitByFamille(FamilleProduit selectedFamilleProduit)
        {
            List <CategorieProduit> resultat = transition.getAllCategorieProduitBy("id_famille_produit=" + selectedFamilleProduit.Id);

            return(resultat);
        }
Esempio n. 14
0
        private FamilleProduit creerFamilleFromView()
        {
            FamilleProduit famille = new FamilleProduit(textBoxNom.Text);

            return(famille);
        }