// Tableau des du stock des matières premières et emballages private void AfficherTableauStockMatieresPremieres(DateTime date) { var matieresPremieres = (from mp in db.ResStockMatieresPremieres orderby mp.NomMatiere select mp.NomMatiere).ToList(); DataTable dt = CreerTableau(); foreach (var matiere in matieresPremieres) { var stock = GestionStocks.CalculerSoldeStockMatierePremiere(matiere, date); var coutU = CoutDAchatDesMatierePremieres.CoutDAchat(matiere); DataRow dr = dt.NewRow(); dt.Rows.InsertAt(dr, dt.Rows.Count); dr["Description"] = matiere; dr["Stock"] = stock; dr["Coût unitaire"] = coutU; dr["Valeur"] = stock * coutU; } dgvTableauAffichageStocks.DataSource = dt; dt.Rows.Add("Total", 0, 0, Conversion.CalculerTotal(dgvTableauAffichageStocks, "Valeur")); FormatterTableau(dgvTableauAffichageStocks); }
public static Single ValeurStockMatieresPremieres(DateTime date) { using (CasaDBEntities db = new CasaDBEntities()) { Single valeurStockMatieresPremieres = 0; var listeMatieresPremieres = (from mp in db.ResStockMatieresPremieres select mp.NomMatiere).ToList(); foreach (var matPrem in listeMatieresPremieres) { valeurStockMatieresPremieres += GestionStocks.CalculerSoldeStockMatierePremiere(matPrem, date) * CoutDAchatDesMatierePremieres.CoutDAchat(matPrem); } return(valeurStockMatieresPremieres); } }
public static Single QuantiteDeMatieresConsommees(DateTime debutPeriode, DateTime finPeriode, string matiere) { using (CasaDBEntities db = new CasaDBEntities()) { Single stockInitial = GestionStocks.CalculerSoldeStockMatierePremiere(matiere, debutPeriode); Single stockFinal = GestionStocks.CalculerSoldeStockMatierePremiere(matiere, finPeriode); Single achatsMatierePremiere = (from rmp in db.EveReceptionMatieresPremieres where rmp.ResStockMatieresPremiere.NomMatiere == matiere where rmp.DateReception >= debutPeriode where rmp.DateReception <= finPeriode select(float?) rmp.Quantite).Sum() ?? 0; Single receptionDonsMatierePremiere = (from rdmp in db.EveReceptionDonsMatieresPremieres where rdmp.ResStockMatieresPremiere.NomMatiere == matiere where rdmp.DateReception >= debutPeriode where rdmp.DateReception <= finPeriode select(float?) rdmp.Quantite).Sum() ?? 0; Single entrees = achatsMatierePremiere + receptionDonsMatierePremiere; return(stockInitial + entrees - stockFinal); } }