コード例 #1
0
ファイル: TitresDAL.cs プロジェクト: rlion/ApplicationENI
        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;
            }
        }
コード例 #2
0
ファイル: NewJure.xaml.cs プロジェクト: rlion/ApplicationENI
 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);
     }
 }