public void Update(Animaux monAnimal)
        {
            try
            {
                SqlParameter monParametre;

                if (!monAnimal.Archive.HasValue)
                {
                    monAnimal.Archive = false;
                }

                SqlCommand cmd = (SqlCommand)maConnexion().CreateCommand();
                cmd.CommandText = " UPDATE Animaux " +
                                  " SET NomAnimal = @NomAnimal, Sexe = @Sexe, Couleur = @Couleur, Race = @Race, Espece = @Espece, CodeClient = @CodeClient, Tatouage = @Tatouage, Antecedents = @Antecedents, Archive = @Archive " +
                                  " WHERE CodeAnimal = @CodeAnimal ; ";

                monParametre = new SqlParameter("@NomAnimal", monAnimal.NomAnimal);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@Sexe", monAnimal.Sexe);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@Couleur", monAnimal.Couleur ?? String.Empty);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@Race", monAnimal.Race.Race);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@Espece", monAnimal.Race.Espece);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@CodeClient", monAnimal.CodeClient);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@Tatouage", monAnimal.Tatouage ?? String.Empty);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@Antecedents", monAnimal.Antecedents ?? String.Empty);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@Archive", monAnimal.Archive);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@CodeAnimal", monAnimal.CodeAnimal.Value);
                cmd.Parameters.Add(monParametre);

                cmd.ExecuteScalar();
            }
            catch (Exception ex)
            {
                throw new Exception("Echec de la modification de l'animal :\n" + ex.Message);
            }
            finally
            {
                cnx.Close();
            }
        }
        public void Add(Animaux unAnimal)
        {
            try
            {
                SqlParameter monParametre;
                Clients      proprietaire = new ADO_Clients().GetOne(unAnimal.CodeClient.Value);

                if (!unAnimal.Archive.HasValue)
                {
                    unAnimal.Archive = false;
                }

                SqlCommand cmd = (SqlCommand)maConnexion().CreateCommand();
                cmd.CommandText = " exec ajout_animal @Nomclient, @PrenomClient, @NomAnimal, @Sexe, @Couleur, @Espece, @Race, @Archive;";

                monParametre = new SqlParameter("@Nomclient", proprietaire.NomClient);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@PrenomClient", proprietaire.PrenomClient);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@NomAnimal", unAnimal.NomAnimal);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@Sexe", unAnimal.Sexe);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@Couleur", unAnimal.Couleur);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@Race", unAnimal.Race.Race);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@Espece", unAnimal.Race.Espece);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@Archive", unAnimal.Archive.Value);
                cmd.Parameters.Add(monParametre);

                cmd.ExecuteScalar();
            }
            catch (Exception ex)
            {
                throw new Exception("Echec de l'insertion d'un animal :\n" + ex.Message);
            }
            finally
            {
                cnx.Close();
            }
        }
Esempio n. 3
0
        public static void ajouterDeuxLignesNonFacture(Consultation consultation)
        {
            using (DbConnection cnx = ConnectionBDD.SeConnecter())
            {
                ADO_Animal   monAnimalDAL = new ADO_Animal();
                Veterinaires _veto        = ADO_Veterinaires.getOneVeto(consultation.CodeVeto.Value);
                Animaux      _animaux     = monAnimalDAL.GetOne(consultation.CodeAnimal.Value);

                SqlParameter monParametre;
                SqlCommand   cmd = (SqlCommand)cnx.CreateCommand();

                cmd.CommandText = " exec ajout_Consultation2 @DateConsultation, @nomVeto, @nomAnimal";

                monParametre = new SqlParameter("@nomVeto", _veto.NomVeto);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@nomAnimal", _animaux.NomAnimal);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@DateConsultation", consultation.DateConsultation.Value);
                cmd.Parameters.Add(monParametre);

                cmd.ExecuteNonQuery();
            }
        }
        public static void Add(Agendas monAgenda)
        {
            ADO_Animal  animalDAL = new ADO_Animal();
            ADO_Clients clientDAL = new ADO_Clients();

            Animaux      monAnimal = animalDAL.GetOne(monAgenda.CodeAnimal.Value);
            Clients      monClient = clientDAL.GetOne(monAnimal.CodeClient.Value);
            Veterinaires monVeto   = ADO_Veterinaires.getOneVeto(monAgenda.CodeVeto.Value);

            using (DbConnection cnx = ConnectionBDD.SeConnecter())
            {
                SqlParameter monParametre;

                SqlCommand cmd = (SqlCommand)cnx.CreateCommand();
                cmd.CommandText = " exec ajout_agenda @nomClient, @prenomClient, @nomAnimal, @nomVeto, @dateRdv ;";

                monParametre = new SqlParameter("@nomClient", monClient.NomClient);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@prenomClient", monClient.PrenomClient);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@nomAnimal", monAnimal.NomAnimal);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@nomVeto", monVeto.NomVeto);
                cmd.Parameters.Add(monParametre);
                monParametre = new SqlParameter("@dateRdv", monAgenda.DateRDV);
                cmd.Parameters.Add(monParametre);

                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw new Exception("Echec de l'insertion dans l'agnda :\n" + ex.Message);
                }
            }
        }