Exemple #1
0
        public int add(Vente vente)
        {
            db.Vente.Add(vente);
            db.SaveChanges();

            return(vente.id_vente);
        }
        //gain month
        public int gain1(int id, int m, int i, int y)
        {
            // List<Vente> vente =  db.Vente.Where(c => c.date_ajout == date).ToList();
            // var n = from v in vente select v.quantite_vendu;

            Vente   pv = db.Vente.Where(c => c.id_produit == id && c.date_ajout.Value.Month == m && c.id_vente == i && c.date_ajout.Value.Year == y).First();
            Produit pr = db.Produit.Where(c => c.id_produit == id).First();

            int q    = Convert.ToInt32(pv.quantite_vendu);
            int prix = Convert.ToInt32(pr.prix_vente);

            int           prix_total = prix_prod(id, q);
            LigneCommande l          = db.LigneCommande.Where(c => c.id_produit == id).First();

            int prix_achat = Convert.ToInt32(l.prix_grossiste / l.quantite);
            int gain       = prix_total - prix_achat * q;

            return(gain);
        }