Exemplo n.º 1
0
 public void ViderArticle()
 {
     using (var context = new DBProdEntities())
     {
         context.DatabaseArticles.RemoveRange(context.DatabaseArticles);
     }
 }
Exemplo n.º 2
0
        public void AjouterArticle(string reference, string designation, decimal prixVente, decimal qteStock, bool sommeil)
        {
            if (reference == null)
            {
                throw new Exception("Reference nulle impossible.");
            }
            if (designation == null || designation.Length < 1)
            {
                throw new Exception("Designation vide impossible.");
            }
            if (prixVente < 0)
            {
                throw new Exception("Prix de vente inférieur à 0 impossible.");
            }
            if (qteStock < 0)
            {
                throw new Exception("Quantité stock inférieur à 0 impossible.");
            }

            using (var context = new DBProdEntities())
            {
                context.DatabaseArticles.Add(new DatabaseArticle()
                {
                    Reference   = reference,
                    Designation = designation,
                    PrixVente   = prixVente,
                    QteStock    = qteStock,
                    Sommeil     = sommeil,
                });

                context.SaveChanges();
            }
        }
Exemplo n.º 3
0
 public List <DatabaseArticle> RechercheParRefApproximative(string reference)
 {
     using (var context = new DBProdEntities())
     {
         return(context.DatabaseArticles.Where(r => r.Reference.Contains(reference)).ToList());
     }
 }
Exemplo n.º 4
0
 public List <DatabaseArticle> Load()
 {
     using (var context = new DBProdEntities())
     {
         return(context.DatabaseArticles.ToList());
     }
 }
Exemplo n.º 5
0
 public void SupprimerParRef(string reference)
 {
     using (var context = new DBProdEntities())
     {
         var temp = context.DatabaseArticles.Where(r => r.Reference == reference);
         context.DatabaseArticles.RemoveRange(temp);
     }
 }
Exemplo n.º 6
0
 public List <DatabaseArticle> RechercheParIntervallePrix(decimal min, decimal max)
 {
     using (var context = new DBProdEntities())
     {
         var temp = context.DatabaseArticles.Where(p => p.PrixVente >= min && p.PrixVente <= max);
         return(temp.ToList());
     }
 }
Exemplo n.º 7
0
 public DatabaseArticle RechercheParRefExacte(string reference)
 {
     using (var context = new DBProdEntities())
     {
         var temp   = context.DatabaseArticles.Where(r => r.Reference == reference);
         var result = temp.FirstOrDefault();
         return(result);
     }
 }
Exemplo n.º 8
0
 public void AfficherArticles()
 {
     using (var context = new DBProdEntities())
     {
         foreach (var LigneArticle in context.DatabaseArticles)
         {
             Console.WriteLine(LigneArticle.ToString());
         }
     }
 }
Exemplo n.º 9
0
        public void ModifierParRef(string reference, string designation = null, decimal?prixVente = null, decimal?qteStock = null)
        {
            if (prixVente < 0)
            {
                throw new Exception("Prix de vente inférieur à 0 impossible.");
            }
            if (qteStock < 0)
            {
                throw new Exception("Quantité stock inférieur à 0 impossible.");
            }

            using (var context = new DBProdEntities())
            {
                var temp   = context.DatabaseArticles.Where(r => r.Reference == reference);
                var result = temp.FirstOrDefault();
                if (result != null)
                {
                    result.Designation = designation ?? result.Designation;
                    result.PrixVente   = prixVente ?? result.PrixVente;
                    result.QteStock    = qteStock ?? result.QteStock;
                }
                context.SaveChanges();
            }
        }