Compare commits

..

10 Commits

46 changed files with 2727 additions and 74 deletions

View File

@ -9,10 +9,10 @@ namespace DataDomain
public class Address
{
public int Id { get; set; }
public string Gata { get; set; }
public string Gata2 { get; set; }
public int PostNr { get; set; }
public string PostOrt { 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

@ -12,9 +12,11 @@ namespace DataDomain
public string FirstName { get; set; }
public string LastName { get; set; }
public string NickName { get; set; }
public DateTime? Born { 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; }
}
}

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

@ -22,35 +22,64 @@ namespace DatamodelLibrary.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Gata")
.HasColumnType("TEXT");
b.Property<string>("Gata2")
b.Property<string>("Destination")
.HasColumnType("TEXT");
b.Property<string>("Nation")
.HasColumnType("TEXT");
b.Property<int>("PostNr")
.HasColumnType("INTEGER");
b.Property<string>("PostOrt")
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<DateTime?>("Born")
b.Property<long>("AccountNo")
.HasColumnType("INTEGER");
b.Property<string>("Born")
.HasColumnType("TEXT");
b.Property<int>("ClearingNo")
.HasColumnType("INTEGER");
b.Property<string>("Comments")
.HasColumnType("TEXT");

View File

@ -14,6 +14,7 @@ namespace DatamodelLibrary
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;
}
}
}

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>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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

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

View File

@ -13,7 +13,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockDAL.Interface", "Stock
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockInfo", "StockInfo\StockInfo.csproj", "{EC122B56-FCE0-4BBD-956D-7BF46D617CF8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Helpers", "Helpers\Helpers.csproj", "{5FEE920E-07B8-4185-A41F-1587643ECC26}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Helpers", "Helpers\Helpers.csproj", "{5FEE920E-07B8-4185-A41F-1587643ECC26}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockBL", "StockBL\StockBL.csproj", "{C8801F5F-1C4F-4067-ADA2-A2DA299A54A8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockBL.Interface", "StockBL.Interface\StockBL.Interface.csproj", "{BFF16A7B-9962-430B-A665-03F4174A289D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqliteBackups", "SqliteBackups\SqliteBackups.csproj", "{2BD170F4-1F7D-4067-980E-284CEEC2232D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -45,6 +51,18 @@ Global
{5FEE920E-07B8-4185-A41F-1587643ECC26}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5FEE920E-07B8-4185-A41F-1587643ECC26}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FEE920E-07B8-4185-A41F-1587643ECC26}.Release|Any CPU.Build.0 = Release|Any CPU
{C8801F5F-1C4F-4067-ADA2-A2DA299A54A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8801F5F-1C4F-4067-ADA2-A2DA299A54A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8801F5F-1C4F-4067-ADA2-A2DA299A54A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8801F5F-1C4F-4067-ADA2-A2DA299A54A8}.Release|Any CPU.Build.0 = Release|Any CPU
{BFF16A7B-9962-430B-A665-03F4174A289D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BFF16A7B-9962-430B-A665-03F4174A289D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BFF16A7B-9962-430B-A665-03F4174A289D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BFF16A7B-9962-430B-A665-03F4174A289D}.Release|Any CPU.Build.0 = Release|Any CPU
{2BD170F4-1F7D-4067-980E-284CEEC2232D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2BD170F4-1F7D-4067-980E-284CEEC2232D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2BD170F4-1F7D-4067-980E-284CEEC2232D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2BD170F4-1F7D-4067-980E-284CEEC2232D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

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

@ -1,4 +1,8 @@
using Autofac;
using SqliteBackups;
using SqliteBackups.Interfaces;
using StockBL;
using StockBL.Interface;
using StockDal;
using StockDal.Interface;
using StockDAL;
@ -24,7 +28,16 @@ namespace StockInfo
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Container = Configure();
Application.Run(new frmInitial( Container.Resolve<IStockRepository>(), Container.Resolve<IStockMarketRepository>()));
Application.Run(new frmInitial(
Container.Resolve<IStockRepository>(),
Container.Resolve<IStockMarketRepository>(),
Container.Resolve<IPersonRepository>(),
Container.Resolve<IAddressRepository>(),
Container.Resolve<IStockPersonConnect>(),
Container.Resolve<IBackupRepository>(),
Container.Resolve<IBackupRoutines>(),
Container.Resolve<IPersonStockFacade>()
));
}
static IContainer Configure()
@ -32,6 +45,12 @@ namespace StockInfo
var builder = new ContainerBuilder();
builder.RegisterType<StockRepository>().As<IStockRepository>();
builder.RegisterType<StockMarketRepository>().As<IStockMarketRepository>();
builder.RegisterType<PersonRepository>().As<IPersonRepository>();
builder.RegisterType<AddressRepository>().As<IAddressRepository>();
builder.RegisterType<StockPersonConnect>().As<IStockPersonConnect>();
builder.RegisterType<BackupRepository>().As<IBackupRepository>();
builder.RegisterType<BackupRoutines>().As<IBackupRoutines>();
builder.RegisterType<PersonStockFacade>().As<IPersonStockFacade>();
builder.RegisterType<frmInitial>();
return builder.Build();
}

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace StockInfo.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StockInfo.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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

@ -26,16 +26,43 @@
<ItemGroup>
<ProjectReference Include="..\DataDomain\DataDomain.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>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="Stocks.db">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="bin\Debug\net5.0-windows\Stocks.db">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

Binary file not shown.

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

@ -0,0 +1,142 @@

namespace StockInfo
{
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
StockInfo/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 StockInfo
{
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
});
}
}
}
}

60
StockInfo/frmBackup.resx Normal file
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

@ -32,13 +32,13 @@ namespace StockInfo
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.lblStockRows = new System.Windows.Forms.Label();
this.button1 = 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();
@ -46,9 +46,15 @@ namespace StockInfo
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
@ -60,7 +66,7 @@ namespace StockInfo
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(829, 363);
this.dataGridView.Size = new System.Drawing.Size(871, 360);
this.dataGridView.TabIndex = 0;
//
// lblTotalRecords
@ -76,21 +82,32 @@ namespace StockInfo
// 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, 388);
this.gB1.Location = new System.Drawing.Point(157, 385);
this.gB1.Name = "gB1";
this.gB1.Size = new System.Drawing.Size(264, 123);
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(7, 54);
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;
@ -100,7 +117,7 @@ namespace StockInfo
//
// btnRestoreShares
//
this.btnRestoreShares.Location = new System.Drawing.Point(131, 84);
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;
@ -110,7 +127,7 @@ namespace StockInfo
//
// btnBackupShares
//
this.btnBackupShares.Location = new System.Drawing.Point(7, 84);
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;
@ -121,7 +138,7 @@ namespace StockInfo
// 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, 22);
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;
@ -132,7 +149,7 @@ namespace StockInfo
// 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, 439);
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;
@ -140,31 +157,22 @@ namespace StockInfo
this.btnTestScrapFunction.UseVisualStyleBackColor = true;
this.btnTestScrapFunction.Click += new System.EventHandler(this.btnTestScrapFunction_Click);
//
// lblStockRows
// btnReloadShares
//
this.lblStockRows.AutoSize = true;
this.lblStockRows.Location = new System.Drawing.Point(93, 456);
this.lblStockRows.Name = "lblStockRows";
this.lblStockRows.Size = new System.Drawing.Size(14, 15);
this.lblStockRows.TabIndex = 5;
this.lblStockRows.Text = "#";
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button1.Location = new System.Drawing.Point(12, 410);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 6;
this.button1.Text = "ReLoad";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
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, 474);
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;
@ -178,9 +186,9 @@ namespace StockInfo
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(427, 388);
this.gbStockMgmnt.Location = new System.Drawing.Point(408, 385);
this.gbStockMgmnt.Name = "gbStockMgmnt";
this.gbStockMgmnt.Size = new System.Drawing.Size(257, 123);
this.gbStockMgmnt.Size = new System.Drawing.Size(216, 144);
this.gbStockMgmnt.TabIndex = 8;
this.gbStockMgmnt.TabStop = false;
this.gbStockMgmnt.Text = "Working";
@ -188,7 +196,7 @@ namespace StockInfo
// 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, 22);
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;
@ -199,7 +207,7 @@ namespace StockInfo
// 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(7, 51);
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;
@ -210,7 +218,7 @@ namespace StockInfo
// 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, 22);
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;
@ -222,15 +230,68 @@ namespace StockInfo
//
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(853, 520);
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.button1);
this.Controls.Add(this.lblStockRows);
this.Controls.Add(this.btnReloadShares);
this.Controls.Add(this.btnTestScrapFunction);
this.Controls.Add(this.gB1);
this.Controls.Add(this.lblTotalRecords);
@ -241,10 +302,12 @@ namespace StockInfo
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();
@ -257,8 +320,7 @@ namespace StockInfo
private System.Windows.Forms.GroupBox gB1;
private System.Windows.Forms.Button btnReload;
private System.Windows.Forms.Button btnTestScrapFunction;
private System.Windows.Forms.Label lblStockRows;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button btnReloadShares;
private System.Windows.Forms.CheckBox chbShowBrowser;
private System.Windows.Forms.GroupBox gbStockMgmnt;
private System.Windows.Forms.Button btnStockReg;
@ -269,6 +331,12 @@ namespace StockInfo
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;
}
}

View File

@ -12,6 +12,9 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.Json;
using System.IO;
using Helpers;
using StockBL.Interface;
using SqliteBackups.Interfaces;
namespace StockInfo
{
@ -19,16 +22,39 @@ namespace StockInfo
{
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 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)
public frmInitial(
IStockRepository stockMemberRepository,
IStockMarketRepository stockMarketRepository,
IPersonRepository personRepository,
IAddressRepository addressRepository,
IStockPersonConnect stockPersonConnect,
IBackupRepository backupRepository,
IBackupRoutines backupRoutines,
IPersonStockFacade personStockFacade)
{
InitializeComponent();
_stockRepository = stockMemberRepository;
_stockMarketRepository = stockMarketRepository;
_personRepository = personRepository;
_addressRepository = addressRepository;
_stockPersonConnect = stockPersonConnect;
_backupRepository = backupRepository;
_backupRoutines = backupRoutines;
_personStockFacade = personStockFacade;
}
private void Form1_Load(object sender, EventArgs e)
@ -36,6 +62,8 @@ namespace StockInfo
ReloadData();
btnRestoreShares.Enabled = false;
btnBackupShares.Enabled = false;
btnReloadShares.Enabled = false;
btnBackupAll.Enabled = false;
}
private void ReloadData()
@ -57,6 +85,7 @@ namespace StockInfo
_stockMarketRepository.LoadStockMarketList(chbShowBrowser.Checked);
var stocklist = _stockMarketRepository.StockMarketList;
lblStockRows.Text = stocklist.Count().ToString();
btnReloadShares.Enabled = true;
}
private void frmInitial_FormClosing(object sender, FormClosingEventArgs e)
@ -64,7 +93,9 @@ namespace StockInfo
_stockMarketRepository.Clean();
}
private void button1_Click(object sender, EventArgs e)
private void Button1reload()
{
lblStockRows.Text = "";
_stockMarketRepository.RefreshMarketList();
@ -88,23 +119,24 @@ namespace StockInfo
private void btnValueView_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
_stockMarketRepository.LoadStockMarketList();
stockWindow = new frmMyStocks(_stockRepository, _stockMarketRepository);
stockWindow.Stocks = _stockMarketRepository.StockMarketList;
Cursor.Current = DefaultCursor;
stockWindow.ShowDialog();
if (SelectedPersonId == 0)
{
MessageBox.Show($"Ingen person vald ({SelectedPersonId})");
}
else
{
var person = _personRepository.GetPersonById(SelectedPersonId);
Cursor.Current = Cursors.WaitCursor;
_stockMarketRepository.LoadStockMarketList();
stockWindow = new frmMyStocks(_stockRepository, _stockMarketRepository, _stockPersonConnect);
stockWindow.ConnectedPerson = person;
stockWindow.Stocks = _stockMarketRepository.StockMarketList;
Cursor.Current = DefaultCursor;
stockWindow.ShowDialog();
}
}
private void btnStockSale_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
sellWindow = new frmSelling(_stockRepository);
Cursor.Current = DefaultCursor;
sellWindow.ShowDialog();
ReloadData();
}
private void chkEnableBackRes_CheckedChanged(object sender, EventArgs e)
{
@ -112,11 +144,13 @@ namespace StockInfo
{
btnRestoreShares.Enabled = true;
btnBackupShares.Enabled = true;
btnBackupAll.Enabled = true;
}
else
{
btnRestoreShares.Enabled = false;
btnBackupShares.Enabled = false;
btnBackupAll.Enabled = false;
}
}
@ -147,5 +181,76 @@ namespace StockInfo
_stockRepository.RestoreStockMembers(stockList);
};
}
private void btnReloadShares_Click(object sender, EventArgs e)
{
Button1reload();
}
private void btnStockSale_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
sellWindow = new frmSelling(_stockRepository);
Cursor.Current = DefaultCursor;
sellWindow.ShowDialog();
ReloadData();
}
private void btnEditPerson_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
personWindow = new frmPerson(_personRepository, _addressRepository);
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);
personShareConnect = new frmPersonShareConnect(_personStockFacade,_stockPersonConnect,_stockRepository);
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

@ -18,6 +18,8 @@ namespace StockInfo
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; }
@ -26,13 +28,15 @@ namespace StockInfo
public Dictionary<string, DiTraderStockRow> Stocks { get; set; }
public IEnumerable<StockMember> CurrentStocks { get; set; }
public Person ConnectedPerson { get; set; }
public frmMyStocks(IStockRepository stockRepository, IStockMarketRepository stockMarketRepository)
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;
}
@ -48,6 +52,8 @@ namespace StockInfo
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;
@ -55,7 +61,10 @@ namespace StockInfo
_stockRepository.UpdateActualPrice(stock.Id, stock.ActValue);
tmpStocks.Add(stock);
}
foreach(var stk in tmpStocks.OrderByDescending(s => s.ActAmount * (s.ActValue -s.BuyValue)))
//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);
}
@ -144,6 +153,7 @@ namespace StockInfo
private void frmMyStocks_Shown(object sender, EventArgs e)
{
this.Text = $"{ConnectedPerson.Id} - {ConnectedPerson.FirstName} {ConnectedPerson.LastName}'s Shares";
ReloadData();
}

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

@ -0,0 +1,362 @@

namespace StockInfo
{
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
StockInfo/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 StockInfo
{
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();
}
}
}
}

60
StockInfo/frmPerson.resx Normal file
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,138 @@

namespace StockInfo
{
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.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 StockInfo
{
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
wAAADsABataJCQAAAKJJREFUOE9jQAffvn3jA+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
wAAADsABataJCQAAAKZJREFUOE9jIAZ8+/btPxDfA2I+qBBpAGTA2rVrQYYsgQqRBkAGeHh4/L958ybI
kCioMASAJInBTk5O/1NSUv5/BAIgXwGqHWIASBKEcbGR8eTJk0FyR4GYmSwDQPjo0aMg+XqyDQgJCfn/
4sWLP0A1VmQZAMKVlZUgNfcGxgCKvUBRIGKNRmIwSDPWhPT//3+QIYQw7qQMAmiKsWHKMxMQY8nODAwA
Xb3/nf2Zot8AAAAASUVORK5CYII=
</value>
</data>
</root>

BIN
X_Backup/Stocks.db Normal file

Binary file not shown.