public static ObservableCollection <CategorieDAO> selectCategories() { ObservableCollection <CategorieDAO> l = new ObservableCollection <CategorieDAO>(); string query = "SELECT * FROM categorie;"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); MySqlDataReader reader = null; try { cmd.ExecuteNonQuery(); reader = cmd.ExecuteReader(); while (reader.Read()) { CategorieDAO p = new CategorieDAO(reader.GetInt32(0), reader.GetString(1), reader.GetString(2)); l.Add(p); } } catch (Exception e) { MessageBox.Show("Il y a un problème dans la table Categorie : {0}", e.StackTrace); } reader.Close(); return(l); }
public static void updateCategorie(CategorieDAO p) { string query = "UPDATE categorie set nomCategorie=\"" + p.nomCategorieDAO + "\", descriptionCategorie=\"" + p.descriptionCategorieDAO + "\" where idCategorie=" + p.idCategorieDAO + ";"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd); cmd.ExecuteNonQuery(); }
public static void insertCategorie(CategorieDAO p) { int id = getMaxIdCategorie() + 1; string query = "INSERT INTO categorie VALUES (\"" + id + "\",\"" + p.nomCategorieDAO + "\",\"" + p.descriptionCategorieDAO + "\");"; MySqlCommand cmd2 = new MySqlCommand(query, DALConnection.OpenConnection()); MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd2); cmd2.ExecuteNonQuery(); }
public static CategorieViewModel getCategorie(int idCategorie) { CategorieDAO cDAO = CategorieDAO.getCategorie(idCategorie); //int idProduit = cDAO.idProduitCategorie; //ProduitViewModel pro = ProduitORM.getProduit(idProduit); CategorieViewModel c = new CategorieViewModel(cDAO.idCategorieDAO, cDAO.nomCategorieDAO, cDAO.descriptionCategorieDAO); return(c); }
public static CategorieDAO getCategorie(int idCategorie) { string query = "SELECT * FROM Categorie WHERE id=" + idCategorie + ";"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); cmd.ExecuteNonQuery(); MySqlDataReader reader = cmd.ExecuteReader(); reader.Read(); CategorieDAO pers = new CategorieDAO(reader.GetInt32(0), reader.GetString(1), reader.GetString(2)); reader.Close(); return(pers); }
public static ObservableCollection <CategorieViewModel> listeCategories() { ObservableCollection <CategorieDAO> lDAO = CategorieDAO.listeCategories(); ObservableCollection <CategorieViewModel> l = new ObservableCollection <CategorieViewModel>(); foreach (CategorieDAO element in lDAO) { //int idProduit = element.idProduitCategorieDAO; //ProduitViewModel pro = ProduitORM.getProduit(idProduit); CategorieViewModel c = new CategorieViewModel(element.idCategorieDAO, element.nomCategorieDAO, element.descriptionCategorieDAO); l.Add(c); } return(l); }
public static void insertCategorie(CategorieDAO p) { CategorieDAL.insertCategorie(p); }
public static void updateCategorie(CategorieDAO p) { CategorieDAL.updateCategorie(p); }
public static CategorieDAO getCategorie(int idCategorie) { CategorieDAO p = CategorieDAL.getCategorie(idCategorie); return(p); }
public static void insertCategorie(CategorieViewModel c) { CategorieDAO.insertCategorie(new CategorieDAO(c.idCategorieProperty, c.nomCategorieProperty, c.descriptionCategorieProperty)); }
public static void supprimerCategorie(int id) { CategorieDAO.supprimerCategorie(id); }