public static void updateCommune(CommuneDAO u) { string query = "UPDATE Commune set nom=\"" + u.nomCommuneDAO + "\", idDepartement=\"" + u.idDepartementDAO + "\" where idCommune=" + u.idCommuneDAO + ";"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.connection); MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd); cmd.ExecuteNonQuery(); }
public static CommuneViewModel getCommune(int idCommune) { CommuneDAO pDAO = CommuneDAO.getCommune(idCommune); int idDep = pDAO.idDepartementCommuneDAO; DepartementViewModel m = DepartementORM.getDepartement(idDep); CommuneViewModel p = new CommuneViewModel(pDAO.idCommuneDAO, pDAO.nomCommuneDAO, pDAO.codePostalDAO, m); return(p); }
public static void insertCommune(CommuneDAO u) { int id = getMaxIdCommune() + 1; string query = "INSERT INTO Commune VALUES (\"" + id + "\",\"" + u.nomCommuneDAO + "\",\"" + u.idDepartementDAO + "\");"; MySqlCommand cmd2 = new MySqlCommand(query, DALConnection.connection); MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd2); cmd2.ExecuteNonQuery(); }
public static CommuneViewModel getCommune(int idCommune) { CommuneDAO cDAO = CommuneDAO.getCommunes(idCommune); int idDepartement = cDAO.idDepartementDAO; DepartementViewModel m = DepartementORM.getDepartement(idDepartement); CommuneViewModel e = new CommuneViewModel(cDAO.idCommuneDAO, cDAO.nomCommuneDAO, m); return(e); }
public static void updateCommune(CommuneDAO p) { if (p.idCommuneDAO != 1) { string query = "UPDATE commune set nom=\"" + p.nomCommuneDAO + "\", idDepartement=\"" + p.idDepartementCommuneDAO + "\" where idCommune=" + p.idCommuneDAO + ";"; MySqlCommand cmd = new MySqlCommand(query, ConnexionBaseDAL.connection); MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd); cmd.ExecuteNonQuery(); } }
public static void insertCommune(CommuneDAO c) { string query = "INSERT INTO commune (nom,codePostal,idDepartement) VALUES (@nomCommune,@codePostal,@idDepartement);"; MySqlCommand cmd1 = new MySqlCommand(query, DALConnection.OpenConnection()); cmd1.Parameters.AddWithValue("@nomCommune", c.nomCommuneDAO); cmd1.Parameters.AddWithValue("@codePostal", c.codePostalDAO); cmd1.Parameters.AddWithValue("@idDepartement", c.idDepartementCommuneDAO); MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd1); cmd1.ExecuteNonQuery(); }
public static void updateCommune(CommuneDAO p) { string query = "UPDATE Commune set Nom=@NomCommune,CodePostale=@CodePostale where idCommune=@IdCommune;"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); cmd.Parameters.AddWithValue("@NomCommune", p.nomCommuneDAO); cmd.Parameters.AddWithValue("@CodePostale", p.CodePostaleDAO); cmd.Parameters.AddWithValue("@IdCommune", p.idCommuneDAO); MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd); cmd.ExecuteNonQuery(); }
public static void updateCommune(CommuneDAO c) { string query = "UPDATE Departement set nom=@nomDepartement NumeroDepartement=@numeroDepartement where idCommune=@idCommune;"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); cmd.Parameters.AddWithValue("@nomDepartement", c.nomCommuneDAO); cmd.Parameters.AddWithValue("@numeroDepartement", c.codePostalDAO); cmd.Parameters.AddWithValue("@idCommune", c.idCommuneDAO); MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd); cmd.ExecuteNonQuery(); }
public static ObservableCollection <CommuneViewModel> listeCommuneDepartement(DepartementViewModel departement) { ObservableCollection <CommuneDAO> lDAO = CommuneDAO.listeCommuneDepartement(departement.idDepartementProperty); ObservableCollection <CommuneViewModel> l = new ObservableCollection <CommuneViewModel>(); foreach (CommuneDAO element in lDAO) { int idDep = element.idDepartementCommuneDAO; CommuneViewModel p = new CommuneViewModel(element.idCommuneDAO, element.nomCommuneDAO, element.codePostalDAO, departement); l.Add(p); } return(l); }
public static ObservableCollection <CommuneViewModel> listeCommune() { ObservableCollection <CommuneDAO> lDAO = CommuneDAO.listeCommune(); ObservableCollection <CommuneViewModel> l = new ObservableCollection <CommuneViewModel>(); foreach (CommuneDAO element in lDAO) { int idDep = element.idDepartementCommuneDAO; DepartementViewModel m = DepartementORM.getDepartement(idDep); CommuneViewModel p = new CommuneViewModel(element.idCommuneDAO, element.nomCommuneDAO, element.codePostalDAO, m); l.Add(p); } return(l); }
public static void insertCommune(CommuneDAO p) { int id = getMaxIdCommune() + 1; string query = "INSERT INTO Commune VALUES (@ID,@NomCommune,@CodePostale,@IdCommune);"; MySqlCommand cmd2 = new MySqlCommand(query, DALConnection.OpenConnection()); cmd2.Parameters.AddWithValue("@ID", id); cmd2.Parameters.AddWithValue("@NomCommune", p.nomCommuneDAO); cmd2.Parameters.AddWithValue("@CodePostale", p.CodePostaleDAO); cmd2.Parameters.AddWithValue("@IdCommune", p.idCommuneDAO); MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd2); cmd2.ExecuteNonQuery(); }
public static CommuneDAO getCommune(int idCommune) { string query = "SELECT * FROM commune WHERE idCommune=" + idCommune + ";"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); cmd.ExecuteNonQuery(); MySqlDataReader reader = cmd.ExecuteReader(); reader.Read(); CommuneDAO commune = new CommuneDAO(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetInt32(3)); reader.Close(); return(commune); }
public static ObservableCollection <CommuneViewModel> listeCommunes() { ObservableCollection <CommuneDAO> lDAO = CommuneDAO.listeCommunes(); ObservableCollection <CommuneViewModel> l = new ObservableCollection <CommuneViewModel>(); foreach (CommuneDAO element in lDAO) { int idDepartement = element.idDepartementDAO; DepartementViewModel m = DepartementORM.getDepartement(idDepartement); // Plus propre que d'aller chercher le departement dans la DAO. CommuneViewModel e = new CommuneViewModel(element.idCommuneDAO, element.nomCommuneDAO, m); l.Add(e); } return(l); }
public static ObservableCollection <CommuneDAO> selectCommunes() { ObservableCollection <CommuneDAO> l = new ObservableCollection <CommuneDAO>(); string query = "SELECT * FROM Commune;"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.connection); cmd.ExecuteNonQuery(); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { CommuneDAO u = new CommuneDAO(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2)); l.Add(u); } reader.Close(); return(l); }
public static ObservableCollection <CommuneDAO> selectCommuneDepartement(int idDepartement) { ObservableCollection <CommuneDAO> l = new ObservableCollection <CommuneDAO>(); string query = "SELECT * FROM commune WHERE idDepartement=@idDepartement;"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); cmd.Parameters.AddWithValue("@idDepartement", idDepartement); cmd.ExecuteNonQuery(); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { CommuneDAO c = new CommuneDAO(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetInt32(3)); l.Add(c); } reader.Close(); return(l); }
public static CommuneDAO getCommune(int idCommune) { string query = "SELECT * FROM Commune WHERE idCommune=" + idCommune + ";"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.connection); cmd.ExecuteNonQuery(); MySqlDataReader reader = cmd.ExecuteReader(); reader.Read(); CommuneDAO com; if (reader.HasRows) { com = new CommuneDAO(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2)); } else { com = new CommuneDAO(1, "Mauvais Num Commune", 1); } reader.Close(); return(com); }
public static CommuneDAO getCommune(int idCommune) { string query = "SELECT * FROM commune WHERE idCommune=@IDCommune;"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); cmd.Parameters.AddWithValue("@IDCommune", idCommune); cmd.ExecuteNonQuery(); MySqlDataReader reader = cmd.ExecuteReader(); reader.Read(); CommuneDAO com; if (reader.HasRows) { com = new CommuneDAO(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetInt32(3)); } else { com = new CommuneDAO(1, "Mauvais Num Commune", "Mauvais Code Postale", 1); } reader.Close(); return(com); }
public static ObservableCollection <PlageViewModel> listePlages() { ObservableCollection <PlageDAO> lDAO = PlageDAO.listePlages(); ObservableCollection <PlageViewModel> l = new ObservableCollection <PlageViewModel>(); foreach (PlageDAO element in lDAO) { int idPrelevement = element.prelevement_idprelevementDAO; int idVille = element.Ville_idVilleDAO; int iDepartement = element.Departement_idDepartementDAO; PrelevementDAO m = PrelevementDAO.getPrelevement(idPrelevement); CommuneDAO c = CommuneDAO.getCommune(idVille); DepartementDAO d = DepartementDAO.getDepartement(iDepartement); PrelevementViewModel prelevement = new PrelevementViewModel(m.idprelevementDAO, m.PositionGPSDAO, m.TypeDAO); CommuneViewModel commune = new CommuneViewModel(c.idVilleDAO, c.nomSpecialisteDAO, c.nomVilleDAO); DepartementViewModel departement = new DepartementViewModel(d.idDepartementDAO, d.nomDAO); PlageViewModel p = new PlageViewModel(element.idPlageDAO, element.nomDAO, commune, prelevement, departement); l.Add(p); } return(l); }
public static ObservableCollection <CommuneDAO> selectCommunes() { ObservableCollection <CommuneDAO> l = new ObservableCollection <CommuneDAO>(); string query = "SELECT * FROM Commune;"; MySqlCommand cmd = new MySqlCommand(query, DALConnection.OpenConnection()); try { cmd.ExecuteNonQuery(); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { CommuneDAO p = new CommuneDAO(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetInt32(3)); l.Add(p); } reader.Close(); } catch (Exception e) { MessageBox.Show("La base de données n'est pas connectée"); } return(l); }
public static void insertCommune(CommuneViewModel p) { CommuneDAO.insertCommune(new CommuneDAO(p.idCommuneProperty, p.nomCommuneProperty, p.departementCommune.idDepartementProperty)); }
public static void supprimerCommune(int id) { CommuneDAO.supprimerCommune(id); }
public static void insertCommune(CommuneViewModel d) { CommuneDAO.insertCommune(new CommuneDAO(d.idCommuneProperty, d.nomCommuneProperty, d.codePostalProperty, d.departementProperty.idDepartementProperty)); }