Ejemplo n.º 1
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 !! ");
            }
        }