public StationAndDistance(Station station, double distanceStation) { this.station = station; this.distanceStation = distanceStation; }
internal Station getStationByID(string id_station) { Station station = null; DataSet ds = new DataSet(); MySqlConnection connection; try { ActionAdmin.logger.ecrireInfoLogger("Connection à la base : " + myConnectionString, activationReadStation); connection = new MySqlConnection(myConnectionString); MySqlCommand cmd; connection.Open(); cmd = connection.CreateCommand(); string requete = "Select station_id, station_adresse, station_cp, station_ville, station_tel, station_lat, station_long, station_id_enseigne, enseigne_marque, station_date_creation From station Join enseigne on enseigne.enseigne_id = station.station_id_enseigne where station_id = @station_id"; ActionAdmin.logger.ecrireInfoLogger("Execution de la requete : " + requete + " avec le parametre station_id = " + id_station, activationReadStation); cmd.CommandText = requete; cmd.Parameters.AddWithValue("@station_id", id_station); MySqlDataAdapter adap = new MySqlDataAdapter(cmd); adap.Fill(ds); foreach (DataRow dr in ds.Tables[0].Rows) { string address = dr["station_adresse"].ToString(); string city = dr["station_ville"].ToString(); string tel = dr["station_tel"].ToString(); string codePostal = dr["station_cp"].ToString(); float longitude = Single.Parse(dr["station_long"].ToString().Replace(".", ",")); float latitude = Single.Parse(dr["station_lat"].ToString().Replace(".", ",")); string id_enseigne = dr["station_id_enseigne"].ToString(); string enseigne_marque = dr["enseigne_marque"].ToString(); string dateCreation = dr["station_date_creation"].ToString(); station = new Station(id_station, null, address, city, codePostal, longitude, latitude, id_enseigne, enseigne_marque, tel, dateCreation); } if (connection.State == System.Data.ConnectionState.Open) { connection.Close(); } } catch (Exception e) { ActionAdmin.logger.ecrireInfoLogger("ERROR : " + e.StackTrace, true); return null; } return station; }