Exemplo 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public override Categorie create(Categorie obj)
        {
            AbstractDAOFactory factoSQL  = AbstractDAOFactory.getFactory(types.SQL_FACTORY);
            DAO <Categorie>    categorie = factoSQL.getCategorieDAO();

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

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


            return(obj);
        }
Exemplo n.º 4
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);
        }