public List <Jouet> jouetAge(int idTrancheAge) { List <Jouet> lesjouets = new List <Jouet>(); SqlConnection laConnection = seConnecter(); SqlCommand maCommande; string requete = "SELECT * FROM Jouet WHERE idTrancheage =" + age;; maCommande = new SqlCommand(requete, laConnection); SqlDataReader Listjouet = maCommande.ExecuteReader(); while (Listjouet.Read()) { string libelle = (string)Listjouet["libelle"]; Int32 prix = (int)Listjouet["id"]; int idcatego = (int)Listjouet["idCategorie"]; CategorieDAO uneCatgorie = new CategorieDAO(); string libelleCat = uneCatgorie.getLibelleCat(idcatego); TrancheageDAO uneTranche = new TrancheageDAO(); int ageMin = uneTranche.getAgeMin(idTrancheAge); int ageMax = uneTranche.getAgeMax(idTrancheAge); lesjouets.Add(new Jouet(libelle, prix, new Categorie(idcatego, libelleCat), new Trancheage(idTrancheAge, 10, 20))); } Listjouet.Close(); return(lesjouets); throw new NotImplementedException(); }
public Formaddjouet() { CategorieDAO cat = new CategorieDAO(); TrancheageDAO tranche = new TrancheageDAO(); InitializeComponent(); cbcat.DataSource = cat.findAll(); cbcat.DisplayMember = "info"; //cbcat.ValueMember = "Id"; cbtrancheage.DataSource = tranche.findAll(); cbtrancheage.DisplayMember = "info"; //cbtrancheage.ValueMember = "Code"; }
private void cmb_enfant_SelectedIndexChanged(object sender, EventArgs e) { int val; Int32.TryParse(cmb_enfant.SelectedValue.ToString(), out val); TrancheageDAO trancheAge = new TrancheageDAO(); List <Trancheage> listTrancheAge = trancheAge.findAll(); //System.Windows.Forms.MessageBox.Show(val.ToString()); EnfantDAO unEnfant = new EnfantDAO(); int age = Int32.Parse(unEnfant.getAge(val)); int idTrancheAge; foreach (Trancheage uneTrancheAge in listTrancheAge) { if (age > uneTrancheAge.getAgeMin() && age < uneTrancheAge.getAgeMin()) { idTrancheAge = uneTrancheAge.getCode(); } } }