Esempio n. 1
0
        public override TypeCours create(TypeCours obj)
        {
            AbstractDAOFactory factoSQL  = AbstractDAOFactory.getFactory(types.SQL_FACTORY);
            DAO <Categorie>    categorie = factoSQL.getCategorieDAO();


            if (obj.Id == -1)
            {
                obj.Id = OutilsSQL.getLastInsertedId("type_cours", Connexion.getInstance()) + 1;
            }

            using (SqlCommand command_c = new SqlCommand("INSERT INTO type_cours VALUES (" + obj.Id + ", '" + obj.Nom + "', '" + obj.Groupes + "');", Connexion.getInstance()))
            {
                command_c.ExecuteNonQuery();
                // Connexion.getInstance().Close();
            }



            //foreach (Categorie categ in categorie.findAll())
            //{
            //    int idT = OutilsSQL.getLastInsertedId("equivalent_td", Connexion.getInstance()) + 1;
            //    using (SqlCommand command_test = new SqlCommand("INSERT INTO equivalent_td VALUES (" + idT + ", '" + categ.Id + "', '" + obj.Id + "', 1 );", Connexion.getInstance()))
            //    {
            //        command_test.ExecuteNonQuery();
            //    }
            //}

            return(obj);
        }
Esempio n. 2
0
        public override List <TypeCours> findAll()

        {
            List <TypeCours> tps = new List <TypeCours>();


            using (SqlCommand command_f = new SqlCommand("SELECT * FROM type_cours;", Connexion.getInstance()))
            {
                using (SqlDataReader reader_f = command_f.ExecuteReader())
                {
                    if (reader_f.HasRows)
                    {
                        while (reader_f.Read())
                        {
                            tps.Add(new TypeCours(reader_f.GetInt32(0), reader_f.GetString(1), reader_f.GetInt32(2)));
                        }
                    }
                }
            }

            return(tps);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 public override void delete(PartieAnnee obj)
 {
     using (SqlCommand command_d = new SqlCommand("DELETE FROM partie_annee WHERE id=" + obj.Id + ";", Connexion.getInstance()))
     {
         command_d.ExecuteNonQuery();
     }
 }
Esempio n. 6
0
 public override void delete(EquivalentTD obj)
 {
     using (SqlCommand command = new SqlCommand("DELETE FROM equivalent_td WHERE id=" + obj.Id + ";", Connexion.getInstance()))
     {
         command.ExecuteNonQuery();
     }
     // Connexion.getInstance().Close();
 }
Esempio n. 7
0
        public override void delete(Categorie obj)
        {
            using (SqlCommand command_d = new SqlCommand("DELETE FROM categorie_enseignant WHERE id=" + obj.Id + ";", Connexion.getInstance()))

            {
                command_d.ExecuteNonQuery();
            }

            //Connexion.getInstance().Close();
        }
Esempio n. 8
0
        public override TypeCours find(string type)
        {
            Console.WriteLine("recherche type cours");
            TypeCours typeCours = null;

            using (SqlCommand command_f = new SqlCommand("SELECT id, nom, has_groups FROM type_cours WHERE nom='" + type + "';", Connexion.getInstance()))
            {
                using (SqlDataReader reader_f = command_f.ExecuteReader())
                {
                    if (reader_f.HasRows)
                    {
                        while (reader_f.Read())
                        {
                            typeCours = new TypeCours(reader_f.GetInt32(0), reader_f.GetString(1), reader_f.GetInt32(2));
                        }
                    }

                    reader_f.Close();
                }
                //Connexion.getInstance().Close();
                return(typeCours);
            }
        }
Esempio n. 9
0
        public override List <Categorie> findAll()
        {
            List <Categorie> categories = new List <Categorie>();


            using (SqlCommand command_f = new SqlCommand("SELECT * FROM categorie_enseignant;", Connexion.getInstance()))
            {
                using (SqlDataReader reader_f = command_f.ExecuteReader())

                {
                    if (reader_f.HasRows)
                    {
                        while (reader_f.Read())
                        {
                            categories.Add(new Categorie(reader_f.GetInt32(0), reader_f.GetString(1), reader_f.GetDouble(2)));
                        }
                    }
                }
            }

            return(categories);
        }
Esempio n. 10
0
        public override Categorie update(int idAupdate, Categorie update)
        {
            using (SqlCommand command_u = new SqlCommand(@"UPDATE categorie_enseignant SET nom='" + update.Nom + "', " +
                                                         "heures_a_travailler=" + update.Heures + " WHERE id=" + idAupdate + ";", Connexion.getInstance()))
            {
                command_u.ExecuteNonQuery();
            }

            // Connexion.getInstance().Close();
            return(update);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
            }
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        public override TypeCours update(int idAupdate, TypeCours update)
        {
            using (SqlCommand command_u = new SqlCommand(@"UPDATE type_cours SET nom='" + update.Nom + "', " +
                                                         "has_groups=" + update.Groupes + " WHERE id=" + idAupdate + ";", Connexion.getInstance()))
            {
                command_u.ExecuteNonQuery();
            }

            // Connexion.getInstance().Close();
            return(update);
        }
Esempio n. 15
0
        public override Categorie find(int id)
        {
            Categorie categorieEnseignant = null;



            using (SqlCommand command_f = new SqlCommand("SELECT nom, heures_a_travailler FROM categorie_enseignant WHERE id=" + id + ";", Connexion.getInstance()))
            {
                using (SqlDataReader reader_f = command_f.ExecuteReader())
                {
                    if (reader_f.HasRows)
                    {
                        while (reader_f.Read())
                        {
                            categorieEnseignant = new Categorie(id, reader_f.GetString(0), reader_f.GetDouble(1));


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

                    reader_f.Close();
                }
            }

            // Connexion.getInstance().Close();


            return(categorieEnseignant);
        }
Esempio n. 16
0
 public override void delete(TypeCours obj)
 {
     using (SqlCommand command_d = new SqlCommand("DELETE FROM type_cours WHERE id=" + obj.Id + ";", Connexion.getInstance()))
     {
         command_d.ExecuteNonQuery();
     }
     //Connexion.getInstance().Close();
 }
Esempio n. 17
0
        public override Categorie find(string nom)
        {
            Categorie categ = null;


            using (SqlCommand command_f = new SqlCommand("SELECT id, nom, heures_a_travailler FROM categorie_enseignant WHERE nom='" + nom + "';", Connexion.getInstance()))
            {
                using (SqlDataReader reader_f = command_f.ExecuteReader())
                {
                    if (reader_f.HasRows)
                    {
                        while (reader_f.Read())
                        {
                            categ = new Categorie(reader_f.GetInt32(0), reader_f.GetString(1),
                                                  reader_f.GetDouble(2));
                        }
                    }

                    reader_f.Close();
                }
                //Connexion.getInstance().Close();
                return(categ);
            }
        }
Esempio n. 18
0
        public override TypeCours find(int id)
        {
            TypeCours typeCours = null;

            using (SqlCommand command_f = new SqlCommand("SELECT id, nom, has_groups FROM type_cours WHERE id=" + id + ";", Connexion.getInstance()))
            {
                using (SqlDataReader reader_f = command_f.ExecuteReader())
                {
                    if (reader_f.HasRows)
                    {
                        while (reader_f.Read())
                        {
                            typeCours = new TypeCours(reader_f.GetInt32(0), reader_f.GetString(1), reader_f.GetInt32(2));

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

                    reader_f.Close();
                }
            }


            //Connexion.getInstance().Close();


            return(typeCours);
        }
Esempio n. 19
0
        public override PartieAnnee create(PartieAnnee obj)
        {
            if (obj.Id == -1)
            {
                obj.Id = OutilsSQL.getLastInsertedId("partie_annee", Connexion.getInstance()) + 1;
            }

            using (SqlCommand command_c = new SqlCommand("INSERT INTO partie_annee VALUES (" + obj.Id + ", '" + obj.Nom + "', " + obj.Annee.Id + ", '" + obj.Description + "');", Connexion.getInstance()))
            {
                command_c.ExecuteNonQuery();
            }

            return(obj);
        }