示例#1
0
 public void ViderArticle()
 {
     using (var context = new DBProdEntities())
     {
         context.DatabaseArticles.RemoveRange(context.DatabaseArticles);
     }
 }
示例#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();
            }
        }
示例#3
0
 public List <DatabaseArticle> RechercheParRefApproximative(string reference)
 {
     using (var context = new DBProdEntities())
     {
         return(context.DatabaseArticles.Where(r => r.Reference.Contains(reference)).ToList());
     }
 }
示例#4
0
 public List <DatabaseArticle> Load()
 {
     using (var context = new DBProdEntities())
     {
         return(context.DatabaseArticles.ToList());
     }
 }
示例#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);
     }
 }
示例#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());
     }
 }
示例#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);
     }
 }
示例#8
0
 public void AfficherArticles()
 {
     using (var context = new DBProdEntities())
     {
         foreach (var LigneArticle in context.DatabaseArticles)
         {
             Console.WriteLine(LigneArticle.ToString());
         }
     }
 }
示例#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();
            }
        }