Example #1
0
        public void RetirerChamp(string nomChamp)
        {
            int indexChamp = Champs.FindIndex(c => c.Nom == nomChamp);

            if (indexChamp >= 0)
            {
                Champs.RemoveAt(indexChamp);
            }
        }
Example #2
0
        public Champ GetChamp(string nomChamp)
        {
            int indexExistant;

            if ((indexExistant = Champs.FindIndex(c => c.Nom == nomChamp)) < 0)
            {
                return(null);
            }

            return(Champs[indexExistant]);
        }
Example #3
0
        public T GetValeurChamp <T>(string nomChamp)
        {
            T   valeurParDefault = default(T);
            int index;

            if ((index = Champs.FindIndex(c => c.Nom == nomChamp)) < 0 || Champs[index].Valeur.GetType() == DBNull.Value.GetType())
            {
                return(valeurParDefault);
            }

            try
            {
                return((T)Global.ConvertirValeur <T>(Champs[index].Valeur));
            }
            catch (InvalidCastException ex)
            {
                Outils.Journal.EcrireException("Erreur de conversion dans la table '" + NomTable + "' pour le champ '" + nomChamp + "'.", ex);
            }

            return(valeurParDefault);
        }
Example #4
0
        public void AjouterChamp(Champ champ, string nomChampSuivant)
        {
            if (champ == null || champ.Nom == null || champ.Nom.Length <= 0)
            {
                Outils.Journal.EcrireMessage("Tentative d'ajout d'un champ null dans la table '" + NomTable + "'.");
                return;
            }

            int indexExistant;

            if ((indexExistant = Champs.FindIndex(c => c.Nom == champ.Nom)) != -1)
            {
                Champs[indexExistant].Valeur = champ.Valeur;
                return;
            }

            if ((indexExistant = Champs.FindIndex(c => c.Nom == nomChampSuivant)) != -1)
            {
                Champs.Insert(indexExistant, champ);
                return;
            }

            Champs.Add(champ);
        }