コード例 #1
0
        public decimal perte_mois(int m, int y)
        {
            decimal        s = 0;
            List <Produit> p = db.Produit.Where(r => r.date_expiration.Value.Month < m && r.date_expiration.Value.Year < y).ToList();

            foreach (var item in p)
            {
                LigneCommande c = db.LigneCommande.Where(w => w.id_produit == item.id_produit).First();
                s += Convert.ToInt32(c.prix_grossiste) * Convert.ToInt32(item.quantite);
            }
            return(s);
        }
コード例 #2
0
        //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);
        }
コード例 #3
0
        public decimal gain_year(int y)
        {
            decimal      s      = 0;
            List <Vente> ventes = findByYear(y);

            foreach (var v in ventes)
            {
                Produit p          = db.Produit.Where(elt => elt.id_produit == v.id_produit).First();
                int     id         = p.id_produit;
                var     prix_vente = p.prix_vente;

                LigneCommande l          = db.LigneCommande.Where(li => li.id_produit == id).First();
                var           prix_achat = l.prix_grossiste / l.quantite;

                //if (prix_vente >= prix_achat)
                //{
                s += Convert.ToDecimal((prix_vente - prix_achat) * v.quantite_vendu);
                //}
            }
            return(s);
        }
コード例 #4
0
 public void add(LigneCommande ligne)
 {
     db.LigneCommande.Add(ligne);
     db.SaveChanges();
 }