}//fin getModule()


            public List<Module> getAllModules()
            {
                List<Module> modules = null;

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

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

                        modules = new List<Module>();
                        String intitule = null;

                        while (reader.Read())
                        {
                            var id = (String)reader["IdModule"];

                            if (!reader.IsDBNull(1))
                            {
                                intitule = (String)reader["Intitule"];
                            }
                            else
                            {
                                intitule = null;
                            }

                            var moduleChoix = (bool)reader["ModuleChoix"];
                            var ue = getUE(id, sqlCommand);

                            var module = new Module
                            {
                                IdModule = id,
                                Intitule = intitule,
                                ModuleChoix = moduleChoix,
                                UE = ue
                            };
                            
                            modules.Add(module);
                        }// fin While
                        reader.Close();
                    }//fin SqlCommand
                    dbConnection.Close();
                }
                return modules;
            }//fin getAllModules()
            }//fin get IdUE

            protected Module getModule (String IdMatiere,SqlCommand sqlCommand)
            {
                var select = "SELECT module.Intitule, module.ModuleChoix ";
                var from = "FROM formation.MODULES module ";
                var where = "WHERE module.IdModules = '{0}'";

                var id = getIdModule(IdMatiere, sqlCommand);
                var ue = getUE(id, sqlCommand);

                sqlCommand.CommandText = String.Format(select + from + where, id);

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

                String intitule = null; 
                if (!reader.IsDBNull(1))
                {
                    intitule = (String)reader["Intitule"];
                } 
                
                bool moduleChoix = (bool)reader["ModuleChoix"];

                reader.Close();
                var module = new Module
                {
                    IdModule = id,
                    Intitule = intitule,
                    ModuleChoix = moduleChoix,
                    UE = ue
                };

                return module; 
            }//fin get Module
            }//fin getAllUEs()


            public Module getModule(String IdModule)
            {
                var select = "SELECT module.Intitule, module.ModuleChoix, module.IdUE" + "\n";
                var from = "FROM formation.MODULES module " + "\n";
                var where = "WHERE module.IdModules = '{0}' ";

                var module = new Module();

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

                    using (SqlCommand sqlCommand = dbConnection.CreateCommand())
                    {
                        var ue = getUE(IdModule, sqlCommand);
                        sqlCommand.CommandText = String.Format(select + from + where, IdModule);

                        SqlDataReader reader = sqlCommand.ExecuteReader();
                        reader.Read();
                        String intitule = null;

                        if (!reader.IsDBNull(1))
                        {
                            intitule = (String)reader["Intitule"];
                        }

                        bool moduleChoix = (bool)reader["ModuleChoix"];

                        reader.Close();

                        module.IdModule = IdModule;
                        module.Intitule = intitule;
                        module.ModuleChoix = moduleChoix;
                        module.UE = ue;

                    }//fin SqlCommand

                    dbConnection.Close();
                }//fin dbConnection

                return module;
            }//fin getModule()