Exemplo n.º 1
0
        public static int AjouterJury(Jury jury)
        {
            try
            {
                string req = "insert into Jury (civilite, nom, prenom) " +
                             "select @civ, @nom, @prenom where not exists " +
                             "(select 0 from Jury where civilite=@civ and nom=@nom and prenom=@prenom)";

                SqlConnection conn = ConnexionSQL.CreationConnexion();
                SqlCommand commande = conn.CreateCommand();
                commande.CommandText = req;
                commande.Parameters.AddWithValue("@civ", jury.Civilite);
                commande.Parameters.AddWithValue("@nom", jury.Nom);
                commande.Parameters.AddWithValue("@prenom", jury.Prenom);

                int retour = commande.ExecuteNonQuery();
                conn.Close();
                return retour;
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show("L'ajout de ce jury est impossible : " + e.Message,
                    "Ajout Jury", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Stop);
                return -1;
            }
        }
Exemplo n.º 2
0
 private void btValider_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Jury jury = new Jury(999, txtCivilite.Text, txtNom.Text, txtPrenom.Text);
         DAL.TitresDAL.AjouterJury(jury);
         this.Close();
     }
     catch(Exception ex)
     {
         MessageBox.Show(ex.Message, "Erreur Création Juré", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }