}//fin getMatiere ()


            public List<Matiere> getAllMatieres()
            {
                List<Matiere> matieres = null;

                using (var dbConnection = new SqlConnection(MasterProgramDbConnectionString))
                {
                    dbConnection.Open();

                    using (SqlCommand sqlCommand = dbConnection.CreateCommand())
                    {
                        sqlCommand.CommandText = "SELECT * FROM formation.MATIERE";
                        SqlDataReader reader = sqlCommand.ExecuteReader();

                        matieres = new List<Matiere>();
                        String intitule = null; 

                        while (reader.Read())
                        {

                            if (!reader.IsDBNull(1))
                            {
                                intitule = (String)reader["Intitule"];
                            }
                            else 
                            {
                                intitule = null; 
                            }
                            var matiere = new Matiere
                            {
                                IdMatiere = (String)reader["IdMatiere"],
                                Intitule = intitule
                            };
                            matieres.Add(matiere);
                        }// fin While
                    }//fin SqlCommand
                    dbConnection.Close();
                }
                return matieres;
            }//fin getMatiere ()
            }//fin getAllModules()


            public Matiere getMatiere(String IdMatiere)
            {
                var select = "SELECT matiere.IdMatiere, matiere.Intitule" + "\n";
                var from = "FROM formation.Matiere matiere " + "\n";
                var where = "WHERE matiere.IdMatiere = '{0}'";

                var matiere = new Matiere();

                using (var dbConnection = new SqlConnection(MasterProgramDbConnectionString))
                {
                    dbConnection.Open();

                    using (SqlCommand sqlCommand = dbConnection.CreateCommand())
                    {
                        
                        sqlCommand.CommandText = String.Format(select + from + where, IdMatiere);

                        SqlDataReader reader = sqlCommand.ExecuteReader();
                        reader.Read();

                        String intitule = null;
                        int nbCM = -1;
                        int nbTD = -1; 
                        int nbTP = -1; 
                  
                        if (!reader.IsDBNull(1))
                        {
                            intitule = (String)reader["Intitule"];
                        }

                        if (!reader.IsDBNull(2))
                        {
                            nbCM = (int)reader["nbCM"];
                        }

                        if (!reader.IsDBNull(3))
                        {
                            nbTD = (int)reader["nbTD"];
                        }

                        if (!reader.IsDBNull(4))
                        {
                            nbTP = (int)reader["nbTP"];
                        }


                        String id = (String)reader["IdMatiere"];
                        String idModule = (String)reader["IdModules"];

                        reader.Close();

                        matiere.IdMatiere = id;
                        matiere.Intitule = intitule;
                        matiere.NbCM = nbCM;
                        matiere.NbTD = nbTD;
                        matiere.NbTP = nbTP;
                        matiere.ModuleAssocie = getModule(id);

                    }//fin SqlCommand

                    dbConnection.Close();
                }//fin dbConnection

                

                return matiere;
            }//fin getMatiere ()