Пример #1
0
 /// <summary>
 /// Modifier animal
 /// </summary>
 /// <param name="animal"></param>
 /// <param name="nomAnimal"></param>
 /// <param name="sexe"></param>
 /// <param name="couleur"></param>
 /// <param name="race"></param>
 /// <param name="tatouage"></param>
 /// <param name="antecedents"></param>
 /// <param name="client"></param>
 /// <param name="archive"></param>
 /// <exception cref="Exception"></exception>
 public void ModifierAnimal(Animal animal, string nomAnimal, Animal.eSexe sexe, string couleur, Race race,
                            string tatouage, string antecedents, Client client, bool archive = false)
 {
     try
     {
         AnimalStore.Instance.Modifier(animal, nomAnimal, sexe, couleur, race, tatouage, antecedents, archive, client);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Пример #2
0
 /// <summary>
 /// creer via le store un object animal et l'ajoute dans la bindinglist
 /// </summary>
 /// <param name="nomAnimal"></param>
 /// <param name="sexe"></param>
 /// <param name="antecedant"></param>
 /// <param name="archive"></param>
 /// <param name="client"></param>
 /// <param name="couleur"></param>
 /// <param name="race"></param>
 /// <param name="tatouage"></param>
 /// <returns>un object animal</returns>
 /// <exception cref="Exception"></exception>
 public Animal AjouterAnimal(string nomAnimal, Animal.eSexe sexe, string couleur, Race race,
                             string tatouage, string antecedant, bool archive, Client client)
 {
     try
     {
         Animal a = AnimalStore.Instance.Ajouter(nomAnimal, sexe, couleur, race, tatouage, antecedant, archive, client);
         _animaux.Add(a);
         return(a);
     }
     catch (Exception e)
     {
         throw e;
     }
     return(null);
 }
Пример #3
0
        /// <summary>
        /// Creer un animal
        /// </summary>
        /// <param name="nomAnimal"></param>
        /// <param name="sexe"></param>
        /// <param name="couleur"></param>
        /// <param name="race"></param>
        /// <param name="tatouage"></param>
        /// <param name="antecedant"></param>
        /// <param name="archive"></param>
        /// <param name="client"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public Animal Ajouter(string nomAnimal, Animal.eSexe sexe, string couleur, Race race,
                              string tatouage, string antecedant, bool archive, Client client)
        {
            Animal animal = new Animal(Guid.NewGuid(), nomAnimal, sexe, couleur, race, tatouage, antecedant, archive, client);

            try
            {
                Database.Instance.insert(animal);
                this.Animaux.Add(animal);
            }
            catch (Exception e)
            {
                throw new Exception("Erreur sur Ajout.\n" + e.Message, e);
            }
            return(animal);
        }
Пример #4
0
        private void _loadAnimaux()
        {
            string        sql = "select * from Animaux";
            IDbConnection cn  = Database.Instance.getConnection();
            IDbCommand    cmd = cn.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = sql;
            try
            {
                cn.Open();
                IDataReader reader = cmd.ExecuteReader();
                object      tatouage, couleur, antecedent;
                while (reader.Read())
                {
                    tatouage   = Database.read(reader, "Tatouage");
                    couleur    = Database.read(reader, "Couleur");
                    antecedent = Database.read(reader, "Antecedents");
                    Client       client = ClientStore.Instance.RecupererClient(Database.read <Guid>(reader, "CodeClient"));
                    Race         race   = RaceStore.Instance.RecupererRace(Database.read <string>(reader, "Race"), Database.read <string>(reader, "Espece"));
                    Animal.eSexe sexe   = (Animal.eSexe)(Database.read <string>(reader, "Sexe")[0]);
                    this.Animaux.Add(new Animal(
                                         Database.read <Guid>(reader, "CodeAnimal"),
                                         Database.read <string>(reader, "NomAnimal"),
                                         sexe,
                                         couleur == null? null : (String)couleur,
                                         race,
                                         tatouage == null? null:(string)tatouage,
                                         antecedent == null ? null:(string)antecedent,
                                         Database.read <bool>(reader, "Archive"),
                                         client
                                         )
                                     );
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                Database.close(cn);
            }
        }
Пример #5
0
 /// <summary>
 /// Modifie l'animal
 /// </summary>
 /// <param name="animal"></param>
 /// <param name="nomAnimal"></param>
 /// <param name="sexe"></param>
 /// <param name="couleur"></param>
 /// <param name="race"></param>
 /// <param name="tatouage"></param>
 /// <param name="antecedents"></param>
 /// <param name="archive"></param>
 /// <param name="client"></param>
 /// <exception cref="Exception"></exception>
 public void Modifier(Animal animal, string nomAnimal, Animal.eSexe sexe, string couleur, Race race,
                      string tatouage, string antecedents, bool archive, Client client)
 {
     animal.Antecedents = antecedents;
     animal.Archive     = archive;
     animal.Client      = client;
     animal.Couleur     = couleur;
     animal.NomAnimal   = nomAnimal;
     animal.Sexe        = sexe;
     animal.Tatouage    = tatouage;
     animal.Race        = race;
     try
     {
         Database.Instance.update(animal);
     }
     catch (Exception e)
     {
         throw new Exception("Erreur sur Modification.\n" + e.Message, e);
     }
 }