//Ajout
 private void button1_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(textBox1.Text))
     {
         DiplomeView.afficherPopup("Le nom est vide");
     }
     else
     {
         TypeCours type = new TypeCours(textBox1.Text);
         TypeCoursDAO.create(type);
         upadateList();
         List <CategoriePersonnel> catList = CategoriePersonnelDAO.findAll();
         foreach (CategoriePersonnel cat in catList)
         {
             Ratio r = new Ratio(type, cat);
             r.ratio = 1;
             RatioDAO.create(r);
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Evenement valider / modifier
        /// </summary>
        private void validerAction(object sender, EventArgs e)
        {
            CategoriePersonnel categorie = new CategoriePersonnel();
            int volumeHoraire            = 0;

            Boolean categorieIncorrect     = String.IsNullOrWhiteSpace(categorietextBox.Text);
            Boolean volumeHoraireIncorrect = !Int32.TryParse(volumeTextBox.Text, out volumeHoraire);

            if (categorieIncorrect || volumeHoraireIncorrect)
            {
                // Initializes the variables to pass to the MessageBox.Show method.
                string message = "Erreur lors de la saisie des données \n";
                message += volumeHoraireIncorrect ? " le volume horaire est incorrect" : "";
                message += categorieIncorrect ? " le nom de la categorie est incorrect" : "";

                DiplomeView.afficherPopup(message);
            }
            else
            {
                categorie.libelle       = categorietextBox.Text;
                categorie.volumeHoraire = volumeHoraire;
                categorie = CategoriePersonnelDAO.create(categorie);

                if (categorie != null)
                {
                    foreach (TypeCours typeCours in TypeCoursDAO.findAll())
                    {
                        Ratio temp = new Ratio();
                        temp.ratio              = 1;
                        temp.typeCours          = typeCours;
                        temp.categoriePersonnel = categorie;
                        RatioDAO.create(temp);
                    }

                    this.Close();
                }
            }
        }