diff --git a/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/MainForm.cs b/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/MainForm.cs index 83d9923..9e96124 100644 --- a/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/MainForm.cs +++ b/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/MainForm.cs @@ -59,6 +59,16 @@ namespace QuantitativerAngebotsvergleich offersTablePanel.Controls.Add(labelDeliveryFee, 0, 7); offersTablePanel.Controls.Add(labelPriceDelivered, 0, 8); + Offer cheapestOffer = null; + + foreach (Offer offer in Offers) + { + if (cheapestOffer == null || offer.PriceDelivered < cheapestOffer.PriceDelivered) + { + cheapestOffer = offer; + } + } + // iterate through all offers and create controls and add them for (int i = 0; i < Offers.Count; i++) { @@ -66,8 +76,6 @@ namespace QuantitativerAngebotsvergleich Offer offer = Offers[i]; offer.offerId = i; - - // save column number int colNumber = i + 1; @@ -84,6 +92,11 @@ namespace QuantitativerAngebotsvergleich Label labelShowDeliveryFee = new() { Text = FormatCurrency(offer.DeliveryFee) }; Label labelShowPriceDelivered = new() { Text = FormatCurrency(offer.PriceDelivered) }; + if (offer == cheapestOffer) + { + labelShowPriceDelivered.BackColor = Color.Green; + } + Console.WriteLine("Adding Controls to Column {0}, ColumnCount is {1}", colNumber, offersTablePanel.ColumnCount); labelShowTitle.MinimumSize = labelShowTitle.GetPreferredSize(default); diff --git a/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/Offer.cs b/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/Offer.cs index d172df3..4b832fb 100644 --- a/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/Offer.cs +++ b/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/Offer.cs @@ -23,6 +23,6 @@ namespace QuantitativerAngebotsvergleich public double PriceTargetPurchase { get => Math.Round(ListPrice - DiscountAmount, 2); } public double EarlyPayDiscountAmount { get => Math.Round(PriceTargetPurchase * EarlyPayDiscount, 2); } public double PriceEarlyPayDiscount { get => Math.Round(PriceTargetPurchase - EarlyPayDiscountAmount, 2); } - public double PriceDelivered { get => Math.Round(PriceTargetPurchase + DeliveryFee, 2); } + public double PriceDelivered { get => Math.Round(PriceEarlyPayDiscount + DeliveryFee, 2); } } }