Direct summing

This commit is contained in:
2022-09-16 07:49:05 +02:00
parent e6121da2ca
commit eb65cead16
2 changed files with 44 additions and 1 deletions

View File

@ -59,6 +59,9 @@ namespace StockInfoCore
this.label7 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label();
this.txtTotalPlus = new System.Windows.Forms.TextBox(); this.txtTotalPlus = new System.Windows.Forms.TextBox();
this.lblOwnerName = new System.Windows.Forms.Label(); 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(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -332,11 +335,42 @@ namespace StockInfoCore
this.lblOwnerName.TabIndex = 16; this.lblOwnerName.TabIndex = 16;
this.lblOwnerName.Text = "Portfölj Ägare Namn"; 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 // frmMyStocks
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1217, 651); 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.lblOwnerName);
this.Controls.Add(this.label7); this.Controls.Add(this.label7);
this.Controls.Add(this.txtTotalPlus); this.Controls.Add(this.txtTotalPlus);
@ -396,5 +430,8 @@ namespace StockInfoCore
private System.Windows.Forms.Label label7; private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox txtTotalPlus; private System.Windows.Forms.TextBox txtTotalPlus;
private Label lblOwnerName; private Label lblOwnerName;
private TextBox txtSummaValue;
private Label label8;
private Label label9;
} }
} }

View File

@ -27,6 +27,8 @@ namespace StockInfoCore
public decimal TotalPlus { get; set; } public decimal TotalPlus { get; set; }
public decimal TotalMinus { get; set; } public decimal TotalMinus { get; set; }
public decimal ExtraValueSum { get; set; }
public Dictionary<string, DiTraderStockRow> Stocks { get; set; } public Dictionary<string, DiTraderStockRow> Stocks { get; set; }
public IEnumerable<StockMember> CurrentStocks { get; set; } public IEnumerable<StockMember> CurrentStocks { get; set; }
public Person ConnectedPerson { get; set; } public Person ConnectedPerson { get; set; }
@ -54,6 +56,7 @@ namespace StockInfoCore
CurrentSum = 0m; CurrentSum = 0m;
TotalMinus = 0m; TotalMinus = 0m;
TotalPlus = 0m; TotalPlus = 0m;
ExtraValueSum = 0m;
var tmpStocks = new List<StockMember>(); var tmpStocks = new List<StockMember>();
var personStocks = new List<StockMember>(); var personStocks = new List<StockMember>();
//Update all handled shares //Update all handled shares
@ -96,7 +99,8 @@ namespace StockInfoCore
txtTotalMinus.Refresh(); txtTotalMinus.Refresh();
txtTotalPlus.Text = TotalPlus.ToString(); txtTotalPlus.Text = TotalPlus.ToString();
txtTotalPlus.Refresh(); txtTotalPlus.Refresh();
txtSummaValue.Text = ExtraValueSum.ToString();
txtSummaValue.Refresh();
lbUpdateTimes.Items.Add($"{DateTime.Now.ToLongTimeString()} - {txtTotDiff.Text.Substring(0, txtTotDiff.Text.Length - 2)}"); 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 actValue = currStock.PostAmount * currStock.ActValue;
var diffValue = actValue - buyValue; var diffValue = actValue - buyValue;
var diffproc = diffValue / buyValue * 100; var diffproc = diffValue / buyValue * 100;
var extraVal = currStock.ActAmount * currStock.ActValue;
BoughtSum += buyValue; BoughtSum += buyValue;
TotalDiff += diffValue; TotalDiff += diffValue;
CurrentSum += actValue; CurrentSum += actValue;
ExtraValueSum += extraVal;
if (diffValue < 0) if (diffValue < 0)
{ {
TotalMinus += diffValue; TotalMinus += diffValue;