예제 #1
0
        private void Add_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (nodeSelectionne == null)
            {
                Annee nouvelleAnne = new Annee {
                    Nom = "Nouvelle annee", Departement = depart.find(departementSelectionne.Id), NavigationDestination = typeof(AnneeVue), Description = ""
                };
                annee.create(nouvelleAnne);
                annees.Add(nouvelleAnne);
            }
            else if (nodeSelectionne.GetType() == typeof(Annee))
            {
                PartieAnnee nouvellePartieAnnee = new PartieAnnee {
                    Nom = "Nouveau semestre", Annee = (Annee)nodeSelectionne, NavigationDestination = typeof(PartieAnneeVue), Description = "", Parent = nodeSelectionne
                };
                partieAnnee.create(nouvellePartieAnnee);
                nodeSelectionne.Children.Add(nouvellePartieAnnee);
            }
            else if (nodeSelectionne.GetType() == typeof(PartieAnnee))
            {
                Enseignement nouvelEnseignement = new Enseignement {
                    Nom = "Nouveau enseignement", PartieAnnee = (PartieAnnee)nodeSelectionne, NavigationDestination = typeof(EnseignementVue), Description = "", Parent = nodeSelectionne
                };
                enseignement.create(nouvelEnseignement);
                nodeSelectionne.Children.Add(nouvelEnseignement);
            }

            // nodeSelectionne.Nom = "fffsdfds";
        }
        public static List <ElementConstitutif> findByUniteEnseignement(long id)
        {
            MySqlConnection _connection = ConnectionMySql.getInstance();

            MySqlCommand _cmd = new MySqlCommand();

            _cmd.Connection = _connection;

            String          sql    = "";
            MySqlDataReader reader = null;

            List <ElementConstitutif> resultats = new List <ElementConstitutif>();

            try
            {
                sql = "SELECT element_constitutif.id as elemConstID, element_constitutif.libelle as elemConstLibelle, "
                      + "unite_enseignement.id as uniteEnsID, unite_enseignement.libelle as uniteEnsLibelle, "
                      + "periode.id AS periodeID, periode.libelle AS periodeLibelle, "
                      + "annee.id AS anneeId, annee.libelle AS anneeLibelle, "
                      + "diplome.id AS diplomeID, diplome.libelle AS diplomeLibelle "
                      + "FROM element_constitutif "
                      + "JOIN unite_enseignement on element_constitutif.ue_id = unite_enseignement.id "
                      + "JOIN periode ON unite_enseignement.periode_id = periode.id "
                      + "JOIN annee ON periode.annee_id = annee.id "
                      + "JOIN diplome ON annee.diplome_id = diplome.id "
                      + "WHERE unite_enseignement.id = @id";

                _cmd.CommandText = sql;

                _cmd.Parameters.AddWithValue("@id", id);
                reader = _cmd.ExecuteReader();

                while (reader.Read())
                {
                    Diplome tempDiplome = DiplomeDAO.populateDiplome(reader);

                    Annee tempAnnee = AnneeDAO.populateAnnee(reader);
                    tempAnnee.diplome = tempDiplome;

                    Periode tempPeriode = PeriodeDAO.populatePeriode(reader);
                    tempPeriode.annee = tempAnnee;

                    UniteEnseignement tempUnite = UniteEnseignementDAO.populateUniteEnseignement(reader);
                    tempUnite.periode = tempPeriode;

                    ElementConstitutif tempElementConstitutif = populateElementConstitutif(reader);
                    tempElementConstitutif.uniteEnseignement = tempUnite;

                    resultats.Add(tempElementConstitutif);
                }
                reader.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception : " + e);
            }
            _cmd.Dispose();

            return(resultats);
        }
예제 #3
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);
            }
        }
예제 #4
0
        public static Annee update(Annee obj)
        {
            MySqlConnection _connection = ConnectionMySql.getInstance();

            MySqlCommand _cmd = new MySqlCommand();

            _cmd.Connection = _connection;

            String sql = "";

            try
            {
                sql = "UPDATE annee set libelle = @libelle, diplome_id = @diplome_id WHERE id = @id";
                _cmd.CommandText = sql;

                _cmd.Parameters.AddWithValue("@id", obj.id);
                _cmd.Parameters.AddWithValue("@libelle", obj.libelle);
                _cmd.Parameters.AddWithValue("@diplome_id", obj.diplome.id);

                _cmd.ExecuteNonQuery();

                obj.id = _cmd.LastInsertedId;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception : " + e);
            }

            _cmd.Dispose();

            return(obj);
        }
예제 #5
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);
        }
예제 #6
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);
        }
예제 #7
0
 public InputModifPeriodeForm(String name, Annee a)
 {
     input     = true;
     this.Text = name;
     this.a    = a;
     InitializeComponent();
 }
예제 #8
0
        public static void delete(Annee obj)
        {
            MySqlConnection _connection = ConnectionMySql.getInstance();

            MySqlCommand _cmd = new MySqlCommand();

            _cmd.Connection = _connection;

            String sql = "";

            try
            {
                sql = "DELETE FROM annee WHERE id = @id";
                _cmd.CommandText = sql;

                _cmd.Parameters.AddWithValue("@id", obj.id);

                _cmd.ExecuteNonQuery();

                obj.id = _cmd.LastInsertedId;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception : " + e);
            }
            _cmd.Dispose();
        }
예제 #9
0
        public static Annee create(Annee obj)
        {
            MySqlConnection _connection = ConnectionMySql.getInstance();

            MySqlCommand _cmd = new MySqlCommand();

            _cmd.Connection = _connection;

            String sql = "";

            try
            {
                sql = "INSERT INTO annee (id, libelle, diplome_id) VALUES (@id,@libelle,@diplome) ";
                _cmd.CommandText = sql;

                _cmd.Parameters.AddWithValue("@id", obj.id);
                _cmd.Parameters.AddWithValue("@libelle", obj.libelle);
                _cmd.Parameters.AddWithValue("@diplome", obj.diplome.id);

                _cmd.ExecuteNonQuery();

                obj.id = _cmd.LastInsertedId;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception : " + e);
            }

            _cmd.Dispose();

            return(obj);
        }
예제 #10
0
        public ActionResult AJouter_Annee(Annee an)
        {
            Debug.WriteLine(an);
            var j = dao.create(an);

            Debug.WriteLine(j);
            return(RedirectToAction("Index"));
        }
예제 #11
0
 public static void supprimerAnnee(Annee annee)
 {
     if (annee != null && annee.diplome != null)
     {
         DiplomeTest.supprimerDiplome(annee.diplome);
     }
     AnneeDAO.delete(annee);
 }
예제 #12
0
 public InputModifAnneeForm(String name, Diplome d, Annee a)
 {
     input        = false;
     this.Text    = name;
     this.modifId = a.id;
     this.d       = d;
     InitializeComponent();
     this.nomBox.Text = a.libelle;
 }
예제 #13
0
 public InputModifPeriodeForm(String name, Annee a, Periode p)
 {
     input        = false;
     this.Text    = name;
     this.modifId = p.id;
     this.a       = a;
     InitializeComponent();
     this.nomBox.Text = p.libelle;
 }
예제 #14
0
        /// <summary>
        /// Évènement changement de sélection diplome
        /// </summary>
        private void anneeGridView_SelectionChanged(object sender, EventArgs e)
        {
            Annee a = getCurrentAnnee();

            if (a != null)
            {
                periodeGridViewLoad();
            }
        }
예제 #15
0
        public static List <UniteEnseignement> findByLibelle(String libelle)
        {
            MySqlConnection _connection = ConnectionMySql.getInstance();

            MySqlCommand _cmd = new MySqlCommand();

            _cmd.Connection = _connection;

            String          sql    = "";
            MySqlDataReader reader = null;

            List <UniteEnseignement> resultats = new List <UniteEnseignement>();

            try
            {
                sql = "SELECT unite_enseignement.id as uniteEnsID, unite_enseignement.libelle as uniteEnsLibelle, "
                      + "periode.id AS periodeID, periode.libelle AS periodeLibelle, "
                      + "annee.id AS anneeId, annee.libelle AS anneeLibelle, "
                      + "diplome.id AS diplomeID, diplome.libelle AS diplomeLibelle "
                      + "FROM unite_enseignement "
                      + "JOIN periode ON unite_enseignement.periode_id = periode.id "
                      + "JOIN annee ON periode.annee_id = annee.id "
                      + "JOIN diplome ON annee.diplome_id = diplome.id "
                      + "WHERE unite_enseignement.libelle LIKE @libelle";

                _cmd.CommandText = sql;

                _cmd.Parameters.AddWithValue("@libelle", libelle);
                reader = _cmd.ExecuteReader();

                while (reader.Read())
                {
                    UniteEnseignement tempUnite = populateUniteEnseignement(reader);

                    Diplome tempDiplome = DiplomeDAO.populateDiplome(reader);

                    Annee tempAnnee = AnneeDAO.populateAnnee(reader);
                    tempAnnee.diplome = tempDiplome;

                    Periode tempPeriode = PeriodeDAO.populatePeriode(reader);
                    tempPeriode.annee = tempAnnee;

                    tempUnite.periode = tempPeriode;

                    resultats.Add(tempUnite);
                }
                reader.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception : " + e);
            }
            _cmd.Dispose();

            return(resultats);
        }
예제 #16
0
        /**
         * Methodes pour aider aux tests
         * **/
        public static Annee creerAnnee(String libelle)
        {
            Annee annee = new Annee();

            annee.libelle = libelle;
            annee.diplome = DiplomeTest.creerDiplome(libelle);
            Annee resultat = AnneeDAO.create(annee);

            return(resultat);
        }
예제 #17
0
        public void TestFind()
        {
            // test du find simple
            Annee resultat = creerAnnee("TEST_ANNEE_FIND");

            Annee resultatFind = AnneeDAO.find(resultat.id);

            Assert.AreEqual("TEST_ANNEE_FIND", resultatFind.libelle);
            Assert.AreNotEqual(0, resultatFind.diplome.id);
        }
예제 #18
0
        public void TestCreationAnnee()
        {
            // test la création d'une annee et la recherche grace à son libelle
            Annee resultat = creerAnnee("TEST_ANNEE");

            Assert.AreNotEqual("", resultat.libelle);
            Assert.AreEqual("TEST_ANNEE", resultat.libelle);
            Assert.IsTrue(resultat.id > 0);
            Assert.IsTrue(resultat.diplome.id > 0);
        }
예제 #19
0
        /// <summary>
        /// Supression d'une annee
        /// </summary>
        private void supprimerAnnee(object sender, EventArgs e)
        {
            Annee a = getCurrentAnnee();

            if (a != null)
            {
                AnneeDAO.delete(a);
                anneeGridViewLoad();
            }
        }
예제 #20
0
        /// <summary>
        /// ajouter d'un periode
        /// </summary>
        private void ajouterPeriode(object sender, EventArgs e)
        {
            Annee a = getCurrentAnnee();

            if (a != null)
            {
                var formPopup = new InputModifPeriodeForm("Ajouter Periode", a);
                formPopup.ShowDialog(this);
                periodeGridViewLoad();
            }
        }
예제 #21
0
        public ActionResult Update(Annee annee)
        {
            var annn = dao.getById(annee.AnneeId);

            annn.Libelle   = annee.Libelle;
            annn.DateDebut = annee.DateDebut;
            annn.DateFin   = annee.DateFin;
            dao.update(annn);

            return(RedirectToAction("Index"));
        }
예제 #22
0
        /// <summary>
        /// Modifier d'un periode
        /// </summary>
        private void modifierPeriode(object sender, EventArgs e)
        {
            Periode p = getCurrentPeriode();
            Annee   a = getCurrentAnnee();

            if (p != null && a != null)
            {
                var formPopup = new InputModifPeriodeForm("Modifier Periode", a, p);
                formPopup.ShowDialog(this);
                periodeGridViewLoad();
            }
        }
예제 #23
0
        /// <summary>
        /// Modifier d'un annee
        /// </summary>
        private void modifierAnnee(object sender, EventArgs e)
        {
            Annee   a = getCurrentAnnee();
            Diplome d = getCurrentDiplome();

            if (a != null && d != null)
            {
                var formPopup = new InputModifAnneeForm("Modifier Annee", d, a);
                formPopup.ShowDialog(this);
                anneeGridViewLoad();
            }
        }
예제 #24
0
        public static Annee populateAnnee(MySqlDataReader reader)
        {
            Annee resultat = new Annee();

            if (reader.IsDBNull(reader.GetOrdinal("anneeId")) || reader.IsDBNull(reader.GetOrdinal("anneeLibelle")))
            {
                return(null);
            }
            resultat.id      = Convert.ToInt64(reader["anneeId"]);
            resultat.libelle = (String)reader["anneeLibelle"];
            return(resultat);
        }
예제 #25
0
 /// <summary>
 /// Année sélectionnée
 /// </summary>
 /// <returns>ue</returns>
 private Annee getCurrentAnnee()
 {
     if (anneeGridView.SelectedCells.Count > 0)
     {
         int   selectedRowIndex = anneeGridView.SelectedCells[0].RowIndex;
         Annee a = ((ObjectView <Annee>)anneeGridView.Rows[selectedRowIndex].DataBoundItem).Object;
         return(a);
     }
     else
     {
         return(null);
     }
 }
        /// <summary>
        /// Supression d'une annee
        /// </summary>
        private void supprimerAnnee(object sender, EventArgs e)
        {
            Annee a = getCurrentAnnee();

            if (a != null)
            {
                AnneeDAO.delete(a);
                anneeGridViewLoad();
            }
            else
            {
                DiplomeView.afficherPopup("Aucune année selectionnée");
            }
        }
예제 #27
0
        public static List <Periode> findAll()
        {
            MySqlConnection _connection = ConnectionMySql.getInstance();

            MySqlCommand _cmd = new MySqlCommand();

            _cmd.Connection = _connection;

            String          sql    = "";
            MySqlDataReader reader = null;

            List <Periode> resultats = new List <Periode>();

            try
            {
                sql = "SELECT periode.id as periodeID, periode.libelle as periodeLibelle, "
                      + "annee.id as anneeId, annee.libelle as anneeLibelle ,"
                      + "diplome.id as diplomeID, diplome.libelle as diplomeLibelle "
                      + "FROM periode "
                      + "join annee on periode.annee_id = annee.id "
                      + "join diplome on annee.diplome_id = diplome.id";

                _cmd.CommandText = sql;

                reader = _cmd.ExecuteReader();

                while (reader.Read())
                {
                    Periode temp = populatePeriode(reader);

                    Diplome tempDiplome = DiplomeDAO.populateDiplome(reader);

                    Annee tempAnnee = AnneeDAO.populateAnnee(reader);
                    tempAnnee.diplome = tempDiplome;

                    temp.annee = tempAnnee;

                    resultats.Add(temp);
                }
                reader.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception : " + e);
            }
            _cmd.Dispose();

            return(resultats);
        }
        /// <summary>
        /// ajouter d'un periode
        /// </summary>
        private void ajouterPeriode(object sender, EventArgs e)
        {
            Annee a = getCurrentAnnee();

            if (a != null)
            {
                var formPopup = new InputModifPeriodeForm("Ajouter Periode", a);
                formPopup.ShowDialog(this);
                periodeGridViewLoad();
            }
            else
            {
                DiplomeView.afficherPopup("Aucune année selectionnée");
            }
        }
예제 #29
0
        public static Periode find(long id)
        {
            MySqlConnection _connection = ConnectionMySql.getInstance();

            MySqlCommand _cmd = new MySqlCommand();

            _cmd.Connection = _connection;

            String          sql    = "";
            MySqlDataReader reader = null;

            Periode resultat = new Periode();

            try
            {
                sql = "SELECT periode.id AS periodeID, periode.libelle AS periodeLibelle, "
                      + "annee.id AS anneeId, annee.libelle AS anneeLibelle, "
                      + "diplome.id AS diplomeID, diplome.libelle AS diplomeLibelle "
                      + "FROM periode "
                      + "JOIN annee ON periode.annee_id = annee.id "
                      + "JOIN diplome ON annee.diplome_id = diplome.id "
                      + "WHERE periode.id = @id";

                _cmd.CommandText = sql;
                _cmd.Parameters.AddWithValue("@id", id);
                reader = _cmd.ExecuteReader();

                while (reader.Read())
                {
                    resultat = populatePeriode(reader);

                    Diplome tempDiplome = DiplomeDAO.populateDiplome(reader);

                    Annee tempAnnee = AnneeDAO.populateAnnee(reader);
                    tempAnnee.diplome = tempDiplome;

                    resultat.annee = tempAnnee;
                }
                reader.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception : " + e);
            }
            _cmd.Dispose();

            return(resultat);
        }
        /// <summary>
        /// Modifier d'un periode
        /// </summary>
        private void modifierPeriode(object sender, EventArgs e)
        {
            Periode p = getCurrentPeriode();
            Annee   a = getCurrentAnnee();

            if (p != null && a != null)
            {
                var formPopup = new InputModifPeriodeForm("Modifier Periode", a, p);
                formPopup.ShowDialog(this);
                periodeGridViewLoad();
            }
            else
            {
                DiplomeView.afficherPopup("Aucune période selectionnée");
            }
        }