Add project files.
This commit is contained in:
7
DataDomain/DataDomain.csproj
Normal file
7
DataDomain/DataDomain.csproj
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
22
DataDomain/DiTraderStockRow.cs
Normal file
22
DataDomain/DiTraderStockRow.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DataDomain
|
||||||
|
{
|
||||||
|
public class DiTraderStockRow
|
||||||
|
{
|
||||||
|
public string StockName { get; set; }
|
||||||
|
public decimal ProcChange { get; set; }
|
||||||
|
public decimal RealChange { get; set; }
|
||||||
|
public decimal BuyPrice { get; set; }
|
||||||
|
public decimal SellPrice { get; set; }
|
||||||
|
public decimal LatestPrice { get; set; }
|
||||||
|
public decimal HighestPrice { get; set; }
|
||||||
|
public decimal LowestPrice { get; set; }
|
||||||
|
public long Volume { get; set; }
|
||||||
|
public TimeSpan TimeOfDay { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
17
DataDomain/Person.cs
Normal file
17
DataDomain/Person.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DataDomain
|
||||||
|
{
|
||||||
|
public class Person
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? FirstName { get; set; }
|
||||||
|
public string? LastName { get; set; }
|
||||||
|
public string? NickName { get; set; }
|
||||||
|
public DateTime? Born { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
26
DataDomain/StockMember.cs
Normal file
26
DataDomain/StockMember.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DataDomain
|
||||||
|
{
|
||||||
|
public class StockMember
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string StockId { get; set; }
|
||||||
|
public string StockExtId { get; set; }
|
||||||
|
public decimal BuyValue { get; set; }
|
||||||
|
public DateTime BuyDate { get; set; }
|
||||||
|
public decimal ActValue { get; set; }
|
||||||
|
public DateTime? ActDate { get; set; }
|
||||||
|
public long ActAmount { get; set; }
|
||||||
|
public decimal? SoldValue { get; set; }
|
||||||
|
public DateTime? SoldDate { get; set; }
|
||||||
|
// public string PostId { get; set; }
|
||||||
|
public string Comment { get; set; }
|
||||||
|
public long PostAmount { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
23
DatamodelLibrary/DatamodelLibrary.csproj
Normal file
23
DatamodelLibrary/DatamodelLibrary.csproj
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.3" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.3">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\DataDomain\DataDomain.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Migrations\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
90
DatamodelLibrary/Migrations/20210301205458_initial.Designer.cs
generated
Normal file
90
DatamodelLibrary/Migrations/20210301205458_initial.Designer.cs
generated
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using DatamodelLibrary;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
namespace DatamodelLibrary.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(StockContext))]
|
||||||
|
[Migration("20210301205458_initial")]
|
||||||
|
partial class initial
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "5.0.3");
|
||||||
|
|
||||||
|
modelBuilder.Entity("DataDomain.Person", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("Born")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("FirstName")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("LastName")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("NickName")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Persons");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DataDomain.StockMember", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("ActAmount")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("ActDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<decimal>("ActValue")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("BuyDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<decimal>("BuyValue")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Comment")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("PostAmount")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("SoldDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<decimal?>("SoldValue")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("StockExtId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("StockId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Stocks");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
59
DatamodelLibrary/Migrations/20210301205458_initial.cs
Normal file
59
DatamodelLibrary/Migrations/20210301205458_initial.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace DatamodelLibrary.Migrations
|
||||||
|
{
|
||||||
|
public partial class initial : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Persons",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
FirstName = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
LastName = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
NickName = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
Born = table.Column<DateTime>(type: "TEXT", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Persons", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Stocks",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
StockId = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
StockExtId = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
BuyValue = table.Column<decimal>(type: "TEXT", nullable: false),
|
||||||
|
BuyDate = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||||
|
ActValue = table.Column<decimal>(type: "TEXT", nullable: false),
|
||||||
|
ActDate = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||||
|
ActAmount = table.Column<long>(type: "INTEGER", nullable: false),
|
||||||
|
SoldValue = table.Column<decimal>(type: "TEXT", nullable: true),
|
||||||
|
SoldDate = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||||
|
Comment = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
PostAmount = table.Column<long>(type: "INTEGER", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Stocks", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Persons");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Stocks");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
88
DatamodelLibrary/Migrations/StockContextModelSnapshot.cs
Normal file
88
DatamodelLibrary/Migrations/StockContextModelSnapshot.cs
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using DatamodelLibrary;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
namespace DatamodelLibrary.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(StockContext))]
|
||||||
|
partial class StockContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "5.0.3");
|
||||||
|
|
||||||
|
modelBuilder.Entity("DataDomain.Person", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("Born")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("FirstName")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("LastName")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("NickName")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Persons");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DataDomain.StockMember", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("ActAmount")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("ActDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<decimal>("ActValue")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("BuyDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<decimal>("BuyValue")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Comment")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<long>("PostAmount")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("SoldDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<decimal?>("SoldValue")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("StockExtId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("StockId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Stocks");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
DatamodelLibrary/StockContext.cs
Normal file
19
DatamodelLibrary/StockContext.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using DataDomain;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DatamodelLibrary
|
||||||
|
{
|
||||||
|
public class StockContext : DbContext
|
||||||
|
{
|
||||||
|
public DbSet<StockMember> Stocks { get; set; }
|
||||||
|
public DbSet<Person> Persons { get; set; }
|
||||||
|
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
|
=> options.UseSqlite("Data Source=Stocks.db");
|
||||||
|
}
|
||||||
|
}
|
||||||
19
StockDAL/StockDAL.csproj
Normal file
19
StockDAL/StockDAL.csproj
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="HtmlAgilityPack" Version="1.11.29" />
|
||||||
|
<PackageReference Include="Selenium.WebDriverBackedSelenium" Version="3.141.0" />
|
||||||
|
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\DataDomain\DataDomain.csproj" />
|
||||||
|
<ProjectReference Include="..\DatamodelLibrary\DatamodelLibrary.csproj" />
|
||||||
|
<ProjectReference Include="..\StockDal.Interface\StockDAL.Interface.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
230
StockDAL/StockMarketRepository.cs
Normal file
230
StockDAL/StockMarketRepository.cs
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using OpenQA.Selenium;
|
||||||
|
using OpenQA.Selenium.Chrome;
|
||||||
|
using StockDal.Interface;
|
||||||
|
using DataDomain;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StockDal
|
||||||
|
{
|
||||||
|
public class StockMarketRepository : IStockMarketRepository
|
||||||
|
{
|
||||||
|
public Dictionary<string, DiTraderStockRow> StockMarketList { get; set; }
|
||||||
|
|
||||||
|
public List<DiTraderStockRow> DumpObjects { get; set; } = new List<DiTraderStockRow>();
|
||||||
|
public DiTraderStockRow SaveRow { get; set; }
|
||||||
|
public StringBuilder TextResults { get; set; }
|
||||||
|
public bool ViewBrowser { get; set; }
|
||||||
|
|
||||||
|
public IWebDriver driver;
|
||||||
|
|
||||||
|
public StockMarketRepository()
|
||||||
|
{
|
||||||
|
ViewBrowser = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Find_Data()
|
||||||
|
{
|
||||||
|
TextResults = new StringBuilder();
|
||||||
|
IList<IWebElement> searchElements = driver.FindElements(By.TagName("tbody"));
|
||||||
|
foreach (IWebElement i in searchElements)
|
||||||
|
{
|
||||||
|
|
||||||
|
HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
|
||||||
|
var text = i.GetAttribute("innerHTML");
|
||||||
|
htmlDocument.LoadHtml(text);
|
||||||
|
var inputs = htmlDocument.DocumentNode.Descendants("tr").ToList();
|
||||||
|
foreach (var items in inputs)
|
||||||
|
{
|
||||||
|
HtmlAgilityPack.HtmlDocument htmlDocument1 = new HtmlAgilityPack.HtmlDocument();
|
||||||
|
htmlDocument1.LoadHtml(items.InnerHtml);
|
||||||
|
var tds = htmlDocument1.DocumentNode.Descendants("td").ToList();
|
||||||
|
var appendText = "";
|
||||||
|
var fNr = 0;
|
||||||
|
foreach (var item in tds)
|
||||||
|
{
|
||||||
|
var intext = item.InnerText.Replace("\r\n", "");
|
||||||
|
appendText += appendText.Length == 0 ? intext : " " + intext;
|
||||||
|
if (tds.Count == 10)
|
||||||
|
{
|
||||||
|
AddValueToListRow(fNr++, intext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(appendText))
|
||||||
|
{
|
||||||
|
TextResults.Append(appendText + "\r\n");
|
||||||
|
}
|
||||||
|
htmlDocument1 = null;
|
||||||
|
}
|
||||||
|
htmlDocument = null;
|
||||||
|
|
||||||
|
TextResults.Append("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// var oxe = StockMarketList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveLogging()
|
||||||
|
{
|
||||||
|
var output = JsonConvert.SerializeObject(DumpObjects, Formatting.Indented);
|
||||||
|
File.WriteAllText($"D:\\TimCoDemos\\DemoLogs\\Log{DateTime.Now.ToShortDateString()}.txt",output);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddValueToListRow(int pos, string value)
|
||||||
|
{
|
||||||
|
switch (pos)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
SaveRow = new DiTraderStockRow();
|
||||||
|
SaveRow.StockName = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
SaveRow.ProcChange = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
SaveRow.RealChange = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
SaveRow.BuyPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
SaveRow.SellPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
SaveRow.LatestPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 6:
|
||||||
|
{
|
||||||
|
SaveRow.HighestPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 7:
|
||||||
|
{
|
||||||
|
SaveRow.LowestPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 8:
|
||||||
|
{
|
||||||
|
|
||||||
|
SaveRow.Volume = string.IsNullOrWhiteSpace(value) ? 0 : long.Parse(value.Replace(" ", ""));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 9:
|
||||||
|
{
|
||||||
|
SaveRow.TimeOfDay = value==""?TimeSpan.Parse("00:01"): TimeSpan.Parse(value);
|
||||||
|
//StockMarketList.Add(SaveRow.StockName, SaveRow);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
StockMarketList.Add(SaveRow.StockName, SaveRow);
|
||||||
|
}
|
||||||
|
catch (ArgumentException ae)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
StockMarketList.Add(SaveRow.StockName + "-2", SaveRow);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
DumpObjects.Add(SaveRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenBrowser(bool burl2 = false)
|
||||||
|
{
|
||||||
|
var driverService = ChromeDriverService.CreateDefaultService();
|
||||||
|
driverService.HideCommandPromptWindow = true;
|
||||||
|
|
||||||
|
if (ViewBrowser)
|
||||||
|
{
|
||||||
|
if (driver == null)
|
||||||
|
{
|
||||||
|
driver = new ChromeDriver(driverService);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (driver == null)
|
||||||
|
{
|
||||||
|
var options = new ChromeOptions();
|
||||||
|
options.AddArgument("headless");
|
||||||
|
driver = new ChromeDriver(driverService, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//var url0 = "https://money.cnn.com/data/hotstocks/index.html";
|
||||||
|
var url = "https://trader.di.se/index.php/stocklist/index/2055?list=7126";
|
||||||
|
var url2 = "https://trader.di.se/index.php/stocklist/index/2055?list=7116";
|
||||||
|
//var url1 = "https://www.finansportalen.se/aktiekurser/";
|
||||||
|
driver.Navigate().GoToUrl(burl2 ? url2 : url);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadStockMarketList()
|
||||||
|
{
|
||||||
|
StockMarketList = new Dictionary<string, DiTraderStockRow>();
|
||||||
|
DumpObjects = new List<DiTraderStockRow>();
|
||||||
|
OpenBrowser();
|
||||||
|
Find_Data();
|
||||||
|
OpenBrowser(true);
|
||||||
|
Find_Data();
|
||||||
|
if (DumpObjects.Any())
|
||||||
|
{
|
||||||
|
SaveLogging();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void LoadStockMarketList(bool viewBrowser)
|
||||||
|
{
|
||||||
|
StockMarketList = new Dictionary<string, DiTraderStockRow>();
|
||||||
|
ViewBrowser = viewBrowser;
|
||||||
|
OpenBrowser();
|
||||||
|
Find_Data();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshMarketList()
|
||||||
|
{
|
||||||
|
StockMarketList = new Dictionary<string, DiTraderStockRow>();
|
||||||
|
driver.Navigate().Refresh();
|
||||||
|
Find_Data();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clean()
|
||||||
|
{
|
||||||
|
driver?.Quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
60
StockDAL/StockRepository.cs
Normal file
60
StockDAL/StockRepository.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using DataDomain;
|
||||||
|
using DatamodelLibrary;
|
||||||
|
using StockDAL.Interface;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StockDAL
|
||||||
|
{
|
||||||
|
public class StockRepository : IStockRepository
|
||||||
|
{
|
||||||
|
public void SaveStockMember(StockMember stockMember)
|
||||||
|
{
|
||||||
|
using (var context = new StockContext())
|
||||||
|
{
|
||||||
|
var sm = context.Stocks.Add(stockMember);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateActualPrice(int id, decimal price)
|
||||||
|
{
|
||||||
|
using var context = new StockContext();
|
||||||
|
var entity = (from stk in context.Stocks
|
||||||
|
where stk.Id == id
|
||||||
|
select stk).FirstOrDefault();
|
||||||
|
|
||||||
|
entity.ActValue = price;
|
||||||
|
entity.ActDate = DateTime.Today;
|
||||||
|
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<StockMember> GetAllStocks()
|
||||||
|
{
|
||||||
|
using var context = new StockContext();
|
||||||
|
var output = context.Stocks;
|
||||||
|
return output.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<StockMember> GetAllRemainingStocks()
|
||||||
|
{
|
||||||
|
using var context = new StockContext();
|
||||||
|
var output = (from stk in context.Stocks
|
||||||
|
where stk.SoldDate == null
|
||||||
|
select stk).ToList();
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InsertMany(List<StockMember> stockMembers)
|
||||||
|
{
|
||||||
|
using var context = new StockContext();
|
||||||
|
context.Stocks.AddRange(stockMembers);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
48
StockDBEF/GreetingService.cs
Normal file
48
StockDBEF/GreetingService.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using StockDBEF.Models;
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
// DI, SeriLog, Settings
|
||||||
|
|
||||||
|
namespace StockDBEF
|
||||||
|
{
|
||||||
|
public class GreetingService : IGreetingService
|
||||||
|
{
|
||||||
|
private readonly ILogger<GreetingService> _log;
|
||||||
|
private readonly IConfiguration _config;
|
||||||
|
private readonly StockDBContext _stockDBContext;
|
||||||
|
|
||||||
|
public GreetingService(ILogger<GreetingService> log, IConfiguration config, StockDBContext stockDBContext)
|
||||||
|
{
|
||||||
|
_log = log;
|
||||||
|
_config = config;
|
||||||
|
_stockDBContext = stockDBContext;
|
||||||
|
}
|
||||||
|
public async void Run()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _config.GetValue<int>("LoopTimes"); i++)
|
||||||
|
{
|
||||||
|
_log.LogInformation("Run number {runNumber}", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
await SaveInitialStock();
|
||||||
|
await SaveInitialPerson();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SaveInitialStock()
|
||||||
|
{
|
||||||
|
StockMember sm = new StockMember { BuyValue = 120M, ActAmount = 100, BuyDate = DateTime.Parse("2021-03-01"), PostAmount = 100, Comment = "Initial aktiepost" };
|
||||||
|
_stockDBContext.StockMembers.Add(sm);
|
||||||
|
await _stockDBContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
public async Task SaveInitialPerson()
|
||||||
|
{
|
||||||
|
Person p = new Person { FirstName="Nisse", LastName="Pärlemo", Born=DateTime.Parse("1995-10-15"), NickName="Nippe" };
|
||||||
|
_stockDBContext.Persons.Add(p);
|
||||||
|
await _stockDBContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
8
StockDBEF/IGreetingService.cs
Normal file
8
StockDBEF/IGreetingService.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
namespace StockDBEF
|
||||||
|
{
|
||||||
|
public interface IGreetingService
|
||||||
|
{
|
||||||
|
void Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
17
StockDBEF/Models/Person.cs
Normal file
17
StockDBEF/Models/Person.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StockDBEF.Models
|
||||||
|
{
|
||||||
|
public class Person
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string FirstName { get; set; }
|
||||||
|
public string LastName { get; set; }
|
||||||
|
public string NickName { get; set; }
|
||||||
|
public DateTime Born { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
28
StockDBEF/Models/StockDBContext.cs
Normal file
28
StockDBEF/Models/StockDBContext.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StockDBEF.Models
|
||||||
|
{
|
||||||
|
public class StockDBContext : DbContext
|
||||||
|
{
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
|
||||||
|
public StockDBContext(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
_configuration = configuration;
|
||||||
|
}
|
||||||
|
public DbSet<Person> Persons { get; set; }
|
||||||
|
public DbSet<StockMember> StockMembers { get; set; }
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
var connectionString = _configuration.GetValue<string>("ConnectionStrings:Stocks");
|
||||||
|
optionsBuilder.UseSqlite(connectionString);
|
||||||
|
//optionsBuilder.UseSqlite("Data Source=Facts.db");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
StockDBEF/Models/StockMember.cs
Normal file
26
StockDBEF/Models/StockMember.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StockDBEF.Models
|
||||||
|
{
|
||||||
|
public class StockMember
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string StockId { get; set; }
|
||||||
|
public string StockExtId { get; set; }
|
||||||
|
public decimal BuyValue { get; set; }
|
||||||
|
public DateTime BuyDate { get; set; }
|
||||||
|
public decimal ActValue { get; set; }
|
||||||
|
public DateTime ActDate { get; set; }
|
||||||
|
public long ActAmount { get; set; }
|
||||||
|
public decimal SoldValue { get; set; }
|
||||||
|
public DateTime? SoldDate { get; set; }
|
||||||
|
// public string PostId { get; set; }
|
||||||
|
public string Comment { get; set; }
|
||||||
|
public long PostAmount { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
83
StockDBEF/Program.cs
Normal file
83
StockDBEF/Program.cs
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Serilog;
|
||||||
|
using StockDBEF.Models;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
// DI, SeriLog, Settings
|
||||||
|
|
||||||
|
namespace StockDBEF
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var builder = new ConfigurationBuilder();
|
||||||
|
BuildConfig(builder);
|
||||||
|
|
||||||
|
Log.Logger = new LoggerConfiguration()
|
||||||
|
.ReadFrom.Configuration(builder.Build())
|
||||||
|
.Enrich.FromLogContext()
|
||||||
|
.WriteTo.Console()
|
||||||
|
.CreateLogger();
|
||||||
|
|
||||||
|
Log.Logger.Information("Application starting");
|
||||||
|
|
||||||
|
var host = Host.CreateDefaultBuilder()
|
||||||
|
.ConfigureServices((context, services) =>
|
||||||
|
{
|
||||||
|
services.AddEntityFrameworkSqlite();
|
||||||
|
services.AddHostedService<DatabaseStartup>();
|
||||||
|
//services.AddDbContext<StockDBContext>();
|
||||||
|
services.AddDbContextPool<StockDBContext>(o =>
|
||||||
|
{
|
||||||
|
o.UseSqlite("Data Source=Stocks.db");
|
||||||
|
});
|
||||||
|
|
||||||
|
services.AddTransient<IGreetingService, GreetingService>();
|
||||||
|
})
|
||||||
|
.UseSerilog()
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var svc = ActivatorUtilities.CreateInstance<GreetingService>(host.Services);
|
||||||
|
svc.Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void BuildConfig(IConfigurationBuilder builder)
|
||||||
|
{
|
||||||
|
builder.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
|
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", optional: true)
|
||||||
|
.AddEnvironmentVariables();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DatabaseStartup : IHostedService
|
||||||
|
{
|
||||||
|
private readonly IServiceProvider serviceProvider;
|
||||||
|
public DatabaseStartup(IServiceProvider serviceProvider)
|
||||||
|
{
|
||||||
|
this.serviceProvider = serviceProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task StartAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
using (var scope = serviceProvider.CreateScope())
|
||||||
|
{
|
||||||
|
var db = scope.ServiceProvider.GetRequiredService<StockDBContext>();
|
||||||
|
await db.Database.EnsureCreated();
|
||||||
|
// or
|
||||||
|
await db.Database.MigrateAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
32
StockDBEF/StockDBEF.csproj
Normal file
32
StockDBEF/StockDBEF.csproj
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.3">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Hosting" Version="4.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.3" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.3" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.3">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
15
StockDBEF/appsettings.json
Normal file
15
StockDBEF/appsettings.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"LoopTimes": 15,
|
||||||
|
"Serilog": {
|
||||||
|
"MinimumLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Override": {
|
||||||
|
"Microsft": "Information",
|
||||||
|
"System": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"Stocks": "Data Source=Stocks.db"
|
||||||
|
}
|
||||||
|
}
|
||||||
49
StockDBEFApp.sln
Normal file
49
StockDBEFApp.sln
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.31005.135
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatamodelLibrary", "DatamodelLibrary\DatamodelLibrary.csproj", "{160EC9C2-0273-43FE-8CEF-D8687722F0B2}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataDomain", "DataDomain\DataDomain.csproj", "{D8057A61-F1CE-4467-9F9E-5E1DA180B3C4}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockDAL", "StockDAL\StockDAL.csproj", "{E84394CB-98B8-48C0-A65F-008BC97E34A3}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockDAL.Interface", "StockDal.Interface\StockDAL.Interface.csproj", "{7B0D0A18-D071-40ED-8788-120D432D16D8}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockInfo", "StockInfo\StockInfo.csproj", "{EC122B56-FCE0-4BBD-956D-7BF46D617CF8}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{160EC9C2-0273-43FE-8CEF-D8687722F0B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{160EC9C2-0273-43FE-8CEF-D8687722F0B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{160EC9C2-0273-43FE-8CEF-D8687722F0B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{160EC9C2-0273-43FE-8CEF-D8687722F0B2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D8057A61-F1CE-4467-9F9E-5E1DA180B3C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D8057A61-F1CE-4467-9F9E-5E1DA180B3C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D8057A61-F1CE-4467-9F9E-5E1DA180B3C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D8057A61-F1CE-4467-9F9E-5E1DA180B3C4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{E84394CB-98B8-48C0-A65F-008BC97E34A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E84394CB-98B8-48C0-A65F-008BC97E34A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E84394CB-98B8-48C0-A65F-008BC97E34A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E84394CB-98B8-48C0-A65F-008BC97E34A3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{7B0D0A18-D071-40ED-8788-120D432D16D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{7B0D0A18-D071-40ED-8788-120D432D16D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{7B0D0A18-D071-40ED-8788-120D432D16D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{7B0D0A18-D071-40ED-8788-120D432D16D8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{EC122B56-FCE0-4BBD-956D-7BF46D617CF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{EC122B56-FCE0-4BBD-956D-7BF46D617CF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{EC122B56-FCE0-4BBD-956D-7BF46D617CF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{EC122B56-FCE0-4BBD-956D-7BF46D617CF8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {FD15FE95-060F-455A-9AEC-B0DA11261CE7}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
20
StockDal.Interface/IStockMarketRepository.cs
Normal file
20
StockDal.Interface/IStockMarketRepository.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using DataDomain;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StockDal.Interface
|
||||||
|
{
|
||||||
|
public interface IStockMarketRepository
|
||||||
|
{
|
||||||
|
Dictionary<string, DiTraderStockRow> StockMarketList { get; set; }
|
||||||
|
bool ViewBrowser { get; set; }
|
||||||
|
|
||||||
|
void Clean();
|
||||||
|
void LoadStockMarketList();
|
||||||
|
void LoadStockMarketList(bool viewBrowser);
|
||||||
|
void RefreshMarketList();
|
||||||
|
}
|
||||||
|
}
|
||||||
18
StockDal.Interface/IStockRepository.cs
Normal file
18
StockDal.Interface/IStockRepository.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using DataDomain;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StockDAL.Interface
|
||||||
|
{
|
||||||
|
public interface IStockRepository
|
||||||
|
{
|
||||||
|
IEnumerable<StockMember> GetAllRemainingStocks();
|
||||||
|
IEnumerable<StockMember> GetAllStocks();
|
||||||
|
void InsertMany(List<StockMember> stockMembers);
|
||||||
|
void SaveStockMember(StockMember stockMember);
|
||||||
|
void UpdateActualPrice(int id, decimal price);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
StockDal.Interface/StockDAL.Interface.csproj
Normal file
15
StockDal.Interface/StockDAL.Interface.csproj
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="HtmlAgilityPack" Version="1.11.29" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\DataDomain\DataDomain.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
40
StockInfo/Program.cs
Normal file
40
StockInfo/Program.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using Autofac;
|
||||||
|
using StockDal;
|
||||||
|
using StockDal.Interface;
|
||||||
|
using StockDAL;
|
||||||
|
using StockDAL.Interface;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace StockInfo
|
||||||
|
{
|
||||||
|
static class Program
|
||||||
|
{
|
||||||
|
public static IContainer Container;
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
Container = Configure();
|
||||||
|
Application.Run(new frmInitial( Container.Resolve<IStockRepository>(), Container.Resolve<IStockMarketRepository>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static IContainer Configure()
|
||||||
|
{
|
||||||
|
var builder = new ContainerBuilder();
|
||||||
|
builder.RegisterType<StockRepository>().As<IStockRepository>();
|
||||||
|
builder.RegisterType<StockMarketRepository>().As<IStockMarketRepository>();
|
||||||
|
builder.RegisterType<frmInitial>();
|
||||||
|
return builder.Build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
40
StockInfo/StockInfo.csproj
Normal file
40
StockInfo/StockInfo.csproj
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net5.0-windows</TargetFramework>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Autofac" Version="6.1.0" />
|
||||||
|
<PackageReference Include="HtmlAgilityPack" Version="1.11.29" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.3">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
|
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="87.0.4280.8800" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\DataDomain\DataDomain.csproj" />
|
||||||
|
<ProjectReference Include="..\StockDal.Interface\StockDAL.Interface.csproj" />
|
||||||
|
<ProjectReference Include="..\StockDAL\StockDAL.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="Stocks.db">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
</Project>
|
||||||
BIN
StockInfo/Stocks.db
Normal file
BIN
StockInfo/Stocks.db
Normal file
Binary file not shown.
199
StockInfo/frmInitial.Designer.cs
generated
Normal file
199
StockInfo/frmInitial.Designer.cs
generated
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
|
||||||
|
namespace StockInfo
|
||||||
|
{
|
||||||
|
partial class frmInitial
|
||||||
|
{
|
||||||
|
/// <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.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.lblTotalRecords = new System.Windows.Forms.Label();
|
||||||
|
this.gB1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.btnReload = new System.Windows.Forms.Button();
|
||||||
|
this.btnTestScrapFunction = new System.Windows.Forms.Button();
|
||||||
|
this.lblStockRows = new System.Windows.Forms.Label();
|
||||||
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
|
this.chbShowBrowser = new System.Windows.Forms.CheckBox();
|
||||||
|
this.gbStockMgmnt = new System.Windows.Forms.GroupBox();
|
||||||
|
this.btnValueView = new System.Windows.Forms.Button();
|
||||||
|
this.btnStockReg = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.gB1.SuspendLayout();
|
||||||
|
this.gbStockMgmnt.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(12, 16);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(776, 389);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// lblTotalRecords
|
||||||
|
//
|
||||||
|
this.lblTotalRecords.AutoSize = true;
|
||||||
|
this.lblTotalRecords.Location = new System.Drawing.Point(12, 408);
|
||||||
|
this.lblTotalRecords.Name = "lblTotalRecords";
|
||||||
|
this.lblTotalRecords.Size = new System.Drawing.Size(98, 15);
|
||||||
|
this.lblTotalRecords.TabIndex = 2;
|
||||||
|
this.lblTotalRecords.Text = "Total Records: ???";
|
||||||
|
//
|
||||||
|
// gB1
|
||||||
|
//
|
||||||
|
this.gB1.Controls.Add(this.btnReload);
|
||||||
|
this.gB1.Location = new System.Drawing.Point(157, 411);
|
||||||
|
this.gB1.Name = "gB1";
|
||||||
|
this.gB1.Size = new System.Drawing.Size(248, 35);
|
||||||
|
this.gB1.TabIndex = 3;
|
||||||
|
this.gB1.TabStop = false;
|
||||||
|
//
|
||||||
|
// btnReload
|
||||||
|
//
|
||||||
|
this.btnReload.Location = new System.Drawing.Point(0, 9);
|
||||||
|
this.btnReload.Name = "btnReload";
|
||||||
|
this.btnReload.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnReload.TabIndex = 2;
|
||||||
|
this.btnReload.Text = "Reload";
|
||||||
|
this.btnReload.UseVisualStyleBackColor = true;
|
||||||
|
this.btnReload.Click += new System.EventHandler(this.btnReload_Click);
|
||||||
|
//
|
||||||
|
// btnTestScrapFunction
|
||||||
|
//
|
||||||
|
this.btnTestScrapFunction.Location = new System.Drawing.Point(12, 452);
|
||||||
|
this.btnTestScrapFunction.Name = "btnTestScrapFunction";
|
||||||
|
this.btnTestScrapFunction.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnTestScrapFunction.TabIndex = 4;
|
||||||
|
this.btnTestScrapFunction.Text = "LoadScrap";
|
||||||
|
this.btnTestScrapFunction.UseVisualStyleBackColor = true;
|
||||||
|
this.btnTestScrapFunction.Click += new System.EventHandler(this.btnTestScrapFunction_Click);
|
||||||
|
//
|
||||||
|
// lblStockRows
|
||||||
|
//
|
||||||
|
this.lblStockRows.AutoSize = true;
|
||||||
|
this.lblStockRows.Location = new System.Drawing.Point(93, 456);
|
||||||
|
this.lblStockRows.Name = "lblStockRows";
|
||||||
|
this.lblStockRows.Size = new System.Drawing.Size(14, 15);
|
||||||
|
this.lblStockRows.TabIndex = 5;
|
||||||
|
this.lblStockRows.Text = "#";
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
this.button1.Location = new System.Drawing.Point(157, 452);
|
||||||
|
this.button1.Name = "button1";
|
||||||
|
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.button1.TabIndex = 6;
|
||||||
|
this.button1.Text = "ReLoad";
|
||||||
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
|
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||||
|
//
|
||||||
|
// chbShowBrowser
|
||||||
|
//
|
||||||
|
this.chbShowBrowser.AutoSize = true;
|
||||||
|
this.chbShowBrowser.Location = new System.Drawing.Point(12, 478);
|
||||||
|
this.chbShowBrowser.Name = "chbShowBrowser";
|
||||||
|
this.chbShowBrowser.Size = new System.Drawing.Size(100, 22);
|
||||||
|
this.chbShowBrowser.TabIndex = 7;
|
||||||
|
this.chbShowBrowser.Text = "Show Browser";
|
||||||
|
this.chbShowBrowser.UseCompatibleTextRendering = true;
|
||||||
|
this.chbShowBrowser.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// gbStockMgmnt
|
||||||
|
//
|
||||||
|
this.gbStockMgmnt.Controls.Add(this.btnValueView);
|
||||||
|
this.gbStockMgmnt.Controls.Add(this.btnStockReg);
|
||||||
|
this.gbStockMgmnt.Location = new System.Drawing.Point(411, 411);
|
||||||
|
this.gbStockMgmnt.Name = "gbStockMgmnt";
|
||||||
|
this.gbStockMgmnt.Size = new System.Drawing.Size(257, 123);
|
||||||
|
this.gbStockMgmnt.TabIndex = 8;
|
||||||
|
this.gbStockMgmnt.TabStop = false;
|
||||||
|
//
|
||||||
|
// btnValueView
|
||||||
|
//
|
||||||
|
this.btnValueView.Location = new System.Drawing.Point(7, 39);
|
||||||
|
this.btnValueView.Name = "btnValueView";
|
||||||
|
this.btnValueView.Size = new System.Drawing.Size(95, 23);
|
||||||
|
this.btnValueView.TabIndex = 1;
|
||||||
|
this.btnValueView.Text = "See values";
|
||||||
|
this.btnValueView.UseVisualStyleBackColor = true;
|
||||||
|
this.btnValueView.Click += new System.EventHandler(this.btnValueView_Click);
|
||||||
|
//
|
||||||
|
// btnStockReg
|
||||||
|
//
|
||||||
|
this.btnStockReg.Location = new System.Drawing.Point(6, 9);
|
||||||
|
this.btnStockReg.Name = "btnStockReg";
|
||||||
|
this.btnStockReg.Size = new System.Drawing.Size(96, 23);
|
||||||
|
this.btnStockReg.TabIndex = 0;
|
||||||
|
this.btnStockReg.Text = "Stock Purchase";
|
||||||
|
this.btnStockReg.UseVisualStyleBackColor = true;
|
||||||
|
this.btnStockReg.Click += new System.EventHandler(this.btnStockReg_Click);
|
||||||
|
//
|
||||||
|
// frmInitial
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 546);
|
||||||
|
this.Controls.Add(this.gbStockMgmnt);
|
||||||
|
this.Controls.Add(this.chbShowBrowser);
|
||||||
|
this.Controls.Add(this.button1);
|
||||||
|
this.Controls.Add(this.lblStockRows);
|
||||||
|
this.Controls.Add(this.btnTestScrapFunction);
|
||||||
|
this.Controls.Add(this.gB1);
|
||||||
|
this.Controls.Add(this.lblTotalRecords);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.MinimizeBox = false;
|
||||||
|
this.Name = "frmInitial";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "Repository Pattern";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmInitial_FormClosing);
|
||||||
|
this.Load += new System.EventHandler(this.Form1_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.gB1.ResumeLayout(false);
|
||||||
|
this.gbStockMgmnt.ResumeLayout(false);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.DataGridView dataGridView;
|
||||||
|
private System.Windows.Forms.Label lblTotalRecords;
|
||||||
|
private System.Windows.Forms.GroupBox gB1;
|
||||||
|
private System.Windows.Forms.Button btnReload;
|
||||||
|
private System.Windows.Forms.Button btnTestScrapFunction;
|
||||||
|
private System.Windows.Forms.Label lblStockRows;
|
||||||
|
private System.Windows.Forms.Button button1;
|
||||||
|
private System.Windows.Forms.CheckBox chbShowBrowser;
|
||||||
|
private System.Windows.Forms.GroupBox gbStockMgmnt;
|
||||||
|
private System.Windows.Forms.Button btnStockReg;
|
||||||
|
private System.Windows.Forms.Button btnValueView;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
117
StockInfo/frmInitial.cs
Normal file
117
StockInfo/frmInitial.cs
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
using StockDal.Interface;
|
||||||
|
using StockDAL.Interface;
|
||||||
|
using DataDomain;
|
||||||
|
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 StockInfo
|
||||||
|
{
|
||||||
|
public partial class frmInitial : Form
|
||||||
|
{
|
||||||
|
private readonly IStockRepository _stockRepository;
|
||||||
|
private readonly IStockMarketRepository _stockMarketRepository;
|
||||||
|
|
||||||
|
private frmRegisterStock regWindow;
|
||||||
|
private frmMyStocks stockWindow;
|
||||||
|
|
||||||
|
public frmInitial(IStockRepository stockMemberRepository, IStockMarketRepository stockMarketRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_stockRepository = stockMemberRepository;
|
||||||
|
_stockMarketRepository = stockMarketRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Form1_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ReloadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReloadData()
|
||||||
|
{
|
||||||
|
var allStocks = _stockRepository.GetAllStocks();
|
||||||
|
dataGridView.DataSource = allStocks;
|
||||||
|
// SaveStocks(allStocks);
|
||||||
|
lblTotalRecords.Text = $"Total records: {dataGridView.RowCount}";
|
||||||
|
}
|
||||||
|
|
||||||
|
//private static async void SaveStocks(IEnumerable<DataDomain.StockMember> allStocks)
|
||||||
|
//{
|
||||||
|
|
||||||
|
// allStocks.ToList().ForEach(async s => await StockProcessor.SaveStockMember(new ApiClient.StockMember
|
||||||
|
// {
|
||||||
|
// ActAmount = s.ActAmount,
|
||||||
|
// ActDate = s.ActDate,
|
||||||
|
// ActValue = (double)s.ActValue,
|
||||||
|
// BuyDate = s.BuyDate,
|
||||||
|
// BuyValue = (double)s.BuyValue,
|
||||||
|
// Comment = s.Comment,
|
||||||
|
// PostAmount = s.PostAmount,
|
||||||
|
// SoldDate = s.SoldDate,
|
||||||
|
// SoldValue = (double)s.SoldValue,
|
||||||
|
// StockExtId = s.StockExtId,
|
||||||
|
// StockId = s.StockId
|
||||||
|
// }));
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
//private async void GetApiStocks()
|
||||||
|
//{
|
||||||
|
// dataGridView.DataSource = await StockProcessor.LoadStocksInformation();
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
private void btnReload_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ReloadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnTestScrapFunction_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_stockMarketRepository.LoadStockMarketList(chbShowBrowser.Checked);
|
||||||
|
var stocklist = _stockMarketRepository.StockMarketList;
|
||||||
|
lblStockRows.Text = stocklist.Count().ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void frmInitial_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
_stockMarketRepository.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
lblStockRows.Text = "";
|
||||||
|
_stockMarketRepository.RefreshMarketList();
|
||||||
|
var stocklist = _stockMarketRepository.StockMarketList;
|
||||||
|
lblStockRows.Text = stocklist.Count().ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnStockReg_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Cursor.Current = Cursors.WaitCursor;
|
||||||
|
_stockMarketRepository.LoadStockMarketList();
|
||||||
|
regWindow = new frmRegisterStock();
|
||||||
|
regWindow.Stocks = _stockMarketRepository.StockMarketList;
|
||||||
|
Cursor.Current = DefaultCursor;
|
||||||
|
regWindow.ShowDialog();
|
||||||
|
|
||||||
|
_stockRepository.InsertMany(regWindow.RegisteredStocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnValueView_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Cursor.Current = Cursors.WaitCursor;
|
||||||
|
_stockMarketRepository.LoadStockMarketList();
|
||||||
|
stockWindow = new frmMyStocks( _stockRepository, _stockMarketRepository);
|
||||||
|
stockWindow.Stocks = _stockMarketRepository.StockMarketList;
|
||||||
|
Cursor.Current = DefaultCursor;
|
||||||
|
stockWindow.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
StockInfo/frmInitial.resx
Normal file
60
StockInfo/frmInitial.resx
Normal file
@ -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>
|
||||||
389
StockInfo/frmMyStocks.Designer.cs
generated
Normal file
389
StockInfo/frmMyStocks.Designer.cs
generated
Normal file
@ -0,0 +1,389 @@
|
|||||||
|
|
||||||
|
namespace StockInfo
|
||||||
|
{
|
||||||
|
partial class frmMyStocks
|
||||||
|
{
|
||||||
|
/// <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.components = new System.ComponentModel.Container();
|
||||||
|
this.lvMyStocks = new System.Windows.Forms.ListView();
|
||||||
|
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.columnHeader7 = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.columnHeader11 = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.columnHeader8 = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.columnHeader9 = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.columnHeader10 = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.txtBuyTotal = new System.Windows.Forms.TextBox();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.txtTotDiff = new System.Windows.Forms.TextBox();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.txtCurrValue = new System.Windows.Forms.TextBox();
|
||||||
|
this.timer1 = new System.Windows.Forms.Timer(this.components);
|
||||||
|
this.chkAutoReload = new System.Windows.Forms.CheckBox();
|
||||||
|
this.lbUpdateTimes = new System.Windows.Forms.ListBox();
|
||||||
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
|
this.label6 = new System.Windows.Forms.Label();
|
||||||
|
this.txtTotalMinus = new System.Windows.Forms.TextBox();
|
||||||
|
this.label7 = new System.Windows.Forms.Label();
|
||||||
|
this.txtTotalPlus = new System.Windows.Forms.TextBox();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// lvMyStocks
|
||||||
|
//
|
||||||
|
this.lvMyStocks.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.lvMyStocks.BackColor = System.Drawing.SystemColors.InactiveCaption;
|
||||||
|
this.lvMyStocks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||||
|
this.columnHeader1,
|
||||||
|
this.columnHeader2,
|
||||||
|
this.columnHeader7,
|
||||||
|
this.columnHeader11,
|
||||||
|
this.columnHeader3,
|
||||||
|
this.columnHeader4,
|
||||||
|
this.columnHeader5,
|
||||||
|
this.columnHeader6,
|
||||||
|
this.columnHeader8,
|
||||||
|
this.columnHeader9,
|
||||||
|
this.columnHeader10});
|
||||||
|
this.lvMyStocks.GridLines = true;
|
||||||
|
this.lvMyStocks.HideSelection = false;
|
||||||
|
this.lvMyStocks.Location = new System.Drawing.Point(14, 43);
|
||||||
|
this.lvMyStocks.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.lvMyStocks.Name = "lvMyStocks";
|
||||||
|
this.lvMyStocks.Size = new System.Drawing.Size(1191, 369);
|
||||||
|
this.lvMyStocks.TabIndex = 0;
|
||||||
|
this.lvMyStocks.UseCompatibleStateImageBehavior = false;
|
||||||
|
this.lvMyStocks.View = System.Windows.Forms.View.Details;
|
||||||
|
this.lvMyStocks.DrawColumnHeader += new System.Windows.Forms.DrawListViewColumnHeaderEventHandler(this.lvMyStocks_DrawColumnHeader);
|
||||||
|
//
|
||||||
|
// columnHeader1
|
||||||
|
//
|
||||||
|
this.columnHeader1.Name = "columnHeader1";
|
||||||
|
this.columnHeader1.Text = "Stock Name";
|
||||||
|
this.columnHeader1.Width = 120;
|
||||||
|
//
|
||||||
|
// columnHeader2
|
||||||
|
//
|
||||||
|
this.columnHeader2.Name = "columnHeader2";
|
||||||
|
this.columnHeader2.Text = "Buy Price";
|
||||||
|
this.columnHeader2.Width = 80;
|
||||||
|
//
|
||||||
|
// columnHeader7
|
||||||
|
//
|
||||||
|
this.columnHeader7.Name = "columnHeader7";
|
||||||
|
this.columnHeader7.Text = "Market price";
|
||||||
|
this.columnHeader7.Width = 100;
|
||||||
|
//
|
||||||
|
// columnHeader11
|
||||||
|
//
|
||||||
|
this.columnHeader11.Name = "columnHeader11";
|
||||||
|
this.columnHeader11.Text = "Price Diff";
|
||||||
|
this.columnHeader11.Width = 100;
|
||||||
|
//
|
||||||
|
// columnHeader3
|
||||||
|
//
|
||||||
|
this.columnHeader3.Name = "columnHeader3";
|
||||||
|
this.columnHeader3.Text = "Amount Stk";
|
||||||
|
this.columnHeader3.Width = 100;
|
||||||
|
//
|
||||||
|
// columnHeader4
|
||||||
|
//
|
||||||
|
this.columnHeader4.Name = "columnHeader4";
|
||||||
|
this.columnHeader4.Text = "Buy Date";
|
||||||
|
this.columnHeader4.Width = 100;
|
||||||
|
//
|
||||||
|
// columnHeader5
|
||||||
|
//
|
||||||
|
this.columnHeader5.Name = "columnHeader5";
|
||||||
|
this.columnHeader5.Text = "Value diff";
|
||||||
|
this.columnHeader5.Width = 100;
|
||||||
|
//
|
||||||
|
// columnHeader6
|
||||||
|
//
|
||||||
|
this.columnHeader6.Name = "columnHeader6";
|
||||||
|
this.columnHeader6.Text = "Value diff %";
|
||||||
|
this.columnHeader6.Width = 80;
|
||||||
|
//
|
||||||
|
// columnHeader8
|
||||||
|
//
|
||||||
|
this.columnHeader8.Name = "columnHeader8";
|
||||||
|
this.columnHeader8.Text = "Market Date";
|
||||||
|
this.columnHeader8.Width = 100;
|
||||||
|
//
|
||||||
|
// columnHeader9
|
||||||
|
//
|
||||||
|
this.columnHeader9.Name = "columnHeader9";
|
||||||
|
this.columnHeader9.Text = "Current value";
|
||||||
|
this.columnHeader9.Width = 80;
|
||||||
|
//
|
||||||
|
// columnHeader10
|
||||||
|
//
|
||||||
|
this.columnHeader10.Name = "columnHeader10";
|
||||||
|
this.columnHeader10.Text = "Owned days";
|
||||||
|
//
|
||||||
|
// txtBuyTotal
|
||||||
|
//
|
||||||
|
this.txtBuyTotal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.txtBuyTotal.Location = new System.Drawing.Point(186, 428);
|
||||||
|
this.txtBuyTotal.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.txtBuyTotal.Name = "txtBuyTotal";
|
||||||
|
this.txtBuyTotal.ReadOnly = true;
|
||||||
|
this.txtBuyTotal.Size = new System.Drawing.Size(114, 27);
|
||||||
|
this.txtBuyTotal.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.label1.Location = new System.Drawing.Point(64, 425);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(101, 21);
|
||||||
|
this.label1.TabIndex = 2;
|
||||||
|
this.label1.Text = "Bought Totalt";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.label2.Location = new System.Drawing.Point(338, 430);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(55, 21);
|
||||||
|
this.label2.TabIndex = 4;
|
||||||
|
this.label2.Text = "TotDiff";
|
||||||
|
//
|
||||||
|
// txtTotDiff
|
||||||
|
//
|
||||||
|
this.txtTotDiff.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.txtTotDiff.Font = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.txtTotDiff.Location = new System.Drawing.Point(415, 419);
|
||||||
|
this.txtTotDiff.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.txtTotDiff.Name = "txtTotDiff";
|
||||||
|
this.txtTotDiff.ReadOnly = true;
|
||||||
|
this.txtTotDiff.Size = new System.Drawing.Size(114, 33);
|
||||||
|
this.txtTotDiff.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.label3.Location = new System.Drawing.Point(582, 425);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(105, 21);
|
||||||
|
this.label3.TabIndex = 6;
|
||||||
|
this.label3.Text = "Current Value";
|
||||||
|
//
|
||||||
|
// txtCurrValue
|
||||||
|
//
|
||||||
|
this.txtCurrValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.txtCurrValue.Location = new System.Drawing.Point(709, 428);
|
||||||
|
this.txtCurrValue.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.txtCurrValue.Name = "txtCurrValue";
|
||||||
|
this.txtCurrValue.ReadOnly = true;
|
||||||
|
this.txtCurrValue.Size = new System.Drawing.Size(114, 27);
|
||||||
|
this.txtCurrValue.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// timer1
|
||||||
|
//
|
||||||
|
this.timer1.Interval = 150000;
|
||||||
|
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
|
||||||
|
//
|
||||||
|
// chkAutoReload
|
||||||
|
//
|
||||||
|
this.chkAutoReload.AutoSize = true;
|
||||||
|
this.chkAutoReload.Location = new System.Drawing.Point(15, 9);
|
||||||
|
this.chkAutoReload.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.chkAutoReload.Name = "chkAutoReload";
|
||||||
|
this.chkAutoReload.Size = new System.Drawing.Size(148, 24);
|
||||||
|
this.chkAutoReload.TabIndex = 7;
|
||||||
|
this.chkAutoReload.Text = "Automatic Reload";
|
||||||
|
this.chkAutoReload.UseVisualStyleBackColor = true;
|
||||||
|
this.chkAutoReload.CheckedChanged += new System.EventHandler(this.chkAutoReload_CheckedChanged);
|
||||||
|
//
|
||||||
|
// lbUpdateTimes
|
||||||
|
//
|
||||||
|
this.lbUpdateTimes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.lbUpdateTimes.FormattingEnabled = true;
|
||||||
|
this.lbUpdateTimes.ItemHeight = 20;
|
||||||
|
this.lbUpdateTimes.Location = new System.Drawing.Point(16, 500);
|
||||||
|
this.lbUpdateTimes.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.lbUpdateTimes.Name = "lbUpdateTimes";
|
||||||
|
this.lbUpdateTimes.Size = new System.Drawing.Size(164, 124);
|
||||||
|
this.lbUpdateTimes.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.label4.AutoSize = true;
|
||||||
|
this.label4.Location = new System.Drawing.Point(14, 472);
|
||||||
|
this.label4.Name = "label4";
|
||||||
|
this.label4.Size = new System.Drawing.Size(97, 20);
|
||||||
|
this.label4.TabIndex = 9;
|
||||||
|
this.label4.Text = "LatestUpdate";
|
||||||
|
//
|
||||||
|
// numericUpDown1
|
||||||
|
//
|
||||||
|
this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.numericUpDown1.Location = new System.Drawing.Point(186, 593);
|
||||||
|
this.numericUpDown1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.numericUpDown1.Name = "numericUpDown1";
|
||||||
|
this.numericUpDown1.Size = new System.Drawing.Size(119, 27);
|
||||||
|
this.numericUpDown1.TabIndex = 10;
|
||||||
|
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.label5.AutoSize = true;
|
||||||
|
this.label5.Location = new System.Drawing.Point(186, 569);
|
||||||
|
this.label5.Name = "label5";
|
||||||
|
this.label5.Size = new System.Drawing.Size(132, 20);
|
||||||
|
this.label5.TabIndex = 11;
|
||||||
|
this.label5.Text = "Uppdatering (min)";
|
||||||
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.label6.AutoSize = true;
|
||||||
|
this.label6.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.label6.Location = new System.Drawing.Point(200, 476);
|
||||||
|
this.label6.Name = "label6";
|
||||||
|
this.label6.Size = new System.Drawing.Size(89, 21);
|
||||||
|
this.label6.TabIndex = 13;
|
||||||
|
this.label6.Text = "Total Minus";
|
||||||
|
//
|
||||||
|
// txtTotalMinus
|
||||||
|
//
|
||||||
|
this.txtTotalMinus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.txtTotalMinus.BackColor = System.Drawing.Color.Pink;
|
||||||
|
this.txtTotalMinus.Font = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.txtTotalMinus.Location = new System.Drawing.Point(295, 474);
|
||||||
|
this.txtTotalMinus.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.txtTotalMinus.Name = "txtTotalMinus";
|
||||||
|
this.txtTotalMinus.ReadOnly = true;
|
||||||
|
this.txtTotalMinus.Size = new System.Drawing.Size(114, 33);
|
||||||
|
this.txtTotalMinus.TabIndex = 12;
|
||||||
|
//
|
||||||
|
// label7
|
||||||
|
//
|
||||||
|
this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.label7.AutoSize = true;
|
||||||
|
this.label7.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.label7.Location = new System.Drawing.Point(438, 476);
|
||||||
|
this.label7.Name = "label7";
|
||||||
|
this.label7.Size = new System.Drawing.Size(75, 21);
|
||||||
|
this.label7.TabIndex = 15;
|
||||||
|
this.label7.Text = "Total Plus";
|
||||||
|
//
|
||||||
|
// txtTotalPlus
|
||||||
|
//
|
||||||
|
this.txtTotalPlus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.txtTotalPlus.BackColor = System.Drawing.Color.LightGreen;
|
||||||
|
this.txtTotalPlus.Font = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.txtTotalPlus.Location = new System.Drawing.Point(533, 474);
|
||||||
|
this.txtTotalPlus.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.txtTotalPlus.Name = "txtTotalPlus";
|
||||||
|
this.txtTotalPlus.ReadOnly = true;
|
||||||
|
this.txtTotalPlus.Size = new System.Drawing.Size(114, 33);
|
||||||
|
this.txtTotalPlus.TabIndex = 14;
|
||||||
|
//
|
||||||
|
// 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.label7);
|
||||||
|
this.Controls.Add(this.txtTotalPlus);
|
||||||
|
this.Controls.Add(this.label6);
|
||||||
|
this.Controls.Add(this.txtTotalMinus);
|
||||||
|
this.Controls.Add(this.label5);
|
||||||
|
this.Controls.Add(this.numericUpDown1);
|
||||||
|
this.Controls.Add(this.label4);
|
||||||
|
this.Controls.Add(this.lbUpdateTimes);
|
||||||
|
this.Controls.Add(this.chkAutoReload);
|
||||||
|
this.Controls.Add(this.label3);
|
||||||
|
this.Controls.Add(this.txtCurrValue);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.txtTotDiff);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.txtBuyTotal);
|
||||||
|
this.Controls.Add(this.lvMyStocks);
|
||||||
|
this.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.Name = "frmMyStocks";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "frmMyStocks";
|
||||||
|
this.Shown += new System.EventHandler(this.frmMyStocks_Shown);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.ListView lvMyStocks;
|
||||||
|
private System.Windows.Forms.ColumnHeader columnHeader1;
|
||||||
|
private System.Windows.Forms.ColumnHeader columnHeader2;
|
||||||
|
private System.Windows.Forms.ColumnHeader columnHeader3;
|
||||||
|
private System.Windows.Forms.ColumnHeader columnHeader4;
|
||||||
|
private System.Windows.Forms.ColumnHeader columnHeader5;
|
||||||
|
private System.Windows.Forms.ColumnHeader columnHeader6;
|
||||||
|
private System.Windows.Forms.ColumnHeader columnHeader7;
|
||||||
|
private System.Windows.Forms.ColumnHeader columnHeader8;
|
||||||
|
private System.Windows.Forms.ColumnHeader columnHeader9;
|
||||||
|
private System.Windows.Forms.ColumnHeader columnHeader10;
|
||||||
|
private System.Windows.Forms.TextBox txtBuyTotal;
|
||||||
|
private System.Windows.Forms.Label label1;
|
||||||
|
private System.Windows.Forms.Label label2;
|
||||||
|
private System.Windows.Forms.TextBox txtTotDiff;
|
||||||
|
private System.Windows.Forms.Label label3;
|
||||||
|
private System.Windows.Forms.TextBox txtCurrValue;
|
||||||
|
private System.Windows.Forms.Timer timer1;
|
||||||
|
private System.Windows.Forms.CheckBox chkAutoReload;
|
||||||
|
private System.Windows.Forms.ListBox lbUpdateTimes;
|
||||||
|
private System.Windows.Forms.Label label4;
|
||||||
|
private System.Windows.Forms.ColumnHeader columnHeader11;
|
||||||
|
private System.Windows.Forms.NumericUpDown numericUpDown1;
|
||||||
|
private System.Windows.Forms.Label label5;
|
||||||
|
private System.Windows.Forms.Label label6;
|
||||||
|
private System.Windows.Forms.TextBox txtTotalMinus;
|
||||||
|
private System.Windows.Forms.Label label7;
|
||||||
|
private System.Windows.Forms.TextBox txtTotalPlus;
|
||||||
|
}
|
||||||
|
}
|
||||||
166
StockInfo/frmMyStocks.cs
Normal file
166
StockInfo/frmMyStocks.cs
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
using StockDal.Interface;
|
||||||
|
using DataDomain;
|
||||||
|
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;
|
||||||
|
using StockDAL.Interface;
|
||||||
|
//
|
||||||
|
namespace StockInfo
|
||||||
|
{
|
||||||
|
public partial class frmMyStocks : Form
|
||||||
|
{
|
||||||
|
Color hdrColor;
|
||||||
|
private readonly IStockRepository _stockRepository;
|
||||||
|
private readonly IStockMarketRepository _stockMarketRepository;
|
||||||
|
public decimal BoughtSum { get; set; }
|
||||||
|
public decimal TotalDiff { get; set; }
|
||||||
|
public decimal CurrentSum { get; set; }
|
||||||
|
public decimal TotalPlus { get; set; }
|
||||||
|
public decimal TotalMinus { get; set; }
|
||||||
|
|
||||||
|
public Dictionary<string, DiTraderStockRow> Stocks { get; set; }
|
||||||
|
public IEnumerable<StockMember> CurrentStocks { get; set; }
|
||||||
|
|
||||||
|
public frmMyStocks(IStockRepository stockRepository, IStockMarketRepository stockMarketRepository)
|
||||||
|
{
|
||||||
|
hdrColor = Color.CadetBlue;
|
||||||
|
InitializeComponent();
|
||||||
|
_stockRepository = stockRepository;
|
||||||
|
_stockMarketRepository = stockMarketRepository;
|
||||||
|
numericUpDown1.Value = timer1.Interval / 60000;
|
||||||
|
numericUpDown1.Enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ReloadData()
|
||||||
|
{
|
||||||
|
CurrentStocks = _stockRepository.GetAllRemainingStocks();
|
||||||
|
lvMyStocks.Items.Clear();
|
||||||
|
BoughtSum = 0m;
|
||||||
|
TotalDiff = 0m;
|
||||||
|
CurrentSum = 0m;
|
||||||
|
TotalMinus = 0m;
|
||||||
|
TotalPlus = 0m;
|
||||||
|
var tmpStocks = new List<StockMember>();
|
||||||
|
foreach (var stock in CurrentStocks)
|
||||||
|
{
|
||||||
|
stock.ActValue = Stocks[stock.StockId.Trim()].LatestPrice;
|
||||||
|
stock.ActDate = DateTime.Today;
|
||||||
|
_stockRepository.UpdateActualPrice(stock.Id, stock.ActValue);
|
||||||
|
tmpStocks.Add(stock);
|
||||||
|
}
|
||||||
|
foreach(var stk in tmpStocks.OrderByDescending(s => s.PostAmount * (s.ActValue -s.BuyValue)))
|
||||||
|
{
|
||||||
|
AddItemToListView(stk);
|
||||||
|
}
|
||||||
|
|
||||||
|
txtBuyTotal.Text = BoughtSum.ToString();
|
||||||
|
txtBuyTotal.Refresh();
|
||||||
|
txtCurrValue.Text = CurrentSum.ToString();
|
||||||
|
txtCurrValue.Refresh();
|
||||||
|
txtTotDiff.Text = TotalDiff.ToString();
|
||||||
|
if (TotalDiff < 0)
|
||||||
|
{
|
||||||
|
txtTotDiff.BackColor = Color.Pink;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
txtTotDiff.BackColor = Color.LightGreen;
|
||||||
|
}
|
||||||
|
txtTotDiff.Refresh();
|
||||||
|
txtTotalMinus.Text = TotalMinus.ToString();
|
||||||
|
txtTotalMinus.Refresh();
|
||||||
|
txtTotalPlus.Text = TotalPlus.ToString();
|
||||||
|
txtTotalPlus.Refresh();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TotalReload()
|
||||||
|
{
|
||||||
|
_stockMarketRepository.LoadStockMarketList();
|
||||||
|
Stocks = _stockMarketRepository.StockMarketList;
|
||||||
|
ReloadData();
|
||||||
|
lbUpdateTimes.Items.Add($"{DateTime.Now.ToLongTimeString()} - {txtTotDiff.Text.Substring(0, txtTotDiff.Text.Length-2)}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lvMyStocks_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
|
||||||
|
{
|
||||||
|
using (Brush hBr = new SolidBrush(hdrColor))
|
||||||
|
{
|
||||||
|
e.Graphics.FillRectangle(hBr, e.Bounds);
|
||||||
|
e.DrawText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddItemToListView(StockMember currStock)
|
||||||
|
{
|
||||||
|
var lv = lvMyStocks.Items.Add(currStock.StockId);
|
||||||
|
lv.SubItems.Add(currStock.BuyValue.ToString());
|
||||||
|
var currValue = lv.SubItems.Add(currStock.ActValue.ToString());
|
||||||
|
//var saveBcolor = currValue.BackColor;
|
||||||
|
//var valueLevel = currStock.ActValue - currStock.BuyValue;
|
||||||
|
//currValue.ForeColor = valueLevel > 5 ? Color.Red : saveBcolor;
|
||||||
|
var priceDiff = currStock.ActValue - currStock.BuyValue;
|
||||||
|
lv.SubItems.Add(priceDiff.ToString());
|
||||||
|
lv.SubItems.Add(currStock.PostAmount.ToString());
|
||||||
|
lv.SubItems.Add(currStock.BuyDate.ToString());
|
||||||
|
var buyValue = currStock.PostAmount * currStock.BuyValue;
|
||||||
|
var actValue = currStock.PostAmount * currStock.ActValue;
|
||||||
|
var diffValue = actValue - buyValue;
|
||||||
|
var diffproc = diffValue / buyValue * 100;
|
||||||
|
BoughtSum += buyValue;
|
||||||
|
TotalDiff += diffValue;
|
||||||
|
CurrentSum += actValue;
|
||||||
|
if (diffValue < 0)
|
||||||
|
{
|
||||||
|
TotalMinus += diffValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TotalPlus += diffValue;
|
||||||
|
}
|
||||||
|
var lvs = lv.SubItems.Add(diffValue.ToString());
|
||||||
|
lv.SubItems.Add(Math.Round(diffproc, 2).ToString());
|
||||||
|
lv.SubItems.Add(currStock.ActDate.ToString());
|
||||||
|
lv.SubItems.Add(actValue.ToString());
|
||||||
|
var owned = (DateTime.Today - currStock.BuyDate).TotalDays;
|
||||||
|
lv.SubItems.Add(owned.ToString());
|
||||||
|
if (diffValue < 0)
|
||||||
|
{
|
||||||
|
lv.BackColor = Color.Pink;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lv.BackColor = Color.LightGreen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void frmMyStocks_Shown(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ReloadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void timer1_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
TotalReload();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void chkAutoReload_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
timer1.Enabled = chkAutoReload.Checked;
|
||||||
|
numericUpDown1.Enabled = chkAutoReload.Checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
timer1.Interval = Convert.ToInt32(numericUpDown1.Value * 60000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
StockInfo/frmMyStocks.resx
Normal file
60
StockInfo/frmMyStocks.resx
Normal file
@ -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>
|
||||||
377
StockInfo/frmRegisterStock.Designer.cs
generated
Normal file
377
StockInfo/frmRegisterStock.Designer.cs
generated
Normal file
@ -0,0 +1,377 @@
|
|||||||
|
|
||||||
|
namespace StockInfo
|
||||||
|
{
|
||||||
|
partial class frmRegisterStock
|
||||||
|
{
|
||||||
|
/// <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.cmbStockChoser = new System.Windows.Forms.ComboBox();
|
||||||
|
this.btnClose = new System.Windows.Forms.Button();
|
||||||
|
this.lblStockExtId = new System.Windows.Forms.Label();
|
||||||
|
this.txtStockExtId = new System.Windows.Forms.TextBox();
|
||||||
|
this.txtBuyPrice = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblBuyPrice = new System.Windows.Forms.Label();
|
||||||
|
this.txtBuyDate = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblBuyDate = new System.Windows.Forms.Label();
|
||||||
|
this.txtBoughtAmount = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblBoughtAmount = new System.Windows.Forms.Label();
|
||||||
|
this.txtActValue = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblActValue = new System.Windows.Forms.Label();
|
||||||
|
this.txtActDate = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblActDate = new System.Windows.Forms.Label();
|
||||||
|
this.txtActAmount = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblRemaining = new System.Windows.Forms.Label();
|
||||||
|
this.txtSoldPrice = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblSoldValue = new System.Windows.Forms.Label();
|
||||||
|
this.txtSoldDate = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblSoldDate = new System.Windows.Forms.Label();
|
||||||
|
this.txtComment = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblComment = new System.Windows.Forms.Label();
|
||||||
|
this.btnSaveStock = new System.Windows.Forms.Button();
|
||||||
|
this.lwRegBuffer = new System.Windows.Forms.ListView();
|
||||||
|
this.Stock = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.Price = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.Number = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.Comment = new System.Windows.Forms.ColumnHeader();
|
||||||
|
this.btnSaveToDB = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// cmbStockChoser
|
||||||
|
//
|
||||||
|
this.cmbStockChoser.FormattingEnabled = true;
|
||||||
|
this.cmbStockChoser.Location = new System.Drawing.Point(38, 39);
|
||||||
|
this.cmbStockChoser.Name = "cmbStockChoser";
|
||||||
|
this.cmbStockChoser.Size = new System.Drawing.Size(179, 23);
|
||||||
|
this.cmbStockChoser.TabIndex = 0;
|
||||||
|
this.cmbStockChoser.SelectedIndexChanged += new System.EventHandler(this.cmbStockChoser_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// btnClose
|
||||||
|
//
|
||||||
|
this.btnClose.Location = new System.Drawing.Point(347, 567);
|
||||||
|
this.btnClose.Name = "btnClose";
|
||||||
|
this.btnClose.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnClose.TabIndex = 1;
|
||||||
|
this.btnClose.Text = "Close";
|
||||||
|
this.btnClose.UseVisualStyleBackColor = true;
|
||||||
|
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
|
||||||
|
//
|
||||||
|
// lblStockExtId
|
||||||
|
//
|
||||||
|
this.lblStockExtId.AutoSize = true;
|
||||||
|
this.lblStockExtId.Location = new System.Drawing.Point(38, 78);
|
||||||
|
this.lblStockExtId.Name = "lblStockExtId";
|
||||||
|
this.lblStockExtId.Size = new System.Drawing.Size(62, 15);
|
||||||
|
this.lblStockExtId.TabIndex = 2;
|
||||||
|
this.lblStockExtId.Text = "StockExtId";
|
||||||
|
//
|
||||||
|
// txtStockExtId
|
||||||
|
//
|
||||||
|
this.txtStockExtId.Location = new System.Drawing.Point(153, 75);
|
||||||
|
this.txtStockExtId.Name = "txtStockExtId";
|
||||||
|
this.txtStockExtId.Size = new System.Drawing.Size(269, 23);
|
||||||
|
this.txtStockExtId.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// txtBuyPrice
|
||||||
|
//
|
||||||
|
this.txtBuyPrice.Location = new System.Drawing.Point(153, 104);
|
||||||
|
this.txtBuyPrice.Name = "txtBuyPrice";
|
||||||
|
this.txtBuyPrice.Size = new System.Drawing.Size(111, 23);
|
||||||
|
this.txtBuyPrice.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// lblBuyPrice
|
||||||
|
//
|
||||||
|
this.lblBuyPrice.AutoSize = true;
|
||||||
|
this.lblBuyPrice.Location = new System.Drawing.Point(38, 107);
|
||||||
|
this.lblBuyPrice.Name = "lblBuyPrice";
|
||||||
|
this.lblBuyPrice.Size = new System.Drawing.Size(56, 15);
|
||||||
|
this.lblBuyPrice.TabIndex = 4;
|
||||||
|
this.lblBuyPrice.Text = "Buy price";
|
||||||
|
//
|
||||||
|
// txtBuyDate
|
||||||
|
//
|
||||||
|
this.txtBuyDate.Location = new System.Drawing.Point(153, 133);
|
||||||
|
this.txtBuyDate.Name = "txtBuyDate";
|
||||||
|
this.txtBuyDate.Size = new System.Drawing.Size(142, 23);
|
||||||
|
this.txtBuyDate.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// lblBuyDate
|
||||||
|
//
|
||||||
|
this.lblBuyDate.AutoSize = true;
|
||||||
|
this.lblBuyDate.Location = new System.Drawing.Point(38, 136);
|
||||||
|
this.lblBuyDate.Name = "lblBuyDate";
|
||||||
|
this.lblBuyDate.Size = new System.Drawing.Size(73, 15);
|
||||||
|
this.lblBuyDate.TabIndex = 6;
|
||||||
|
this.lblBuyDate.Text = "Bought Date";
|
||||||
|
//
|
||||||
|
// txtBoughtAmount
|
||||||
|
//
|
||||||
|
this.txtBoughtAmount.Location = new System.Drawing.Point(153, 162);
|
||||||
|
this.txtBoughtAmount.Name = "txtBoughtAmount";
|
||||||
|
this.txtBoughtAmount.Size = new System.Drawing.Size(111, 23);
|
||||||
|
this.txtBoughtAmount.TabIndex = 9;
|
||||||
|
this.txtBoughtAmount.TextChanged += new System.EventHandler(this.txtBoughtAmount_TextChanged);
|
||||||
|
//
|
||||||
|
// lblBoughtAmount
|
||||||
|
//
|
||||||
|
this.lblBoughtAmount.AutoSize = true;
|
||||||
|
this.lblBoughtAmount.Location = new System.Drawing.Point(38, 165);
|
||||||
|
this.lblBoughtAmount.Name = "lblBoughtAmount";
|
||||||
|
this.lblBoughtAmount.Size = new System.Drawing.Size(93, 15);
|
||||||
|
this.lblBoughtAmount.TabIndex = 8;
|
||||||
|
this.lblBoughtAmount.Text = "Bought Number";
|
||||||
|
//
|
||||||
|
// txtActValue
|
||||||
|
//
|
||||||
|
this.txtActValue.Location = new System.Drawing.Point(153, 191);
|
||||||
|
this.txtActValue.Name = "txtActValue";
|
||||||
|
this.txtActValue.Size = new System.Drawing.Size(111, 23);
|
||||||
|
this.txtActValue.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// lblActValue
|
||||||
|
//
|
||||||
|
this.lblActValue.AutoSize = true;
|
||||||
|
this.lblActValue.Location = new System.Drawing.Point(38, 194);
|
||||||
|
this.lblActValue.Name = "lblActValue";
|
||||||
|
this.lblActValue.Size = new System.Drawing.Size(76, 15);
|
||||||
|
this.lblActValue.TabIndex = 10;
|
||||||
|
this.lblActValue.Text = "Current price";
|
||||||
|
//
|
||||||
|
// txtActDate
|
||||||
|
//
|
||||||
|
this.txtActDate.Location = new System.Drawing.Point(153, 220);
|
||||||
|
this.txtActDate.Name = "txtActDate";
|
||||||
|
this.txtActDate.Size = new System.Drawing.Size(142, 23);
|
||||||
|
this.txtActDate.TabIndex = 13;
|
||||||
|
//
|
||||||
|
// lblActDate
|
||||||
|
//
|
||||||
|
this.lblActDate.AutoSize = true;
|
||||||
|
this.lblActDate.Location = new System.Drawing.Point(38, 223);
|
||||||
|
this.lblActDate.Name = "lblActDate";
|
||||||
|
this.lblActDate.Size = new System.Drawing.Size(61, 15);
|
||||||
|
this.lblActDate.TabIndex = 12;
|
||||||
|
this.lblActDate.Text = "Value date";
|
||||||
|
//
|
||||||
|
// txtActAmount
|
||||||
|
//
|
||||||
|
this.txtActAmount.Location = new System.Drawing.Point(153, 249);
|
||||||
|
this.txtActAmount.Name = "txtActAmount";
|
||||||
|
this.txtActAmount.Size = new System.Drawing.Size(111, 23);
|
||||||
|
this.txtActAmount.TabIndex = 15;
|
||||||
|
//
|
||||||
|
// lblRemaining
|
||||||
|
//
|
||||||
|
this.lblRemaining.AutoSize = true;
|
||||||
|
this.lblRemaining.Location = new System.Drawing.Point(38, 252);
|
||||||
|
this.lblRemaining.Name = "lblRemaining";
|
||||||
|
this.lblRemaining.Size = new System.Drawing.Size(109, 15);
|
||||||
|
this.lblRemaining.TabIndex = 14;
|
||||||
|
this.lblRemaining.Text = "Remaining number";
|
||||||
|
//
|
||||||
|
// txtSoldPrice
|
||||||
|
//
|
||||||
|
this.txtSoldPrice.Location = new System.Drawing.Point(153, 278);
|
||||||
|
this.txtSoldPrice.Name = "txtSoldPrice";
|
||||||
|
this.txtSoldPrice.Size = new System.Drawing.Size(111, 23);
|
||||||
|
this.txtSoldPrice.TabIndex = 17;
|
||||||
|
//
|
||||||
|
// lblSoldValue
|
||||||
|
//
|
||||||
|
this.lblSoldValue.AutoSize = true;
|
||||||
|
this.lblSoldValue.Location = new System.Drawing.Point(38, 281);
|
||||||
|
this.lblSoldValue.Name = "lblSoldValue";
|
||||||
|
this.lblSoldValue.Size = new System.Drawing.Size(59, 15);
|
||||||
|
this.lblSoldValue.TabIndex = 16;
|
||||||
|
this.lblSoldValue.Text = "Sold price";
|
||||||
|
//
|
||||||
|
// txtSoldDate
|
||||||
|
//
|
||||||
|
this.txtSoldDate.Location = new System.Drawing.Point(153, 307);
|
||||||
|
this.txtSoldDate.Name = "txtSoldDate";
|
||||||
|
this.txtSoldDate.Size = new System.Drawing.Size(142, 23);
|
||||||
|
this.txtSoldDate.TabIndex = 19;
|
||||||
|
//
|
||||||
|
// lblSoldDate
|
||||||
|
//
|
||||||
|
this.lblSoldDate.AutoSize = true;
|
||||||
|
this.lblSoldDate.Location = new System.Drawing.Point(38, 310);
|
||||||
|
this.lblSoldDate.Name = "lblSoldDate";
|
||||||
|
this.lblSoldDate.Size = new System.Drawing.Size(57, 15);
|
||||||
|
this.lblSoldDate.TabIndex = 18;
|
||||||
|
this.lblSoldDate.Text = "Sold Date";
|
||||||
|
//
|
||||||
|
// txtComment
|
||||||
|
//
|
||||||
|
this.txtComment.Location = new System.Drawing.Point(153, 336);
|
||||||
|
this.txtComment.Multiline = true;
|
||||||
|
this.txtComment.Name = "txtComment";
|
||||||
|
this.txtComment.Size = new System.Drawing.Size(269, 72);
|
||||||
|
this.txtComment.TabIndex = 21;
|
||||||
|
//
|
||||||
|
// lblComment
|
||||||
|
//
|
||||||
|
this.lblComment.AutoSize = true;
|
||||||
|
this.lblComment.Location = new System.Drawing.Point(39, 339);
|
||||||
|
this.lblComment.Name = "lblComment";
|
||||||
|
this.lblComment.Size = new System.Drawing.Size(61, 15);
|
||||||
|
this.lblComment.TabIndex = 20;
|
||||||
|
this.lblComment.Text = "Comment";
|
||||||
|
//
|
||||||
|
// btnSaveStock
|
||||||
|
//
|
||||||
|
this.btnSaveStock.Location = new System.Drawing.Point(39, 385);
|
||||||
|
this.btnSaveStock.Name = "btnSaveStock";
|
||||||
|
this.btnSaveStock.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnSaveStock.TabIndex = 23;
|
||||||
|
this.btnSaveStock.Text = "Register";
|
||||||
|
this.btnSaveStock.UseVisualStyleBackColor = true;
|
||||||
|
this.btnSaveStock.Click += new System.EventHandler(this.btnSaveStock_Click);
|
||||||
|
//
|
||||||
|
// lwRegBuffer
|
||||||
|
//
|
||||||
|
this.lwRegBuffer.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||||
|
this.Stock,
|
||||||
|
this.Price,
|
||||||
|
this.Number,
|
||||||
|
this.Comment});
|
||||||
|
this.lwRegBuffer.GridLines = true;
|
||||||
|
this.lwRegBuffer.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
|
||||||
|
this.lwRegBuffer.HideSelection = false;
|
||||||
|
this.lwRegBuffer.Location = new System.Drawing.Point(39, 427);
|
||||||
|
this.lwRegBuffer.Name = "lwRegBuffer";
|
||||||
|
this.lwRegBuffer.Size = new System.Drawing.Size(383, 119);
|
||||||
|
this.lwRegBuffer.TabIndex = 24;
|
||||||
|
this.lwRegBuffer.UseCompatibleStateImageBehavior = false;
|
||||||
|
this.lwRegBuffer.View = System.Windows.Forms.View.Details;
|
||||||
|
this.lwRegBuffer.DrawColumnHeader += new System.Windows.Forms.DrawListViewColumnHeaderEventHandler(this.lwRegBuffer_DrawColumnHeader);
|
||||||
|
//
|
||||||
|
// Stock
|
||||||
|
//
|
||||||
|
this.Stock.Name = "Stock";
|
||||||
|
this.Stock.Text = "Stock";
|
||||||
|
this.Stock.Width = 120;
|
||||||
|
//
|
||||||
|
// Price
|
||||||
|
//
|
||||||
|
this.Price.Name = "Price";
|
||||||
|
this.Price.Text = "Price";
|
||||||
|
this.Price.Width = 80;
|
||||||
|
//
|
||||||
|
// Number
|
||||||
|
//
|
||||||
|
this.Number.Name = "Number";
|
||||||
|
this.Number.Text = "Number";
|
||||||
|
this.Number.Width = 80;
|
||||||
|
//
|
||||||
|
// Comment
|
||||||
|
//
|
||||||
|
this.Comment.Name = "Comment";
|
||||||
|
this.Comment.Text = "Comment";
|
||||||
|
this.Comment.Width = 120;
|
||||||
|
//
|
||||||
|
// btnSaveToDB
|
||||||
|
//
|
||||||
|
this.btnSaveToDB.Location = new System.Drawing.Point(266, 567);
|
||||||
|
this.btnSaveToDB.Name = "btnSaveToDB";
|
||||||
|
this.btnSaveToDB.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnSaveToDB.TabIndex = 25;
|
||||||
|
this.btnSaveToDB.Text = "Save";
|
||||||
|
this.btnSaveToDB.UseVisualStyleBackColor = true;
|
||||||
|
this.btnSaveToDB.Click += new System.EventHandler(this.btnSaveToDB_Click);
|
||||||
|
//
|
||||||
|
// frmRegisterStock
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(441, 602);
|
||||||
|
this.Controls.Add(this.btnSaveToDB);
|
||||||
|
this.Controls.Add(this.lwRegBuffer);
|
||||||
|
this.Controls.Add(this.btnSaveStock);
|
||||||
|
this.Controls.Add(this.txtComment);
|
||||||
|
this.Controls.Add(this.lblComment);
|
||||||
|
this.Controls.Add(this.txtSoldDate);
|
||||||
|
this.Controls.Add(this.lblSoldDate);
|
||||||
|
this.Controls.Add(this.txtSoldPrice);
|
||||||
|
this.Controls.Add(this.lblSoldValue);
|
||||||
|
this.Controls.Add(this.txtActAmount);
|
||||||
|
this.Controls.Add(this.lblRemaining);
|
||||||
|
this.Controls.Add(this.txtActDate);
|
||||||
|
this.Controls.Add(this.lblActDate);
|
||||||
|
this.Controls.Add(this.txtActValue);
|
||||||
|
this.Controls.Add(this.lblActValue);
|
||||||
|
this.Controls.Add(this.txtBoughtAmount);
|
||||||
|
this.Controls.Add(this.lblBoughtAmount);
|
||||||
|
this.Controls.Add(this.txtBuyDate);
|
||||||
|
this.Controls.Add(this.lblBuyDate);
|
||||||
|
this.Controls.Add(this.txtBuyPrice);
|
||||||
|
this.Controls.Add(this.lblBuyPrice);
|
||||||
|
this.Controls.Add(this.txtStockExtId);
|
||||||
|
this.Controls.Add(this.lblStockExtId);
|
||||||
|
this.Controls.Add(this.btnClose);
|
||||||
|
this.Controls.Add(this.cmbStockChoser);
|
||||||
|
this.Name = "frmRegisterStock";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "frmRegisterStock";
|
||||||
|
this.Shown += new System.EventHandler(this.frmRegisterStock_Shown);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.ComboBox cmbStockChoser;
|
||||||
|
private System.Windows.Forms.Button btnClose;
|
||||||
|
private System.Windows.Forms.Label lblStockExtId;
|
||||||
|
private System.Windows.Forms.TextBox txtStockExtId;
|
||||||
|
private System.Windows.Forms.TextBox txtBuyPrice;
|
||||||
|
private System.Windows.Forms.Label lblBuyPrice;
|
||||||
|
private System.Windows.Forms.TextBox txtBuyDate;
|
||||||
|
private System.Windows.Forms.Label lblBuyDate;
|
||||||
|
private System.Windows.Forms.TextBox txtBoughtAmount;
|
||||||
|
private System.Windows.Forms.Label lblBoughtAmount;
|
||||||
|
private System.Windows.Forms.TextBox txtActValue;
|
||||||
|
private System.Windows.Forms.Label lblActValue;
|
||||||
|
private System.Windows.Forms.TextBox txtActDate;
|
||||||
|
private System.Windows.Forms.Label lblActDate;
|
||||||
|
private System.Windows.Forms.TextBox txtActAmount;
|
||||||
|
private System.Windows.Forms.Label lblRemaining;
|
||||||
|
private System.Windows.Forms.TextBox txtSoldPrice;
|
||||||
|
private System.Windows.Forms.Label lblSoldValue;
|
||||||
|
private System.Windows.Forms.TextBox txtSoldDate;
|
||||||
|
private System.Windows.Forms.Label lblSoldDate;
|
||||||
|
private System.Windows.Forms.TextBox txtComment;
|
||||||
|
private System.Windows.Forms.Label lblComment;
|
||||||
|
private System.Windows.Forms.Button btnSaveStock;
|
||||||
|
private System.Windows.Forms.ListView lwRegBuffer;
|
||||||
|
private System.Windows.Forms.ColumnHeader Stock;
|
||||||
|
private System.Windows.Forms.ColumnHeader Price;
|
||||||
|
private System.Windows.Forms.ColumnHeader Number;
|
||||||
|
private System.Windows.Forms.ColumnHeader Comment;
|
||||||
|
private System.Windows.Forms.Button btnSaveToDB;
|
||||||
|
}
|
||||||
|
}
|
||||||
129
StockInfo/frmRegisterStock.cs
Normal file
129
StockInfo/frmRegisterStock.cs
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
using DataDomain;
|
||||||
|
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 StockInfo
|
||||||
|
{
|
||||||
|
public partial class frmRegisterStock : Form
|
||||||
|
{
|
||||||
|
Color hdr = Color.Red;
|
||||||
|
public Dictionary<string, DiTraderStockRow> Stocks { get; set; }
|
||||||
|
public List<StockMember> RegisteredStocks { get; set; } = new List<StockMember>();
|
||||||
|
|
||||||
|
public frmRegisterStock()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadStockCombo()
|
||||||
|
{
|
||||||
|
if (Stocks.Count() > 0)
|
||||||
|
{
|
||||||
|
foreach (var key in Stocks.Keys)
|
||||||
|
{
|
||||||
|
cmbStockChoser.Items.Add(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnClose_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void frmRegisterStock_Shown(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadStockCombo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cmbStockChoser_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var stockChosen = Stocks[cmbStockChoser.SelectedItem.ToString()];
|
||||||
|
txtStockExtId.Text = stockChosen.StockName;
|
||||||
|
txtActValue.Text = stockChosen.LatestPrice.ToString();
|
||||||
|
txtActDate.Text = (DateTime.Today + stockChosen.TimeOfDay).ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnSaveStock_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
AddValidateData();
|
||||||
|
RefreshListViewFromRegList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshListViewFromRegList()
|
||||||
|
{
|
||||||
|
lwRegBuffer.Items.Clear();
|
||||||
|
foreach (var currStock in RegisteredStocks)
|
||||||
|
{
|
||||||
|
AddItemToListView(currStock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddItemToListView(StockMember currStock)
|
||||||
|
{
|
||||||
|
var lv = lwRegBuffer.Items.Add(currStock.StockId);
|
||||||
|
lv.SubItems.Add(currStock.BuyValue.ToString());
|
||||||
|
lv.SubItems.Add(currStock.PostAmount.ToString());
|
||||||
|
lv.SubItems.Add(currStock.Comment);
|
||||||
|
//lv.BackColor = Color.Aquamarine;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddValidateData()
|
||||||
|
{
|
||||||
|
var currentStock = new StockMember();
|
||||||
|
currentStock.StockId = cmbStockChoser.SelectedItem.ToString();
|
||||||
|
currentStock.StockExtId = txtStockExtId.Text;
|
||||||
|
currentStock.BuyValue = decimal.Parse(string.IsNullOrEmpty(txtBuyPrice.Text) ? "0" : txtBuyPrice.Text);
|
||||||
|
currentStock.PostAmount = long.Parse(string.IsNullOrEmpty(txtBoughtAmount.Text) ? "0" : txtBoughtAmount.Text);
|
||||||
|
currentStock.ActDate = DateTime.Parse(txtActDate.Text);
|
||||||
|
currentStock.BuyDate = string.IsNullOrWhiteSpace(txtBuyDate.Text) ? DateTime.Today : DateTime.Parse(txtBuyDate.Text);
|
||||||
|
currentStock.ActValue = decimal.Parse(string.IsNullOrEmpty(txtActValue.Text) ? "0" : txtActValue.Text);
|
||||||
|
currentStock.SoldDate = null; //DateTime.MaxValue;
|
||||||
|
currentStock.SoldValue = decimal.Parse("0");
|
||||||
|
currentStock.Comment = txtComment.Text;
|
||||||
|
RegisteredStocks.Add(currentStock);
|
||||||
|
initiateRegWin();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initiateRegWin()
|
||||||
|
{
|
||||||
|
txtStockExtId.Text = "";
|
||||||
|
txtBuyPrice.Text = "";
|
||||||
|
txtBuyDate.Text = "";
|
||||||
|
txtBoughtAmount.Text = "";
|
||||||
|
txtActValue.Text = "";
|
||||||
|
txtActDate.Text = "";
|
||||||
|
txtActAmount.Text = "";
|
||||||
|
txtSoldPrice.Text = "";
|
||||||
|
txtSoldDate.Text = "";
|
||||||
|
txtComment.Text = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnSaveToDB_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void txtBoughtAmount_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
txtActAmount.Text = txtBoughtAmount.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lwRegBuffer_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
|
||||||
|
{
|
||||||
|
using (Brush hBr = new SolidBrush(hdr))
|
||||||
|
{
|
||||||
|
e.Graphics.FillRectangle(hBr, e.Bounds);
|
||||||
|
e.DrawText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
StockInfo/frmRegisterStock.resx
Normal file
60
StockInfo/frmRegisterStock.resx
Normal file
@ -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>
|
||||||
BIN
Z_Backup/Stocks.db
Normal file
BIN
Z_Backup/Stocks.db
Normal file
Binary file not shown.
Reference in New Issue
Block a user