added comparing offers, fixed minor stupidity

main
Fionn 3 years ago
parent 69910bbf49
commit 723cbe777b

@ -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);

@ -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); }
}
}

Loading…
Cancel
Save