コード例 #1
0
        //-------- méthodes qui recherche les statistiques d'une année d'un niveau
        public StatistiqueNiveauBE getStatistiqueDuneAnnee(String codeNiveau, int annee)
        {
            //string codeClasse;
            int    effectif;
            int    nbAdmis;
            string pourcentageAdmis;
            int    nbEchec;
            string pourcentageEchec;

            StatistiqueNiveauBE stat;

            try
            {
                // Création d'une commande SQL
                MySqlCommand cmd = con.connexion.CreateCommand();
                cmd.CommandText = "SELECT e.codeNiveau, e.effectif, r.nbAdmis, ((r.nbAdmis / e.effectif)*100) as PourcentageAdmis, " +
                                  "(e.effectif - r.nbAdmis) as nbEchec, (((e.effectif - r.nbAdmis) / e.effectif))*100 as PourcentageEchec " +
                                  "FROM   (SELECT codeNiveau, count(*) as effectif " +
                                  "FROM classe c, inscrire i " +
                                  "WHERE c.codeClasse = i.codeClasse AND c.codeNiveau = '" + codeNiveau + "' AND i.annee = '" + annee + "' GROUP BY codeNiveau) e, " +
                                  "(SELECT count(*) as nbAdmis " +
                                  "FROM resultatannuel " +
                                  "WHERE matricule in (SELECT matricule FROM inscrire i, classe c WHERE i.codeClasse = c.codeClasse AND c.codeNiveau = '" + codeNiveau + "' AND annee = '" + annee + "') " +
                                  "AND annee = '" + annee + "' AND decision = 'Admis') r;";

                using (MySqlDataReader dataReader = cmd.ExecuteReader())
                {
                    //fabriquer l'objet à retourner
                    while (dataReader.Read())
                    {
                        //codeClasse = Convert.ToString(dataReader["codeclasse"]);
                        effectif         = Convert.ToInt16(dataReader["effectif"]);
                        nbAdmis          = Convert.ToInt16(dataReader["nbAdmis"]);
                        pourcentageAdmis = Convert.ToString(Math.Round(Convert.ToDecimal(dataReader["PourcentageAdmis"]), 2)) + "%";
                        nbEchec          = Convert.ToInt16(dataReader["nbEchec"]);
                        pourcentageEchec = Convert.ToString(Math.Round(Convert.ToDecimal(dataReader["PourcentageEchec"]), 2)) + "%";

                        stat = new StatistiqueNiveauBE(codeNiveau, effectif, nbAdmis, pourcentageAdmis, nbEchec, pourcentageEchec);

                        return(stat);
                    }

                    return(null);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
        }
コード例 #2
0
        private void cmdValider_Click(object sender, RoutedEventArgs e)
        {
            //on vérifit si tous les champs ont été corectement rempli
            if ((cmbNiveau.Text != null && cmbPeriode.Text != null && txtAnneeScolaire.Text != null) &&
                (cmbNiveau.Text != "" && cmbPeriode.Text != "" && txtAnneeScolaire.Text != ""))
            {
                niveauChoisi        = cmbNiveau.Text;
                periodeChoisi       = cmbChoixPeriode.Text;
                anneeScolaireChoisi = Convert.ToInt16(txtAnneeScolaire.Text);

                if (cmbPeriode.Text.Equals("Séquence"))
                {
                    if (cmbChoixPeriode.Text != null && cmbChoixPeriode.Text != "")
                    {
                        // traitement pour une Séquence

                        //--------------------- Action pour une Séquence particulière
                        List <StatistiqueNiveauBE> LStatistique = new List <StatistiqueNiveauBE>();

                        if (cmbNiveau.Text.Equals("<Tous Les Niveaux>"))
                        {
                            List <NiveauBE> ListNiveau    = statistiqueNiveauBL.listerTousLesNiveaux();
                            int             effectifTotal = 0;
                            int             nbAdmisTotal  = 0;
                            int             nbEchecTotal  = 0;
                            for (int i = 0; i < ListNiveau.Count; i++)
                            {
                                StatistiqueNiveauBE stat = statistiqueNiveauBL.getStatistiqueDuneSequence(ListNiveau.ElementAt(i).codeNiveau, Convert.ToInt16(txtAnnee.Text), cmbChoixPeriode.Text);
                                if (stat != null)
                                {
                                    effectifTotal += stat.effectif;
                                    nbAdmisTotal  += stat.nbAdmis;
                                    nbEchecTotal  += stat.nbEchec;
                                    LStatistique.Add(stat);
                                }
                            }

                            string pourcentageTotalAdmis = Convert.ToString(Math.Round((Convert.ToDecimal(nbAdmisTotal) / Convert.ToDecimal(effectifTotal)) * 100, 2)) + "%";
                            string pourcentageTotalEchec = Convert.ToString(Math.Round((Convert.ToDecimal(nbEchecTotal) / Convert.ToDecimal(effectifTotal)) * 100, 2)) + "%";

                            StatistiqueNiveauBE stat2 = new StatistiqueNiveauBE("TOTAL", effectifTotal, nbAdmisTotal, pourcentageTotalAdmis, nbEchecTotal, pourcentageTotalEchec);
                            if (stat2 != null)
                            {
                                LStatistique.Add(stat2);
                            }
                        }
                        else
                        {
                            //génération des statisques
                            StatistiqueNiveauBE stat = statistiqueNiveauBL.getStatistiqueDuneSequence(cmbNiveau.Text, Convert.ToInt16(txtAnnee.Text), cmbChoixPeriode.Text);
                            if (stat != null)
                            {
                                LStatistique.Add(stat);
                            }
                        }


                        grdStatistiqueNiveau.ItemsSource = LStatistique;
                    }
                    else
                    {
                        MessageBox.Show("Vous devez choisir une Séquence !");
                    }
                }
                else if (cmbPeriode.Text.Equals("Trimestre"))
                {
                    if (cmbChoixPeriode.Text != null && cmbChoixPeriode.Text != "")
                    {
                        List <StatistiqueNiveauBE> LStatistique = new List <StatistiqueNiveauBE>();

                        if (cmbNiveau.Text.Equals("<Tous Les Niveaux>"))
                        {
                            List <NiveauBE> ListNiveau    = statistiqueNiveauBL.listerTousLesNiveaux();
                            int             effectifTotal = 0;
                            int             nbAdmisTotal  = 0;
                            int             nbEchecTotal  = 0;
                            for (int i = 0; i < ListNiveau.Count; i++)
                            {
                                StatistiqueNiveauBE stat = statistiqueNiveauBL.getStatistiqueDuneSequence(ListNiveau.ElementAt(i).codeNiveau, Convert.ToInt16(txtAnnee.Text), cmbChoixPeriode.Text);
                                if (stat != null)
                                {
                                    effectifTotal += stat.effectif;
                                    nbAdmisTotal  += stat.nbAdmis;
                                    nbEchecTotal  += stat.nbEchec;
                                    LStatistique.Add(stat);
                                }
                            }

                            string pourcentageTotalAdmis = Convert.ToString(Math.Round((Convert.ToDecimal(nbAdmisTotal) / Convert.ToDecimal(effectifTotal)) * 100, 2)) + "%";
                            string pourcentageTotalEchec = Convert.ToString(Math.Round((Convert.ToDecimal(nbEchecTotal) / Convert.ToDecimal(effectifTotal)) * 100, 2)) + "%";

                            StatistiqueNiveauBE stat2 = new StatistiqueNiveauBE("TOTAL", effectifTotal, nbAdmisTotal, pourcentageTotalAdmis, nbEchecTotal, pourcentageTotalEchec);
                            if (stat2 != null)
                            {
                                LStatistique.Add(stat2);
                            }
                        }
                        else
                        {
                            //génération des statisques
                            StatistiqueNiveauBE stat = statistiqueNiveauBL.getStatistiqueDuneSequence(cmbNiveau.Text, Convert.ToInt16(txtAnnee.Text), cmbChoixPeriode.Text);
                            if (stat != null)
                            {
                                LStatistique.Add(stat);
                            }
                        }


                        grdStatistiqueNiveau.ItemsSource = LStatistique;
                    }
                    else
                    {
                        MessageBox.Show("Vous devez choisir un Trimestre !");
                    }
                }
                else
                {
                    // traitement pour une année

                    List <StatistiqueNiveauBE> LStatistique = new List <StatistiqueNiveauBE>();

                    if (cmbNiveau.Text.Equals("<Tous Les Niveaux>"))
                    {
                        List <NiveauBE> ListNiveau    = statistiqueNiveauBL.listerTousLesNiveaux();
                        int             effectifTotal = 0;
                        int             nbAdmisTotal  = 0;
                        int             nbEchecTotal  = 0;
                        for (int i = 0; i < ListNiveau.Count; i++)
                        {
                            StatistiqueNiveauBE stat = statistiqueNiveauBL.getStatistiqueDuneSequence(ListNiveau.ElementAt(i).codeNiveau, Convert.ToInt16(txtAnnee.Text), cmbChoixPeriode.Text);
                            if (stat != null)
                            {
                                effectifTotal += stat.effectif;
                                nbAdmisTotal  += stat.nbAdmis;
                                nbEchecTotal  += stat.nbEchec;
                                LStatistique.Add(stat);
                            }
                        }

                        string pourcentageTotalAdmis = Convert.ToString(Math.Round((Convert.ToDecimal(nbAdmisTotal) / Convert.ToDecimal(effectifTotal)) * 100, 2)) + "%";
                        string pourcentageTotalEchec = Convert.ToString(Math.Round((Convert.ToDecimal(nbEchecTotal) / Convert.ToDecimal(effectifTotal)) * 100, 2)) + "%";

                        StatistiqueNiveauBE stat2 = new StatistiqueNiveauBE("TOTAL", effectifTotal, nbAdmisTotal, pourcentageTotalAdmis, nbEchecTotal, pourcentageTotalEchec);
                        if (stat2 != null)
                        {
                            LStatistique.Add(stat2);
                        }
                    }
                    else
                    {
                        //génération des statisques
                        StatistiqueNiveauBE stat = statistiqueNiveauBL.getStatistiqueDuneSequence(cmbNiveau.Text, Convert.ToInt16(txtAnnee.Text), cmbChoixPeriode.Text);
                        if (stat != null)
                        {
                            LStatistique.Add(stat);
                        }
                    }


                    grdStatistiqueNiveau.ItemsSource = LStatistique;
                }
            }
            else
            {
                MessageBox.Show("Tous les champs doivent êtres remplis !! ");
            }
        }