From 69910bbf49b765e6f3ebcc29c086d21e70c8247c Mon Sep 17 00:00:00 2001 From: Fionn Date: Thu, 24 Feb 2022 15:33:45 +0100 Subject: [PATCH] added rounding, refactored labels --- .../MainForm.cs | 34 +++++++++---------- .../QuantitativerAngebotsvergleich/Offer.cs | 14 ++++---- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/MainForm.cs b/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/MainForm.cs index 73d7f29..83d9923 100644 --- a/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/MainForm.cs +++ b/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/MainForm.cs @@ -75,31 +75,31 @@ namespace QuantitativerAngebotsvergleich Button editButton = new() { Text = "Bearbeiten" }; editButton.Click += (s, e) => { new OfferDetail(this, offer).Show(); }; - Label labelTitle = new() { Text = offer.Label }; - Label labelListPrice = new() { Text = FormatCurrency(offer.ListPrice) }; - Label labelDiscount = new() { Text = FormatCurrency(offer.DiscountAmount) }; - Label labelPriceTargetPurchase = new() { Text = FormatCurrency(offer.PriceTargetPurchase) }; - Label labelEarlyPayDiscount = new() { Text = FormatCurrency(offer.EarlyPayDiscountAmount) }; - Label labelPriceEarlyPay = new() { Text = FormatCurrency(offer.PriceEarlyPayDiscount) }; - Label labelDeliveryFee = new() { Text = FormatCurrency(offer.DeliveryFee) }; - Label labelPriceDelivered = new() { Text = FormatCurrency(offer.PriceDelivered) }; + Label labelShowTitle = new() { Text = offer.Label }; + Label labelShowListPrice = new() { Text = FormatCurrency(offer.ListPrice) }; + Label labelShowDiscount = new() { Text = FormatCurrency(offer.DiscountAmount) }; + Label labelShowPriceTargetPurchase = new() { Text = FormatCurrency(offer.PriceTargetPurchase) }; + Label labelShowEarlyPayDiscount = new() { Text = FormatCurrency(offer.EarlyPayDiscountAmount) }; + Label labelShowPriceEarlyPay = new() { Text = FormatCurrency(offer.PriceEarlyPayDiscount) }; + Label labelShowDeliveryFee = new() { Text = FormatCurrency(offer.DeliveryFee) }; + Label labelShowPriceDelivered = new() { Text = FormatCurrency(offer.PriceDelivered) }; Console.WriteLine("Adding Controls to Column {0}, ColumnCount is {1}", colNumber, offersTablePanel.ColumnCount); - labelTitle.MinimumSize = labelTitle.GetPreferredSize(default); + labelShowTitle.MinimumSize = labelShowTitle.GetPreferredSize(default); // add col styling offersTablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); - offersTablePanel.Controls.Add(labelTitle, colNumber, 0); + offersTablePanel.Controls.Add(labelShowTitle, colNumber, 0); offersTablePanel.Controls.Add(editButton, colNumber, 1); - offersTablePanel.Controls.Add(labelListPrice, colNumber, 2); - offersTablePanel.Controls.Add(labelDiscount, colNumber, 3); - offersTablePanel.Controls.Add(labelPriceTargetPurchase, colNumber, 4); - offersTablePanel.Controls.Add(labelEarlyPayDiscount, colNumber, 5); - offersTablePanel.Controls.Add(labelPriceEarlyPay, colNumber, 6); - offersTablePanel.Controls.Add(labelDeliveryFee, colNumber, 7); - offersTablePanel.Controls.Add(labelPriceDelivered, colNumber, 8); + offersTablePanel.Controls.Add(labelShowListPrice, colNumber, 2); + offersTablePanel.Controls.Add(labelShowDiscount, colNumber, 3); + offersTablePanel.Controls.Add(labelShowPriceTargetPurchase, colNumber, 4); + offersTablePanel.Controls.Add(labelShowEarlyPayDiscount, colNumber, 5); + offersTablePanel.Controls.Add(labelShowPriceEarlyPay, colNumber, 6); + offersTablePanel.Controls.Add(labelShowDeliveryFee, colNumber, 7); + offersTablePanel.Controls.Add(labelShowPriceDelivered, colNumber, 8); } // disable add button if coutn of offers is 2 or more diff --git a/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/Offer.cs b/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/Offer.cs index 43b15e5..d172df3 100644 --- a/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/Offer.cs +++ b/QuantitativerAngebotsvergleich/QuantitativerAngebotsvergleich/Offer.cs @@ -11,18 +11,18 @@ namespace QuantitativerAngebotsvergleich public string Label { get; set; } = ""; public int offerId { get; set; } = -1; - + // given Values public double ListPrice { get; set; } public double Discount { get; set; } public double EarlyPayDiscount { get; set; } public double DeliveryFee { get; set; } - + // calculated Values - public double DiscountAmount { get => ListPrice * Discount; } - public double PriceTargetPurchase { get => ListPrice - DiscountAmount; } - public double EarlyPayDiscountAmount { get => PriceTargetPurchase * EarlyPayDiscount; } - public double PriceEarlyPayDiscount { get => PriceTargetPurchase - EarlyPayDiscountAmount; } - public double PriceDelivered { get => PriceTargetPurchase + DeliveryFee; } + public double DiscountAmount { get => Math.Round(ListPrice * Discount, 2); } + 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); } } }