コード例 #1
0
 internal void enregistrerAnonymat(NotesBE note)
 {
     if (notesDA.modifier(note))
     {
         journalDA.journaliser("Enregistrement d'une note - " + note.note);
     }
 }
コード例 #2
0
        private void grdListe_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            int         COLUMN_NOTE = 2;
            int         MAX_ROW     = lignes.Count;
            var         grid        = sender as DataGrid;
            DataGridRow row         = new DataGridRow();
            string      codeclasse  = cmbClasse.SelectedValue.ToString();
            string      codematiere = cmbMatiere.SelectedValue.ToString();
            string      codeeval    = cmbEvaluation.SelectedValue.ToString();
            string      codeseq     = cmbSequence.SelectedValue.ToString();
            int         bareme      = Convert.ToInt32(cmbBareme.SelectedValue.ToString());
            double      moyenne     = 1;
            LigneNote   ligne       = new LigneNote();

            NotesBE note = new NotesBE("", codematiere, codeseq, codeeval, 0, annee, "");

            note.annee = annee;

            if (e.Key == Key.Return)
            {
                e.Handled = true;

                int row_index = grdListe.Items.IndexOf(grdListe.CurrentItem);
                int col_index = grdListe.CurrentColumn.DisplayIndex;
                row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(row_index);
                if (col_index == COLUMN_NOTE)
                {
                    DataGridCellInfo cell = grid.SelectedCells[0];
                    TextBox          textBox;
                    try
                    {
                        textBox        = (TextBox)cell.Column.GetCellContent(cell.Item);
                        ligne          = lignes.ElementAt(row_index);
                        note.anonymat  = ligne.anonymat;
                        note.matricule = ligne.matricule;
                        try
                        {
                            moyenne = Convert.ToDouble(textBox.Text);
                            if (moyenne <= bareme && moyenne >= 0)
                            {
                                note.note = (moyenne * 20) / bareme;
                                noteBL.enregistrerAnonymat(note);
                                row_index = (row_index + 1) % MAX_ROW;
                                SelectCellByIndex(grdListe, row_index, COLUMN_NOTE);
                            }
                            else
                            {
                                MessageBox.Show("La note doit être positive et inférieure à " + bareme);
                                textBox.Text = "";
                            }
                        }
                        catch (FormatException)
                        {
                            if (textBox.Text.ToUpper() == "A")
                            {
                                note.note = -1;
                                noteBL.enregistrerAnonymat(note);
                                row_index = (row_index + 1) % MAX_ROW;
                                SelectCellByIndex(grdListe, row_index, COLUMN_NOTE);
                            }
                            else
                            {
                                MessageBox.Show("Format incorrect, saisissez A pour absent ou un nombre pour sa  note", "School brain:Alerte");
                                textBox.Text = "";
                            }
                        }
                    }
                    catch (Exception)
                    {
                        row_index = (row_index + 1) % MAX_ROW;
                        SelectCellByIndex(grdListe, row_index, COLUMN_NOTE);
                    }
                }
                else
                {
                    MessageBox.Show("cellule non modifiable");
                }
            }
        }
コード例 #3
0
 internal NotesBE rechercherNotes(NotesBE note)
 {
     return(notesDA.rechercher(note));
 }
コード例 #4
0
        private void cmdOK_Click(object sender, RoutedEventArgs e)
        {
            if (validerFormulaire())
            {
                cmdOK.IsEnabled = false;

                string        codeclasse      = cmbClasse.SelectedValue.ToString();
                string        codematiere     = cmbMatiere.SelectedValue.ToString();
                string        codeeval        = cmbEvaluation.SelectedValue.ToString();
                string        codeseq         = cmbSequence.SelectedValue.ToString();
                int           bareme          = Convert.ToInt32(cmbBareme.SelectedValue.ToString());
                int           i               = 1;
                EleveBE       eleve           = new EleveBE();
                NotesBE       note            = new NotesBE("", codematiere, codeseq, codeeval, 0, annee, "");
                List <string> matriculetampon = new List <string>();

                notes = noteBL.listerSuivantCritereNotes("codemat = " + "'" + codematiere + "' and codeseq = " + "'" + codeseq + "' and codeevaluation = " + "'" + codeeval
                                                         + "' and annee = " + "'" + annee + "' and matricule in (SELECT matricule from inscrire where codeclasse = " + "'" + codeclasse + "' and annee = " + "'" + annee + "' )");
                if (notes != null)
                {
                    foreach (NotesBE n in notes)
                    {
                        eleve.matricule = n.matricule;
                        eleve           = noteBL.rechercherEleve(eleve);
                        matriculetampon.Add(n.matricule.ToUpper());
                        if (n.note != -1)
                        {
                            lignes.Add(new LigneNote(i++, eleve.nom, n.matricule, n.anonymat, (decimal)n.note * bareme / 20));
                        }
                        else
                        {
                            lignes.Add(new LigneNote(i++, eleve.nom, n.matricule, n.anonymat, -1));
                        }
                    }
                }
                inscrires = noteBL.listerSuivantCritereInscrire("codeclasse = " + "'" + codeclasse + "' and annee = " + "'" + annee + "'");
                if (inscrires != null)
                {
                    foreach (InscrireBE inscrire in inscrires)
                    {
                        if (!matriculetampon.Contains(inscrire.matricule.ToUpper()))
                        {
                            eleve.matricule = inscrire.matricule;
                            eleve           = noteBL.rechercherEleve(eleve);
                            lignes.Add(new LigneNote(i++, eleve.nom, eleve.matricule, ""));
                        }
                    }
                }

                List <LigneNote> liste = lignes.OrderBy(o => o.nom).ToList();
                lignes.Clear();
                i = 1;
                foreach (LigneNote l in liste)
                {
                    l.numero = i++;
                    lignes.Add(l);
                }
                grdListe.ItemsSource = lignes;
                grdListe.Items.Refresh();
            }
            else
            {
                MessageBox.Show("Veuillez remplir tous les champs");
            }
        }
コード例 #5
0
        private void grdListe_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            int    COLUMN_NOM       = 1;
            int    COLUMN_MATRICULE = 2;
            int    COLUMN_ANONYMAT  = 3;
            int    MAX_ROW          = lignes.Count;
            string codeclasse       = cmbClasse.SelectedValue.ToString();
            string codematiere      = cmbMatiere.SelectedValue.ToString();
            string codeeval         = cmbEvaluation.SelectedValue.ToString();
            string codeseq          = cmbSequence.SelectedValue.ToString();

            var         grid        = sender as DataGrid;
            DataGridRow row         = new DataGridRow();
            bool        deplacement = false;

            if (grid != null)
            {
                //row = grid.SelectedItem as DataGridRow;

                if (e.Key == Key.Return)
                {
                    e.Handled = true;
                    EleveBE    eleve       = new EleveBE();
                    InscrireBE inscrire    = new InscrireBE();
                    int        rowIndex    = grdListe.Items.IndexOf(grdListe.CurrentItem);
                    int        columnIndex = grdListe.CurrentColumn.DisplayIndex;
                    row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(rowIndex);
                    LigneSaisieAnonymat ligne = new LigneSaisieAnonymat();

                    NotesBE note_old = new NotesBE();
                    NotesBE note     = new NotesBE("", codematiere, codeseq, codeeval, 0, annee, "");
                    note.annee          = annee;
                    inscrire.annee      = annee;
                    inscrire.codeClasse = codeclasse;
                    ligne = lignes.ElementAt(rowIndex);
                    if (columnIndex == COLUMN_MATRICULE)
                    {
                        TextBox          textBox;
                        DataGridCellInfo cell = grid.SelectedCells[0];
                        try
                        {
                            textBox = (TextBox)cell.Column.GetCellContent(cell.Item);
                            string matriculeSaisie = textBox.Text;
                            inscrire.matricule = matriculeSaisie;
                            inscrire           = anonymatBL.rechercherInscrire(inscrire);
                            eleve.matricule    = matriculeSaisie;
                            eleve = anonymatBL.rechercherEleve(eleve);
                            if (inscrire != null)
                            {
                                if (!matriculeSaisies.Contains(inscrire.matricule.ToUpper()))
                                {
                                    if (inscrire != null)
                                    {
                                        deplacement = true;
                                        GetCell(grdListe, row, COLUMN_NOM).Content = eleve.nom;
                                        lignes.ElementAt(rowIndex).nom             = eleve.nom;
                                        matriculeSaisies.Add(inscrire.matricule.ToUpper());
                                    }
                                    else
                                    {
                                        deplacement = false;
                                        ((TextBox)cell.Column.GetCellContent(cell.Item)).Text = "";
                                        MessageBox.Show("Cet élève n'est pas inscrit en " + codeclasse + " en " + annee);
                                    }
                                }
                                else
                                {
                                    deplacement = false;
                                    ((TextBox)cell.Column.GetCellContent(cell.Item)).Text = "";
                                    MessageBox.Show("Ce matricule est déjà saisi " + inscrire.matricule);
                                }
                            }
                            else
                            {
                                deplacement = false;
                                ((TextBox)cell.Column.GetCellContent(cell.Item)).Text = "";
                                MessageBox.Show("L'élève de matricule -" + matriculeSaisie + "- n'est pas inscrit en -" + codeclasse);
                            }
                        }
                        catch (Exception)
                        {
                            deplacement = true;
                        }
                    }
                    else if (columnIndex == COLUMN_ANONYMAT)
                    {
                        string matricule = lignes.ElementAt(rowIndex).matricule;

                        inscrire.matricule = matricule;
                        inscrire           = anonymatBL.rechercherInscrire(inscrire);
                        if (inscrire == null)
                        {
                            deplacement = false;
                            MessageBox.Show("Cet élève n'est pas inscrit en " + codeclasse + " en " + annee);
                            DataGridCellInfo cell = grid.SelectedCells[0];
                            ((TextBox)cell.Column.GetCellContent(cell.Item)).Text = "";
                        }
                        else
                        {
                            TextBox          textBox;
                            DataGridCellInfo cell = grid.SelectedCells[0];
                            try
                            {
                                textBox        = (TextBox)cell.Column.GetCellContent(cell.Item);
                                note.matricule = matricule;
                                note.anonymat  = textBox.Text;
                                try
                                {
                                    anonymatsSaisies[rowIndex] = "";
                                }
                                catch (Exception) { }

                                if (anonymatsSaisies.Contains(note.anonymat))
                                {
                                    MessageBox.Show("L'anonymat " + note.anonymat + " a déjà été saisie");
                                    deplacement = false;
                                    ((TextBox)cell.Column.GetCellContent(cell.Item)).Text = "";
                                }
                                else
                                {
                                    deplacement = true;
                                    note_old    = anonymatBL.rechercherNote(note);
                                    if (note_old != null && note_old.note != 0)
                                    {
                                        note.note = note_old.note;
                                    }
                                    anonymatBL.enregistrerAnonymat(note);
                                    try
                                    {
                                        anonymatsSaisies[rowIndex] = note.anonymat;
                                    }
                                    catch (Exception)
                                    {
                                        anonymatsSaisies.Add(note.anonymat);
                                    }
                                }
                            }
                            catch (Exception)
                            {
                                deplacement = true;
                            }
                        }
                    }


                    if (deplacement)
                    {
                        if (columnIndex == COLUMN_MATRICULE)
                        {
                            SelectCellByIndex(grdListe, rowIndex, COLUMN_ANONYMAT);
                        }
                        else
                        if (columnIndex == COLUMN_ANONYMAT)
                        {
                            rowIndex = (rowIndex + 1) % MAX_ROW;
                            SelectCellByIndex(grdListe, rowIndex, COLUMN_MATRICULE);
                        }
                        else
                        {
                            MessageBox.Show("cellule non modifiable");
                        }
                    }
                }
            }
        }
コード例 #6
0
 internal NotesBE rechercherEleveDansNote(NotesBE note)
 {
     return(notesDA.rechercherEleve(note));
 }