public override List <EquivalentTD> findAll() { List <EquivalentTD> eqtds = new List <EquivalentTD>(); using (SqlCommand command_f = new SqlCommand("SELECT * FROM equivalent_td;", 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 <Categorie> TPSQL = factoSQL.getCategorieDAO(); DAO <TypeCours> TPSQL2 = factoSQL.getTypeCoursDao(); Categorie categ = TPSQL.find(reader_f.GetInt32(1)); TypeCours tp = reader_f.IsDBNull(2) ? default(TypeCours) : TPSQL2.find(reader_f.GetInt32(2)); eqtds.Add(new EquivalentTD(reader_f.GetInt32(0), categ, tp, reader_f.GetDouble(3))); } } } } return(eqtds); }
public override PartieAnnee find(string nom) { PartieAnnee annee = null; using (SqlCommand command_f = new SqlCommand("SELECT id, nom, id_annee, description FROM partie_annee 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 <Annee> TPSQL = factoSQL.getAnneeDAO(); Annee annee2 = TPSQL.find(reader_f.GetInt32(2)); annee = new PartieAnnee(reader_f.GetInt32(0), reader_f.GetString(1), annee2, reader_f.GetString(3)); } } reader_f.Close(); } // Connexion.getInstance().Close(); return(annee); } }
public override List <PartieAnnee> findAll() { List <PartieAnnee> ans = new List <PartieAnnee>(); using (SqlCommand command_f = new SqlCommand("SELECT * FROM partie_annee;", 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 <Annee> TPSQL = factoSQL.getAnneeDAO(); Annee annee2 = TPSQL.find(reader_f.GetInt32(2)); ans.Add(new PartieAnnee(reader_f.GetInt32(0), reader_f.GetString(1), annee2, reader_f.GetString(3))); } } } } return(ans); }
public override PartieAnnee find(int id) { PartieAnnee annee = null; using (SqlCommand command_f = new SqlCommand("SELECT id, nom, id_annee, description FROM partie_annee 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 <Annee> TPSQL = factoSQL.getAnneeDAO(); Annee annee2 = TPSQL.find(reader_f.GetInt32(2)); annee = new PartieAnnee(reader_f.GetInt32(0), reader_f.GetString(1), annee2, reader_f.GetString(3)); reader_f.NextResult(); } } else { throw new Exception("Aucun objet avec cet id n'a été trouvé."); } reader_f.Close(); } } return(annee); }
public override EquivalentTD find(int id) { EquivalentTD eqtd = null; using (SqlCommand command_f = new SqlCommand("SELECT id, id_categorie_enseignant, id_type_cours, ratio_cours_td FROM equivalent_td 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 <Categorie> TPSQL = factoSQL.getCategorieDAO(); DAO <TypeCours> TPSQL2 = factoSQL.getTypeCoursDao(); Categorie categ = TPSQL.find(reader_f.GetInt32(1)); TypeCours tp = TPSQL2.find(reader_f.GetInt32(2)); eqtd = new EquivalentTD(reader_f.GetInt32(0), categ, tp, reader_f.GetDouble(3)); reader_f.NextResult(); } } else { throw new Exception("Aucun objet avec cet id n'a été trouvé."); } reader_f.Close(); } } //Connexion.getInstance().Close(); return(eqtd); }