Esempio n. 1
0
        public override InfosAssignation find(string nom)
        {
            InfosAssignation IA = null;

            using (SqlCommand command_f = new SqlCommand("SELECT id, nom, id_ec, id_typecours, id_enseignant, nb_heures FROM infos_assignation WHERE nom='" + nom + "';", Connexion.getInstance()))
            {
                using (SqlDataReader reader_f = command_f.ExecuteReader())
                {
                    if (reader_f.HasRows)
                    {
                        while (reader_f.Read())
                        {
                            AbstractDAOFactory factoSQL = AbstractDAOFactory.getFactory(types.SQL_FACTORY);
                            DAO <EC>           TPSQLEC  = factoSQL.getECDAO();
                            DAO <TypeCours>    TPSQLTP  = factoSQL.getTypeCoursDao();
                            DAO <Enseignant>   TPSQLEns = factoSQL.getEnseignantDAO();

                            EC         ec  = TPSQLEC.find(reader_f.GetInt32(2));
                            TypeCours  tp  = TPSQLTP.find(reader_f.GetInt32(3));
                            Enseignant ens = TPSQLEns.find(reader_f.GetInt32(4));

                            IA = new InfosAssignation(reader_f.GetInt32(0), reader_f.GetString(1), ec, tp, ens, reader_f.GetDouble(5));
                        }
                    }

                    reader_f.Close();
                }
                // Connexion.getInstance().Close();
                return(IA);
            }
        }
Esempio n. 2
0
        public override List <InfosAssignation> findAll()
        {
            List <InfosAssignation> IAs = new List <InfosAssignation>();


            using (SqlCommand command_f = new SqlCommand("SELECT * FROM infos_assignation;", Connexion.getInstance()))
            {
                using (SqlDataReader reader_f = command_f.ExecuteReader())
                {
                    if (reader_f.HasRows)
                    {
                        while (reader_f.Read())
                        {
                            AbstractDAOFactory factoSQL = AbstractDAOFactory.getFactory(types.SQL_FACTORY);
                            DAO <EC>           TPSQLEC  = factoSQL.getECDAO();
                            DAO <TypeCours>    TPSQLTP  = factoSQL.getTypeCoursDao();
                            DAO <Enseignant>   TPSQLEns = factoSQL.getEnseignantDAO();

                            EC         ec  = TPSQLEC.find(reader_f.GetInt32(2));
                            TypeCours  tp  = reader_f.IsDBNull(3) ? default(TypeCours) : TPSQLTP.find(reader_f.GetInt32(3));
                            Enseignant ens = reader_f.IsDBNull(4) ? default(Enseignant) : TPSQLEns.find(reader_f.GetInt32(4));


                            IAs.Add(new InfosAssignation(reader_f.GetInt32(0), reader_f.GetString(1), ec, tp, ens, reader_f.GetDouble(5)));
                        }
                    }
                }
            }

            return(IAs);
        }
Esempio n. 3
0
        public override InfosAssignation find(int id)
        {
            InfosAssignation IA = null;

            using (SqlCommand command_f = new SqlCommand("SELECT id, nom, id_ec, id_typecours, id_enseignant, nb_heures FROM infos_assignation WHERE id=" + id + ";", Connexion.getInstance()))
            {
                using (SqlDataReader reader_f = command_f.ExecuteReader())
                {
                    if (reader_f.HasRows)
                    {
                        while (reader_f.Read())
                        {
                            AbstractDAOFactory factoSQL = AbstractDAOFactory.getFactory(types.SQL_FACTORY);
                            DAO <EC>           TPSQLEC  = factoSQL.getECDAO();
                            DAO <TypeCours>    TPSQLTP  = factoSQL.getTypeCoursDao();
                            DAO <Enseignant>   TPSQLEns = factoSQL.getEnseignantDAO();

                            EC         ec  = TPSQLEC.find(reader_f.GetInt32(2));
                            TypeCours  tp  = TPSQLTP.find(reader_f.GetInt32(3));
                            Enseignant ens = TPSQLEns.find(reader_f.GetInt32(4));

                            IA = new InfosAssignation(reader_f.GetInt32(0), reader_f.GetString(1), ec, tp, ens, reader_f.GetDouble(5));

                            reader_f.NextResult();
                        }
                    }
                    else
                    {
                        throw new Exception("Aucun objet avec cet id n'a été trouvé.");
                    }

                    reader_f.Close();
                }
            }
            return(IA);
        }