Пример #1
0
        public static Jouet getLeJouet(int idEnfant)
        {
            seConnecter();
            Jouet      unJouet = null;
            SqlCommand maCommande;
            string     requete = "select j.id, j.libelle, idCategorie, idTrancheAge, c.libelle as cLibelle, ageMin  "
                                 + "from jouet j join enfant e on j.id = e.idJouet "
                                 + "join categorie c on c.id = j.idCategorie join trancheAge ta on ta.id = j.idTrancheAge  "
                                 + "where e.id = " + idEnfant;

            maCommande = new SqlCommand(requete, laConnexion);
            SqlDataReader Resultat = maCommande.ExecuteReader();

            while (Resultat.Read())
            {
                int    id           = (int)Resultat["id"];
                string libelle      = (string)Resultat["libelle"];
                int    idCat        = (int)Resultat["idCategorie"];
                int    idTrancheAge = (int)Resultat["idTrancheAge"];
                string cLibelle     = (string)Resultat["cLibelle"];
                int    ageMin       = (int)Resultat["ageMin"];

                Categorie  uneCat = new Categorie(idCat, cLibelle);
                TrancheAge uneTA  = new TrancheAge(idTrancheAge, ageMin);
                unJouet = new Jouet(id, libelle, uneCat, uneTA);
            }
            Resultat.Close();
            seDeconnecter();

            return(unJouet);
        }
Пример #2
0
        public static List <Jouet> ToutLesJouetsCommande()
        {
            seConnecter();
            List <Jouet> pJouetList;

            pJouetList = new List <Jouet>();
            SqlCommand maCommande;
            string     requeteIdentifiant = "SELECT J.id , J.libelle , J.idCategorie , J.idTrancheAge , C.libelle AS libelleC , T.ageMin , COUNT(E.idJouet) AS nbCom FROM Jouet J JOIN Categorie C ON (J.idCategorie = C.id) JOIN TrancheAge T ON (J.idTrancheAge=T.id) JOIN Enfant E ON (E.idJouet=J.id) GROUP BY E.idJouet,J.id , J.libelle , J.idCategorie , J.idTrancheAge , C.libelle , T.ageMin HAVING J.id <> 12"; // recupere les informations

            maCommande = new SqlCommand(requeteIdentifiant, laConnexion);
            SqlDataReader Resultat = maCommande.ExecuteReader();

            while (Resultat.Read()) //Parcours le resultat
            {
                int    pId       = (int)Resultat["id"];
                string pLibelle  = (string)Resultat["libelle"];
                int    pIdC      = (int)Resultat["idCategorie"];
                int    pIdT      = (int)Resultat["idTrancheAge"];
                string pLibelleC = (string)Resultat["libelleC"];
                int    pAgeMin   = (int)Resultat["ageMin"];
                int    pQtte     = (int)Resultat["nbCom"];

                Categorie  uneCategorie = new Categorie(pIdC, pLibelleC);
                TrancheAge uneTrancheA  = new TrancheAge(pIdT, pAgeMin);
                Jouet      unJouet      = new Jouet(pId, pLibelle, uneCategorie, uneTrancheA, pQtte);
                pJouetList.Add(unJouet);
            }
            Resultat.Close();
            return(pJouetList);
        }
Пример #3
0
        public static List <Jouet> ToutLesJouets(int pAge)
        {
            seConnecter();
            List <Jouet> JouetList = new List <Jouet>();
            SqlCommand   maCommande;
            string       requeteIdentifiant = "SELECT DISTINCT J.id , J.libelle , J.idCategorie , J.idTrancheAge , C.libelle as cLibelle , T.ageMin " +
                                              "FROM Jouet J LEFT JOIN Categorie C " +
                                              "ON (J.idCategorie = C.id) LEFT JOIN TrancheAge T " +
                                              "ON (J.idTrancheAge=T.id) LEFT JOIN Enfant E " +
                                              "ON (E.idJouet = J.id) " +
                                              "WHERE T.ageMin <= " + pAge;

            maCommande = new SqlCommand(requeteIdentifiant, laConnexion);
            SqlDataReader Resultat = maCommande.ExecuteReader();

            while (Resultat.Read()) //Parcours le resultat
            {
                int    pId       = (int)Resultat["id"];
                string pLibelle  = (string)Resultat["libelle"];
                int    pIdC      = (int)Resultat["idCategorie"];
                int    pIdT      = (int)Resultat["idTrancheAge"];
                string pLibelleC = (string)Resultat["cLibelle"];
                int    pAgeMin   = (int)Resultat["ageMin"];

                Categorie  uneCategorie = new Categorie(pIdC, pLibelleC);
                TrancheAge uneTrancheA  = new TrancheAge(pIdT, pAgeMin);
                Jouet      unJouet      = new Jouet(pId, pLibelle, uneCategorie, uneTrancheA);
                JouetList.Add(unJouet);
            }
            Resultat.Close();
            return(JouetList);
        }
Пример #4
0
        private void cb_enfant_SelectedIndexChanged(object sender, EventArgs e)
        {
            Enfant unEnfant = (Enfant)cb_enfant.SelectedItem;

            Jouet unJouet = Passerelle.getLeJouet(unEnfant.getId());

            lbl_jouetCorrespondant.Text = unJouet.getLibelle();
        }
Пример #5
0
 //construct
 public Enfant(int id, string nom, string prenom, int age, Personne unEmploye, Jouet unJouet)
 {
     this.id        = id;
     this.nom       = nom;
     this.prenom    = prenom;
     this.age       = age;
     this.unEmploye = unEmploye;
     this.unJouet   = unJouet;
 }
Пример #6
0
        private void Form_Choix_Enfants_Load(object sender, EventArgs e)
        {
            int idEmp = Passerelle.recupIdEmploye(unLogin, unMdp);

            cb_enfant.DataSource    = Passerelle.EnfantsDeEmploye(idEmp);
            cb_enfant.DisplayMember = "Infos";
            cb_enfant.ValueMember   = "Id";
            Enfant unEnfant = (Enfant)cb_enfant.SelectedItem;

            Jouet unJouet = Passerelle.getLeJouet(unEnfant.getId());

            lbl_jouetCorrespondant.Text = unJouet.getLibelle();
        }
Пример #7
0
 public void setUnJouet(Jouet jouet)
 {
     this.unJouet = jouet;
 }
Пример #8
0
        public static List <Enfant> EnfantsDeEmploye(int idEmploye)
        {
            seConnecter();
            List <Enfant> lesEnfants = new List <Enfant>();
            SqlCommand    maCommande;
            string        requeteIdentifiant = "SELECT E.id, E.nom, E.prenom ,E.age, E.idJouet, E.idEmploye, "                                                          //enfant
                                               + "P.nom as empNom, P.prenom as empPrenom, P.numAdr, P.rue, P.ville, P.cp, P.mail, P.mdp, P.estResponsable, P.aValide, " //employé
                                               + "J.libelle, J.idCategorie, J.idTrancheAge, "                                                                           //jouet
                                               + "T.ageMin, "                                                                                                           //tranche age
                                               + "C.libelle "                                                                                                           //catégorie
                                               + "FROM Enfant E JOIN Employe P ON (E.idEmploye=P.id) JOIN Jouet J ON(E.idJouet=J.id) "
                                               + "JOIN Categorie C on C.id = J.idCategorie JOIN TrancheAge T on T.id = J.idTrancheAge "
                                               + "WHERE idEmploye =" + idEmploye; // recupere les informations

            maCommande = new SqlCommand(requeteIdentifiant, laConnexion);
            SqlDataReader Resultat = maCommande.ExecuteReader();

            while (Resultat.Read()) //Parcours le resultat
            {
                //données enfant
                int    pIdE    = (int)Resultat["id"];
                string pNom    = (string)Resultat["nom"];
                string pPrenom = (string)Resultat["prenom"];
                int    pAge    = (int)Resultat["age"];
                int    pIdJ    = (int)Resultat["idJouet"];
                int    pIdEm   = (int)Resultat["idEmploye"];

                //données employé
                string pNomEm     = (string)Resultat["empNom"];
                string pPrenomEm  = (string)Resultat["empPrenom"];
                string pnumAdre   = (string)Resultat["numAdr"];
                string pRue       = (string)Resultat["rue"];
                string pVille     = (string)Resultat["ville"];
                string pCp        = (string)Resultat["cp"];
                string pMail      = (string)Resultat["mail"];
                string pMdp       = (string)Resultat["mdp"];
                bool   pEstRes    = (bool)Resultat["estResponsable"];
                bool   pEstValide = (bool)Resultat["aValide"];

                //données jouet
                string pLibelleJ     = (string)Resultat["libelle"];
                int    pIdCat        = (int)Resultat["idCategorie"];
                int    pIdTrancheAge = (int)Resultat["idTrancheAge"];

                //données tranche age
                int pAgeMin = (int)Resultat["ageMin"];

                //données catégorie
                string pLibelleCat = (string)Resultat["libelle"];

                Personne   unePersonne   = new Personne(pIdEm, pNomEm, pPrenomEm, pnumAdre, pRue, pVille, pCp, pMail, pMdp, pEstRes, pEstValide);
                Categorie  uneCat        = new Categorie(pIdCat, pLibelleCat);
                TrancheAge uneTrancheAge = new TrancheAge(pIdTrancheAge, pAgeMin);
                Jouet      unJouet       = new Jouet(pIdJ, pLibelleJ, uneCat, uneTrancheAge);
                Enfant     unEnfant      = new Enfant(pIdE, pNom, pPrenom, pAge, unePersonne, unJouet);

                lesEnfants.Add(unEnfant);
            }
            Resultat.Close();

            return(lesEnfants);
        }