public ActionResult SyntheseVenteAnnuel() { // LangueController.CreateCulture(getLangue()); CreateCulture(getLangue()); List <Commissions> listCommisions = EvaluationRequette.getCommissions(); List <SyntheseVentes> synthese = EnchereRequette.getSynthese(listCommisions); SyntheseVentes v = synthese[synthese.Count - 1]; ViewBag.TotalVente = v.TotalVente; ViewBag.TotalCom = v.TotalCommision; return(View(synthese)); }
public static List <SyntheseVentes> getSynthese(List <Commissions> listComs) { string connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; SqlConnection connection = new SqlConnection(connectionString); string request = ""; Decimal TotalVente = 0; Decimal TotalCom = 0; List <SyntheseVentes> maListe = new List <SyntheseVentes>(); foreach (Commissions s in listComs) { connection.Open(); try { request = "SELECT o.Nom FROM Enchere e INNER JOIN Objet o ON o.Id = e.IdObjet WHERE e.Id= '" + s.IdEnchere + "' AND e.Etat !=0 AND e.Etat != 2"; SqlCommand command = new SqlCommand(request, connection); SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { TotalVente += s.Prix; TotalCom += (s.Prix * s.Taux) / 100; SyntheseVentes v = new SyntheseVentes((string)reader["Nom"], (decimal)s.Prix, s.Date, (decimal)(s.Prix * s.Taux) / 100, (decimal)TotalVente, (decimal)TotalCom); maListe.Add(v); } reader.Close(); } catch (Exception e) { System.Console.WriteLine(e.Message); } finally { connection.Close(); } } return(maListe); }