From eb65cead168bd22ff153b8d85be5e7afc92f25a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Fri, 16 Sep 2022 07:49:05 +0200 Subject: [PATCH] Direct summing --- StockInfoCore/frmMyStocks.Designer.cs | 37 +++++++++++++++++++++++++++ StockInfoCore/frmMyStocks.cs | 8 +++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/StockInfoCore/frmMyStocks.Designer.cs b/StockInfoCore/frmMyStocks.Designer.cs index 050ed4a..158816a 100644 --- a/StockInfoCore/frmMyStocks.Designer.cs +++ b/StockInfoCore/frmMyStocks.Designer.cs @@ -59,6 +59,9 @@ namespace StockInfoCore this.label7 = new System.Windows.Forms.Label(); this.txtTotalPlus = new System.Windows.Forms.TextBox(); this.lblOwnerName = new System.Windows.Forms.Label(); + this.txtSummaValue = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); this.SuspendLayout(); // @@ -332,11 +335,42 @@ namespace StockInfoCore this.lblOwnerName.TabIndex = 16; this.lblOwnerName.Text = "Portfölj Ägare Namn"; // + // txtSummaValue + // + this.txtSummaValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.txtSummaValue.Location = new System.Drawing.Point(862, 428); + this.txtSummaValue.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.txtSummaValue.Name = "txtSummaValue"; + this.txtSummaValue.ReadOnly = true; + this.txtSummaValue.Size = new System.Drawing.Size(114, 27); + this.txtSummaValue.TabIndex = 17; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(842, 429); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(14, 20); + this.label8.TabIndex = 18; + this.label8.Text = "("; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(982, 431); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(14, 20); + this.label9.TabIndex = 19; + this.label9.Text = ")"; + // // frmMyStocks // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1217, 651); + this.Controls.Add(this.label9); + this.Controls.Add(this.label8); + this.Controls.Add(this.txtSummaValue); this.Controls.Add(this.lblOwnerName); this.Controls.Add(this.label7); this.Controls.Add(this.txtTotalPlus); @@ -396,5 +430,8 @@ namespace StockInfoCore private System.Windows.Forms.Label label7; private System.Windows.Forms.TextBox txtTotalPlus; private Label lblOwnerName; + private TextBox txtSummaValue; + private Label label8; + private Label label9; } } \ No newline at end of file diff --git a/StockInfoCore/frmMyStocks.cs b/StockInfoCore/frmMyStocks.cs index 51e562c..9ce8168 100644 --- a/StockInfoCore/frmMyStocks.cs +++ b/StockInfoCore/frmMyStocks.cs @@ -27,6 +27,8 @@ namespace StockInfoCore public decimal TotalPlus { get; set; } public decimal TotalMinus { get; set; } + public decimal ExtraValueSum { get; set; } + public Dictionary Stocks { get; set; } public IEnumerable CurrentStocks { get; set; } public Person ConnectedPerson { get; set; } @@ -54,6 +56,7 @@ namespace StockInfoCore CurrentSum = 0m; TotalMinus = 0m; TotalPlus = 0m; + ExtraValueSum = 0m; var tmpStocks = new List(); var personStocks = new List(); //Update all handled shares @@ -96,7 +99,8 @@ namespace StockInfoCore txtTotalMinus.Refresh(); txtTotalPlus.Text = TotalPlus.ToString(); txtTotalPlus.Refresh(); - + txtSummaValue.Text = ExtraValueSum.ToString(); + txtSummaValue.Refresh(); lbUpdateTimes.Items.Add($"{DateTime.Now.ToLongTimeString()} - {txtTotDiff.Text.Substring(0, txtTotDiff.Text.Length - 2)}"); } @@ -134,9 +138,11 @@ namespace StockInfoCore var actValue = currStock.PostAmount * currStock.ActValue; var diffValue = actValue - buyValue; var diffproc = diffValue / buyValue * 100; + var extraVal = currStock.ActAmount * currStock.ActValue; BoughtSum += buyValue; TotalDiff += diffValue; CurrentSum += actValue; + ExtraValueSum += extraVal; if (diffValue < 0) { TotalMinus += diffValue;