Fionn 3 years ago
parent 724657cebf
commit 21c1923ffe

@ -28,19 +28,191 @@
/// </summary>
private void InitializeComponent()
{
this.buttonAddNewOffer = new System.Windows.Forms.Button();
this.offersTablePanel = new System.Windows.Forms.TableLayoutPanel();
this.labelPriceDelivered = new System.Windows.Forms.Label();
this.labelDeliveryFee = new System.Windows.Forms.Label();
this.labelPriceEarlyPayDiscount = new System.Windows.Forms.Label();
this.labelEarlyPayDiscount = new System.Windows.Forms.Label();
this.labelPriceTargetPurchase = new System.Windows.Forms.Label();
this.labelDiscount = new System.Windows.Forms.Label();
this.labelListPrice = new System.Windows.Forms.Label();
this.labelEdit = new System.Windows.Forms.Label();
this.labelOfferTitle = new System.Windows.Forms.Label();
this.buttonMetaData = new System.Windows.Forms.Button();
this.offersTablePanel.SuspendLayout();
this.SuspendLayout();
//
// buttonAddNewOffer
//
this.buttonAddNewOffer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonAddNewOffer.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.buttonAddNewOffer.Location = new System.Drawing.Point(656, 12);
this.buttonAddNewOffer.Name = "buttonAddNewOffer";
this.buttonAddNewOffer.Size = new System.Drawing.Size(132, 25);
this.buttonAddNewOffer.TabIndex = 0;
this.buttonAddNewOffer.Text = "Angebot hinzufügen";
this.buttonAddNewOffer.UseVisualStyleBackColor = true;
this.buttonAddNewOffer.Click += new System.EventHandler(this.buttonAddNewOffer_Click);
//
// offersTablePanel
//
this.offersTablePanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.offersTablePanel.AutoSize = true;
this.offersTablePanel.ColumnCount = 2;
this.offersTablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.offersTablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.offersTablePanel.Controls.Add(this.labelOfferTitle, 0, 0);
this.offersTablePanel.Controls.Add(this.labelEdit, 0, 1);
this.offersTablePanel.Controls.Add(this.labelListPrice, 0, 2);
this.offersTablePanel.Controls.Add(this.labelDiscount, 0, 3);
this.offersTablePanel.Controls.Add(this.labelPriceTargetPurchase, 0, 4);
this.offersTablePanel.Controls.Add(this.labelEarlyPayDiscount, 0, 5);
this.offersTablePanel.Controls.Add(this.labelPriceEarlyPayDiscount, 0, 6);
this.offersTablePanel.Controls.Add(this.labelDeliveryFee, 0, 7);
this.offersTablePanel.Controls.Add(this.labelPriceDelivered, 0, 8);
this.offersTablePanel.Location = new System.Drawing.Point(12, 41);
this.offersTablePanel.Name = "offersTablePanel";
this.offersTablePanel.RowCount = 11;
this.offersTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.offersTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.offersTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.offersTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.offersTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.offersTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.offersTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.offersTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.offersTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.offersTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.offersTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.offersTablePanel.Size = new System.Drawing.Size(776, 220);
this.offersTablePanel.TabIndex = 1;
//
// labelPriceDelivered
//
this.labelPriceDelivered.AutoSize = true;
this.labelPriceDelivered.Location = new System.Drawing.Point(3, 155);
this.labelPriceDelivered.Name = "labelPriceDelivered";
this.labelPriceDelivered.Size = new System.Drawing.Size(69, 15);
this.labelPriceDelivered.TabIndex = 8;
this.labelPriceDelivered.Text = "Bezugspreis";
//
// labelDeliveryFee
//
this.labelDeliveryFee.AutoSize = true;
this.labelDeliveryFee.Location = new System.Drawing.Point(3, 135);
this.labelDeliveryFee.Name = "labelDeliveryFee";
this.labelDeliveryFee.Size = new System.Drawing.Size(79, 15);
this.labelDeliveryFee.TabIndex = 7;
this.labelDeliveryFee.Text = "Bezugskosten";
//
// labelPriceEarlyPayDiscount
//
this.labelPriceEarlyPayDiscount.AutoSize = true;
this.labelPriceEarlyPayDiscount.Location = new System.Drawing.Point(3, 115);
this.labelPriceEarlyPayDiscount.Name = "labelPriceEarlyPayDiscount";
this.labelPriceEarlyPayDiscount.Size = new System.Drawing.Size(93, 15);
this.labelPriceEarlyPayDiscount.TabIndex = 6;
this.labelPriceEarlyPayDiscount.Text = "Bareinkaufspreis";
//
// labelEarlyPayDiscount
//
this.labelEarlyPayDiscount.AutoSize = true;
this.labelEarlyPayDiscount.Location = new System.Drawing.Point(3, 95);
this.labelEarlyPayDiscount.Name = "labelEarlyPayDiscount";
this.labelEarlyPayDiscount.Size = new System.Drawing.Size(82, 15);
this.labelEarlyPayDiscount.TabIndex = 5;
this.labelEarlyPayDiscount.Text = "Liefererskonto";
//
// labelPriceTargetPurchase
//
this.labelPriceTargetPurchase.AutoSize = true;
this.labelPriceTargetPurchase.Location = new System.Drawing.Point(3, 75);
this.labelPriceTargetPurchase.Name = "labelPriceTargetPurchase";
this.labelPriceTargetPurchase.Size = new System.Drawing.Size(95, 15);
this.labelPriceTargetPurchase.TabIndex = 4;
this.labelPriceTargetPurchase.Text = "Zieleinkaufspreis";
//
// labelDiscount
//
this.labelDiscount.AutoSize = true;
this.labelDiscount.Location = new System.Drawing.Point(3, 55);
this.labelDiscount.Name = "labelDiscount";
this.labelDiscount.Size = new System.Drawing.Size(67, 15);
this.labelDiscount.TabIndex = 3;
this.labelDiscount.Text = "Lieferrabatt";
//
// labelListPrice
//
this.labelListPrice.AutoSize = true;
this.labelListPrice.Location = new System.Drawing.Point(3, 35);
this.labelListPrice.Name = "labelListPrice";
this.labelListPrice.Size = new System.Drawing.Size(107, 15);
this.labelListPrice.TabIndex = 2;
this.labelListPrice.Text = "Listeneinkaufspreis";
//
// labelEdit
//
this.labelEdit.AutoSize = true;
this.labelEdit.Location = new System.Drawing.Point(3, 20);
this.labelEdit.Name = "labelEdit";
this.labelEdit.Size = new System.Drawing.Size(112, 15);
this.labelEdit.TabIndex = 1;
this.labelEdit.Text = "Bearbeiten/Löschen";
//
// labelOfferTitle
//
this.labelOfferTitle.AutoSize = true;
this.labelOfferTitle.Location = new System.Drawing.Point(3, 0);
this.labelOfferTitle.Name = "labelOfferTitle";
this.labelOfferTitle.Size = new System.Drawing.Size(78, 15);
this.labelOfferTitle.TabIndex = 0;
this.labelOfferTitle.Text = "Angebotstitel";
//
// buttonMetaData
//
this.buttonMetaData.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.buttonMetaData.Location = new System.Drawing.Point(12, 12);
this.buttonMetaData.Name = "buttonMetaData";
this.buttonMetaData.Size = new System.Drawing.Size(638, 25);
this.buttonMetaData.TabIndex = 2;
this.buttonMetaData.Text = "Metadaten";
this.buttonMetaData.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.buttonMetaData.UseVisualStyleBackColor = true;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.buttonMetaData);
this.Controls.Add(this.offersTablePanel);
this.Controls.Add(this.buttonAddNewOffer);
this.Name = "MainForm";
this.Text = "Quantitativer Angebotsvergleich";
this.offersTablePanel.ResumeLayout(false);
this.offersTablePanel.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Button buttonAddNewOffer;
private TableLayoutPanel offersTablePanel;
private Label labelOfferTitle;
private Label labelEdit;
private Label labelListPrice;
private Label labelDiscount;
private Label labelPriceTargetPurchase;
private Label labelEarlyPayDiscount;
private Label labelPriceEarlyPayDiscount;
private Label labelDeliveryFee;
private Label labelPriceDelivered;
private Button buttonMetaData;
}
}

@ -2,9 +2,119 @@ namespace QuantitativerAngebotsvergleich
{
public partial class MainForm : Form
{
internal readonly OfferMeta Meta = new();
private List<Offer> Offers = new();
public MainForm()
{
InitializeComponent();
}
public void AddOffer(Offer offer)
{
Offers.Add(offer);
RedrawFields();
}
public void OverwriteOffer(int index, Offer newOffer)
{
Offers[index] = newOffer;
RedrawFields();
}
public void DeleteOffer(int index)
{
Offers.RemoveAt(index);
RedrawFields();
}
public void RedrawFields()
{
// get rid of all controls ad column styles
offersTablePanel.Controls.Clear();
offersTablePanel.ColumnStyles.Clear();
// add column style for label col
offersTablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
// set column count to fit all offers
offersTablePanel.ColumnCount = Offers.Count + 1;
// add all controls back
offersTablePanel.Controls.Add(labelOfferTitle, 0, 0);
offersTablePanel.Controls.Add(labelEdit, 0, 1);
offersTablePanel.Controls.Add(labelListPrice, 0, 2);
offersTablePanel.Controls.Add(labelDiscount, 0, 3);
offersTablePanel.Controls.Add(labelPriceTargetPurchase, 0, 4);
offersTablePanel.Controls.Add(labelEarlyPayDiscount, 0, 5);
offersTablePanel.Controls.Add(labelPriceEarlyPayDiscount, 0, 6);
offersTablePanel.Controls.Add(labelDeliveryFee, 0, 7);
offersTablePanel.Controls.Add(labelPriceDelivered, 0, 8);
// iterate through all offers and create controls and add them
for (int i = 0; i < Offers.Count; i++)
{
// take offer and set offer id for later modification
Offer offer = Offers[i];
offer.offerId = i;
// save column number
int colNumber = i + 1;
// create button and add click handler
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) };
Console.WriteLine("Adding Controls to Column {0}, ColumnCount is {1}", colNumber, offersTablePanel.ColumnCount);
labelTitle.MinimumSize = labelTitle.GetPreferredSize(default);
// add col styling
offersTablePanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
offersTablePanel.Controls.Add(labelTitle, 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);
}
if (Offers.Count > 1)
{
buttonAddNewOffer.Enabled = false;
}
}
private void buttonAddNewOffer_Click(object sender, EventArgs e)
{
new OfferDetail(this, null).Show();
}
private string FormatCurrency(dynamic val)
{
return $"{Meta.Currency} {val}";
}
}
public class OfferMeta
{
public int Amount { get; set; } = 0;
public string Currency { get; set; } = "€";
}
}

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QuantitativerAngebotsvergleich
{
public class Offer
{
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; }
}
}

@ -0,0 +1,391 @@
namespace QuantitativerAngebotsvergleich
{
partial class OfferDetail
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.buttonAddOffer = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.textBoxInputListPrice = new System.Windows.Forms.TextBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.labelPriceDelivered = new System.Windows.Forms.Label();
this.labelOutputDiscount = new System.Windows.Forms.Label();
this.labelField = new System.Windows.Forms.Label();
this.labelInput = new System.Windows.Forms.Label();
this.labelOutput = new System.Windows.Forms.Label();
this.labelInputListPrice = new System.Windows.Forms.Label();
this.labelOutputListPrice = new System.Windows.Forms.Label();
this.textBoxInputDiscount = new System.Windows.Forms.TextBox();
this.labelInputDiscount = new System.Windows.Forms.Label();
this.labelPriceTargetPurchase = new System.Windows.Forms.Label();
this.labelInputEarlyPayDiscount = new System.Windows.Forms.Label();
this.labelPriceEarlyPayDiscount = new System.Windows.Forms.Label();
this.labelInputDeliveryFee = new System.Windows.Forms.Label();
this.textBoxInputEarlyPayDiscount = new System.Windows.Forms.TextBox();
this.textBoxInputDeliveryFee = new System.Windows.Forms.TextBox();
this.labelOutputPriceTargetPurchase = new System.Windows.Forms.Label();
this.labelOutputEarlyPayDiscount = new System.Windows.Forms.Label();
this.labelOutputPriceEarlyPayDiscount = new System.Windows.Forms.Label();
this.labelOutputDeliveryFee = new System.Windows.Forms.Label();
this.labelOutputPriceDelivered = new System.Windows.Forms.Label();
this.labelInputLabel = new System.Windows.Forms.Label();
this.textBoxInputLabel = new System.Windows.Forms.TextBox();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// buttonAddOffer
//
this.buttonAddOffer.Location = new System.Drawing.Point(247, 283);
this.buttonAddOffer.Name = "buttonAddOffer";
this.buttonAddOffer.Size = new System.Drawing.Size(226, 23);
this.buttonAddOffer.TabIndex = 0;
this.buttonAddOffer.Text = "Hinzufügen";
this.buttonAddOffer.UseVisualStyleBackColor = true;
this.buttonAddOffer.Click += new System.EventHandler(this.buttonAddOffer_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(12, 283);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(229, 23);
this.buttonCancel.TabIndex = 1;
this.buttonCancel.Text = "Abbrechen";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// textBoxInputListPrice
//
this.textBoxInputListPrice.Location = new System.Drawing.Point(156, 23);
this.textBoxInputListPrice.Name = "textBoxInputListPrice";
this.textBoxInputListPrice.Size = new System.Drawing.Size(146, 23);
this.textBoxInputListPrice.TabIndex = 2;
this.textBoxInputListPrice.TextChanged += new System.EventHandler(this.FormFieldUpdate);
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 3;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33332F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F));
this.tableLayoutPanel1.Controls.Add(this.labelPriceDelivered, 0, 7);
this.tableLayoutPanel1.Controls.Add(this.labelOutputDiscount, 2, 2);
this.tableLayoutPanel1.Controls.Add(this.textBoxInputListPrice, 1, 1);
this.tableLayoutPanel1.Controls.Add(this.labelField, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.labelInput, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.labelOutput, 2, 0);
this.tableLayoutPanel1.Controls.Add(this.labelInputListPrice, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.labelOutputListPrice, 2, 1);
this.tableLayoutPanel1.Controls.Add(this.textBoxInputDiscount, 1, 2);
this.tableLayoutPanel1.Controls.Add(this.labelInputDiscount, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.labelPriceTargetPurchase, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.labelInputEarlyPayDiscount, 0, 4);
this.tableLayoutPanel1.Controls.Add(this.labelPriceEarlyPayDiscount, 0, 5);
this.tableLayoutPanel1.Controls.Add(this.labelInputDeliveryFee, 0, 6);
this.tableLayoutPanel1.Controls.Add(this.textBoxInputEarlyPayDiscount, 1, 4);
this.tableLayoutPanel1.Controls.Add(this.textBoxInputDeliveryFee, 1, 6);
this.tableLayoutPanel1.Controls.Add(this.labelOutputPriceTargetPurchase, 2, 3);
this.tableLayoutPanel1.Controls.Add(this.labelOutputEarlyPayDiscount, 2, 4);
this.tableLayoutPanel1.Controls.Add(this.labelOutputPriceEarlyPayDiscount, 2, 5);
this.tableLayoutPanel1.Controls.Add(this.labelOutputDeliveryFee, 2, 6);
this.tableLayoutPanel1.Controls.Add(this.labelOutputPriceDelivered, 2, 7);
this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 35);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 8;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(461, 242);
this.tableLayoutPanel1.TabIndex = 3;
//
// labelPriceDelivered
//
this.labelPriceDelivered.AutoSize = true;
this.labelPriceDelivered.Location = new System.Drawing.Point(3, 200);
this.labelPriceDelivered.Name = "labelPriceDelivered";
this.labelPriceDelivered.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
this.labelPriceDelivered.Size = new System.Drawing.Size(69, 21);
this.labelPriceDelivered.TabIndex = 14;
this.labelPriceDelivered.Text = "Bezugspreis";
//
// labelOutputDiscount
//
this.labelOutputDiscount.AutoSize = true;
this.labelOutputDiscount.Location = new System.Drawing.Point(309, 50);
this.labelOutputDiscount.Name = "labelOutputDiscount";
this.labelOutputDiscount.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
this.labelOutputDiscount.Size = new System.Drawing.Size(117, 21);
this.labelOutputDiscount.TabIndex = 10;
this.labelOutputDiscount.Text = "labelOutputDiscount";
//
// labelField
//
this.labelField.AutoSize = true;
this.labelField.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.labelField.Location = new System.Drawing.Point(3, 0);
this.labelField.Name = "labelField";
this.labelField.Size = new System.Drawing.Size(30, 15);
this.labelField.TabIndex = 3;
this.labelField.Text = "Feld";
//
// labelInput
//
this.labelInput.AutoSize = true;
this.labelInput.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.labelInput.Location = new System.Drawing.Point(156, 0);
this.labelInput.Name = "labelInput";
this.labelInput.Size = new System.Drawing.Size(50, 15);
this.labelInput.TabIndex = 4;
this.labelInput.Text = "Eingabe";
//
// labelOutput
//
this.labelOutput.AutoSize = true;
this.labelOutput.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.labelOutput.Location = new System.Drawing.Point(309, 0);
this.labelOutput.Name = "labelOutput";
this.labelOutput.Size = new System.Drawing.Size(54, 15);
this.labelOutput.TabIndex = 5;
this.labelOutput.Text = "Ausgabe";
//
// labelInputListPrice
//
this.labelInputListPrice.AutoSize = true;
this.labelInputListPrice.Location = new System.Drawing.Point(3, 20);
this.labelInputListPrice.Name = "labelInputListPrice";
this.labelInputListPrice.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
this.labelInputListPrice.Size = new System.Drawing.Size(107, 21);
this.labelInputListPrice.TabIndex = 6;
this.labelInputListPrice.Text = "Listeneinkaufspreis";
//
// labelOutputListPrice
//
this.labelOutputListPrice.AutoSize = true;
this.labelOutputListPrice.Location = new System.Drawing.Point(309, 20);
this.labelOutputListPrice.Name = "labelOutputListPrice";
this.labelOutputListPrice.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
this.labelOutputListPrice.Size = new System.Drawing.Size(114, 21);
this.labelOutputListPrice.TabIndex = 7;
this.labelOutputListPrice.Text = "labelOutputListPrice";
//
// textBoxInputDiscount
//
this.textBoxInputDiscount.Location = new System.Drawing.Point(156, 53);
this.textBoxInputDiscount.Name = "textBoxInputDiscount";
this.textBoxInputDiscount.Size = new System.Drawing.Size(146, 23);
this.textBoxInputDiscount.TabIndex = 8;
this.textBoxInputDiscount.TextChanged += new System.EventHandler(this.FormFieldUpdate);
//
// labelInputDiscount
//
this.labelInputDiscount.AutoSize = true;
this.labelInputDiscount.Location = new System.Drawing.Point(3, 50);
this.labelInputDiscount.Name = "labelInputDiscount";
this.labelInputDiscount.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
this.labelInputDiscount.Size = new System.Drawing.Size(67, 21);
this.labelInputDiscount.TabIndex = 9;
this.labelInputDiscount.Text = "Lieferrabatt";
//
// labelPriceTargetPurchase
//
this.labelPriceTargetPurchase.AutoSize = true;
this.labelPriceTargetPurchase.Location = new System.Drawing.Point(3, 80);
this.labelPriceTargetPurchase.Name = "labelPriceTargetPurchase";
this.labelPriceTargetPurchase.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
this.labelPriceTargetPurchase.Size = new System.Drawing.Size(95, 21);
this.labelPriceTargetPurchase.TabIndex = 11;
this.labelPriceTargetPurchase.Text = "Zieleinkaufspreis";
//
// labelInputEarlyPayDiscount
//
this.labelInputEarlyPayDiscount.AutoSize = true;
this.labelInputEarlyPayDiscount.Location = new System.Drawing.Point(3, 110);
this.labelInputEarlyPayDiscount.Name = "labelInputEarlyPayDiscount";
this.labelInputEarlyPayDiscount.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
this.labelInputEarlyPayDiscount.Size = new System.Drawing.Size(72, 21);
this.labelInputEarlyPayDiscount.TabIndex = 12;
this.labelInputEarlyPayDiscount.Text = "Lieferskonto";
//
// labelPriceEarlyPayDiscount
//
this.labelPriceEarlyPayDiscount.AutoSize = true;
this.labelPriceEarlyPayDiscount.Location = new System.Drawing.Point(3, 140);
this.labelPriceEarlyPayDiscount.Name = "labelPriceEarlyPayDiscount";
this.labelPriceEarlyPayDiscount.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
this.labelPriceEarlyPayDiscount.Size = new System.Drawing.Size(93, 21);
this.labelPriceEarlyPayDiscount.TabIndex = 13;
this.labelPriceEarlyPayDiscount.Text = "Bareinkaufspreis";
//
// labelInputDeliveryFee
//
this.labelInputDeliveryFee.AutoSize = true;
this.labelInputDeliveryFee.Location = new System.Drawing.Point(3, 170);
this.labelInputDeliveryFee.Name = "labelInputDeliveryFee";
this.labelInputDeliveryFee.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
this.labelInputDeliveryFee.Size = new System.Drawing.Size(79, 21);
this.labelInputDeliveryFee.TabIndex = 15;
this.labelInputDeliveryFee.Text = "Bezugskosten";
//
// textBoxInputEarlyPayDiscount
//
this.textBoxInputEarlyPayDiscount.Location = new System.Drawing.Point(156, 113);
this.textBoxInputEarlyPayDiscount.Name = "textBoxInputEarlyPayDiscount";
this.textBoxInputEarlyPayDiscount.Size = new System.Drawing.Size(146, 23);
this.textBoxInputEarlyPayDiscount.TabIndex = 17;
this.textBoxInputEarlyPayDiscount.TextChanged += new System.EventHandler(this.FormFieldUpdate);
//
// textBoxInputDeliveryFee
//
this.textBoxInputDeliveryFee.Location = new System.Drawing.Point(156, 173);
this.textBoxInputDeliveryFee.Name = "textBoxInputDeliveryFee";
this.textBoxInputDeliveryFee.Size = new System.Drawing.Size(146, 23);
this.textBoxInputDeliveryFee.TabIndex = 19;
this.textBoxInputDeliveryFee.TextChanged += new System.EventHandler(this.FormFieldUpdate);
//
// labelOutputPriceTargetPurchase
//
this.labelOutputPriceTargetPurchase.AutoSize = true;
this.labelOutputPriceTargetPurchase.Location = new System.Drawing.Point(309, 80);
this.labelOutputPriceTargetPurchase.Name = "labelOutputPriceTargetPurchase";
this.labelOutputPriceTargetPurchase.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
this.labelOutputPriceTargetPurchase.Size = new System.Drawing.Size(146, 30);
this.labelOutputPriceTargetPurchase.TabIndex = 21;
this.labelOutputPriceTargetPurchase.Text = "labelOutputPriceTargetPurchase";
//
// labelOutputEarlyPayDiscount
//
this.labelOutputEarlyPayDiscount.AutoSize = true;
this.labelOutputEarlyPayDiscount.Location = new System.Drawing.Point(309, 110);
this.labelOutputEarlyPayDiscount.Name = "labelOutputEarlyPayDiscount";
this.labelOutputEarlyPayDiscount.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
this.labelOutputEarlyPayDiscount.Size = new System.Drawing.Size(143, 30);
this.labelOutputEarlyPayDiscount.TabIndex = 22;
this.labelOutputEarlyPayDiscount.Text = "labelOutputEarlyPayDiscount";
//
// labelOutputPriceEarlyPayDiscount
//
this.labelOutputPriceEarlyPayDiscount.AutoSize = true;
this.labelOutputPriceEarlyPayDiscount.Location = new System.Drawing.Point(309, 140);
this.labelOutputPriceEarlyPayDiscount.Name = "labelOutputPriceEarlyPayDiscount";
this.labelOutputPriceEarlyPayDiscount.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
this.labelOutputPriceEarlyPayDiscount.Size = new System.Drawing.Size(148, 30);
this.labelOutputPriceEarlyPayDiscount.TabIndex = 23;
this.labelOutputPriceEarlyPayDiscount.Text = "labelOutputPriceEarlyPayDiscount";
//
// labelOutputDeliveryFee
//
this.labelOutputDeliveryFee.AutoSize = true;
this.labelOutputDeliveryFee.Location = new System.Drawing.Point(309, 170);
this.labelOutputDeliveryFee.Name = "labelOutputDeliveryFee";
this.labelOutputDeliveryFee.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
this.labelOutputDeliveryFee.Size = new System.Drawing.Size(130, 21);
this.labelOutputDeliveryFee.TabIndex = 24;
this.labelOutputDeliveryFee.Text = "labelOutputDeliveryFee";
//
// labelOutputPriceDelivered
//
this.labelOutputPriceDelivered.AutoSize = true;
this.labelOutputPriceDelivered.Location = new System.Drawing.Point(309, 200);
this.labelOutputPriceDelivered.Name = "labelOutputPriceDelivered";
this.labelOutputPriceDelivered.Padding = new System.Windows.Forms.Padding(0, 6, 0, 0);
this.labelOutputPriceDelivered.Size = new System.Drawing.Size(145, 21);
this.labelOutputPriceDelivered.TabIndex = 25;
this.labelOutputPriceDelivered.Text = "labelOutputPriceDelivered";
//
// labelInputLabel
//
this.labelInputLabel.AutoSize = true;
this.labelInputLabel.Location = new System.Drawing.Point(15, 9);
this.labelInputLabel.Name = "labelInputLabel";
this.labelInputLabel.Size = new System.Drawing.Size(35, 15);
this.labelInputLabel.TabIndex = 4;
this.labelInputLabel.Text = "Label";
//
// textBoxInputLabel
//
this.textBoxInputLabel.Location = new System.Drawing.Point(168, 6);
this.textBoxInputLabel.Name = "textBoxInputLabel";
this.textBoxInputLabel.Size = new System.Drawing.Size(305, 23);
this.textBoxInputLabel.TabIndex = 26;
this.textBoxInputLabel.TextChanged += new System.EventHandler(this.FormFieldUpdate);
//
// OfferDetail
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(485, 314);
this.Controls.Add(this.textBoxInputLabel);
this.Controls.Add(this.labelInputLabel);
this.Controls.Add(this.tableLayoutPanel1);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonAddOffer);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "OfferDetail";
this.Text = "Angebotsdetails";
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Button buttonAddOffer;
private Button buttonCancel;
private TextBox textBoxInputListPrice;
private TableLayoutPanel tableLayoutPanel1;
private Label labelOutputDiscount;
private Label labelField;
private Label labelInput;
private Label labelOutput;
private Label labelInputListPrice;
private Label labelOutputListPrice;
private TextBox textBoxInputDiscount;
private Label labelInputDiscount;
private Label labelPriceDelivered;
private Label labelPriceTargetPurchase;
private Label labelInputEarlyPayDiscount;
private Label labelPriceEarlyPayDiscount;
private Label labelInputDeliveryFee;
private TextBox textBoxInputEarlyPayDiscount;
private TextBox textBoxInputDeliveryFee;
private Label labelOutputPriceTargetPurchase;
private Label labelOutputEarlyPayDiscount;
private Label labelOutputPriceEarlyPayDiscount;
private Label labelOutputDeliveryFee;
private Label labelOutputPriceDelivered;
private Label labelInputLabel;
private TextBox textBoxInputLabel;
}
}

@ -0,0 +1,118 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace QuantitativerAngebotsvergleich
{
public partial class OfferDetail : Form
{
private MainForm mainForm;
private Offer offer;
private int existingOfferId;
internal OfferDetail(MainForm mainForm, Offer existingOffer = null)
{
InitializeComponent();
this.existingOfferId = existingOffer == null ? -1 : existingOffer.offerId;
this.mainForm = mainForm;
if (existingOffer == null)
{
this.Text = "Angebot hinzufügen";
offer = new();
}
else
{
offer = existingOffer;
// fill input boxes with given values
textBoxInputLabel.Text = offer.Label;
textBoxInputListPrice.Text = String.Format("{0}", offer.ListPrice);
textBoxInputDiscount.Text = String.Format("{0}", offer.Discount);
textBoxInputEarlyPayDiscount.Text = String.Format("{0}", offer.EarlyPayDiscount);
textBoxInputDeliveryFee.Text = String.Format("{0}", offer.DeliveryFee);
// set add offer button to save
buttonAddOffer.Text = "Speichern";
}
RedrawFields();
}
private void RedrawFields()
{
labelOutputListPrice.Text = $"{mainForm.Meta.Currency} {offer.ListPrice}";
labelOutputDiscount.Text = $"{mainForm.Meta.Currency} {offer.DiscountAmount}";
labelOutputPriceTargetPurchase.Text = $"{mainForm.Meta.Currency} {offer.PriceTargetPurchase}";
labelOutputEarlyPayDiscount.Text = $"{mainForm.Meta.Currency} {offer.EarlyPayDiscountAmount}";
labelOutputPriceEarlyPayDiscount.Text = $"{mainForm.Meta.Currency} {offer.PriceEarlyPayDiscount}";
labelOutputDeliveryFee.Text = $"{mainForm.Meta.Currency} {offer.DeliveryFee}";
labelOutputPriceDelivered.Text = $"{mainForm.Meta.Currency} {offer.PriceDelivered}";
}
private void FormFieldUpdate(Control sender)
{
try
{
if (sender == textBoxInputDiscount)
{
offer.Discount = double.Parse(sender.Text);
}
else if (sender == textBoxInputListPrice)
{
offer.ListPrice = double.Parse(sender.Text);
}
else if (sender == textBoxInputEarlyPayDiscount)
{
offer.EarlyPayDiscount = double.Parse(sender.Text);
}
else if (sender == textBoxInputDeliveryFee)
{
offer.DeliveryFee = double.Parse(sender.Text);
}
else if (sender == textBoxInputLabel)
{
offer.Label = sender.Text;
}
}
catch (Exception e) { }
RedrawFields();
}
private void FormFieldUpdate(object sender, EventArgs e)
{
if (sender is Control c)
{
FormFieldUpdate(c);
}
return;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
Close();
}
private void buttonAddOffer_Click(object sender, EventArgs e)
{
if (existingOfferId == -1)
{
mainForm.AddOffer(offer);
}
else
{
mainForm.OverwriteOffer(existingOfferId, offer);
}
Close();
}
}
}

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
Loading…
Cancel
Save