Ejemplo n.º 1
0
        //- Méthodes
        public bool AjouterArticle(string codeEAN, string description, decimal prixArticle, int poidsArticle)
        {
            try
            {
                LignePanier lignePanier = this[codeEAN];

                bool existeDeja = lignePanier != null;
                if (existeDeja)
                {
                    lignePanier.Quantite++;
                }
                else
                {
                    lignePanier = new LignePanier(codeEAN, description, poidsArticle, prixArticle);

                    this.lignes.Add(lignePanier);
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public bool AjouterArticle(string codeEAN13)
        {
            LignePanier lignePanier = this[codeEAN13];

            bool existe = lignePanier != null;   //si panier vide, vaudra false, sinon, true

            if (existe)
            {
                lignePanier.Quantite++;
            }

            return(existe);
        }
Ejemplo n.º 3
0
        //- Indexeur
        public LignePanier this[string codeEAN] //Ici LignePanier est le type de retour. L'indexeur n'a pas de nom
        {
            get
            {
                LignePanier retVal = null;

                foreach (LignePanier lp in this)
                {
                    if (lp.CodeEAN13 == codeEAN)
                    {
                        retVal = lp;
                        break;
                    }
                }

                return(retVal);
            }
        }
Ejemplo n.º 4
0
        public bool SupprimerArticle(string codeEAN13)
        {
            LignePanier lignePanier = this[codeEAN13];

            bool existe = lignePanier != null;

            if (existe)
            {
                bool estDernierArticle = lignePanier.Quantite == 1;
                if (estDernierArticle)
                {
                    this.lignes.Remove(lignePanier);
                }
                else
                {
                    lignePanier.Quantite--;
                }
            }

            return(existe);
        }