Add project files.

This commit is contained in:
2021-05-09 22:10:25 +02:00
parent f20ba23e7b
commit f8c472a4cd
70 changed files with 6207 additions and 0 deletions

18
DataDomain/Address.cs Normal file
View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataDomain
{
public class Address
{
public int Id { get; set; }
public string Street { get; set; }
public string Street2 { get; set; }
public int Zipcode { get; set; }
public string Destination { get; set; }
public string Nation { get; set; }
}
}

View 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 BackupRegister
{
public int Id { get; set; }
public DateTime BackedUp { get; set; }
public string DbName { get; set; }
public string BackupDbName { get; set; }
public string BackupPath { get; set; }
}
}

View File

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>

View 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; }
}
}

22
DataDomain/Person.cs Normal file
View 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 Person
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string NickName { get; set; }
public String Born { get; set; }
public string Comments { get; set; }
public int HomeAddress { get; set; }
public int InvoiceAddress { get; set; }
public int ClearingNo { get; set; }
public long AccountNo { get; set; }
}
}

16
DataDomain/PersonStock.cs Normal file
View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataDomain
{
public class PersonStock
{
public int Id { get; set; }
public int PersonId { get; set; }
public int StockId { get; set; }
public string Comment { get; set; }
}
}

26
DataDomain/StockMember.cs Normal file
View 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; }
}
}

View 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>

View 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
}
}
}

View 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");
}
}
}

View File

@ -0,0 +1,125 @@
// <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("20210306151633_completion_person_address")]
partial class completion_person_address
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.3");
modelBuilder.Entity("DataDomain.Address", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Gata")
.HasColumnType("TEXT");
b.Property<string>("Gata2")
.HasColumnType("TEXT");
b.Property<string>("Nation")
.HasColumnType("TEXT");
b.Property<int>("PostNr")
.HasColumnType("INTEGER");
b.Property<string>("PostOrt")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Addresses");
});
modelBuilder.Entity("DataDomain.Person", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime?>("Born")
.HasColumnType("TEXT");
b.Property<string>("Comments")
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.HasColumnType("TEXT");
b.Property<int>("HomeAddress")
.HasColumnType("INTEGER");
b.Property<int>("InvoiceAddress")
.HasColumnType("INTEGER");
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
}
}
}

View File

@ -0,0 +1,65 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace DatamodelLibrary.Migrations
{
public partial class completion_person_address : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Comments",
table: "Persons",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "HomeAddress",
table: "Persons",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "InvoiceAddress",
table: "Persons",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "Addresses",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Gata = table.Column<string>(type: "TEXT", nullable: true),
Gata2 = table.Column<string>(type: "TEXT", nullable: true),
PostNr = table.Column<int>(type: "INTEGER", nullable: false),
PostOrt = table.Column<string>(type: "TEXT", nullable: true),
Nation = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Addresses", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Addresses");
migrationBuilder.DropColumn(
name: "Comments",
table: "Persons");
migrationBuilder.DropColumn(
name: "HomeAddress",
table: "Persons");
migrationBuilder.DropColumn(
name: "InvoiceAddress",
table: "Persons");
}
}
}

View File

@ -0,0 +1,145 @@
// <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("20210307074530_completion_person_stock")]
partial class completion_person_stock
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.3");
modelBuilder.Entity("DataDomain.Address", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Gata")
.HasColumnType("TEXT");
b.Property<string>("Gata2")
.HasColumnType("TEXT");
b.Property<string>("Nation")
.HasColumnType("TEXT");
b.Property<int>("PostNr")
.HasColumnType("INTEGER");
b.Property<string>("PostOrt")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Addresses");
});
modelBuilder.Entity("DataDomain.Person", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime?>("Born")
.HasColumnType("TEXT");
b.Property<string>("Comments")
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.HasColumnType("TEXT");
b.Property<int>("HomeAddress")
.HasColumnType("INTEGER");
b.Property<int>("InvoiceAddress")
.HasColumnType("INTEGER");
b.Property<string>("LastName")
.HasColumnType("TEXT");
b.Property<string>("NickName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Persons");
});
modelBuilder.Entity("DataDomain.PersonStock", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Comment")
.HasColumnType("TEXT");
b.Property<int>("PersonId")
.HasColumnType("INTEGER");
b.Property<int>("StockId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("PersonStocks");
});
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
}
}
}

View File

@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace DatamodelLibrary.Migrations
{
public partial class completion_person_stock : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PersonStocks",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
PersonId = table.Column<int>(type: "INTEGER", nullable: false),
StockId = table.Column<int>(type: "INTEGER", nullable: false),
Comment = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PersonStocks", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PersonStocks");
}
}
}

View File

@ -0,0 +1,151 @@
// <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("20210307212939_ChangedFormat_Person_Address")]
partial class ChangedFormat_Person_Address
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.3");
modelBuilder.Entity("DataDomain.Address", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Destination")
.HasColumnType("TEXT");
b.Property<string>("Nation")
.HasColumnType("TEXT");
b.Property<string>("Street")
.HasColumnType("TEXT");
b.Property<string>("Street2")
.HasColumnType("TEXT");
b.Property<int>("Zipcode")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Addresses");
});
modelBuilder.Entity("DataDomain.Person", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountNo")
.HasColumnType("INTEGER");
b.Property<string>("Born")
.HasColumnType("TEXT");
b.Property<int>("ClearingNo")
.HasColumnType("INTEGER");
b.Property<string>("Comments")
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.HasColumnType("TEXT");
b.Property<int>("HomeAddress")
.HasColumnType("INTEGER");
b.Property<int>("InvoiceAddress")
.HasColumnType("INTEGER");
b.Property<string>("LastName")
.HasColumnType("TEXT");
b.Property<string>("NickName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Persons");
});
modelBuilder.Entity("DataDomain.PersonStock", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Comment")
.HasColumnType("TEXT");
b.Property<int>("PersonId")
.HasColumnType("INTEGER");
b.Property<int>("StockId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("PersonStocks");
});
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
}
}
}

View File

@ -0,0 +1,75 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace DatamodelLibrary.Migrations
{
public partial class ChangedFormat_Person_Address : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "PostOrt",
table: "Addresses",
newName: "Street2");
migrationBuilder.RenameColumn(
name: "PostNr",
table: "Addresses",
newName: "Zipcode");
migrationBuilder.RenameColumn(
name: "Gata2",
table: "Addresses",
newName: "Street");
migrationBuilder.RenameColumn(
name: "Gata",
table: "Addresses",
newName: "Destination");
migrationBuilder.AddColumn<long>(
name: "AccountNo",
table: "Persons",
type: "INTEGER",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<int>(
name: "ClearingNo",
table: "Persons",
type: "INTEGER",
nullable: false,
defaultValue: 0);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AccountNo",
table: "Persons");
migrationBuilder.DropColumn(
name: "ClearingNo",
table: "Persons");
migrationBuilder.RenameColumn(
name: "Zipcode",
table: "Addresses",
newName: "PostNr");
migrationBuilder.RenameColumn(
name: "Street2",
table: "Addresses",
newName: "PostOrt");
migrationBuilder.RenameColumn(
name: "Street",
table: "Addresses",
newName: "Gata2");
migrationBuilder.RenameColumn(
name: "Destination",
table: "Addresses",
newName: "Gata");
}
}
}

View File

@ -0,0 +1,174 @@
// <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("20210316200448_backupregister")]
partial class backupregister
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.3");
modelBuilder.Entity("DataDomain.Address", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Destination")
.HasColumnType("TEXT");
b.Property<string>("Nation")
.HasColumnType("TEXT");
b.Property<string>("Street")
.HasColumnType("TEXT");
b.Property<string>("Street2")
.HasColumnType("TEXT");
b.Property<int>("Zipcode")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Addresses");
});
modelBuilder.Entity("DataDomain.BackupRegister", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("BackedUp")
.HasColumnType("TEXT");
b.Property<string>("BackupDbName")
.HasColumnType("TEXT");
b.Property<string>("BackupPath")
.HasColumnType("TEXT");
b.Property<string>("DbName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("BackupRegings");
});
modelBuilder.Entity("DataDomain.Person", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountNo")
.HasColumnType("INTEGER");
b.Property<string>("Born")
.HasColumnType("TEXT");
b.Property<int>("ClearingNo")
.HasColumnType("INTEGER");
b.Property<string>("Comments")
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.HasColumnType("TEXT");
b.Property<int>("HomeAddress")
.HasColumnType("INTEGER");
b.Property<int>("InvoiceAddress")
.HasColumnType("INTEGER");
b.Property<string>("LastName")
.HasColumnType("TEXT");
b.Property<string>("NickName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Persons");
});
modelBuilder.Entity("DataDomain.PersonStock", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Comment")
.HasColumnType("TEXT");
b.Property<int>("PersonId")
.HasColumnType("INTEGER");
b.Property<int>("StockId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("PersonStocks");
});
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
}
}
}

View File

@ -0,0 +1,33 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace DatamodelLibrary.Migrations
{
public partial class backupregister : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "BackupRegings",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
BackedUp = table.Column<DateTime>(type: "TEXT", nullable: false),
DbName = table.Column<string>(type: "TEXT", nullable: true),
BackupDbName = table.Column<string>(type: "TEXT", nullable: true),
BackupPath = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_BackupRegings", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BackupRegings");
}
}
}

View File

@ -0,0 +1,172 @@
// <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.Address", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Destination")
.HasColumnType("TEXT");
b.Property<string>("Nation")
.HasColumnType("TEXT");
b.Property<string>("Street")
.HasColumnType("TEXT");
b.Property<string>("Street2")
.HasColumnType("TEXT");
b.Property<int>("Zipcode")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Addresses");
});
modelBuilder.Entity("DataDomain.BackupRegister", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("BackedUp")
.HasColumnType("TEXT");
b.Property<string>("BackupDbName")
.HasColumnType("TEXT");
b.Property<string>("BackupPath")
.HasColumnType("TEXT");
b.Property<string>("DbName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("BackupRegings");
});
modelBuilder.Entity("DataDomain.Person", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<long>("AccountNo")
.HasColumnType("INTEGER");
b.Property<string>("Born")
.HasColumnType("TEXT");
b.Property<int>("ClearingNo")
.HasColumnType("INTEGER");
b.Property<string>("Comments")
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.HasColumnType("TEXT");
b.Property<int>("HomeAddress")
.HasColumnType("INTEGER");
b.Property<int>("InvoiceAddress")
.HasColumnType("INTEGER");
b.Property<string>("LastName")
.HasColumnType("TEXT");
b.Property<string>("NickName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Persons");
});
modelBuilder.Entity("DataDomain.PersonStock", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Comment")
.HasColumnType("TEXT");
b.Property<int>("PersonId")
.HasColumnType("INTEGER");
b.Property<int>("StockId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("PersonStocks");
});
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
}
}
}

View File

@ -0,0 +1,22 @@
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; }
public DbSet<Address> Addresses { get; set; }
public DbSet<PersonStock> PersonStocks { get; set; }
public DbSet<BackupRegister> BackupRegings { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite("Data Source=Stocks.db");
}
}

32
Helpers/ComboboxItem.cs Normal file
View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Helpers
{
public class ComboboxItem
{
private readonly string _display;
private readonly int _hidden;
public ComboboxItem(string display,int hidden)
{
_display = display;
_hidden = hidden;
}
public int HiddenValue
{
get
{
return _hidden;
}
}
public override string ToString()
{
return _display;
}
}
}

7
Helpers/Helpers.csproj Normal file
View File

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,13 @@
using System;
using System.Globalization;
namespace Helpers
{
public static class StringExtensions
{
public static bool IsNumeric(this string s)
{
return float.TryParse(s, NumberStyles.Float | NumberStyles.Integer, CultureInfo.CurrentUICulture, out _);
}
}
}

View File

@ -0,0 +1,22 @@
using SqliteBackups.Interfaces;
using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqliteBackups
{
public class BackupRoutines : IBackupRoutines
{
public void BackupSqliteDb(string fromDb, string toDb)
{
using var source = new SQLiteConnection($"Data Source={fromDb}; Version=3;");
using var destination = new SQLiteConnection($"Data Source={toDb}; Version=3;");
source.Open();
destination.Open();
source.BackupDatabase(destination, "main", "main", -1, null, 0);
}
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqliteBackups.Interfaces
{
public interface IBackupRoutines
{
void BackupSqliteDb(string fromDb, string toDb);
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Data.SQLite" Version="1.0.113.7" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using DataDomain;
namespace StockBL.Interface
{
public interface IPersonStockFacade
{
IEnumerable<StockMember> GetAllSharesConnectedTo(int personId);
System.Collections.Generic.IEnumerable<StockMember> GetUnconnectedShares();
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DataDomain\DataDomain.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,47 @@
using DataDomain;
using StockBL.Interface;
using StockDAL.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
namespace StockBL
{
public class PersonStockFacade : IPersonStockFacade
{
private readonly IStockPersonConnect _stockPersonConnect;
private readonly IStockRepository _stockRepository;
public PersonStockFacade(IStockPersonConnect stockPersonConnect, IStockRepository stockRepository)
{
_stockPersonConnect = stockPersonConnect;
_stockRepository = stockRepository;
}
public IEnumerable<StockMember> GetUnconnectedShares()
{
var stockList = _stockRepository.GetAllStocks();
var connectList = _stockPersonConnect.GetAllConnectedStocks();
var stcList = (from st in stockList
where connectList.Any(co => st.Id == co.StockId)
select st).ToList();
var sList = stockList.Except(stcList).ToList();
return sList;
}
public IEnumerable<StockMember> GetAllSharesConnectedTo(int personId)
{
var personConnections = _stockPersonConnect.GetAllConnectionsByPersId(personId);
var stockList = _stockRepository.GetAllStocks();
var stcList = (from st in stockList
where personConnections.Any(pc => st.Id == pc.StockId)
select st).ToList();
return stcList;
}
}
}

14
StockBL/StockBL.csproj Normal file
View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DataDomain\DataDomain.csproj" />
<ProjectReference Include="..\DatamodelLibrary\DatamodelLibrary.csproj" />
<ProjectReference Include="..\StockBL.Interface\StockBL.Interface.csproj" />
<ProjectReference Include="..\StockDal.Interface\StockDAL.Interface.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,55 @@
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 AddressRepository : IAddressRepository
{
public Address GetAddressById(int AddressId)
{
using var context = new StockContext();
var entity = (from adr in context.Addresses
where adr.Id == AddressId
select adr).FirstOrDefault();
return entity;
}
public Address SaveAddress(Address address)
{
using var context = new StockContext();
var entity = (from adr in context.Addresses
where adr.Id == address.Id
select adr).FirstOrDefault();
if (entity == null)
{
entity = new Address
{
Street = address.Street,
Street2 = address.Street2,
Zipcode = address.Zipcode,
Destination = address.Destination,
Nation = address.Nation
};
context.Addresses.Add(entity);
}
else
{
entity.Street = address.Street;
entity.Street2 = address.Street2;
entity.Zipcode = address.Zipcode;
entity.Destination = address.Destination;
entity.Nation = address.Nation;
}
context.SaveChanges();
return entity;
}
}
}

View File

@ -0,0 +1,61 @@
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 BackupRepository : IBackupRepository
{
public BackupRegister SaveBackupReging(BackupRegister backupRegister)
{
using var context = new StockContext();
var entity = (from brr in context.BackupRegings
where brr.Id == backupRegister.Id
select brr).FirstOrDefault();
if (entity == null)
{
entity = new BackupRegister
{
BackedUp = DateTime.Now,
DbName = "Stocks.db",
BackupDbName = backupRegister.BackupDbName,
BackupPath = backupRegister.BackupPath
};
context.BackupRegings.Add(entity);
}
else
{
entity.BackedUp = backupRegister.BackedUp;
entity.DbName = backupRegister.DbName;
entity.BackupDbName = backupRegister.BackupDbName;
entity.BackupPath = backupRegister.BackupPath;
}
context.SaveChanges();
return entity;
}
public BackupRegister GetBackupRegisterById(int brId)
{
using var context = new StockContext();
var entity = (from br in context.BackupRegings
where br.Id == brId
select br).FirstOrDefault();
return entity;
}
public IEnumerable<BackupRegister> GetAllBackupRegisters()
{
using var context = new StockContext();
var entities = context.BackupRegings;
return entities.ToList();
}
}
}

View File

@ -0,0 +1,75 @@
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 PersonRepository : IPersonRepository
{
public Person GetPersonById(int personId)
{
using var context = new StockContext();
var entity = (from prs in context.Persons
where prs.Id == personId
select prs).FirstOrDefault();
return entity;
}
public IEnumerable<Person> GetAllOwners()
{
using var context = new StockContext();
var output = context.Persons;
return output.ToList();
}
public Person SavePerson(Person person)
{
using var context = new StockContext();
var entity = (from prs in context.Persons
where prs.Id == person.Id
select prs).FirstOrDefault();
if (entity == null)
{
entity = new Person
{
AccountNo = person.AccountNo,
Born = person.Born,
ClearingNo = person.ClearingNo,
Comments = person.Comments,
FirstName = person.FirstName,
HomeAddress = person.HomeAddress,
InvoiceAddress = person.InvoiceAddress,
LastName = person.LastName,
NickName = person.NickName
};
context.Persons.Add(entity);
}
else
{
entity.AccountNo = person.AccountNo;
entity.Born = person.Born;
entity.ClearingNo = person.ClearingNo;
entity.Comments = person.Comments;
entity.FirstName = person.FirstName;
entity.HomeAddress = person.HomeAddress;
entity.InvoiceAddress = person.InvoiceAddress;
entity.LastName = person.LastName;
entity.NickName = person.NickName;
}
context.SaveChanges();
return entity;
}
}
}

20
StockDAL/StockDAL.csproj Normal file
View File

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.33" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="90.0.4430.2400" />
<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>

View File

@ -0,0 +1,239 @@
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;
using System.Reflection;
using System.Diagnostics;
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);
Assembly assem = typeof(StockMarketRepository).Assembly;
var programPath = assem.Location.Substring(0, assem.Location.LastIndexOf("\\"));
var logPath = new DirectoryInfo(programPath + "\\Loggings");
if (!logPath.Exists)
{
logPath.Create();
}
File.WriteAllText($"{programPath}\\Loggings\\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 )
{
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();
}
}
}

View File

@ -0,0 +1,72 @@
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 StockPersonConnect : IStockPersonConnect
{
public IEnumerable<PersonStock> GetAllConnectionsByPersId(int personId)
{
using var context = new StockContext();
var connections = (from spc in context.PersonStocks
where spc.PersonId == personId
select spc).ToList();
return connections;
}
public IEnumerable<PersonStock> GetAllConnectedStocks()
{
using var context = new StockContext();
var entities = (from spc in context.PersonStocks
where spc.PersonId != 0
select spc).ToList();
return entities;
}
public PersonStock SavePersonStockConnection(PersonStock personStock)
{
using var context = new StockContext();
var entity = (from ps in context.PersonStocks
where ps.Id == personStock.Id
select ps).FirstOrDefault();
if (entity == null)
{
entity = new PersonStock
{
PersonId = personStock.PersonId,
StockId = personStock.StockId,
Comment = personStock.Comment
};
context.PersonStocks.Add(entity);
}
else
{
entity.PersonId = personStock.PersonId;
entity.StockId = personStock.StockId;
entity.Comment = personStock.Comment;
}
context.SaveChanges();
return entity;
}
public void RemoveConnectedShare(PersonStock personStock)
{
using var context = new StockContext();
var entity = (from ps in context.PersonStocks
where ps.StockId == personStock.StockId
select ps).FirstOrDefault();
if (entity != null)
{
context.PersonStocks.Remove(entity);
context.SaveChanges();
}
}
}
}

115
StockDAL/StockRepository.cs Normal file
View File

@ -0,0 +1,115 @@
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 void UpdateActualForSell(int id, int sellAmount, decimal sellPrice, DateTime sellDate)
{
using var context = new StockContext();
var entity = (from stk in context.Stocks
where stk.Id == id
select stk).FirstOrDefault();
var rest = entity.ActAmount - sellAmount;
entity.ActAmount = rest < 0 ? 0 : rest;
entity.SoldDate = DateTime.Today;
entity.SoldValue = sellAmount * sellPrice;
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 || stk.ActAmount > 0
select stk).ToList();
return output;
}
public void RemoveAllStocks()
{
using var context = new StockContext();
context.Stocks.RemoveRange(GetAllStocks());
context.SaveChanges();
}
public void InsertMany(List<StockMember> stockMembers)
{
using var context = new StockContext();
context.Stocks.AddRange(stockMembers);
context.SaveChanges();
}
public void RestoreStockMembers(List<StockMember> stockMembers)
{
using var context = new StockContext();
using var transaction = context.Database.BeginTransaction();
try
{
var stocksToRemove = context.Stocks;
context.Stocks.RemoveRange(stocksToRemove);
var insertStocks = stockMembers.Select(o => new StockMember
{
Id = 0,
StockId = o.StockId,
StockExtId = o.StockExtId,
BuyDate = o.BuyDate,
BuyValue = o.BuyValue,
ActAmount = o.ActAmount,
ActValue = o.ActValue,
ActDate = o.ActDate,
SoldValue = o.SoldValue,
SoldDate = o.SoldDate,
Comment = o.Comment,
PostAmount = o.PostAmount
}).ToList();
context.Stocks.AddRange(insertStocks);
context.SaveChanges();
transaction.Commit();
}
catch (Exception ex)
{
throw new InvalidOperationException(ex.Message);
}
}
}
}

View File

@ -0,0 +1,15 @@
using DataDomain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StockDAL.Interface
{
public interface IAddressRepository
{
Address GetAddressById(int AddressId);
Address SaveAddress(Address address);
}
}

View File

@ -0,0 +1,16 @@
using DataDomain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StockDAL.Interface
{
public interface IBackupRepository
{
IEnumerable<BackupRegister> GetAllBackupRegisters();
BackupRegister GetBackupRegisterById(int brId);
BackupRegister SaveBackupReging(BackupRegister backupRegister);
}
}

View File

@ -0,0 +1,16 @@
using DataDomain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StockDAL.Interface
{
public interface IPersonRepository
{
IEnumerable<Person> GetAllOwners();
Person GetPersonById(int personId);
Person SavePerson(Person person);
}
}

View 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();
}
}

View File

@ -0,0 +1,17 @@
using DataDomain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StockDAL.Interface
{
public interface IStockPersonConnect
{
IEnumerable<PersonStock> GetAllConnectedStocks();
IEnumerable<PersonStock> GetAllConnectionsByPersId(int personId);
void RemoveConnectedShare(PersonStock personStock);
PersonStock SavePersonStockConnection(PersonStock personStock);
}
}

View File

@ -0,0 +1,21 @@
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 RemoveAllStocks();
void RestoreStockMembers(List<StockMember> stockMembers);
void SaveStockMember(StockMember stockMember);
void UpdateActualForSell(int id, int sellAmount, decimal sellPrice, DateTime sellDate);
void UpdateActualPrice(int id, decimal price);
}
}

View File

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.33" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="90.0.4430.2400" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DataDomain\DataDomain.csproj" />
</ItemGroup>
</Project>

49
StockInfoCore/Program.cs Normal file
View File

@ -0,0 +1,49 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StockInfoCore
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
var builder = new HostBuilder()
.ConfigureServices((_, services) =>
{
services.AddDIInfo();
});
var host = builder.Build();
using var scope = host.Services.CreateScope();
try
{
var services = scope.ServiceProvider;
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var frm = services.GetRequiredService<frmInitial>();
Application.Run(frm);
}
catch (Exception ex)
{
Console.WriteLine($"An error has occured: { ex.Message}");
}
}
}
}

View File

@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DataDomain\DataDomain.csproj" />
<ProjectReference Include="..\DatamodelLibrary\DatamodelLibrary.csproj" />
<ProjectReference Include="..\Helpers\Helpers.csproj" />
<ProjectReference Include="..\SqliteBackups\SqliteBackups.csproj" />
<ProjectReference Include="..\StockBL.Interface\StockBL.Interface.csproj" />
<ProjectReference Include="..\StockBL\StockBL.csproj" />
<ProjectReference Include="..\StockDal.Interface\StockDAL.Interface.csproj" />
<ProjectReference Include="..\StockDAL\StockDAL.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Stocks.db">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<!--<ItemGroup>
--><!--<ProjectReference Include="..\DIDemoLib\DIDemoLib.csproj" />--><!--
</ItemGroup>-->
</Project>

View File

@ -0,0 +1,43 @@
using Microsoft.Extensions.DependencyInjection;
using SqliteBackups;
using SqliteBackups.Interfaces;
using StockBL;
using StockBL.Interface;
using StockDal;
using StockDal.Interface;
using StockDAL;
using StockDAL.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StockInfoCore
{
public static class StockInfoDISetup
{
public static IServiceCollection AddDIInfo(this IServiceCollection services)
{
services.AddTransient<IBackupRepository, BackupRepository>();
services.AddTransient<IBackupRoutines, BackupRoutines>();
services.AddTransient<IStockRepository, StockRepository>();
services.AddTransient<IStockMarketRepository,StockMarketRepository>();
services.AddTransient<IPersonRepository,PersonRepository>();
services.AddTransient<IAddressRepository,AddressRepository>();
services.AddTransient<IStockPersonConnect,StockPersonConnect>();
services.AddTransient<IPersonStockFacade,PersonStockFacade>();
services.AddTransient<frmBackup>();
services.AddTransient<frmRegisterStock>();
services.AddTransient<frmMyStocks>();
services.AddTransient<frmSelling>();
services.AddTransient<frmPerson>();
services.AddTransient<frmPersonShareConnect>();
services.AddTransient<frmInitial>();
return services;
}
}
}

BIN
StockInfoCore/Stocks.db Normal file

Binary file not shown.

142
StockInfoCore/frmBackup.Designer.cs generated Normal file
View File

@ -0,0 +1,142 @@

namespace StockInfoCore
{
partial class frmBackup
{
/// <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.label1 = new System.Windows.Forms.Label();
this.sfdChoosePlaceAndFile = new System.Windows.Forms.SaveFileDialog();
this.btnChooseBackupDest = new System.Windows.Forms.Button();
this.txtBackupPath = new System.Windows.Forms.TextBox();
this.txtBackupFile = new System.Windows.Forms.TextBox();
this.lstBackups = new System.Windows.Forms.ListBox();
this.btnClose = new System.Windows.Forms.Button();
this.btnRestore = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(13, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(226, 15);
this.label1.TabIndex = 0;
this.label1.Text = "Backup Local database to where you wish";
//
// sfdChoosePlaceAndFile
//
this.sfdChoosePlaceAndFile.Title = "Choose path and filename";
//
// btnChooseBackupDest
//
this.btnChooseBackupDest.Location = new System.Drawing.Point(13, 31);
this.btnChooseBackupDest.Name = "btnChooseBackupDest";
this.btnChooseBackupDest.Size = new System.Drawing.Size(152, 23);
this.btnChooseBackupDest.TabIndex = 1;
this.btnChooseBackupDest.Text = "Choose BU destination";
this.btnChooseBackupDest.UseVisualStyleBackColor = true;
this.btnChooseBackupDest.Click += new System.EventHandler(this.btnChooseBackupDest_Click);
//
// txtBackupPath
//
this.txtBackupPath.Location = new System.Drawing.Point(171, 32);
this.txtBackupPath.Name = "txtBackupPath";
this.txtBackupPath.ReadOnly = true;
this.txtBackupPath.Size = new System.Drawing.Size(148, 23);
this.txtBackupPath.TabIndex = 2;
//
// txtBackupFile
//
this.txtBackupFile.Location = new System.Drawing.Point(325, 31);
this.txtBackupFile.Name = "txtBackupFile";
this.txtBackupFile.ReadOnly = true;
this.txtBackupFile.Size = new System.Drawing.Size(100, 23);
this.txtBackupFile.TabIndex = 3;
//
// lstBackups
//
this.lstBackups.FormattingEnabled = true;
this.lstBackups.ItemHeight = 15;
this.lstBackups.Location = new System.Drawing.Point(13, 70);
this.lstBackups.Name = "lstBackups";
this.lstBackups.Size = new System.Drawing.Size(306, 184);
this.lstBackups.TabIndex = 4;
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(350, 259);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 23);
this.btnClose.TabIndex = 5;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnRestore
//
this.btnRestore.Location = new System.Drawing.Point(350, 70);
this.btnRestore.Name = "btnRestore";
this.btnRestore.Size = new System.Drawing.Size(75, 23);
this.btnRestore.TabIndex = 6;
this.btnRestore.Text = "Restore";
this.btnRestore.UseVisualStyleBackColor = true;
this.btnRestore.Click += new System.EventHandler(this.btnRestore_Click);
//
// frmBackup
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(438, 294);
this.Controls.Add(this.btnRestore);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.lstBackups);
this.Controls.Add(this.txtBackupFile);
this.Controls.Add(this.txtBackupPath);
this.Controls.Add(this.btnChooseBackupDest);
this.Controls.Add(this.label1);
this.Name = "frmBackup";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "frmBackup";
this.Shown += new System.EventHandler(this.frmBackup_Shown);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.SaveFileDialog sfdChoosePlaceAndFile;
private System.Windows.Forms.Button btnChooseBackupDest;
private System.Windows.Forms.TextBox txtBackupPath;
private System.Windows.Forms.TextBox txtBackupFile;
private System.Windows.Forms.ListBox lstBackups;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnRestore;
}
}

106
StockInfoCore/frmBackup.cs Normal file
View File

@ -0,0 +1,106 @@
using DataDomain;
using Helpers;
using SqliteBackups.Interfaces;
using StockDAL.Interface;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StockInfoCore
{
public partial class frmBackup : Form
{
private readonly IBackupRepository _backupRepository;
private readonly IBackupRoutines _backupRoutines;
public List<BackupRegister> CurrentBackups { get; set; } = new List<BackupRegister>();
public frmBackup(IBackupRepository backupRepository,IBackupRoutines backupRoutines)
{
InitializeComponent();
_backupRepository = backupRepository;
_backupRoutines = backupRoutines;
}
private void btnChooseBackupDest_Click(object sender, EventArgs e)
{
sfdChoosePlaceAndFile.Filter = "Database files (*.db)|*.db|All files (*.*)|*.*";
if (sfdChoosePlaceAndFile.ShowDialog() == DialogResult.OK)
{
var wholeFile = sfdChoosePlaceAndFile.FileName;
var lastBackslash = wholeFile.LastIndexOf('\\') + 1;
var dir = wholeFile.Substring(0, lastBackslash);
var file = wholeFile.Substring(lastBackslash, wholeFile.Length - lastBackslash);
//Debug.WriteLine($"Chosen file:{wholeFile}");
//Debug.WriteLine($"Path: {dir} , File {file}");
BackupRegister reg = new();
reg.BackupDbName = file;
reg.BackupPath = dir;
reg = _backupRepository.SaveBackupReging(reg);
txtBackupPath.Text = dir;
txtBackupFile.Text = file;
_backupRoutines.BackupSqliteDb(reg.DbName, Path.Combine(dir, file));
var cmbItem = new ComboboxItem($"{reg.BackedUp.ToLocalTime()} {wholeFile}", reg.Id);
lstBackups.Items.Add(cmbItem);
CurrentBackups = _backupRepository.GetAllBackupRegisters().ToList();
};
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void frmBackup_Shown(object sender, EventArgs e)
{
CurrentBackups =_backupRepository.GetAllBackupRegisters().ToList();
lstBackups.Items.Clear();
foreach(var bckrg in CurrentBackups)
{
var cmbItem = new ComboboxItem($"{bckrg.BackedUp.ToLocalTime()} {Path.Combine(bckrg.BackupPath, bckrg.BackupDbName)}", bckrg.Id);
lstBackups.Items.Add(cmbItem);
}
}
private void btnRestore_Click(object sender, EventArgs e)
{
if (lstBackups.SelectedIndex != -1)
{
BackupRegister br = new();
br.Id = ((ComboboxItem)lstBackups.SelectedItem).HiddenValue;
var backupReg = _backupRepository.GetBackupRegisterById(br.Id);
if (File.Exists(backupReg.DbName))
{
File.Move(backupReg.DbName, "tempFile.bak",true);
}
_backupRoutines.BackupSqliteDb(Path.Combine(backupReg.BackupPath, backupReg.BackupDbName), backupReg.DbName);
UpdateBackupRegs(CurrentBackups);
MessageBox.Show($"Backup {Path.Combine(backupReg.BackupPath, backupReg.BackupDbName)} loaded !");
}
}
private void UpdateBackupRegs(List<BackupRegister> currentBackups)
{
var backupRegs = _backupRepository.GetAllBackupRegisters();
var result = currentBackups.Where(cb => backupRegs.All(br => br.BackupDbName != cb.BackupDbName || br.BackupPath != cb.BackupPath));
foreach(var br in result)
{
_backupRepository.SaveBackupReging(new BackupRegister
{
BackedUp = br.BackedUp,
BackupDbName = br.BackupDbName,
BackupPath = br.BackupPath,
DbName = br.DbName,
Id = 0
});
}
}
}
}

View 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>

342
StockInfoCore/frmInitial.Designer.cs generated Normal file
View File

@ -0,0 +1,342 @@

namespace StockInfoCore
{
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.btnBackupAll = new System.Windows.Forms.Button();
this.chkEnableBackRes = new System.Windows.Forms.CheckBox();
this.btnRestoreShares = new System.Windows.Forms.Button();
this.btnBackupShares = new System.Windows.Forms.Button();
this.btnReload = new System.Windows.Forms.Button();
this.btnTestScrapFunction = new System.Windows.Forms.Button();
this.btnReloadShares = new System.Windows.Forms.Button();
this.chbShowBrowser = new System.Windows.Forms.CheckBox();
this.gbStockMgmnt = new System.Windows.Forms.GroupBox();
this.btnStockSale = new System.Windows.Forms.Button();
this.btnValueView = new System.Windows.Forms.Button();
this.btnStockReg = new System.Windows.Forms.Button();
this.sfdSaver = new System.Windows.Forms.SaveFileDialog();
this.ofdOpener = new System.Windows.Forms.OpenFileDialog();
this.lblStockRows = new System.Windows.Forms.Label();
this.gpOwners = new System.Windows.Forms.GroupBox();
this.btnConnShares = new System.Windows.Forms.Button();
this.btnEditPerson = new System.Windows.Forms.Button();
this.cmbOwners = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.gB1.SuspendLayout();
this.gbStockMgmnt.SuspendLayout();
this.gpOwners.SuspendLayout();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.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.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(871, 360);
this.dataGridView.TabIndex = 0;
//
// lblTotalRecords
//
this.lblTotalRecords.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblTotalRecords.AutoSize = true;
this.lblTotalRecords.Location = new System.Drawing.Point(12, 385);
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.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.gB1.Controls.Add(this.btnBackupAll);
this.gB1.Controls.Add(this.chkEnableBackRes);
this.gB1.Controls.Add(this.btnRestoreShares);
this.gB1.Controls.Add(this.btnBackupShares);
this.gB1.Controls.Add(this.btnReload);
this.gB1.Location = new System.Drawing.Point(157, 385);
this.gB1.Name = "gB1";
this.gB1.Size = new System.Drawing.Size(245, 144);
this.gB1.TabIndex = 3;
this.gB1.TabStop = false;
this.gB1.Text = "Sharelist";
//
// btnBackupAll
//
this.btnBackupAll.Location = new System.Drawing.Point(130, 82);
this.btnBackupAll.Name = "btnBackupAll";
this.btnBackupAll.Size = new System.Drawing.Size(105, 23);
this.btnBackupAll.TabIndex = 6;
this.btnBackupAll.Text = "Backup / Restore";
this.btnBackupAll.UseVisualStyleBackColor = true;
this.btnBackupAll.Click += new System.EventHandler(this.btnBackupAll_Click);
//
// chkEnableBackRes
//
this.chkEnableBackRes.AutoSize = true;
this.chkEnableBackRes.Location = new System.Drawing.Point(6, 61);
this.chkEnableBackRes.Name = "chkEnableBackRes";
this.chkEnableBackRes.Size = new System.Drawing.Size(144, 19);
this.chkEnableBackRes.TabIndex = 5;
this.chkEnableBackRes.Text = "Enable backup/restore";
this.chkEnableBackRes.UseVisualStyleBackColor = true;
this.chkEnableBackRes.CheckedChanged += new System.EventHandler(this.chkEnableBackRes_CheckedChanged);
//
// btnRestoreShares
//
this.btnRestoreShares.Location = new System.Drawing.Point(6, 111);
this.btnRestoreShares.Name = "btnRestoreShares";
this.btnRestoreShares.Size = new System.Drawing.Size(118, 23);
this.btnRestoreShares.TabIndex = 4;
this.btnRestoreShares.Text = "Restore Share data";
this.btnRestoreShares.UseVisualStyleBackColor = true;
this.btnRestoreShares.Click += new System.EventHandler(this.btnRestoreShares_Click);
//
// btnBackupShares
//
this.btnBackupShares.Location = new System.Drawing.Point(6, 82);
this.btnBackupShares.Name = "btnBackupShares";
this.btnBackupShares.Size = new System.Drawing.Size(118, 23);
this.btnBackupShares.TabIndex = 3;
this.btnBackupShares.Text = "Backup Share data";
this.btnBackupShares.UseVisualStyleBackColor = true;
this.btnBackupShares.Click += new System.EventHandler(this.btnBackupShares_Click);
//
// btnReload
//
this.btnReload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnReload.Location = new System.Drawing.Point(6, 32);
this.btnReload.Name = "btnReload";
this.btnReload.Size = new System.Drawing.Size(112, 23);
this.btnReload.TabIndex = 2;
this.btnReload.Text = "Reload Share list";
this.btnReload.UseVisualStyleBackColor = true;
this.btnReload.Click += new System.EventHandler(this.btnReload_Click);
//
// btnTestScrapFunction
//
this.btnTestScrapFunction.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnTestScrapFunction.Location = new System.Drawing.Point(12, 467);
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);
//
// btnReloadShares
//
this.btnReloadShares.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnReloadShares.Location = new System.Drawing.Point(12, 417);
this.btnReloadShares.Name = "btnReloadShares";
this.btnReloadShares.Size = new System.Drawing.Size(75, 23);
this.btnReloadShares.TabIndex = 6;
this.btnReloadShares.Text = "ReLoad";
this.btnReloadShares.UseVisualStyleBackColor = true;
this.btnReloadShares.Click += new System.EventHandler(this.btnReloadShares_Click);
//
// chbShowBrowser
//
this.chbShowBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.chbShowBrowser.AutoSize = true;
this.chbShowBrowser.Location = new System.Drawing.Point(12, 497);
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.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.gbStockMgmnt.Controls.Add(this.btnStockSale);
this.gbStockMgmnt.Controls.Add(this.btnValueView);
this.gbStockMgmnt.Controls.Add(this.btnStockReg);
this.gbStockMgmnt.Location = new System.Drawing.Point(408, 385);
this.gbStockMgmnt.Name = "gbStockMgmnt";
this.gbStockMgmnt.Size = new System.Drawing.Size(216, 144);
this.gbStockMgmnt.TabIndex = 8;
this.gbStockMgmnt.TabStop = false;
this.gbStockMgmnt.Text = "Working";
//
// btnStockSale
//
this.btnStockSale.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnStockSale.Location = new System.Drawing.Point(108, 82);
this.btnStockSale.Name = "btnStockSale";
this.btnStockSale.Size = new System.Drawing.Size(96, 23);
this.btnStockSale.TabIndex = 2;
this.btnStockSale.Text = "Stock Sell";
this.btnStockSale.UseVisualStyleBackColor = true;
this.btnStockSale.Click += new System.EventHandler(this.btnStockSale_Click);
//
// btnValueView
//
this.btnValueView.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnValueView.Location = new System.Drawing.Point(6, 32);
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.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnStockReg.Location = new System.Drawing.Point(6, 82);
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);
//
// ofdOpener
//
this.ofdOpener.FileName = "openFileDialog1";
//
// lblStockRows
//
this.lblStockRows.AutoSize = true;
this.lblStockRows.Location = new System.Drawing.Point(13, 446);
this.lblStockRows.Name = "lblStockRows";
this.lblStockRows.Size = new System.Drawing.Size(0, 15);
this.lblStockRows.TabIndex = 9;
//
// gpOwners
//
this.gpOwners.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.gpOwners.Controls.Add(this.btnConnShares);
this.gpOwners.Controls.Add(this.btnEditPerson);
this.gpOwners.Controls.Add(this.cmbOwners);
this.gpOwners.Location = new System.Drawing.Point(630, 385);
this.gpOwners.Name = "gpOwners";
this.gpOwners.Size = new System.Drawing.Size(252, 141);
this.gpOwners.TabIndex = 10;
this.gpOwners.TabStop = false;
this.gpOwners.Text = "ShareOwners";
//
// btnConnShares
//
this.btnConnShares.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnConnShares.Location = new System.Drawing.Point(120, 82);
this.btnConnShares.Name = "btnConnShares";
this.btnConnShares.Size = new System.Drawing.Size(108, 23);
this.btnConnShares.TabIndex = 4;
this.btnConnShares.Text = "Connect Shares";
this.btnConnShares.UseVisualStyleBackColor = true;
this.btnConnShares.Click += new System.EventHandler(this.btnConnShares_Click);
//
// btnEditPerson
//
this.btnEditPerson.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnEditPerson.Location = new System.Drawing.Point(6, 82);
this.btnEditPerson.Name = "btnEditPerson";
this.btnEditPerson.Size = new System.Drawing.Size(108, 23);
this.btnEditPerson.TabIndex = 3;
this.btnEditPerson.Text = "Add/Edit Person";
this.btnEditPerson.UseVisualStyleBackColor = true;
this.btnEditPerson.Click += new System.EventHandler(this.btnEditPerson_Click);
//
// cmbOwners
//
this.cmbOwners.FormattingEnabled = true;
this.cmbOwners.Location = new System.Drawing.Point(6, 33);
this.cmbOwners.Name = "cmbOwners";
this.cmbOwners.Size = new System.Drawing.Size(152, 23);
this.cmbOwners.TabIndex = 0;
this.cmbOwners.SelectedIndexChanged += new System.EventHandler(this.cmbOwners_SelectedIndexChanged);
//
// frmInitial
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(895, 538);
this.Controls.Add(this.gpOwners);
this.Controls.Add(this.lblStockRows);
this.Controls.Add(this.gbStockMgmnt);
this.Controls.Add(this.chbShowBrowser);
this.Controls.Add(this.btnReloadShares);
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 = "Stock Overview";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmInitial_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
this.Shown += new System.EventHandler(this.frmInitial_Shown);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.gB1.ResumeLayout(false);
this.gB1.PerformLayout();
this.gbStockMgmnt.ResumeLayout(false);
this.gpOwners.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.Button btnReloadShares;
private System.Windows.Forms.CheckBox chbShowBrowser;
private System.Windows.Forms.GroupBox gbStockMgmnt;
private System.Windows.Forms.Button btnStockReg;
private System.Windows.Forms.Button btnValueView;
private System.Windows.Forms.Button btnStockSale;
private System.Windows.Forms.CheckBox chkEnableBackRes;
private System.Windows.Forms.Button btnRestoreShares;
private System.Windows.Forms.Button btnBackupShares;
private System.Windows.Forms.SaveFileDialog sfdSaver;
private System.Windows.Forms.OpenFileDialog ofdOpener;
private System.Windows.Forms.Label lblStockRows;
private System.Windows.Forms.GroupBox gpOwners;
private System.Windows.Forms.Button btnConnShares;
private System.Windows.Forms.Button btnEditPerson;
private System.Windows.Forms.ComboBox cmbOwners;
private System.Windows.Forms.Button btnBackupAll;
}
}

268
StockInfoCore/frmInitial.cs Normal file
View File

@ -0,0 +1,268 @@
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;
using System.Text.Json;
using System.IO;
using Helpers;
using StockBL.Interface;
using SqliteBackups.Interfaces;
namespace StockInfoCore
{
public partial class frmInitial : Form
{
private readonly IStockRepository _stockRepository;
private readonly IStockMarketRepository _stockMarketRepository;
private readonly IPersonRepository _personRepository;
private readonly IAddressRepository _addressRepository;
private readonly IStockPersonConnect _stockPersonConnect;
private readonly IBackupRepository _backupRepository;
private readonly IBackupRoutines _backupRoutines;
private readonly IPersonStockFacade _personStockFacade;
private readonly frmRegisterStock _regWindow;
private readonly frmMyStocks _stockWindow;
private readonly frmSelling _sellWindow;
private readonly frmPerson _personWindow;
private readonly frmPersonShareConnect _personShareConnect;
private readonly frmBackup _backupWindow;
//private frmRegisterStock regWindow;
//private frmMyStocks stockWindow;
//private frmSelling sellWindow;
//private frmPerson personWindow;
//private frmPersonShareConnect personShareConnect;
//private frmBackup backupWindow;
public int SelectedPersonId { get; set; } = 0;
public frmInitial(
IStockRepository stockMemberRepository,
IStockMarketRepository stockMarketRepository,
IPersonRepository personRepository,
IAddressRepository addressRepository,
IStockPersonConnect stockPersonConnect,
IBackupRepository backupRepository,
IBackupRoutines backupRoutines,
IPersonStockFacade personStockFacade,
frmRegisterStock regWindow,
frmMyStocks stockWindow,
frmSelling sellWindow,
frmPerson personWindow,
frmPersonShareConnect personShareConnect,
frmBackup backupWindow
)
{
InitializeComponent();
_stockRepository = stockMemberRepository;
_stockMarketRepository = stockMarketRepository;
_personRepository = personRepository;
_addressRepository = addressRepository;
_stockPersonConnect = stockPersonConnect;
_backupRepository = backupRepository;
_backupRoutines = backupRoutines;
_personStockFacade = personStockFacade;
_regWindow = regWindow;
_stockWindow = stockWindow;
_sellWindow = sellWindow;
_personWindow = personWindow;
_personShareConnect = personShareConnect;
_backupWindow = backupWindow;
}
private void Form1_Load(object sender, EventArgs e)
{
ReloadData();
btnRestoreShares.Enabled = false;
btnBackupShares.Enabled = false;
btnReloadShares.Enabled = false;
btnBackupAll.Enabled = false;
}
private void ReloadData()
{
var allStocks = _stockRepository.GetAllStocks();
dataGridView.DataSource = allStocks;
// SaveStocks(allStocks);
lblTotalRecords.Text = $"Total records: {dataGridView.RowCount}";
}
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();
btnReloadShares.Enabled = true;
}
private void frmInitial_FormClosing(object sender, FormClosingEventArgs e)
{
_stockMarketRepository.Clean();
}
private void Button1reload()
{
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.Stocks = _stockMarketRepository.StockMarketList;
Cursor.Current = DefaultCursor;
_regWindow.ShowDialog();
_stockRepository.InsertMany(_regWindow.RegisteredStocks);
ReloadData();
}
private void btnValueView_Click(object sender, EventArgs e)
{
if (SelectedPersonId == 0)
{
MessageBox.Show($"Ingen person vald ({SelectedPersonId})");
}
else
{
var person = _personRepository.GetPersonById(SelectedPersonId);
Cursor.Current = Cursors.WaitCursor;
_stockMarketRepository.LoadStockMarketList();
_stockWindow.ConnectedPerson = person;
_stockWindow.Stocks = _stockMarketRepository.StockMarketList;
Cursor.Current = DefaultCursor;
_stockWindow.ShowDialog();
}
}
private void chkEnableBackRes_CheckedChanged(object sender, EventArgs e)
{
if (chkEnableBackRes.Checked)
{
btnRestoreShares.Enabled = true;
btnBackupShares.Enabled = true;
btnBackupAll.Enabled = true;
}
else
{
btnRestoreShares.Enabled = false;
btnBackupShares.Enabled = false;
btnBackupAll.Enabled = false;
}
}
private void btnBackupShares_Click(object sender, EventArgs e)
{
var stockList = _stockRepository.GetAllStocks();
var jsonStr = JsonSerializer.Serialize(stockList);
sfdSaver.Title = "Backup your sharedata";
sfdSaver.Filter = "Backup file (.json)|*.json";
sfdSaver.FileName = $"StockBackup{DateTime.Now.ToFileTime()}";
if (sfdSaver.ShowDialog() == DialogResult.OK)
{
File.WriteAllText(sfdSaver.FileName, jsonStr);
}
}
private void btnRestoreShares_Click(object sender, EventArgs e)
{
ofdOpener.Title = "Restore your share data";
ofdOpener.Filter = "Restore file (.json)|*.json";
ofdOpener.CheckFileExists = true;
if (ofdOpener.ShowDialog() == DialogResult.OK)
{
var jsonStr = File.ReadAllText(ofdOpener.FileName);
var stockList = JsonSerializer.Deserialize<List<StockMember>>(jsonStr);
_stockRepository.RestoreStockMembers(stockList);
};
}
private void btnReloadShares_Click(object sender, EventArgs e)
{
Button1reload();
}
private void btnStockSale_Click(object sender, EventArgs e)
{
_sellWindow.ShowDialog();
ReloadData();
}
private void btnEditPerson_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
_personWindow.PersonId = SelectedPersonId;
Cursor.Current = DefaultCursor;
_personWindow.ShowDialog();
LoadCmbOwners();
}
private void btnConnShares_Click(object sender, EventArgs e)
{
if (SelectedPersonId == 0)
{
MessageBox.Show($"Ingen person vald ({SelectedPersonId})");
}
else
{
var person = _personRepository.GetPersonById(SelectedPersonId);
Cursor.Current = Cursors.WaitCursor;
_personShareConnect.ConnectPerson = person;
Cursor.Current = DefaultCursor;
_personShareConnect.ShowDialog();
}
}
private void frmInitial_Shown(object sender, EventArgs e)
{
LoadCmbOwners();
}
private void LoadCmbOwners()
{
cmbOwners.Items.Clear();
var owners = _personRepository.GetAllOwners();
if (owners.Count() > 0)
{
foreach (var person in owners)
{
var itemIndex = cmbOwners.Items.Add(new ComboboxItem($"{person.FirstName} {person.LastName} ({person.NickName})", person.Id));
}
}
cmbOwners.Items.Add(new ComboboxItem($"< ny person> ", 0));
}
private void cmbOwners_SelectedIndexChanged(object sender, EventArgs e)
{
SelectedPersonId = ((ComboboxItem)cmbOwners.SelectedItem).HiddenValue;
}
private void btnBackupAll_Click(object sender, EventArgs e)
{
// backupWindow = new frmBackup(_backupRepository, _backupRoutines);
_backupWindow.ShowDialog();
}
}
}

View File

@ -0,0 +1,63 @@
<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>
<metadata name="$this.TrayHeight" type="System.Int32, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">
<value>27</value>
</metadata>
</root>

389
StockInfoCore/frmMyStocks.Designer.cs generated Normal file
View File

@ -0,0 +1,389 @@

namespace StockInfoCore
{
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(439, 422);
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(208, 457);
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(312, 455);
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(478, 459);
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(573, 455);
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;
}
}

View File

@ -0,0 +1,178 @@
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 StockInfoCore
{
public partial class frmMyStocks : Form
{
Color hdrColor;
private readonly IStockRepository _stockRepository;
private readonly IStockMarketRepository _stockMarketRepository;
private readonly IStockPersonConnect _stockPersonConnect;
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 Person ConnectedPerson { get; set; }
public frmMyStocks(IStockRepository stockRepository,
IStockMarketRepository stockMarketRepository,
IStockPersonConnect stockPersonConnect)
{
hdrColor = Color.CadetBlue;
InitializeComponent();
_stockRepository = stockRepository;
_stockMarketRepository = stockMarketRepository;
_stockPersonConnect = stockPersonConnect;
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>();
var personStocks = new List<StockMember>();
//Update all handled shares
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);
}
//Use only Stocks belonging to person
var connects =_stockPersonConnect.GetAllConnectionsByPersId(ConnectedPerson.Id);
personStocks.AddRange(tmpStocks.Where(ts => connects.Any(c => c.StockId == ts.Id)).ToList());
foreach(var stk in personStocks.OrderByDescending(s => s.ActAmount * (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.ActAmount.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)
{
this.Text = $"{ConnectedPerson.Id} - {ConnectedPerson.FirstName} {ConnectedPerson.LastName}'s Shares";
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);
}
}
}

View 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>

362
StockInfoCore/frmPerson.Designer.cs generated Normal file
View File

@ -0,0 +1,362 @@

namespace StockInfoCore
{
partial class frmPerson
{
/// <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.label1 = new System.Windows.Forms.Label();
this.txtFirstName = new System.Windows.Forms.TextBox();
this.txtComment = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.txtPersonNr = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.txtNickName = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.txtLastName = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.gbAddress = new System.Windows.Forms.GroupBox();
this.txtDestination = new System.Windows.Forms.TextBox();
this.txtNation = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.txtZipCode = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.txtStreet2 = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.txtStreet = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.rdbInvoiceAddr = new System.Windows.Forms.RadioButton();
this.rdbHome = new System.Windows.Forms.RadioButton();
this.txtClearingNo = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.txtAccountNr = new System.Windows.Forms.TextBox();
this.btnAddSave = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.gbAddress.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(13, 49);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(64, 15);
this.label1.TabIndex = 0;
this.label1.Text = "First Name";
//
// txtFirstName
//
this.txtFirstName.Location = new System.Drawing.Point(113, 46);
this.txtFirstName.Name = "txtFirstName";
this.txtFirstName.Size = new System.Drawing.Size(188, 23);
this.txtFirstName.TabIndex = 1;
//
// txtComment
//
this.txtComment.Location = new System.Drawing.Point(113, 162);
this.txtComment.Name = "txtComment";
this.txtComment.Size = new System.Drawing.Size(188, 23);
this.txtComment.TabIndex = 5;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(13, 165);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(61, 15);
this.label2.TabIndex = 2;
this.label2.Text = "Comment";
//
// txtPersonNr
//
this.txtPersonNr.Location = new System.Drawing.Point(113, 133);
this.txtPersonNr.Name = "txtPersonNr";
this.txtPersonNr.Size = new System.Drawing.Size(188, 23);
this.txtPersonNr.TabIndex = 4;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(13, 136);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 15);
this.label3.TabIndex = 4;
this.label3.Text = "PersonNr";
//
// txtNickName
//
this.txtNickName.Location = new System.Drawing.Point(113, 104);
this.txtNickName.Name = "txtNickName";
this.txtNickName.Size = new System.Drawing.Size(188, 23);
this.txtNickName.TabIndex = 3;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(13, 104);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(63, 15);
this.label4.TabIndex = 6;
this.label4.Text = "NickName";
//
// txtLastName
//
this.txtLastName.Location = new System.Drawing.Point(113, 75);
this.txtLastName.Name = "txtLastName";
this.txtLastName.Size = new System.Drawing.Size(188, 23);
this.txtLastName.TabIndex = 2;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(13, 78);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(63, 15);
this.label5.TabIndex = 8;
this.label5.Text = "Last Name";
//
// gbAddress
//
this.gbAddress.Controls.Add(this.txtDestination);
this.gbAddress.Controls.Add(this.txtNation);
this.gbAddress.Controls.Add(this.label10);
this.gbAddress.Controls.Add(this.txtZipCode);
this.gbAddress.Controls.Add(this.label9);
this.gbAddress.Controls.Add(this.txtStreet2);
this.gbAddress.Controls.Add(this.label8);
this.gbAddress.Controls.Add(this.txtStreet);
this.gbAddress.Controls.Add(this.label7);
this.gbAddress.Controls.Add(this.rdbInvoiceAddr);
this.gbAddress.Controls.Add(this.rdbHome);
this.gbAddress.Location = new System.Drawing.Point(13, 221);
this.gbAddress.Name = "gbAddress";
this.gbAddress.Size = new System.Drawing.Size(300, 177);
this.gbAddress.TabIndex = 10;
this.gbAddress.TabStop = false;
this.gbAddress.Text = "Addresses";
//
// txtDestination
//
this.txtDestination.Location = new System.Drawing.Point(148, 106);
this.txtDestination.Name = "txtDestination";
this.txtDestination.Size = new System.Drawing.Size(146, 23);
this.txtDestination.TabIndex = 12;
//
// txtNation
//
this.txtNation.Location = new System.Drawing.Point(84, 135);
this.txtNation.Name = "txtNation";
this.txtNation.Size = new System.Drawing.Size(210, 23);
this.txtNation.TabIndex = 13;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(6, 138);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(43, 15);
this.label10.TabIndex = 8;
this.label10.Text = "Nation";
//
// txtZipCode
//
this.txtZipCode.Location = new System.Drawing.Point(84, 106);
this.txtZipCode.Name = "txtZipCode";
this.txtZipCode.Size = new System.Drawing.Size(58, 23);
this.txtZipCode.TabIndex = 11;
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(6, 109);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(58, 15);
this.label9.TabIndex = 6;
this.label9.Text = "Zip / Dest";
//
// txtStreet2
//
this.txtStreet2.Location = new System.Drawing.Point(84, 77);
this.txtStreet2.Name = "txtStreet2";
this.txtStreet2.Size = new System.Drawing.Size(210, 23);
this.txtStreet2.TabIndex = 10;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(6, 80);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(46, 15);
this.label8.TabIndex = 4;
this.label8.Text = "Street 2";
//
// txtStreet
//
this.txtStreet.Location = new System.Drawing.Point(84, 48);
this.txtStreet.Name = "txtStreet";
this.txtStreet.Size = new System.Drawing.Size(210, 23);
this.txtStreet.TabIndex = 9;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(6, 51);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(37, 15);
this.label7.TabIndex = 2;
this.label7.Text = "Street";
//
// rdbInvoiceAddr
//
this.rdbInvoiceAddr.AutoSize = true;
this.rdbInvoiceAddr.Location = new System.Drawing.Point(116, 23);
this.rdbInvoiceAddr.Name = "rdbInvoiceAddr";
this.rdbInvoiceAddr.Size = new System.Drawing.Size(108, 19);
this.rdbInvoiceAddr.TabIndex = 1;
this.rdbInvoiceAddr.Text = "Invoice Address";
this.rdbInvoiceAddr.UseVisualStyleBackColor = true;
this.rdbInvoiceAddr.CheckedChanged += new System.EventHandler(this.rdbInvoiceAddr_CheckedChanged);
//
// rdbHome
//
this.rdbHome.AutoSize = true;
this.rdbHome.Checked = true;
this.rdbHome.Location = new System.Drawing.Point(7, 23);
this.rdbHome.Name = "rdbHome";
this.rdbHome.Size = new System.Drawing.Size(103, 19);
this.rdbHome.TabIndex = 8;
this.rdbHome.TabStop = true;
this.rdbHome.Text = "Home Address";
this.rdbHome.UseVisualStyleBackColor = true;
this.rdbHome.CheckedChanged += new System.EventHandler(this.rdbInvoiceAddr_CheckedChanged);
//
// txtClearingNo
//
this.txtClearingNo.Location = new System.Drawing.Point(113, 191);
this.txtClearingNo.Name = "txtClearingNo";
this.txtClearingNo.Size = new System.Drawing.Size(42, 23);
this.txtClearingNo.TabIndex = 6;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(13, 194);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(52, 15);
this.label6.TabIndex = 11;
this.label6.Text = "Account";
//
// txtAccountNr
//
this.txtAccountNr.Location = new System.Drawing.Point(161, 191);
this.txtAccountNr.Name = "txtAccountNr";
this.txtAccountNr.Size = new System.Drawing.Size(152, 23);
this.txtAccountNr.TabIndex = 7;
//
// btnAddSave
//
this.btnAddSave.Location = new System.Drawing.Point(319, 355);
this.btnAddSave.Name = "btnAddSave";
this.btnAddSave.Size = new System.Drawing.Size(107, 23);
this.btnAddSave.TabIndex = 14;
this.btnAddSave.Text = "Add/Save Owner";
this.btnAddSave.UseVisualStyleBackColor = true;
this.btnAddSave.Click += new System.EventHandler(this.btnAddSave_Click);
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(432, 355);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 23);
this.btnClose.TabIndex = 15;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// frmPerson
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(534, 419);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnAddSave);
this.Controls.Add(this.txtAccountNr);
this.Controls.Add(this.txtClearingNo);
this.Controls.Add(this.label6);
this.Controls.Add(this.gbAddress);
this.Controls.Add(this.txtLastName);
this.Controls.Add(this.label5);
this.Controls.Add(this.txtNickName);
this.Controls.Add(this.label4);
this.Controls.Add(this.txtPersonNr);
this.Controls.Add(this.label3);
this.Controls.Add(this.txtComment);
this.Controls.Add(this.label2);
this.Controls.Add(this.txtFirstName);
this.Controls.Add(this.label1);
this.Name = "frmPerson";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "frmPerson";
this.Load += new System.EventHandler(this.frmPerson_Load);
this.gbAddress.ResumeLayout(false);
this.gbAddress.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtFirstName;
private System.Windows.Forms.TextBox txtComment;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtPersonNr;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtNickName;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txtLastName;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.GroupBox gbAddress;
private System.Windows.Forms.RadioButton rdbInvoiceAddr;
private System.Windows.Forms.RadioButton rdbHome;
private System.Windows.Forms.TextBox txtClearingNo;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txtAccountNr;
private System.Windows.Forms.TextBox txtNation;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox txtZipCode;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txtStreet2;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox txtStreet;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Button btnAddSave;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.TextBox txtDestination;
}
}

214
StockInfoCore/frmPerson.cs Normal file
View File

@ -0,0 +1,214 @@
using DataDomain;
using Helpers;
using StockDAL.Interface;
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 StockInfoCore
{
public partial class frmPerson : Form
{
private readonly IPersonRepository _personRepository;
private readonly IAddressRepository _addressRepository;
private bool radioOk = false;
public frmPerson(IPersonRepository personRepository, IAddressRepository addressRepository)
{
InitializeComponent();
_personRepository = personRepository;
_addressRepository = addressRepository;
}
public int PersonId { get; set; }
public int HomeAddressId { get; set; }
public int CheckHomeAddressId { get; set; }
public int InvoiceAddressId { get; set; }
public int CheckInvoiceAddressId { get; set; }
private void btnAddSave_Click(object sender, EventArgs e)
{
(Person person, bool OK) = validatePerson();
if (OK)
{
person = _personRepository.SavePerson(person);
initializeAllFields();
PersonId = 0;
}
else
{
}
}
private (Person person, bool OK) validatePerson()
{
var person = new Person();
person.Id = PersonId;
person.FirstName = txtFirstName.Text;
person.LastName = txtLastName.Text;
person.NickName = txtNickName.Text;
person.ClearingNo = txtClearingNo.Text.IsNumeric()?int.Parse(txtClearingNo.Text):0;
person.AccountNo = txtAccountNr.Text.IsNumeric() ? int.Parse(txtAccountNr.Text) : 0;
person.Born = txtPersonNr.Text;
person.Comments = txtComment.Text;
if (rdbHome.Checked)
{
HomeAddressId = AddressSave(HomeAddressId);
}
else
{
InvoiceAddressId = AddressSave(InvoiceAddressId);
}
person.HomeAddress = HomeAddressId;
CheckHomeAddressId = HomeAddressId;
person.InvoiceAddress = InvoiceAddressId;
CheckInvoiceAddressId = InvoiceAddressId;
return (person, true);
}
private int AddressSave(int AddressId)
{
var retval = 0;
bool changed = false;
Address address = new Address();
(address.Id, changed) = checkInt(AddressId.ToString());
(address.Street, changed) = checkString(txtStreet.Text);
(address.Street2, changed) = checkString(txtStreet2.Text);
(address.Zipcode, changed) = checkInt(txtZipCode.Text);
(address.Destination, changed) = checkString(txtDestination.Text);
(address.Nation, changed) = checkString(txtNation.Text);
if (changed)
{
retval =_addressRepository.SaveAddress(address).Id;
}
return retval;
}
private (string, bool ) checkString(string text)
{
bool chgd = !string.IsNullOrWhiteSpace(text);
return (text, chgd);
}
private (int, bool) checkInt(string text)
{
bool chgd = false;
if(!string.IsNullOrWhiteSpace(text))
{
chgd = int.Parse(text) > 0;
}
return (chgd?int.Parse(text):0, chgd);
}
private void frmPerson_Load(object sender, EventArgs e)
{
var person = _personRepository.GetPersonById(PersonId);
initializeAllFields();
if (person != null)
{
HomeAddressId = person.HomeAddress;
CheckHomeAddressId = person.HomeAddress;
InvoiceAddressId = person.InvoiceAddress;
CheckInvoiceAddressId = person.InvoiceAddress;
fillFieldsFromPerson(person);
}
}
private void fillFieldsFromPerson(Person person)
{
txtFirstName.Text = person.FirstName;
txtLastName.Text = person.LastName;
txtNickName.Text = person.NickName;
txtPersonNr.Text = person.Born;
txtComment.Text = person.Comments;
txtClearingNo.Text = person.ClearingNo.ToString();
txtAccountNr.Text = person.AccountNo.ToString();
ShowAddressFrom(HomeAddressId);
}
private void ShowAddressFrom(int AddrId)
{
var address = _addressRepository.GetAddressById(AddrId);
if (address != null)
{
txtStreet.Text = address.Street;
txtStreet2.Text = address.Street2;
txtZipCode.Text = address.Zipcode.ToString();
txtDestination.Text = address.Destination;
txtNation.Text = address.Nation;
}
}
private void initializeAllFields()
{
txtFirstName.Text = "";
txtLastName.Text = "";
txtNickName.Text = "";
txtPersonNr.Text = "";
txtComment.Text = "";
txtClearingNo.Text = "";
txtAccountNr.Text = "";
ClearAddress();
HomeAddressId = 0;
InvoiceAddressId = 0;
CheckHomeAddressId = 0;
CheckInvoiceAddressId = 0;
rdbHome.Checked = true;
}
private void ClearAddress()
{
txtStreet.Text = "";
txtStreet2.Text = "";
txtZipCode.Text = "";
txtDestination.Text = "";
txtNation.Text = "";
}
private void rdbInvoiceAddr_CheckedChanged(object sender, EventArgs e)
{
if (!radioOk)
{
if (rdbInvoiceAddr.Checked)
{
HomeAddressId = AddressSave(HomeAddressId);
ClearAddress();
ShowAddressFrom(InvoiceAddressId);
radioOk = true;
}
else
{
InvoiceAddressId = AddressSave(InvoiceAddressId);
ClearAddress();
ShowAddressFrom(HomeAddressId);
radioOk = true;
}
}
else
{
radioOk = false;
}
}
private void btnClose_Click(object sender, EventArgs e)
{
if (HomeAddressId != CheckHomeAddressId || InvoiceAddressId != CheckInvoiceAddressId)
{
MessageBox.Show("NB Save info first to insure not losing addresses");
}
else
{
this.Close();
}
}
}
}

View 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>

View File

@ -0,0 +1,139 @@

namespace StockInfoCore
{
partial class frmPersonShareConnect
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmPersonShareConnect));
this.lstShares = new System.Windows.Forms.ListBox();
this.lstPersConnected = new System.Windows.Forms.ListBox();
this.btnDisconnect = new System.Windows.Forms.Button();
this.lblShareHolder = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.btnConnect = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lstShares
//
this.lstShares.FormattingEnabled = true;
this.lstShares.ItemHeight = 15;
this.lstShares.Location = new System.Drawing.Point(35, 35);
this.lstShares.Name = "lstShares";
this.lstShares.Size = new System.Drawing.Size(173, 349);
this.lstShares.TabIndex = 0;
//
// lstPersConnected
//
this.lstPersConnected.FormattingEnabled = true;
this.lstPersConnected.ItemHeight = 15;
this.lstPersConnected.Location = new System.Drawing.Point(270, 35);
this.lstPersConnected.Name = "lstPersConnected";
this.lstPersConnected.Size = new System.Drawing.Size(173, 349);
this.lstPersConnected.TabIndex = 1;
//
// btnDisconnect
//
this.btnDisconnect.Image = ((System.Drawing.Image)(resources.GetObject("btnDisconnect.Image")));
this.btnDisconnect.Location = new System.Drawing.Point(214, 202);
this.btnDisconnect.Name = "btnDisconnect";
this.btnDisconnect.Size = new System.Drawing.Size(49, 23);
this.btnDisconnect.TabIndex = 2;
this.btnDisconnect.UseVisualStyleBackColor = true;
this.btnDisconnect.Click += new System.EventHandler(this.btnDisconnect_Click);
//
// lblShareHolder
//
this.lblShareHolder.AutoSize = true;
this.lblShareHolder.Location = new System.Drawing.Point(270, 12);
this.lblShareHolder.Name = "lblShareHolder";
this.lblShareHolder.Size = new System.Drawing.Size(80, 15);
this.lblShareHolder.TabIndex = 3;
this.lblShareHolder.Text = "[share holder]";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(35, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(102, 15);
this.label1.TabIndex = 4;
this.label1.Text = "Uncoupled Shares";
//
// btnConnect
//
this.btnConnect.Image = ((System.Drawing.Image)(resources.GetObject("btnConnect.Image")));
this.btnConnect.Location = new System.Drawing.Point(215, 173);
this.btnConnect.Name = "btnConnect";
this.btnConnect.Size = new System.Drawing.Size(49, 23);
this.btnConnect.TabIndex = 5;
this.btnConnect.UseVisualStyleBackColor = true;
this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(422, 415);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 23);
this.btnClose.TabIndex = 6;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// frmPersonShareConnect
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(509, 450);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnConnect);
this.Controls.Add(this.label1);
this.Controls.Add(this.lblShareHolder);
this.Controls.Add(this.btnDisconnect);
this.Controls.Add(this.lstPersConnected);
this.Controls.Add(this.lstShares);
this.Name = "frmPersonShareConnect";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "frmPersonShareConnect";
this.Shown += new System.EventHandler(this.frmPersonShareConnect_Shown);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ListBox lstShares;
private System.Windows.Forms.ListBox lstPersConnected;
private System.Windows.Forms.Button btnDisconnect;
private System.Windows.Forms.Label lblShareHolder;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnConnect;
private System.Windows.Forms.Button btnClose;
}
}

View File

@ -0,0 +1,89 @@
using DataDomain;
using StockBL.Interface;
using StockDAL.Interface;
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 StockInfoCore
{
public partial class frmPersonShareConnect : Form
{
private readonly IPersonStockFacade _personStockFacade;
private readonly IStockPersonConnect _stockPersonConnect;
private readonly IStockRepository _stockRepository;
public Person ConnectPerson { get; set; }
public frmPersonShareConnect(IPersonStockFacade personStockFacade, IStockPersonConnect stockPersonConnect,IStockRepository stockRepository)
{
InitializeComponent();
_personStockFacade = personStockFacade;
_stockPersonConnect = stockPersonConnect;
_stockRepository = stockRepository;
}
private void frmPersonShareConnect_Shown(object sender, EventArgs e)
{
this.Text = $"{ConnectPerson.Id} - {ConnectPerson.FirstName} {ConnectPerson.LastName}'s Shares";
this.lblShareHolder.Text = $"{ConnectPerson.FirstName} {ConnectPerson.LastName}'s Shares";
RefreshShareList();
RefreshConnectedList();
}
private void RefreshShareList()
{
var dataSource = _personStockFacade.GetUnconnectedShares();
lstShares.DataSource = dataSource;
lstShares.DisplayMember = "StockId";
lstShares.ValueMember = "Id";
lstShares.Refresh();
}
private void RefreshConnectedList()
{
var dataSource = _personStockFacade.GetAllSharesConnectedTo(ConnectPerson.Id);
lstPersConnected.DataSource = dataSource;
lstPersConnected.DisplayMember = "StockId";
lstPersConnected.ValueMember = "Id";
lstPersConnected.Refresh();
}
private void btnConnect_Click(object sender, EventArgs e)
{
if (lstShares.SelectedIndex != -1)
{
PersonStock ps = new PersonStock();
ps.PersonId = ConnectPerson.Id;
ps.StockId = int.Parse(lstShares.SelectedValue.ToString());
_stockPersonConnect.SavePersonStockConnection(ps);
RefreshShareList();
RefreshConnectedList();
}
}
private void btnDisconnect_Click(object sender, EventArgs e)
{
if (lstPersConnected.SelectedIndex != -1)
{
PersonStock ps = new PersonStock();
ps.PersonId = ConnectPerson.Id;
ps.StockId = int.Parse(lstPersConnected.SelectedValue.ToString());
_stockPersonConnect.RemoveConnectedShare(ps);
RefreshShareList();
RefreshConnectedList();
}
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

View File

@ -0,0 +1,79 @@
<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>
<assembly alias="System.Drawing.Common" name="System.Drawing.Common, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
<data name="btnDisconnect.Image" type="System.Drawing.Bitmap, System.Drawing.Common" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vwAADr8BOAVTJAAAAKJJREFUOE9jQAffvn3jA+J7QPwfiKGiJACgpiWrV68GaSbdAKCGqBs3bvz38PAg
3QCgYoWPQJCUlPTfyckJZgBBDNPMDMRHJ06cCNaMjkEKcbFhBtQfOXIELoGO8RoAJKyeP3/+Jzg4GC6B
jgkZcK+iogIuiA3T3ADKvEBxIEINoCwaQQDIIT8hwQBQACMpE8IYACiIkpkIYQwAFCQhOzMwAABkGA25
6rPaRQAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnConnect.Image" type="System.Drawing.Bitmap, System.Drawing.Common" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vwAADr8BOAVTJAAAAKZJREFUOE9jIAZ8+/btPxDfA2I+qBBpAGTA2rVrQYYsgQqRBkAGeHh4/L958ybI
kCioMASAJInBTk5O/1NSUv5/BAIgXwGqHWIASBKEcbGR8eTJk0FyR4GYmSwDQPjo0aMg+XqyDQgJCfn/
4sWLP0A1VmQZAMKVlZUgNfcGxgCKvUBRIGKNRmIwSDPWhPT//3+QIYQw7qQMAmiKsWHKMxMQY8nODAwA
Xb3/nf2Zot8AAAAASUVORK5CYII=
</value>
</data>
</root>

377
StockInfoCore/frmRegisterStock.Designer.cs generated Normal file
View File

@ -0,0 +1,377 @@

namespace StockInfoCore
{
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;
}
}

View File

@ -0,0 +1,130 @@
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 StockInfoCore
{
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.ActAmount = long.Parse(string.IsNullOrEmpty(txtActAmount.Text) ? "0" : txtActAmount.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();
}
}
}
}

View 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>

452
StockInfoCore/frmSelling.Designer.cs generated Normal file
View File

@ -0,0 +1,452 @@

namespace StockInfoCore
{
partial class frmSelling
{
/// <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.lvSellCandidates = new System.Windows.Forms.ListView();
this.StockName = new System.Windows.Forms.ColumnHeader();
this.Buydate = new System.Windows.Forms.ColumnHeader();
this.BuyPrice = new System.Windows.Forms.ColumnHeader();
this.LeftNumber = new System.Windows.Forms.ColumnHeader();
this.ActPrice = new System.Windows.Forms.ColumnHeader();
this.TotalValue = new System.Windows.Forms.ColumnHeader();
this.gbInfo = new System.Windows.Forms.GroupBox();
this.txtBuyValue = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.txtBuyPrice = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.txtBuyNumber = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.txtBuyDate = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.txtStockId = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.txtId = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.gbSell = new System.Windows.Forms.GroupBox();
this.txtGainLoose = new System.Windows.Forms.TextBox();
this.label12 = new System.Windows.Forms.Label();
this.btnConfirm = new System.Windows.Forms.Button();
this.txtRemainingNo = new System.Windows.Forms.TextBox();
this.label11 = new System.Windows.Forms.Label();
this.txtSellValue = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.txtSoldAmount = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.txtSoldPrice = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.txtSoldDate = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.btnClose = new System.Windows.Forms.Button();
this.gbInfo.SuspendLayout();
this.gbSell.SuspendLayout();
this.SuspendLayout();
//
// lvSellCandidates
//
this.lvSellCandidates.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.StockName,
this.Buydate,
this.BuyPrice,
this.LeftNumber,
this.ActPrice,
this.TotalValue});
this.lvSellCandidates.FullRowSelect = true;
this.lvSellCandidates.HideSelection = false;
this.lvSellCandidates.Location = new System.Drawing.Point(13, 13);
this.lvSellCandidates.MultiSelect = false;
this.lvSellCandidates.Name = "lvSellCandidates";
this.lvSellCandidates.Size = new System.Drawing.Size(519, 128);
this.lvSellCandidates.TabIndex = 0;
this.lvSellCandidates.UseCompatibleStateImageBehavior = false;
this.lvSellCandidates.View = System.Windows.Forms.View.Details;
this.lvSellCandidates.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lvSellCandidates_MouseUp);
//
// StockName
//
this.StockName.Name = "StockName";
this.StockName.Text = "StockId";
this.StockName.Width = 80;
//
// Buydate
//
this.Buydate.Name = "Buydate";
this.Buydate.Text = "Date of Buy";
this.Buydate.Width = 80;
//
// BuyPrice
//
this.BuyPrice.Name = "BuyPrice";
this.BuyPrice.Text = "Price per stock";
this.BuyPrice.Width = 80;
//
// LeftNumber
//
this.LeftNumber.Name = "LeftNumber";
this.LeftNumber.Text = "Remaining Nr";
this.LeftNumber.Width = 80;
//
// ActPrice
//
this.ActPrice.Name = "ActPrice";
this.ActPrice.Text = "Price today";
this.ActPrice.Width = 80;
//
// TotalValue
//
this.TotalValue.Name = "TotalValue";
this.TotalValue.Text = "Value Today";
this.TotalValue.Width = 80;
//
// gbInfo
//
this.gbInfo.Controls.Add(this.txtBuyValue);
this.gbInfo.Controls.Add(this.label6);
this.gbInfo.Controls.Add(this.txtBuyPrice);
this.gbInfo.Controls.Add(this.label5);
this.gbInfo.Controls.Add(this.txtBuyNumber);
this.gbInfo.Controls.Add(this.label4);
this.gbInfo.Controls.Add(this.txtBuyDate);
this.gbInfo.Controls.Add(this.label3);
this.gbInfo.Controls.Add(this.txtStockId);
this.gbInfo.Controls.Add(this.label2);
this.gbInfo.Controls.Add(this.txtId);
this.gbInfo.Controls.Add(this.label1);
this.gbInfo.Location = new System.Drawing.Point(13, 170);
this.gbInfo.Name = "gbInfo";
this.gbInfo.Size = new System.Drawing.Size(276, 250);
this.gbInfo.TabIndex = 1;
this.gbInfo.TabStop = false;
this.gbInfo.Text = "Actual Stock";
//
// txtBuyValue
//
this.txtBuyValue.Location = new System.Drawing.Point(116, 165);
this.txtBuyValue.Name = "txtBuyValue";
this.txtBuyValue.ReadOnly = true;
this.txtBuyValue.Size = new System.Drawing.Size(73, 23);
this.txtBuyValue.TabIndex = 11;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(7, 168);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(58, 15);
this.label6.TabIndex = 10;
this.label6.Text = "Buy value";
//
// txtBuyPrice
//
this.txtBuyPrice.Location = new System.Drawing.Point(116, 136);
this.txtBuyPrice.Name = "txtBuyPrice";
this.txtBuyPrice.ReadOnly = true;
this.txtBuyPrice.Size = new System.Drawing.Size(73, 23);
this.txtBuyPrice.TabIndex = 9;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(7, 139);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(56, 15);
this.label5.TabIndex = 8;
this.label5.Text = "Buy price";
//
// txtBuyNumber
//
this.txtBuyNumber.Location = new System.Drawing.Point(116, 107);
this.txtBuyNumber.Name = "txtBuyNumber";
this.txtBuyNumber.ReadOnly = true;
this.txtBuyNumber.Size = new System.Drawing.Size(73, 23);
this.txtBuyNumber.TabIndex = 7;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(7, 110);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(93, 15);
this.label4.TabIndex = 6;
this.label4.Text = "Bought Number";
//
// txtBuyDate
//
this.txtBuyDate.Location = new System.Drawing.Point(116, 78);
this.txtBuyDate.Name = "txtBuyDate";
this.txtBuyDate.ReadOnly = true;
this.txtBuyDate.Size = new System.Drawing.Size(73, 23);
this.txtBuyDate.TabIndex = 5;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(7, 81);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 15);
this.label3.TabIndex = 4;
this.label3.Text = "Bought date";
//
// txtStockId
//
this.txtStockId.Location = new System.Drawing.Point(116, 49);
this.txtStockId.Name = "txtStockId";
this.txtStockId.ReadOnly = true;
this.txtStockId.Size = new System.Drawing.Size(154, 23);
this.txtStockId.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(7, 52);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(49, 15);
this.label2.TabIndex = 2;
this.label2.Text = "Stock Id";
//
// txtId
//
this.txtId.Location = new System.Drawing.Point(116, 20);
this.txtId.Name = "txtId";
this.txtId.ReadOnly = true;
this.txtId.Size = new System.Drawing.Size(73, 23);
this.txtId.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(7, 23);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 15);
this.label1.TabIndex = 0;
this.label1.Text = "Local Id";
//
// gbSell
//
this.gbSell.Controls.Add(this.txtGainLoose);
this.gbSell.Controls.Add(this.label12);
this.gbSell.Controls.Add(this.btnConfirm);
this.gbSell.Controls.Add(this.txtRemainingNo);
this.gbSell.Controls.Add(this.label11);
this.gbSell.Controls.Add(this.txtSellValue);
this.gbSell.Controls.Add(this.label10);
this.gbSell.Controls.Add(this.txtSoldAmount);
this.gbSell.Controls.Add(this.label9);
this.gbSell.Controls.Add(this.txtSoldPrice);
this.gbSell.Controls.Add(this.label8);
this.gbSell.Controls.Add(this.txtSoldDate);
this.gbSell.Controls.Add(this.label7);
this.gbSell.Location = new System.Drawing.Point(296, 170);
this.gbSell.Name = "gbSell";
this.gbSell.Size = new System.Drawing.Size(236, 250);
this.gbSell.TabIndex = 2;
this.gbSell.TabStop = false;
this.gbSell.Text = "Sell decision";
//
// txtGainLoose
//
this.txtGainLoose.Location = new System.Drawing.Point(121, 165);
this.txtGainLoose.Name = "txtGainLoose";
this.txtGainLoose.ReadOnly = true;
this.txtGainLoose.Size = new System.Drawing.Size(73, 23);
this.txtGainLoose.TabIndex = 14;
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(12, 168);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(73, 15);
this.label12.TabIndex = 13;
this.label12.Text = "Gain / Loose";
//
// btnConfirm
//
this.btnConfirm.Location = new System.Drawing.Point(121, 221);
this.btnConfirm.Name = "btnConfirm";
this.btnConfirm.Size = new System.Drawing.Size(75, 23);
this.btnConfirm.TabIndex = 12;
this.btnConfirm.Text = "Confirm";
this.btnConfirm.UseVisualStyleBackColor = true;
this.btnConfirm.Click += new System.EventHandler(this.btnConfirm_Click);
//
// txtRemainingNo
//
this.txtRemainingNo.Location = new System.Drawing.Point(121, 136);
this.txtRemainingNo.Name = "txtRemainingNo";
this.txtRemainingNo.ReadOnly = true;
this.txtRemainingNo.Size = new System.Drawing.Size(73, 23);
this.txtRemainingNo.TabIndex = 11;
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(12, 139);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(80, 15);
this.label11.TabIndex = 10;
this.label11.Text = "Remaining Nr";
//
// txtSellValue
//
this.txtSellValue.Location = new System.Drawing.Point(121, 107);
this.txtSellValue.Name = "txtSellValue";
this.txtSellValue.ReadOnly = true;
this.txtSellValue.Size = new System.Drawing.Size(73, 23);
this.txtSellValue.TabIndex = 9;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(12, 110);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(56, 15);
this.label10.TabIndex = 8;
this.label10.Text = "Sell Value";
//
// txtSoldAmount
//
this.txtSoldAmount.Location = new System.Drawing.Point(121, 78);
this.txtSoldAmount.Name = "txtSoldAmount";
this.txtSoldAmount.Size = new System.Drawing.Size(73, 23);
this.txtSoldAmount.TabIndex = 7;
this.txtSoldAmount.TextChanged += new System.EventHandler(this.txtSoldAmount_TextChanged);
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(12, 81);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(77, 15);
this.label9.TabIndex = 6;
this.label9.Text = "Sold Number";
//
// txtSoldPrice
//
this.txtSoldPrice.Location = new System.Drawing.Point(121, 49);
this.txtSoldPrice.Name = "txtSoldPrice";
this.txtSoldPrice.Size = new System.Drawing.Size(73, 23);
this.txtSoldPrice.TabIndex = 5;
this.txtSoldPrice.TextChanged += new System.EventHandler(this.txtSoldPrice_TextChanged);
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(12, 52);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(71, 15);
this.label8.TabIndex = 4;
this.label8.Text = "Selling Price";
//
// txtSoldDate
//
this.txtSoldDate.Location = new System.Drawing.Point(121, 20);
this.txtSoldDate.Name = "txtSoldDate";
this.txtSoldDate.Size = new System.Drawing.Size(73, 23);
this.txtSoldDate.TabIndex = 3;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(12, 23);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(57, 15);
this.label7.TabIndex = 2;
this.label7.Text = "Sold Date";
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(417, 440);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 23);
this.btnClose.TabIndex = 3;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// frmSelling
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(543, 478);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.gbSell);
this.Controls.Add(this.gbInfo);
this.Controls.Add(this.lvSellCandidates);
this.Name = "frmSelling";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "frmSelling";
this.Load += new System.EventHandler(this.frmSelling_Load);
this.gbInfo.ResumeLayout(false);
this.gbInfo.PerformLayout();
this.gbSell.ResumeLayout(false);
this.gbSell.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListView lvSellCandidates;
private System.Windows.Forms.ColumnHeader StockName;
private System.Windows.Forms.ColumnHeader Buydate;
private System.Windows.Forms.ColumnHeader BuyPrice;
private System.Windows.Forms.ColumnHeader LeftNumber;
private System.Windows.Forms.ColumnHeader ActPrice;
private System.Windows.Forms.ColumnHeader TotalValue;
private System.Windows.Forms.GroupBox gbInfo;
private System.Windows.Forms.TextBox txtStockId;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtId;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtBuyDate;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtBuyValue;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txtBuyPrice;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txtBuyNumber;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.GroupBox gbSell;
private System.Windows.Forms.Button btnConfirm;
private System.Windows.Forms.TextBox txtRemainingNo;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.TextBox txtSellValue;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox txtSoldAmount;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txtSoldPrice;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox txtSoldDate;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox txtGainLoose;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Button btnClose;
}
}

145
StockInfoCore/frmSelling.cs Normal file
View File

@ -0,0 +1,145 @@
using DataDomain;
using Helpers;
using StockDAL.Interface;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
namespace StockInfoCore
{
public partial class frmSelling : Form
{
private readonly IStockRepository _stockRepository;
private List<StockMember> remainingStocks = new();
public StockMember stkMemSelected { get; set; } = null;
public frmSelling(IStockRepository stockRepository)
{
InitializeComponent();
_stockRepository = stockRepository;
}
private void frmSelling_Load(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
ReloadRemainingStocks();
Cursor.Current = DefaultCursor;
}
private void ReloadRemainingStocks()
{
remainingStocks = _stockRepository.GetAllRemainingStocks().ToList();
foreach (var stock in remainingStocks)
{
var lvRow = lvSellCandidates.Items.Add(stock.StockId);
lvRow.Tag = stock.Id;
lvRow.SubItems.Add(stock.BuyDate.ToShortDateString());
lvRow.SubItems.Add(stock.BuyValue.ToString());
lvRow.SubItems.Add(stock.ActAmount.ToString());
lvRow.SubItems.Add(stock.ActValue.ToString());
lvRow.SubItems.Add((stock.ActValue * stock.ActAmount).ToString());
}
}
private void SelectStock(object tag)
{
//Debug.WriteLine($"selected item {(int)tag}");
foreach (var remStk in remainingStocks)
{
if (remStk.Id == (int)tag)
{
stkMemSelected = remStk;
break;
}
}
EditStockForSelling(stkMemSelected);
}
private void EditStockForSelling(StockMember stkMemSelected)
{
txtId.Text = stkMemSelected.Id.ToString();
txtStockId.Text = stkMemSelected.StockId;
txtBuyDate.Text = stkMemSelected.BuyDate.ToShortDateString();
txtBuyNumber.Text = stkMemSelected.PostAmount.ToString();
txtBuyPrice.Text = stkMemSelected.BuyValue.ToString("N2");
txtBuyValue.Text = (stkMemSelected.BuyValue * stkMemSelected.PostAmount).ToString("N2");
txtSoldDate.Text = DateTime.Today.ToShortDateString();
txtSoldPrice.Text = stkMemSelected.ActValue.ToString("N2");
txtSoldAmount.Text = stkMemSelected.ActAmount.ToString();
}
private void lvSellCandidates_MouseUp(object sender, MouseEventArgs e)
{
var selRows = lvSellCandidates.SelectedItems;
SelectStock(selRows[0].Tag);
}
private void txtSoldPrice_TextChanged(object sender, EventArgs e)
{
CalcNumberAndValue();
}
private void txtSoldAmount_TextChanged(object sender, EventArgs e)
{
CalcNumberAndValue();
}
private void CalcNumberAndValue()
{
if (txtSoldPrice.Text.IsNumeric() && txtSoldAmount.Text.IsNumeric())
{
txtSellValue.Text = (decimal.Parse(txtSoldPrice.Text) * long.Parse(txtSoldAmount.Text)).ToString();
txtRemainingNo.Text = stkMemSelected.ActAmount > 0 ? (stkMemSelected.PostAmount - long.Parse(txtSoldAmount.Text)).ToString() : 0.ToString();
var gainLoose = (decimal.Parse(txtSellValue.Text) - decimal.Parse(txtBuyPrice.Text)*long.Parse(txtSoldAmount.Text));
txtGainLoose.Text = gainLoose.ToString();
if (gainLoose > 0)
{
txtGainLoose.BackColor = Color.LightGreen;
}
else if (gainLoose == 0)
{
txtGainLoose.BackColor = default;
}
else
{
txtGainLoose.BackColor = Color.LightPink;
}
}
}
private void btnConfirm_Click(object sender, EventArgs e)
{
SellCurrentStock();
}
private void SellCurrentStock()
{
if (txtSoldAmount.Text.IsNumeric() && txtSoldPrice.Text.IsNumeric())
{
_stockRepository.UpdateActualForSell(stkMemSelected.Id, int.Parse(txtSoldAmount.Text), decimal.Parse(txtSoldPrice.Text), DateTime.Parse(txtSoldDate.Text));
var answer = MessageBox.Show($"Ok att sälja {stkMemSelected.StockId} ?","Selling" , MessageBoxButtons.OKCancel);
if (DialogResult.OK == answer)
{
ReloadRemainingStocks();
}
}
else
{
MessageBox.Show("Something wrong with amounts");
}
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

View 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>

73
StockInfoCoreApp.sln Normal file
View File

@ -0,0 +1,73 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockInfoCore", "StockInfoCore\StockInfoCore.csproj", "{99122CA3-5625-4004-BED6-5423873FACAC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataDomain", "DataDomain\DataDomain.csproj", "{3E7E4CBD-FDBE-4424-880E-0BA24D29B599}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Helpers", "Helpers\Helpers.csproj", "{F415D933-B9A7-4418-948B-8937296B9D0E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqliteBackups", "SqliteBackups\SqliteBackups.csproj", "{71EF72E9-5A60-41E6-8649-2B9FDFFED8F2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockDAL", "StockDAL\StockDAL.csproj", "{DD041C3F-0883-456C-A3E1-26868BDE2363}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockDAL.Interface", "StockDal.Interface\StockDAL.Interface.csproj", "{90C9E06C-4774-4FD0-B15E-2BE6E23328E6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatamodelLibrary", "DatamodelLibrary\DatamodelLibrary.csproj", "{D08DA97B-3B26-4A81-B778-440DA9BC55FF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockBL", "StockBL\StockBL.csproj", "{BA58D226-460C-41B8-8C7D-7A43B75151E1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockBL.Interface", "StockBL.Interface\StockBL.Interface.csproj", "{BEAD00C3-74AD-416B-9B36-EBE40DAFF16F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{99122CA3-5625-4004-BED6-5423873FACAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99122CA3-5625-4004-BED6-5423873FACAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99122CA3-5625-4004-BED6-5423873FACAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99122CA3-5625-4004-BED6-5423873FACAC}.Release|Any CPU.Build.0 = Release|Any CPU
{3E7E4CBD-FDBE-4424-880E-0BA24D29B599}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E7E4CBD-FDBE-4424-880E-0BA24D29B599}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E7E4CBD-FDBE-4424-880E-0BA24D29B599}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E7E4CBD-FDBE-4424-880E-0BA24D29B599}.Release|Any CPU.Build.0 = Release|Any CPU
{F415D933-B9A7-4418-948B-8937296B9D0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F415D933-B9A7-4418-948B-8937296B9D0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F415D933-B9A7-4418-948B-8937296B9D0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F415D933-B9A7-4418-948B-8937296B9D0E}.Release|Any CPU.Build.0 = Release|Any CPU
{71EF72E9-5A60-41E6-8649-2B9FDFFED8F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71EF72E9-5A60-41E6-8649-2B9FDFFED8F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71EF72E9-5A60-41E6-8649-2B9FDFFED8F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71EF72E9-5A60-41E6-8649-2B9FDFFED8F2}.Release|Any CPU.Build.0 = Release|Any CPU
{DD041C3F-0883-456C-A3E1-26868BDE2363}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD041C3F-0883-456C-A3E1-26868BDE2363}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD041C3F-0883-456C-A3E1-26868BDE2363}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD041C3F-0883-456C-A3E1-26868BDE2363}.Release|Any CPU.Build.0 = Release|Any CPU
{90C9E06C-4774-4FD0-B15E-2BE6E23328E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90C9E06C-4774-4FD0-B15E-2BE6E23328E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90C9E06C-4774-4FD0-B15E-2BE6E23328E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90C9E06C-4774-4FD0-B15E-2BE6E23328E6}.Release|Any CPU.Build.0 = Release|Any CPU
{D08DA97B-3B26-4A81-B778-440DA9BC55FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D08DA97B-3B26-4A81-B778-440DA9BC55FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D08DA97B-3B26-4A81-B778-440DA9BC55FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D08DA97B-3B26-4A81-B778-440DA9BC55FF}.Release|Any CPU.Build.0 = Release|Any CPU
{BA58D226-460C-41B8-8C7D-7A43B75151E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BA58D226-460C-41B8-8C7D-7A43B75151E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA58D226-460C-41B8-8C7D-7A43B75151E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA58D226-460C-41B8-8C7D-7A43B75151E1}.Release|Any CPU.Build.0 = Release|Any CPU
{BEAD00C3-74AD-416B-9B36-EBE40DAFF16F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BEAD00C3-74AD-416B-9B36-EBE40DAFF16F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BEAD00C3-74AD-416B-9B36-EBE40DAFF16F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BEAD00C3-74AD-416B-9B36-EBE40DAFF16F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {540C3730-0438-4FF3-823A-0FA1BF296A10}
EndGlobalSection
EndGlobal