public List <Prestation> getAllPrestationsBy(string whereClause) { List <Prestation> listePrestation = new List <Prestation>(); string query = "SELECT p.*, cp.nom AS categorie FROM prestation p INNER JOIN categorie_prestation cp ON p.id_categorie_prestation = cp.id"; if (whereClause != null && whereClause != "") { query += " WHERE " + whereClause; } SQLiteDataReader dataReader = sqliteAccess.ExecuteCommandWReturn(query); while (dataReader.Read()) { int idPrestation = int.Parse(dataReader["id"].ToString()); int idCategoriePrestation = int.Parse(dataReader["id_categorie_prestation"].ToString()); CategoriePrestation categoriePrestation = new CategoriePrestation(idCategoriePrestation, dataReader["categorie"].ToString()); listePrestation.Add(new Prestation(idPrestation, dataReader["nom"].ToString(), int.Parse(dataReader["prix_ttc"].ToString()), dataReader["type_prestation"].ToString(), categoriePrestation )); } return(listePrestation); }
private void comboBox_categoriePrestation_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (comboBox_categoriePrestation.SelectedIndex >= 0) { CategoriePrestation selectedCategoriePrestation = listCategoriePrestation[comboBox_categoriePrestation.SelectedIndex]; listPrestations = controller.getPrestationByCategorie(selectedCategoriePrestation); } }
public Prestation(string nom, float prixTTC, string typePrestation, CategoriePrestation categorie) { Id = -1; Nom = nom; PrixTTC = prixTTC; Type = typePrestation; Categorie = categorie; }
public int addCategoriePrestation(CategoriePrestation categorie) { string query = "INSERT INTO categorie_prestation('nom') VALUES("; StringBuilder stringBuilder = new StringBuilder(query); stringBuilder.Append("'" + categorie.Nom.Replace("'", "''") + "'" + ")"); int res = sqliteAccess.ExecuteComandWOReturn(stringBuilder.ToString()); return(res); }
private CategoriePrestation creerCategorieFromView() { CategoriePrestation res = null; try { res = new CategoriePrestation(textBoxNom.Text); } catch { } return(res); }
private Prestation creerPrestationFromView() { Prestation res = null; try { CategoriePrestation selectedCategorie = null; if (comboBoxCategorie.SelectedIndex >= 0) { selectedCategorie = listCategorie[comboBoxCategorie.SelectedIndex]; } return(new Prestation(textBoxNom.Text, int.Parse(textBoxPrix.Text), textBoxTypePrestation.Text, selectedCategorie)); } catch { } 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) { CategoriePrestation selectedCategorie = DataGrid.SelectedItem as CategoriePrestation; int res = prestationController.supprimerCategoriePrestation(selectedCategorie); if (res == 1) { MessageBox.Show("L'élement a été supprimé", "Informations"); listCategoriePrestation = prestationController.getAllCategoriePrestation(); } else { MessageBox.Show("Echec de la supression", "Informations"); } } } }
private void Button_Click(object sender, RoutedEventArgs e) { CategoriePrestation categorieToAdd = creerCategorieFromView(); if (categorieToAdd != null) { int res = prestationtController.ajouterCategoriePrestation(categorieToAdd); if (res == 1) { MessageBox.Show("L'utilisateur a été rajouté"); textBoxNom.Text = ""; } else { MessageBox.Show("Problème interne, l'utilisateur n'a pas été ajouté"); } } else { MessageBox.Show("Veuillez vérifier que les informations sont correctes (Bon format de date par exemple)"); } }
public List <Prestation> getPrestationByCategorie(CategoriePrestation selectedCategoriePrestation) { List <Prestation> resultat = transition.getAllPrestationsBy("id_categorie_prestation=" + selectedCategoriePrestation.Id); return(resultat); }
public int supprimerCategoriePrestation(CategoriePrestation categorie) { int res = transition.deleteCategorieProduitBy("id=" + categorie.Id); return(res); }
public int ajouterCategoriePrestation(CategoriePrestation categorie) { int res = transition.addCategoriePrestation(categorie); return(res); }