Början till enskild analys av aktierna
This commit is contained in:
@ -10,4 +10,8 @@ public class StockEquity
|
||||
public DateTime Sold { get; set; }
|
||||
public decimal SoldPrice { get; set; }
|
||||
public int SoldQuant { get; set; }
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Id} {StockCode} {Bought} {BoughtPrice} {Quantity} {Sold} {SoldPrice} {SoldQuant}";
|
||||
}
|
||||
}
|
||||
|
||||
2
StockHistory/frmStockHistoryAnalyse.Designer.cs
generated
2
StockHistory/frmStockHistoryAnalyse.Designer.cs
generated
@ -98,12 +98,14 @@
|
||||
// lwStocks
|
||||
//
|
||||
lwStocks.Columns.AddRange(new ColumnHeader[] { chStock, chBought, chPrize, chNumber, chValue });
|
||||
lwStocks.FullRowSelect = true;
|
||||
lwStocks.Location = new Point(111, 103);
|
||||
lwStocks.Name = "lwStocks";
|
||||
lwStocks.Size = new Size(676, 154);
|
||||
lwStocks.TabIndex = 9;
|
||||
lwStocks.UseCompatibleStateImageBehavior = false;
|
||||
lwStocks.View = View.Details;
|
||||
lwStocks.MouseClick += lwStocks_MouseClick;
|
||||
//
|
||||
// chStock
|
||||
//
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using StockHistory.Models;
|
||||
using StockHistory.Services;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace StockHistory;
|
||||
|
||||
@ -100,4 +101,35 @@ public partial class frmStockHistoryAnalyse : Form
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void lwStocks_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (lwStocks.SelectedItems.Count > 0)
|
||||
{
|
||||
var item = lwStocks.SelectedItems[0];
|
||||
LoadHistoryRecsAsync(item.Text).Wait();
|
||||
}
|
||||
}
|
||||
private async Task LoadHistoryRecsAsync(string stockName)
|
||||
{
|
||||
//MessageBox.Show("Du klickade på: " + item.Text);
|
||||
var result = _equityServices.GetByCodeAsync(stockName);
|
||||
if (result != null)
|
||||
{
|
||||
lwStockHistory.Items.Clear();
|
||||
foreach (var histRec in await result)
|
||||
{
|
||||
var l_item = new ListViewItem(histRec.StockCode);
|
||||
l_item.SubItems.Add(histRec.Bought.ToString());
|
||||
l_item.SubItems.Add(histRec.BoughtPrice.ToString());
|
||||
l_item.SubItems.Add(histRec.Quantity.ToString());
|
||||
Debug.WriteLine(histRec.ToString());
|
||||
var totval = (histRec.SoldQuant > 0) ? histRec.SoldQuant * histRec.SoldPrice - histRec.BoughtPrice * histRec.Quantity : histRec.BoughtPrice * histRec.Quantity;
|
||||
l_item.SubItems.Add((totval).ToString("C"));
|
||||
lwStockHistory.Items.Add(l_item);
|
||||
}
|
||||
}
|
||||
lwStockHistory.Refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user