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); } }
public override List <EnseignementEnseignant> findAll() { List <EnseignementEnseignant> enss = new List <EnseignementEnseignant>(); using (SqlCommand command_f = new SqlCommand("SELECT * FROM enseignement_enseignant;", 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 <Enseignement> TPSQL = factoSQL.getEnseignementDAO(); DAO <Enseignant> TPSQL2 = factoSQL.getEnseignantDAO(); Enseignement ensfacto = TPSQL.find(reader_f.GetInt32(1)); Enseignant ensfacto2 = TPSQL2.find(reader_f.GetInt32(2)); enss.Add(new EnseignementEnseignant(reader_f.GetInt32(0), ensfacto, ensfacto2)); } } } } return(enss); }
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); }
public override EnseignementEnseignant find(int id) { EnseignementEnseignant ens = null; using (SqlCommand command_f = new SqlCommand("SELECT id, id_enseignement, id_enseignant FROM enseignement_enseignant 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 <Enseignement> TPSQL = factoSQL.getEnseignementDAO(); DAO <Enseignant> TPSQL2 = factoSQL.getEnseignantDAO(); Enseignement ensfacto = TPSQL.find(reader_f.GetInt32(1)); Enseignant ensfacto2 = TPSQL2.find(reader_f.GetInt32(2)); ens = new EnseignementEnseignant(reader_f.GetInt32(0), ensfacto, ensfacto2); reader_f.NextResult(); } } else { throw new Exception("Aucun objet avec cet id n'a été trouvé."); } reader_f.Close(); } } return(ens); }
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); }