private void cmdValider_Click(object sender, RoutedEventArgs e)
        {
            //on vérifit si tous les champs ont été corectement rempli
            if ((cmbClasse.Text != null && txtAnneeScolaire.Text != null && cmbTrimestre.Text != null) && (cmbClasse.Text != "" && txtAnneeScolaire.Text != "" && cmbTrimestre.Text != ""))
            {
                //si on a choisi <Toutes les classes>
                if (cmbClasse.Text.Equals("<Toutes Les Classes>"))
                {
                    if (cmbTrimestre.Text.Equals("<Tous Les Trimestres>"))
                    {
                        //--------------------------- Action pour toutes les classes et tous les trimestres

                        //on liste toutes les classes
                        List <ClasseBE> LClasse = genererBulletinsTrimestrielBL.listerToutesLesClasses();

                        List <TrimestreBE> LTrimestre = genererBulletinsTrimestrielBL.listerTousLesTrimestres();

                        //Configure the ProgressBar
                        ProgressBar1.Minimum = 0;
                        ProgressBar1.Maximum = LClasse.Count;
                        ProgressBar1.Value   = 0;

                        //Stores the value of the ProgressBar
                        double value = 0;

                        //Create a new instance of our ProgressBar Delegate that points
                        // to the ProgressBar's SetValue method.
                        UpdateProgressBarDelegate updatePbDelegate =
                            new UpdateProgressBarDelegate(ProgressBar1.SetValue);


                        //on affiche la barre de progression
                        ProgressBar1.Visibility = System.Windows.Visibility.Visible;

                        for (int i = 0; i < LClasse.Count; i++)
                        {
                            //on liste les élèves de la classe
                            List <EleveBE> LEleve = genererBulletinsTrimestrielBL.listeEleves(LClasse.ElementAt(i), Convert.ToInt16(txtAnnee.Text));
                            for (int j = 0; j < LEleve.Count; j++)
                            {
                                for (int k = 0; k < LTrimestre.Count; k++)
                                {
                                    // ***********calcul des moyennes
                                    //remplissage de la table "moyennes"

                                    genererBulletinsTrimestrielBL.genererBulletinTrimestrielDunEleve(LEleve.ElementAt(j).matricule, Convert.ToInt16(txtAnnee.Text),
                                                                                                     LClasse.ElementAt(i).codeClasse, LTrimestre.ElementAt(k).codetrimestre, LEleve.ElementAt(j).photo);


                                    value += 1;

                                    Dispatcher.Invoke(updatePbDelegate,
                                                      System.Windows.Threading.DispatcherPriority.Background,
                                                      new object[] { ProgressBar.ValueProperty, value });
                                }
                            }
                        }

                        MessageBox.Show("Opération Terminée !! ");

                        //on cache la barre de progression
                        ProgressBar1.Visibility = System.Windows.Visibility.Hidden;
                    }
                    else
                    {
                        //--------------------------- Action pour toutes les classes et un trimestre particulier

                        //on liste toutes les classes
                        List <ClasseBE> LClasse = genererBulletinsTrimestrielBL.listerToutesLesClasses();

                        //Configure the ProgressBar
                        ProgressBar1.Minimum = 0;
                        ProgressBar1.Maximum = LClasse.Count;
                        ProgressBar1.Value   = 0;

                        //Stores the value of the ProgressBar
                        double value = 0;

                        //Create a new instance of our ProgressBar Delegate that points
                        // to the ProgressBar's SetValue method.
                        UpdateProgressBarDelegate updatePbDelegate =
                            new UpdateProgressBarDelegate(ProgressBar1.SetValue);


                        //on affiche la barre de progression
                        ProgressBar1.Visibility = System.Windows.Visibility.Visible;

                        for (int i = 0; i < LClasse.Count; i++)
                        {
                            //on liste les élèves de la classe
                            List <EleveBE> LEleve = genererBulletinsTrimestrielBL.listeEleves(LClasse.ElementAt(i), Convert.ToInt16(txtAnnee.Text));
                            for (int j = 0; j < LEleve.Count; j++)
                            {
                                // ***********calcul des moyennes
                                //remplissage de la table "moyennes"

                                genererBulletinsTrimestrielBL.genererBulletinTrimestrielDunEleve(LEleve.ElementAt(j).matricule, Convert.ToInt16(txtAnnee.Text),
                                                                                                 LClasse.ElementAt(i).codeClasse, cmbTrimestre.Text, LEleve.ElementAt(j).photo);


                                value += 1;

                                Dispatcher.Invoke(updatePbDelegate,
                                                  System.Windows.Threading.DispatcherPriority.Background,
                                                  new object[] { ProgressBar.ValueProperty, value });
                            }
                        }

                        MessageBox.Show("Opération Terminée !! ");

                        //on cache la barre de progression
                        ProgressBar1.Visibility = System.Windows.Visibility.Hidden;
                    }
                }
                else
                {
                    if (cmbTrimestre.Text.Equals("<Tous Les Trimestres>"))
                    {
                        //--------------------- Action pour une classe particulière et tous les trimestres
                        List <TrimestreBE> LTrimestre = genererBulletinsTrimestrielBL.listerTousLesTrimestres();

                        //Configure the ProgressBar
                        ProgressBar1.Minimum = 0;
                        ProgressBar1.Maximum = LTrimestre.Count;
                        ProgressBar1.Value   = 0;

                        //Stores the value of the ProgressBar
                        double value = 0;

                        //Create a new instance of our ProgressBar Delegate that points
                        // to the ProgressBar's SetValue method.
                        UpdateProgressBarDelegate updatePbDelegate =
                            new UpdateProgressBarDelegate(ProgressBar1.SetValue);


                        //on affiche la barre de progression
                        ProgressBar1.Visibility = System.Windows.Visibility.Visible;

                        ClasseBE classe = new ClasseBE();
                        classe.codeClasse = cmbClasse.Text;
                        classe            = genererBulletinsTrimestrielBL.rechercherClasse(classe);
                        //on liste les élèves de la classe
                        List <EleveBE> LEleve = genererBulletinsTrimestrielBL.listeEleves(classe, Convert.ToInt16(txtAnnee.Text));
                        for (int j = 0; j < LEleve.Count; j++)
                        {
                            for (int k = 0; k < LTrimestre.Count; k++)
                            {
                                // ***********calcul des moyennes
                                //remplissage de la table "moyennes"

                                genererBulletinsTrimestrielBL.genererBulletinTrimestrielDunEleve(LEleve.ElementAt(j).matricule, Convert.ToInt16(txtAnnee.Text), classe.codeClasse,
                                                                                                 LTrimestre.ElementAt(k).codetrimestre, LEleve.ElementAt(j).photo);


                                value += 1;

                                Dispatcher.Invoke(updatePbDelegate,
                                                  System.Windows.Threading.DispatcherPriority.Background,
                                                  new object[] { ProgressBar.ValueProperty, value });
                            }
                        }

                        MessageBox.Show("Opération Terminée !! ");

                        //on cache la barre de progression
                        ProgressBar1.Visibility = System.Windows.Visibility.Hidden;
                    }
                    else
                    {
                        //--------------------- Action pour une classe particulière et un trimestre particulier

                        //Configure the ProgressBar
                        ProgressBar1.Minimum = 0;
                        ProgressBar1.Maximum = 1;
                        ProgressBar1.Value   = 0;

                        //Stores the value of the ProgressBar
                        double value = 0;

                        //Create a new instance of our ProgressBar Delegate that points
                        // to the ProgressBar's SetValue method.
                        UpdateProgressBarDelegate updatePbDelegate =
                            new UpdateProgressBarDelegate(ProgressBar1.SetValue);


                        //on affiche la barre de progression
                        ProgressBar1.Visibility = System.Windows.Visibility.Visible;

                        // ***********calcul des moyennes
                        //remplissage de la table "moyennes"

                        ClasseBE classe = new ClasseBE();
                        classe.codeClasse = cmbClasse.Text;
                        classe            = genererBulletinsTrimestrielBL.rechercherClasse(classe);

                        //on liste les élèves de la classe
                        List <EleveBE> LEleve = genererBulletinsTrimestrielBL.listeEleves(classe, Convert.ToInt16(txtAnnee.Text));
                        for (int j = 0; j < LEleve.Count; j++)
                        {
                            // ***********calcul des moyennes
                            //remplissage de la table "moyennes"

                            genererBulletinsTrimestrielBL.genererBulletinTrimestrielDunEleve(LEleve.ElementAt(j).matricule, Convert.ToInt16(txtAnnee.Text), cmbClasse.Text,
                                                                                             cmbTrimestre.Text, LEleve.ElementAt(j).photo);


                            value += 1;

                            Dispatcher.Invoke(updatePbDelegate,
                                              System.Windows.Threading.DispatcherPriority.Background,
                                              new object[] { ProgressBar.ValueProperty, value });
                        }

                        //calcul des résultats
                        //remplissage de la table "resultats"

                        //genererResultatsTrimestrielsBL.calculerResultatsTrimestriels(cmbClasse.Text, cmbTrimestre.Text, Convert.ToInt16(txtAnnee.Text));

                        MessageBox.Show("Opération Terminée !! ");

                        //on cache la barre de progression
                        ProgressBar1.Visibility = System.Windows.Visibility.Hidden;
                    }
                }
            }
            else
            {
                MessageBox.Show("Tous les champs doivent êtres remplis !! ");
            }
        }
Ejemplo n.º 2
0
        //-------------------Imprimer les relevés des élèves sélectionnés-------------------
        public void imprimerBulletinTrimestriel(int annee, string classe, string sequence)
        {
            Document  doc  = new Document(iTextSharp.text.PageSize.A4, 5, 5, 5, 25);
            CreerEtat etat = new CreerEtat();

            etat.docname = ConnexionUI.DOSSIER_BULLETINS + annee + "-" + classe + "-" + sequence + ".pdf";
            etat.title   = "BULLETIN DE NOTES DU TRIMESTRE " + sequence;
            PdfWriter writer = PdfWriter.GetInstance(doc, new System.IO.FileStream(etat.docname, System.IO.FileMode.Create));

            Ecole.DataAccess.ParametresDA parametreDA = new Ecole.DataAccess.ParametresDA();
            ParametresBE parametre = parametreDA.rechercherDerniereValeur();

            writer.PageEvent = new PDFFooter1(parametre.nomEcole);
            doc.Open();

            //on vérifit si tous les champs ont été corectement rempli
            if ((cmbClasse.Text != null && txtAnnee.Text != null && cmbTrimestre.Text != null) && (cmbClasse.Text != "" && txtAnnee.Text != "" && cmbTrimestre.Text != ""))
            {
                if (cmbTrimestre.Text.Equals("<Tous Les Trimestres>"))
                {
                    //--------------------- Action pour une classe particulière et tous les trimestres
                    List <TrimestreBE> LTrimestre = bulletinsTrimestrielBL.listerTousLesTrimestres();

                    //Configure the ProgressBar
                    ProgressBar1.Minimum = 0;
                    ProgressBar1.Maximum = LTrimestre.Count;
                    ProgressBar1.Value   = 0;

                    //Stores the value of the ProgressBar
                    double value = 0;

                    //Create a new instance of our ProgressBar Delegate that points
                    // to the ProgressBar's SetValue method.
                    UpdateProgressBarDelegate updatePbDelegate =
                        new UpdateProgressBarDelegate(ProgressBar1.SetValue);


                    //on affiche la barre de progression
                    ProgressBar1.Visibility = System.Windows.Visibility.Visible;

                    for (int i = 0; i < listBoxEleve.Items.Count; i++)
                    {
                        for (int k = 0; k < LTrimestre.Count; k++)
                        {
                            ListBoxItem item = listBoxEleve.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem;

                            if (item != null)
                            {
                                CheckBox myCheckBox = FindVisualChild <CheckBox>(item) as CheckBox;
                                if (myCheckBox.IsChecked.Value)
                                {
                                    //bulletinsTrimestrielBL.genererBulletinTrimestrielDunEleve((listBoxEleve.Items[i] as ElementListeEleve).matricule, annee, classe, sequence);
                                    string  matricule = (listBoxEleve.Items[i] as ElementListeEleve).matricule;
                                    EleveBE eleve     = new EleveBE();
                                    eleve.matricule = matricule;
                                    eleve           = bulletinsTrimestrielBL.rechercherEleve(eleve);
                                    bulletinsTrimestrielBL.genererBulletinTrimestrielDunEleve(doc, etat, writer, matricule, Convert.ToInt16(txtAnnee.Text), classe,
                                                                                              LTrimestre.ElementAt(k).codetrimestre, eleve.photo);

                                    value += 1;

                                    Dispatcher.Invoke(updatePbDelegate,
                                                      System.Windows.Threading.DispatcherPriority.Background,
                                                      new object[] { ProgressBar.ValueProperty, value });
                                }
                            }
                        }
                    }

                    MessageBox.Show("Opération Terminée !! ");

                    //on cache la barre de progression
                    ProgressBar1.Visibility = System.Windows.Visibility.Hidden;
                }
                else
                {
                    //--------------------- Action pour une classe particulière et un trimestre particulier

                    //Configure the ProgressBar
                    ProgressBar1.Minimum = 0;
                    ProgressBar1.Maximum = 1;
                    ProgressBar1.Value   = 0;

                    //Stores the value of the ProgressBar
                    double value = 0;

                    //Create a new instance of our ProgressBar Delegate that points
                    // to the ProgressBar's SetValue method.
                    UpdateProgressBarDelegate updatePbDelegate =
                        new UpdateProgressBarDelegate(ProgressBar1.SetValue);


                    //on affiche la barre de progression
                    ProgressBar1.Visibility = System.Windows.Visibility.Visible;

                    // ***********calcul des moyennes
                    //remplissage de la table "moyennes"

                    for (int i = 0; i < listBoxEleve.Items.Count; i++)
                    {
                        ListBoxItem item = listBoxEleve.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem;

                        if (item != null)
                        {
                            CheckBox myCheckBox = FindVisualChild <CheckBox>(item) as CheckBox;
                            if (myCheckBox.IsChecked.Value)
                            {
                                //bulletinsTrimestrielBL.genererBulletinTrimestrielDunEleve((listBoxEleve.Items[i] as ElementListeEleve).matricule, annee, classe, sequence);
                                string  matricule = (listBoxEleve.Items[i] as ElementListeEleve).matricule;
                                EleveBE eleve     = new EleveBE();
                                eleve.matricule = matricule;
                                eleve           = bulletinsTrimestrielBL.rechercherEleve(eleve);
                                bulletinsTrimestrielBL.genererBulletinTrimestrielDunEleve(doc, etat, writer, matricule, Convert.ToInt16(txtAnnee.Text), classe, cmbTrimestre.Text, eleve.photo);

                                value += 1;

                                Dispatcher.Invoke(updatePbDelegate,
                                                  System.Windows.Threading.DispatcherPriority.Background,
                                                  new object[] { ProgressBar.ValueProperty, value });
                            }
                        }
                    }

                    MessageBox.Show("Opération Terminée !! ");

                    //on cache la barre de progression
                    ProgressBar1.Visibility = System.Windows.Visibility.Hidden;
                }
            }
            else
            {
                MessageBox.Show("Tous les champs doivent êtres remplis !! ");
            }

            try
            {
                doc.Close();
            }
            catch (Exception) { }
            System.Diagnostics.Process.Start(System.IO.Path.GetFullPath(etat.docname));
        }
        //-------------------Imprimer les relevés des élèves sélectionnés-------------------
        public void imprimerBulletinTrimestriel(int annee, string classe, string sequence)
        {
            //on vérifit si tous les champs ont été corectement rempli
            if ((cmbClasse.Text != null && txtAnnee.Text != null && cmbTrimestre.Text != null) && (cmbClasse.Text != "" && txtAnnee.Text != "" && cmbTrimestre.Text != ""))
            {
                if (cmbTrimestre.Text.Equals("<Tous Les Trimestres>"))
                {
                    //--------------------- Action pour une classe particulière et tous les trimestres
                    List <TrimestreBE> LTrimestre = bulletinsTrimestrielBL.listerTousLesTrimestres();

                    //Configure the ProgressBar
                    ProgressBar1.Minimum = 0;
                    ProgressBar1.Maximum = LTrimestre.Count;
                    ProgressBar1.Value   = 0;

                    //Stores the value of the ProgressBar
                    double value = 0;

                    //Create a new instance of our ProgressBar Delegate that points
                    // to the ProgressBar's SetValue method.
                    UpdateProgressBarDelegate updatePbDelegate =
                        new UpdateProgressBarDelegate(ProgressBar1.SetValue);


                    //on affiche la barre de progression
                    ProgressBar1.Visibility = System.Windows.Visibility.Visible;

                    for (int i = 0; i < listBoxEleve.Items.Count; i++)
                    {
                        for (int k = 0; k < LTrimestre.Count; k++)
                        {
                            ListBoxItem item = listBoxEleve.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem;

                            if (item != null)
                            {
                                CheckBox myCheckBox = FindVisualChild <CheckBox>(item) as CheckBox;
                                if (myCheckBox.IsChecked.Value)
                                {
                                    //bulletinsTrimestrielBL.genererBulletinTrimestrielDunEleve((listBoxEleve.Items[i] as ElementListeEleve).matricule, annee, classe, sequence);
                                    string  matricule = (listBoxEleve.Items[i] as ElementListeEleve).matricule;
                                    EleveBE eleve     = new EleveBE();
                                    eleve = bulletinsTrimestrielBL.rechercherEleve(eleve);
                                    bulletinsTrimestrielBL.genererBulletinTrimestrielDunEleve(matricule, Convert.ToInt16(txtAnnee.Text), classe,
                                                                                              LTrimestre.ElementAt(k).codetrimestre, eleve.photo);

                                    value += 1;

                                    Dispatcher.Invoke(updatePbDelegate,
                                                      System.Windows.Threading.DispatcherPriority.Background,
                                                      new object[] { ProgressBar.ValueProperty, value });
                                }
                            }
                        }
                    }

                    MessageBox.Show("Opération Terminée !! ");

                    //on cache la barre de progression
                    ProgressBar1.Visibility = System.Windows.Visibility.Hidden;
                }
                else
                {
                    //--------------------- Action pour une classe particulière et un trimestre particulier

                    //Configure the ProgressBar
                    ProgressBar1.Minimum = 0;
                    ProgressBar1.Maximum = 1;
                    ProgressBar1.Value   = 0;

                    //Stores the value of the ProgressBar
                    double value = 0;

                    //Create a new instance of our ProgressBar Delegate that points
                    // to the ProgressBar's SetValue method.
                    UpdateProgressBarDelegate updatePbDelegate =
                        new UpdateProgressBarDelegate(ProgressBar1.SetValue);


                    //on affiche la barre de progression
                    ProgressBar1.Visibility = System.Windows.Visibility.Visible;

                    // ***********calcul des moyennes
                    //remplissage de la table "moyennes"

                    for (int i = 0; i < listBoxEleve.Items.Count; i++)
                    {
                        ListBoxItem item = listBoxEleve.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem;

                        if (item != null)
                        {
                            CheckBox myCheckBox = FindVisualChild <CheckBox>(item) as CheckBox;
                            if (myCheckBox.IsChecked.Value)
                            {
                                //bulletinsTrimestrielBL.genererBulletinTrimestrielDunEleve((listBoxEleve.Items[i] as ElementListeEleve).matricule, annee, classe, sequence);
                                string  matricule = (listBoxEleve.Items[i] as ElementListeEleve).matricule;
                                EleveBE eleve     = new EleveBE();
                                eleve = bulletinsTrimestrielBL.rechercherEleve(eleve);
                                bulletinsTrimestrielBL.genererBulletinTrimestrielDunEleve(matricule, Convert.ToInt16(txtAnnee.Text), classe,
                                                                                          cmbTrimestre.Text, eleve.photo);

                                value += 1;

                                Dispatcher.Invoke(updatePbDelegate,
                                                  System.Windows.Threading.DispatcherPriority.Background,
                                                  new object[] { ProgressBar.ValueProperty, value });
                            }
                        }
                    }

                    MessageBox.Show("Opération Terminée !! ");

                    //on cache la barre de progression
                    ProgressBar1.Visibility = System.Windows.Visibility.Hidden;
                }
            }
            else
            {
                MessageBox.Show("Tous les champs doivent êtres remplis !! ");
            }
        }