public List <CategorieProduit> getAllCategorieProduitByFamille(FamilleProduit famille) { List <CategorieProduit> listCategorie = null; listCategorie = transition.getAllCategorieProduitBy("id_famille_produit=" + famille.Id); return(listCategorie); }
private void ComboBoxFamille_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (ComboBoxFamille.SelectedIndex >= 0) { FamilleProduit selectedFamille = listFamille[ComboBoxFamille.SelectedIndex]; listCategorie = ProduitController.getAllCategorieProduitByFamille(selectedFamille); } }
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); } }
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); }
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"); } } } }
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); }
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); }
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)"); } }
public int supprimerFamilleProduit(FamilleProduit famille) { int res = transition.deleteFamilleProduitBy("id=" + famille.Id); return(res); }
public int addFamilleProduit(FamilleProduit famille) { int res = transition.addFamilleProduit(famille); return(res); }
public List <CategorieProduit> getCategorieProduitByFamille(FamilleProduit selectedFamilleProduit) { List <CategorieProduit> resultat = transition.getAllCategorieProduitBy("id_famille_produit=" + selectedFamilleProduit.Id); return(resultat); }
private FamilleProduit creerFamilleFromView() { FamilleProduit famille = new FamilleProduit(textBoxNom.Text); return(famille); }