Exemple #1
0
        /*
         * Procédure changeInformations qui recherche et actualise les informations liées à un
         * utilisateur et les affiche
         */
        public void changeInformations()
        {
            con.ConnectionString = CONNECTION_STRING;

            try
            {
                //Ouverture de la connexion
                con.Open();

                //Remplissage d'une DataTable avec les informations d'un exercice
                string request = @"SELECT C.titreCours, L.titreLecon, L.commentLecon, U.codeExo, C.numCours, L.numLecon
                            FROM ((Utilisateurs U INNER JOIN Cours C
                            ON U.codeCours = C.numCours)
                            LEFT JOIN Lecons L
                            ON L.numLecon = U.codeLeçon AND L.numCours = U.codeCours)
                            WHERE U.codeUtil = " + codeUtil;

                DataTable        dt = new DataTable();
                OleDbCommand     cd = new OleDbCommand(request, con);
                OleDbDataAdapter da = new OleDbDataAdapter(cd);

                da.SelectCommand = cd;
                da.Fill(dt);

                //Actualisation des informations dans la classe Exercice
                exo.numeroExercice = dt.Rows[0].Field <int>(3);
                exo.numeroLecon    = dt.Rows[0].Field <int>(5);
                exo.numeroCours    = dt.Rows[0].Field <string>(4);

                int nombreExercices = exo.calculerNbExo();

                //Actualisation des informations à afficher
                lblCoursActu.Text  = dt.Rows[0].Field <string>(0);
                lblLeconActu.Text  = dt.Rows[0].Field <string>(1);
                lblLeconCom.Text   = dt.Rows[0].Field <string>(2);
                lblExoFiniNb.Text  = (dt.Rows[0].Field <int>(3) - 1).ToString();
                lblExoFiniNb.Text += "/" + nombreExercices;


                /** Actualisation des différentes informations d'affichage */
                //Description
                actualiserDescription();

                //Barre de progression
                actualiserBarre(dt.Rows[0].Field <int>(3), nombreExercices);

                //Bouton administrateur
                administrateur(codeUtil);

                //Bouton de commencement des exercices
                commencerExo();
            }
            catch (Exception ex)
            {
                //Affichage d'une erreur
                MessageBox.Show("Error: " + ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                //Fermeture de la connexion
                con.Close();
            }
        }