private Appelation reader2Appelation(IDataReader reader) { Appelation a = new Appelation(); a.Id = Convert.ToInt32(reader["IdAppelation"]); a.NomAppelation = reader["NomAppelation"].ToString(); return(a); }
public void Supprimer(Appelation a) { con.Open(); try { IDbCommand com = con.CreateCommand(); com.CommandText = "DELETE FROM Appelation WHERE IdAppelation=" + a.Id.ToString(); com.ExecuteNonQuery(); } finally { con.Close(); } }
public void Sauver(Appelation a) { con.Open(); try { IDbCommand com = con.CreateCommand(); com.CommandText = "UPDATE Appelation SETNomAppelation='" + a.NomAppelation + "' WHERE IdAppelation=" + a.Id.ToString(); com.ExecuteNonQuery(); } finally { con.Close(); } }
public void Relire(Appelation a) { con.Open(); try { IDbCommand com = con.CreateCommand(); com.CommandText = "SELECT * FROM Appelation WHERE IdAppelation=" + a.Id.ToString(); IDataReader reader = com.ExecuteReader(); if (reader.Read()) { a.NomAppelation = reader["NomAppelation"].ToString(); } } finally { con.Close(); } }
public void Créer(Appelation a) { try { IDbCommand com = con.CreateCommand(); com.CommandText = "INSERT INTO Appelation(NomAppelation) VALUES('" + a.NomAppelation + "');"; com.ExecuteNonQuery(); com.CommandText = "SELECT LAST_INSERT_ID() FROM Appelation;"; IDataReader reader = com.ExecuteReader(); int id = 1; if (reader.Read()) { id = Convert.ToInt32(reader[0]); } a.Id = id; } finally { con.Close(); } }
public Bouteilles Lister(Appelation a) { Bouteilles liste = new Bouteilles(); con.Open(); try { IDbCommand com = con.CreateCommand(); com.CommandText = "SELECT * FROM Bouteille WHERE IdAppelation=" + a.Id.ToString(); IDataReader reader = com.ExecuteReader(); while (reader.Read()) { Bouteille b = reader2Bouteille(reader); liste.Ajouter(b); } } finally { con.Close(); } return(liste); }
public Appelations Lister() { Appelations liste = new Appelations(); con.Open(); try { IDbCommand com = con.CreateCommand(); com.CommandText = "SELECT * FROM Appelation"; IDataReader reader = com.ExecuteReader(); while (reader.Read()) { Appelation a = reader2Appelation(reader); liste.Ajouter(a); } } finally { con.Close(); } return(liste); }
public Appelation Chercher(string nom) { Appelation a = null; con.Open(); try { IDbCommand com = con.CreateCommand(); com.CommandText = "SELECT * FROM Appelation WHERE NomAppelation='" + nom + "'"; IDataReader reader = com.ExecuteReader(); if (reader.Read()) { a = reader2Appelation(reader); } } finally { con.Close(); } return(a); }
public Appelation Chercher(int ID) { Appelation a = null; con.Open(); try { IDbCommand com = con.CreateCommand(); com.CommandText = "SELECT * FROM Appelation WHERE IdAppelation=" + ID.ToString(); IDataReader reader = com.ExecuteReader(); if (reader.Read()) { a = reader2Appelation(reader); } } finally { con.Close(); } return(a); }
private Bouteille reader2BouteilleRecherche(IDataReader reader) { Bouteille bouteille = new Bouteille(); bouteille.Texte = reader[1].ToString(); bouteille.Id = Convert.ToInt32(reader[0]); bouteille.PosX = Convert.ToInt32(reader[3]); bouteille.PosY = Convert.ToInt32(reader[4]); bouteille.Bue = Convert.ToBoolean(reader[2]); Casier c = new Casier(); c.Id = Convert.ToInt32(reader[5]); c.Nom = reader[16].ToString(); bouteille.Casier = c; Metier.Type t = new Metier.Type(); t.Id = Convert.ToInt32(reader[6]); t.NomType = reader[21].ToString(); bouteille.Type = t; try { Region r = new Region(); r.Id = Convert.ToInt32(reader[7]); r.NomRegion = reader[24].ToString(); bouteille.Region = r; } catch { } try { Pays p = new Pays(); p.Id = Convert.ToInt32(reader[8]); p.NomPays = reader[26].ToString(); bouteille.Pays = p; } catch { } try { Domaine d = new Domaine(); d.Id = Convert.ToInt32(reader[9]); d.NomDomaine = reader[28].ToString(); bouteille.Domaine = d; } catch { } try { Contenance co = new Contenance(); co.Id = Convert.ToInt32(reader[10]); co.Valeur = Convert.ToInt32(reader[30]); bouteille.Contenance = co; } catch { } try { Cru cr = new Cru(); cr.Id = Convert.ToInt32(reader[11]); cr.NomCru = reader[32].ToString(); bouteille.Cru = cr; } catch { } try { Millesime m = new Millesime(); m.Id = Convert.ToInt32(reader[12]); m.NomMillesime = reader[34].ToString(); bouteille.Millesime = m; } catch { } try { Type_vinification tv = new Type_vinification(); tv.Id = Convert.ToInt32(reader[13]); tv.NomVinif = reader[36].ToString(); bouteille.Type_vinification = tv; } catch { } try { Appelation a = new Appelation(); a.Id = Convert.ToInt32(reader[14]); a.NomAppelation = reader[38].ToString(); bouteille.Appelation = a; } catch { } return(bouteille); }