public static ObservableCollection <AdresseDAO> selectAdresses() { ObservableCollection <AdresseDAO> l = new ObservableCollection <AdresseDAO>(); string query = "SELECT * FROM adresse;"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); MySqlDataReader reader = null; try { cmd.ExecuteNonQuery(); reader = cmd.ExecuteReader(); while (reader.Read()) { AdresseDAO p = new AdresseDAO(reader.GetInt32(0), reader.GetInt32(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5)); l.Add(p); } } catch (Exception e) { MessageBox.Show("Il y a un problème dans la table Adresse : {0}", e.StackTrace); } reader.Close(); return(l); }
public static void updateAdresse(AdresseDAO p) { string query = "UPDATE adresse set numero=\"" + p.numeroDAO + "\", rue=\"" + p.rueDAO + "\", ville=\"" + p.villeDAO + "\", codePostal=\"" + p.codePostalDAO + "\", pays=\"" + p.paysDAO + "\" where idAdresse=" + p.idAdresseDAO + ";"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd); cmd.ExecuteNonQuery(); }
public static void insertAdresse(AdresseDAO p) { int id = getMaxIdAdresse() + 1; string query = "INSERT INTO adresse VALUES (\"" + id + "\",\"" + p.numeroDAO + "\",\"" + p.rueDAO + "\",\"" + p.villeDAO + "\",\"" + p.codePostalDAO + "\",\"" + p.paysDAO + "\");"; MySqlCommand cmd2 = new MySqlCommand(query, DALConnection.OpenConnection()); MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd2); cmd2.ExecuteNonQuery(); }
public static AdresseViewModel getAdresse(int idAdresse) { AdresseDAO aDAO = AdresseDAO.getAdresse(idAdresse); AdresseViewModel a = new AdresseViewModel(aDAO.idAdresseDAO, aDAO.numeroDAO, aDAO.rueDAO, aDAO.villeDAO, aDAO.codePostalDAO, aDAO.paysDAO); return(a); }
public static AdresseDAO getAdresse(int idAdresse) { string query = "SELECT * FROM Adresse WHERE id=" + idAdresse + ";"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); cmd.ExecuteNonQuery(); MySqlDataReader reader = cmd.ExecuteReader(); reader.Read(); AdresseDAO pers = new AdresseDAO(reader.GetInt32(0), reader.GetInt32(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5)); reader.Close(); return(pers); }
public static ObservableCollection <AdresseViewModel> listeAdresses() { ObservableCollection <AdresseDAO> lDAO = AdresseDAO.listeAdresses(); ObservableCollection <AdresseViewModel> l = new ObservableCollection <AdresseViewModel>(); foreach (AdresseDAO element in lDAO) { AdresseViewModel a = new AdresseViewModel(element.idAdresseDAO, element.numeroDAO, element.rueDAO, element.villeDAO, element.codePostalDAO, element.paysDAO); l.Add(a); } return(l); }
public static void insertAdresse(AdresseDAO a) { AdresseDAL.insertAdresse(a); }
public static void updateAdresse(AdresseDAO a) { AdresseDAL.updateAdresse(a); }
public static AdresseDAO getAdresse(int idAdresse) { AdresseDAO p = AdresseDAL.getAdresse(idAdresse); return(p); }
public static void insertAdresse(AdresseViewModel a) { AdresseDAO.insertAdresse(new AdresseDAO(a.idAdresseProperty, a.numeroProperty, a.rueProperty, a.villeProperty, a.codePostalProperty, a.paysProperty)); }
public static void supprimerAdresse(int id) { AdresseDAO.supprimerAdresse(id); }