// public int ModifierNuancier(Nuancier nuancier, int ID_nuancier) { try { connexion.Open(); string requete = "UPDATE `ref_nuancier` SET `teinte`='" + nuancier.teinte + "',`numero`='" + nuancier.numero + "',`coefficient`='" + nuancier.coefficient + "',`gamme`='" + nuancier.gamme + "',`plus_value`='" + nuancier.plus_value + "' WHERE ID_nuancier = '" + ID_nuancier + "'"; MySqlCommand cmd = new MySqlCommand(requete, connexion); int Result = cmd.ExecuteNonQuery(); return(Result); } catch (Exception ex) { throw new Exception(ex.Message); } }
// public int AjouterNuancier(Nuancier nuancier) { try { connexion.Open(); string requete = "INSERT INTO `ref_nuancier`(`teinte`, `numero`, `coefficient`, `gamme`, `plus_value`) VALUES ('" + nuancier.teinte + "','" + nuancier.numero + "','" + nuancier.coefficient + "','" + nuancier.gamme + "','" + nuancier.plus_value + "')"; // MySqlCommand cmd = new MySqlCommand(requete, connexion); int Result = cmd.ExecuteNonQuery(); return(Result); } catch (Exception ex) { throw new Exception(ex.Message); } }
/* ----- Partie Nuancier ----- */ public List <Nuancier> ChercheNuancier(string Teinte) { try { connexion.Open(); string requete = "SELECT * FROM `ref_nuancier` WHERE teinte LIKE '" + Teinte + "%' ORDER BY gamme DESC,teinte"; MySqlCommand cmd = new MySqlCommand(requete, connexion); MySqlDataReader reader = cmd.ExecuteReader(); List <Nuancier> ListNuanciers = new List <Nuancier>(); while (reader.Read()) { Nuancier nuancier = new Nuancier(reader["ID_nuancier"].ToString(), reader["teinte"].ToString(), reader["numero"].ToString(), reader["coefficient"].ToString(), reader["gamme"].ToString(), reader["plus_value"].ToString()); ListNuanciers.Add(nuancier); } return(ListNuanciers); } catch (Exception ex) { throw new Exception(ex.Message); } }