public List <C_Desideratas> Lire(string Index) { CreerCommande("SelectionnerDesideratasVoiture"); Commande.Parameters.AddWithValue("@Index", Index); Commande.Connection.Open(); SqlDataReader dr = Commande.ExecuteReader(); List <C_Desideratas> res = new List <C_Desideratas>(); while (dr.Read()) { C_Desideratas tmp = new C_Desideratas(); tmp.idDesiderata = int.Parse(dr["idDesiderata"].ToString()); tmp.idClient = int.Parse(dr["idClient"].ToString()); tmp.idMarque = int.Parse(dr["idMarque"].ToString()); if (dr["idModele"] != DBNull.Value) { tmp.idModele = int.Parse(dr["idModele"].ToString()); } if (dr["idCat"] != DBNull.Value) { tmp.idCat = int.Parse(dr["idCat"].ToString()); } if (dr["kilometrageMax"] != DBNull.Value) { tmp.kilometrageMax = int.Parse(dr["kilometrageMax"].ToString()); } if (dr["idCouleur"] != DBNull.Value) { tmp.idCouleur = int.Parse(dr["idCouleur"].ToString()); } if (dr["idCarburant"] != DBNull.Value) { tmp.idCarburant = int.Parse(dr["idCarburant"].ToString()); } if (dr["anneeMin"] != DBNull.Value) { tmp.anneeMin = int.Parse(dr["anneeMin"].ToString()); } res.Add(tmp); } dr.Close(); Commande.Connection.Close(); return(res); }
public C_Desideratas Lire_ID(int idDesiderata) { CreerCommande("SelectionnerDesideratasVoiture_ID"); Commande.Parameters.AddWithValue("@idDesiderata", idDesiderata); Commande.Connection.Open(); SqlDataReader dr = Commande.ExecuteReader(); C_Desideratas res = new C_Desideratas(); while (dr.Read()) { res.idDesiderata = int.Parse(dr["idDesiderata"].ToString()); res.idClient = int.Parse(dr["idClient"].ToString()); res.idMarque = int.Parse(dr["idMarque"].ToString()); if (dr["idModele"] != DBNull.Value) { res.idModele = int.Parse(dr["idModele"].ToString()); } if (dr["idCat"] != DBNull.Value) { res.idCat = int.Parse(dr["idCat"].ToString()); } if (dr["kilometrageMax"] != DBNull.Value) { res.kilometrageMax = int.Parse(dr["kilometrageMax"].ToString()); } if (dr["idCouleur"] != DBNull.Value) { res.idCouleur = int.Parse(dr["idCouleur"].ToString()); } if (dr["idCarburant"] != DBNull.Value) { res.idCarburant = int.Parse(dr["idCarburant"].ToString()); } if (dr["anneeMin"] != DBNull.Value) { res.anneeMin = int.Parse(dr["anneeMin"].ToString()); } } dr.Close(); Commande.Connection.Close(); return(res); }