示例#1
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);
                }
            }
        }