private void buttonValider_Click(object sender, EventArgs e)
        {
            int idPrevision = 0;

            if (!buttonValiderModifClick && comboBoxQualification.SelectedItem != null && numericUpDownNbJours.Value > 0)
            {
                Prevision Prev = new Prevision(((ProjetForfait)comboBoxProjet.SelectedItem).CodeProjet, ((Qualification)comboBoxQualification.SelectedItem), (short)numericUpDownNbJours.Value, idPrevision);
                if (DaoProjet.AddPrevision(Prev, out idPrevision) == true)
                {
                    Prev.CodePrevision = idPrevision;
                    previsionBindingSource.Add(Prev);
                }
                else
                {
                    MessageBox.Show("La prévision n'a pas été ajouté");
                }
                previsionBindingSource.ResumeBinding();
            }
            else if (buttonValiderModifClick)
            {
                ((Prevision)laQualifDataGridViewTextBoxColumn.DataGridView.CurrentRow.DataBoundItem).LaQualif = (Qualification)comboBoxQualification.SelectedItem;
                Prevision p = (Prevision)dataGridViewPrevisions.CurrentRow.DataBoundItem;
                p.NbJours = Convert.ToInt16(numericUpDownNbJours.Value);
                previsionBindingSource.ResetBindings(true);
            }
            groupBoxPrevision.Visible = false;
        }
 // Gestion du boutton supprimer
 private void buttonSupprimer_Click(object sender, EventArgs e)
 {
     if (comboBoxNomProjet.SelectedIndex >= 0)
     {
         string message = "Etes-vous sûr de vouloir supprimer";
         string caption = "Suppression d'un projet";
         var    result  = MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (result == DialogResult.Yes)
         {
             ProjetForfait projet = new ProjetForfait();
             projet.CodeProjet = ((ProjetForfait)comboBoxNomProjet.SelectedItem).CodeProjet;
             if (DaoProjet.DelProjet(projet) == true)
             {
                 projetForfaitBindingSource.Remove(comboBoxNomProjet.SelectedItem);
                 projetForfaitBindingSource.ResetBindings(true);
             }
             else
             {
                 MessageBox.Show("Le projet n'a pas pu etre supprimé");
             }
         }
     }
     comboBoxNomProjet.SelectedItem = null;
     groupBoxProjet.Visible         = false;
     groupBoxForfait.Visible        = false;
 }
 //Gestion du selected index
 private void comboBoxProjet_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBoxProjet.SelectedItem != null)
     {
         previsionBindingSource.DataSource = DaoProjet.GetPrevisionByProjet(((ProjetForfait)comboBoxProjet.SelectedItem).CodeProjet);
         buttonCreer.Enabled = true;
     }
 }
        // Gestion du chargement des bindings
        private void Prevision_Load(object sender, EventArgs e)
        {
            projetForfaitBindingSource.DataSource = DaoProjet.GetAllProject();
            qualificationBindingSource.DataSource = DaoProjet.GetAllQualification();

            comboBoxProjet.SelectedItem = null;
            groupBoxPrevision.Visible   = false;
        }
 // On lance le databinding au chargement
 private void Form1_Load(object sender, EventArgs e)
 {
     projetForfaitBindingSource.DataSource = DaoProjet.GetAllProject();
     clientBindingSource.DataSource        = DaoProjet.GetAllclients();
     collaborateurBindingSource.DataSource = DaoProjet.GetAllCollaborateurs();
     comboBoxNomProjet.SelectedItem        = null;
     groupBoxProjet.Visible  = false;
     groupBoxForfait.Visible = false;
 }
        // On gère l'evenement du click sur valider
        private void buttonValider_Click(object sender, EventArgs e)
        {
            int CodeProjet = 0;



            if (comboBoxResponsable.SelectedItem != null && comboBoxClient != null && nomIsOk == true && dateIsOk == true && montantIsOk == true)
            {
                ProjetForfait projet = new ProjetForfait(CodeProjet, textBoxNomProjet.Text, dateDebut, dateFin, (Client)comboBoxClient.SelectedItem, textBoxContact.Text, textBoxMailContact.Text, Convert.ToDecimal(textBoxMontantContrat.Text), radioButtonOui.Checked, (Collaborateur)comboBoxResponsable.SelectedItem);
                if (clickCreer == true)
                {
                    if (DaoProjet.AddProjet(projet, out CodeProjet) == true)
                    {
                        projet.CodeProjet = CodeProjet;
                        projetForfaitBindingSource.Add(projet);
                    }
                    else
                    {
                        MessageBox.Show("Le projet n'a pas été ajouté");
                    }
                    projetForfaitBindingSource.ResumeBinding();
                    const string caption = "Projet enregistré";
                    string       message = "Projet" + projet.ToString() + "\n" + "Client" + comboBoxClient.SelectedItem.ToString() + "\n" + textBoxContact.Text + "," + textBoxMailContact.Text + "\n" + "[" + textBoxMontantContrat.Text + "," + "Collaborateur" + comboBoxResponsable.SelectedItem.ToString();
                    MessageBox.Show(message, caption, MessageBoxButtons.OK);
                    comboBoxNomProjet.Enabled      = true;
                    comboBoxNomProjet.SelectedItem = null;
                    ChangerEnabledTrueOrFalse(false);
                    groupBoxForfait.Visible = false;
                    groupBoxProjet.Visible  = false;
                }
                if (clickModif == true)
                {
                    Verif();

                    string message = "Veuillez confirmer la modification";
                    string caption = "Validation de la modification";
                    var    result  = MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        projet.CodeProjet = ((ProjetForfait)comboBoxNomProjet.SelectedItem).CodeProjet;

                        if (DaoProjet.UpdProjet(projet) == true)
                        {
                            projetForfaitBindingSource.ResumeBinding();
                        }
                        else
                        {
                            MessageBox.Show("La mise a jour n'a pas été effectuée");
                        }
                        const string caption2 = "Projet modifié";
                        string       message2 = "Projet" + projet.ToString() + "\n" + "Client" + comboBoxClient.SelectedItem.ToString() + "\n" + textBoxContact.Text + "," + textBoxMailContact.Text + "\n" + "[" + textBoxMontantContrat.Text + "," + "Collaborateur" + comboBoxResponsable.SelectedItem.ToString();
                        MessageBox.Show(message2, caption2, MessageBoxButtons.OK);
                        comboBoxNomProjet.Enabled = true;
                        projetForfaitBindingSource.ResumeBinding();
                        comboBoxNomProjet.SelectedItem = null;
                        ChangerEnabledTrueOrFalse(false);
                        groupBoxForfait.Visible = false;
                        groupBoxProjet.Visible  = false;
                    }
                }
            }
            else
            {
                if (nomIsOk == false)
                {
                    errorProviderNomProjet.SetError(textBoxNomProjet, "Le nom est obligatoire pour créer un projet");
                }
                else if (dateIsOk == false)
                {
                    errorProviderDateDebut.SetError(maskedTextBoxDateDebut, "La saisie des dates est obligatoire");
                    errorProviderDateFin.SetError(maskedTextBoxDateFin, "La saisie des dates est obligatoire");
                }
                else if (montantIsOk == false)
                {
                    errorProviderMontant.SetError(textBoxMontantContrat, "Le montant du contrat est obligatoire pour créer un projet");
                }
                else if (comboBoxClient.SelectedItem == null)
                {
                    MessageBox.Show("Veuillez selectionner un client");
                }
                else if (comboBoxResponsable.SelectedItem == null)
                {
                    MessageBox.Show("Veuillez selectionneur un collaborateur");
                }
            }
        }