Add project files.

This commit is contained in:
2021-02-12 08:09:38 +01:00
parent 1644fce30a
commit fcad75f530
33 changed files with 2768 additions and 0 deletions

34
MyStocks/App.config Normal file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<connectionStrings>
<add name="StockDB" connectionString="Data Source=oemansv7win;Initial Catalog=StockDB;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.1" newVersion="5.0.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

150
MyStocks/MyStocks.csproj Normal file
View File

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B72206DB-4BA5-4C74-B61D-8CCAB6DA9634}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>MyStocks</RootNamespace>
<AssemblyName>MyStocks</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Autofac, Version=6.1.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<HintPath>..\packages\Autofac.6.1.0\lib\netstandard2.0\Autofac.dll</HintPath>
</Reference>
<Reference Include="Dapper, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapper.2.0.78\lib\net461\Dapper.dll</HintPath>
</Reference>
<Reference Include="HtmlAgilityPack, Version=1.11.30.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.1.11.30\lib\Net45\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Data.SqlClient, Version=4.6.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SqlClient.4.8.2\lib\net461\System.Data.SqlClient.dll</HintPath>
</Reference>
<Reference Include="System.Diagnostics.DiagnosticSource, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.5.0.1\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="frmInitial.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmInitial.Designer.cs" />
<Compile Include="frmMyStocks.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmMyStocks.Designer.cs" />
<Compile Include="frmRegisterStock.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmRegisterStock.Designer.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="frmInitial.resx" />
<EmbeddedResource Include="frmMyStocks.resx" />
<EmbeddedResource Include="frmRegisterStock.resx" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StockDal.Interface\StockDal.Interface.csproj">
<Project>{3e23c2d6-3257-42b1-a6df-f6f7b7e71b17}</Project>
<Name>StockDal.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\StockDal\StockDal.csproj">
<Project>{4a000259-9a8e-4a83-bdcf-40d06a2ee6cf}</Project>
<Name>StockDal</Name>
</ProjectReference>
<ProjectReference Include="..\StockDomain\StockDomain.csproj">
<Project>{a4b17e50-0ff3-4b94-81f8-e7aab3d333df}</Project>
<Name>StockDomain</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Selenium.WebDriver.ChromeDriver.88.0.4324.9600\build\Selenium.WebDriver.ChromeDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.ChromeDriver.88.0.4324.9600\build\Selenium.WebDriver.ChromeDriver.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Selenium.WebDriver.ChromeDriver.88.0.4324.9600\build\Selenium.WebDriver.ChromeDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.ChromeDriver.88.0.4324.9600\build\Selenium.WebDriver.ChromeDriver.targets'))" />
</Target>
</Project>

41
MyStocks/Program.cs Normal file
View File

@ -0,0 +1,41 @@
using Autofac;
using RepositoryPattern;
using StockDal;
using StockDal.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MyStocks
{
static class Program
{
public static IContainer Container;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Container = Configure();
Application.Run(new frmInitial( Container.Resolve<IStockMemberRepository>(), Container.Resolve<IStockMarketRepository>()));
}
/// <summary>
/// Setting dependency injection
/// </summary>
/// <returns></returns>
static IContainer Configure()
{
var builder = new ContainerBuilder();
builder.RegisterType<StockMemberRepository>().As<IStockMemberRepository>();
builder.RegisterType<StockMarketRepository>().As<IStockMarketRepository>();
builder.RegisterType<frmInitial>();
return builder.Build();
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MyStocks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MyStocks")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b72206db-4ba5-4c74-b61d-8ccab6da9634")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,70 @@
//------------------------------------------------------------------------------
// <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 MyStocks.Properties
{
/// <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", "4.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 ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MyStocks.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,117 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

29
MyStocks/Properties/Settings.Designer.cs generated Normal file
View File

@ -0,0 +1,29 @@
//------------------------------------------------------------------------------
// <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 MyStocks.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

228
MyStocks/frmInitial.Designer.cs generated Normal file
View File

@ -0,0 +1,228 @@

namespace RepositoryPattern
{
partial class frmInitial
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.lblTotalRecords = new System.Windows.Forms.Label();
this.gB1 = new System.Windows.Forms.GroupBox();
this.btnReload = new System.Windows.Forms.Button();
this.rdbStock = new System.Windows.Forms.RadioButton();
this.rdbNorth = new System.Windows.Forms.RadioButton();
this.btnTestScrapFunction = new System.Windows.Forms.Button();
this.lblStockRows = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.chbShowBrowser = new System.Windows.Forms.CheckBox();
this.gbStockMgmnt = new System.Windows.Forms.GroupBox();
this.btnStockReg = new System.Windows.Forms.Button();
this.btnValueView = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.gB1.SuspendLayout();
this.gbStockMgmnt.SuspendLayout();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(12, 16);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(776, 389);
this.dataGridView.TabIndex = 0;
//
// lblTotalRecords
//
this.lblTotalRecords.AutoSize = true;
this.lblTotalRecords.Location = new System.Drawing.Point(12, 408);
this.lblTotalRecords.Name = "lblTotalRecords";
this.lblTotalRecords.Size = new System.Drawing.Size(98, 15);
this.lblTotalRecords.TabIndex = 2;
this.lblTotalRecords.Text = "Total Records: ???";
//
// gB1
//
this.gB1.Controls.Add(this.btnReload);
this.gB1.Controls.Add(this.rdbStock);
this.gB1.Controls.Add(this.rdbNorth);
this.gB1.Location = new System.Drawing.Point(157, 411);
this.gB1.Name = "gB1";
this.gB1.Size = new System.Drawing.Size(248, 35);
this.gB1.TabIndex = 3;
this.gB1.TabStop = false;
//
// btnReload
//
this.btnReload.Location = new System.Drawing.Point(158, 9);
this.btnReload.Name = "btnReload";
this.btnReload.Size = new System.Drawing.Size(75, 23);
this.btnReload.TabIndex = 2;
this.btnReload.Text = "Reload";
this.btnReload.UseVisualStyleBackColor = true;
this.btnReload.Click += new System.EventHandler(this.btnReload_Click);
//
// rdbStock
//
this.rdbStock.AutoSize = true;
this.rdbStock.Checked = true;
this.rdbStock.Location = new System.Drawing.Point(98, 9);
this.rdbStock.Name = "rdbStock";
this.rdbStock.Size = new System.Drawing.Size(54, 19);
this.rdbStock.TabIndex = 1;
this.rdbStock.TabStop = true;
this.rdbStock.Text = "Stock";
this.rdbStock.UseVisualStyleBackColor = true;
//
// rdbNorth
//
this.rdbNorth.AutoSize = true;
this.rdbNorth.Location = new System.Drawing.Point(7, 9);
this.rdbNorth.Name = "rdbNorth";
this.rdbNorth.Size = new System.Drawing.Size(84, 19);
this.rdbNorth.TabIndex = 0;
this.rdbNorth.Text = "NorthWind";
this.rdbNorth.UseVisualStyleBackColor = true;
//
// btnTestScrapFunction
//
this.btnTestScrapFunction.Location = new System.Drawing.Point(12, 452);
this.btnTestScrapFunction.Name = "btnTestScrapFunction";
this.btnTestScrapFunction.Size = new System.Drawing.Size(75, 23);
this.btnTestScrapFunction.TabIndex = 4;
this.btnTestScrapFunction.Text = "LoadScrap";
this.btnTestScrapFunction.UseVisualStyleBackColor = true;
this.btnTestScrapFunction.Click += new System.EventHandler(this.btnTestScrapFunction_Click);
//
// lblStockRows
//
this.lblStockRows.AutoSize = true;
this.lblStockRows.Location = new System.Drawing.Point(93, 456);
this.lblStockRows.Name = "lblStockRows";
this.lblStockRows.Size = new System.Drawing.Size(14, 15);
this.lblStockRows.TabIndex = 5;
this.lblStockRows.Text = "#";
//
// button1
//
this.button1.Location = new System.Drawing.Point(157, 452);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 6;
this.button1.Text = "ReLoad";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// chbShowBrowser
//
this.chbShowBrowser.AutoSize = true;
this.chbShowBrowser.Location = new System.Drawing.Point(12, 478);
this.chbShowBrowser.Name = "chbShowBrowser";
this.chbShowBrowser.Size = new System.Drawing.Size(100, 22);
this.chbShowBrowser.TabIndex = 7;
this.chbShowBrowser.Text = "Show Browser";
this.chbShowBrowser.UseCompatibleTextRendering = true;
this.chbShowBrowser.UseVisualStyleBackColor = true;
//
// gbStockMgmnt
//
this.gbStockMgmnt.Controls.Add(this.btnValueView);
this.gbStockMgmnt.Controls.Add(this.btnStockReg);
this.gbStockMgmnt.Location = new System.Drawing.Point(411, 411);
this.gbStockMgmnt.Name = "gbStockMgmnt";
this.gbStockMgmnt.Size = new System.Drawing.Size(257, 123);
this.gbStockMgmnt.TabIndex = 8;
this.gbStockMgmnt.TabStop = false;
//
// btnStockReg
//
this.btnStockReg.Location = new System.Drawing.Point(6, 9);
this.btnStockReg.Name = "btnStockReg";
this.btnStockReg.Size = new System.Drawing.Size(96, 23);
this.btnStockReg.TabIndex = 0;
this.btnStockReg.Text = "Stock Purchase";
this.btnStockReg.UseVisualStyleBackColor = true;
this.btnStockReg.Click += new System.EventHandler(this.btnStockReg_Click);
//
// btnValueView
//
this.btnValueView.Location = new System.Drawing.Point(7, 39);
this.btnValueView.Name = "btnValueView";
this.btnValueView.Size = new System.Drawing.Size(95, 23);
this.btnValueView.TabIndex = 1;
this.btnValueView.Text = "See values";
this.btnValueView.UseVisualStyleBackColor = true;
this.btnValueView.Click += new System.EventHandler(this.btnValueView_Click);
//
// frmInitial
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 546);
this.Controls.Add(this.gbStockMgmnt);
this.Controls.Add(this.chbShowBrowser);
this.Controls.Add(this.button1);
this.Controls.Add(this.lblStockRows);
this.Controls.Add(this.btnTestScrapFunction);
this.Controls.Add(this.gB1);
this.Controls.Add(this.lblTotalRecords);
this.Controls.Add(this.dataGridView);
this.MinimizeBox = false;
this.Name = "frmInitial";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Repository Pattern";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmInitial_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.gB1.ResumeLayout(false);
this.gB1.PerformLayout();
this.gbStockMgmnt.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.DataGridView dataGridView;
private System.Windows.Forms.Label lblTotalRecords;
private System.Windows.Forms.GroupBox gB1;
private System.Windows.Forms.RadioButton rdbStock;
private System.Windows.Forms.RadioButton rdbNorth;
private System.Windows.Forms.Button btnReload;
private System.Windows.Forms.Button btnTestScrapFunction;
private System.Windows.Forms.Label lblStockRows;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.CheckBox chbShowBrowser;
private System.Windows.Forms.GroupBox gbStockMgmnt;
private System.Windows.Forms.Button btnStockReg;
private System.Windows.Forms.Button btnValueView;
}
}

99
MyStocks/frmInitial.cs Normal file
View File

@ -0,0 +1,99 @@
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 RepositoryPattern
{
public partial class frmInitial : Form
{
private readonly IStockMemberRepository _stockMemberRepository;
private readonly IStockMarketRepository _stockMarketRepository;
private frmRegisterStock regWindow;
private frmMyStocks stockWindow;
public frmInitial( IStockMemberRepository stockMemberRepository, IStockMarketRepository stockMarketRepository)
{
InitializeComponent();
_stockMemberRepository = stockMemberRepository;
_stockMarketRepository = stockMarketRepository;
}
private void Form1_Load(object sender, EventArgs e)
{
ReloadData();
}
private void ReloadData()
{
dataGridView.DataSource = _stockMemberRepository.GetStocks();
lblTotalRecords.Text = $"Total records: {dataGridView.RowCount}";
}
private void btnReload_Click(object sender, EventArgs e)
{
ReloadData();
}
private void btnTestScrapFunction_Click(object sender, EventArgs e)
{
if (rdbStock.Checked)
{
_stockMarketRepository.LoadStockMarketList(chbShowBrowser.Checked);
var stocklist = _stockMarketRepository.StockMarketList;
lblStockRows.Text = stocklist.Count().ToString();
}
}
private void frmInitial_FormClosing(object sender, FormClosingEventArgs e)
{
_stockMarketRepository.Clean();
}
private void button1_Click(object sender, EventArgs e)
{
if (rdbStock.Checked)
{
lblStockRows.Text = "";
_stockMarketRepository.RefreshMarketList();
var stocklist = _stockMarketRepository.StockMarketList;
lblStockRows.Text = stocklist.Count().ToString();
}
}
private void btnStockReg_Click(object sender, EventArgs e)
{
if (rdbStock.Checked)
{
Cursor.Current = Cursors.WaitCursor;
_stockMarketRepository.LoadStockMarketList();
regWindow = new frmRegisterStock();
regWindow.Stocks = _stockMarketRepository.StockMarketList;
Cursor.Current = DefaultCursor;
regWindow.ShowDialog();
_stockMemberRepository.InsertMany(regWindow.RegisteredStocks);
}
}
private void btnValueView_Click(object sender, EventArgs e)
{
if (rdbStock.Checked)
{
Cursor.Current = Cursors.WaitCursor;
_stockMarketRepository.LoadStockMarketList();
stockWindow = new frmMyStocks(_stockMemberRepository,_stockMarketRepository);
stockWindow.Stocks = _stockMarketRepository.StockMarketList;
Cursor.Current = DefaultCursor;
stockWindow.ShowDialog();
}
}
}
}

60
MyStocks/frmInitial.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>

330
MyStocks/frmMyStocks.Designer.cs generated Normal file
View File

@ -0,0 +1,330 @@

namespace RepositoryPattern
{
partial class frmMyStocks
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.lvMyStocks = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader7 = new System.Windows.Forms.ColumnHeader();
this.columnHeader11 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
this.columnHeader8 = new System.Windows.Forms.ColumnHeader();
this.columnHeader9 = new System.Windows.Forms.ColumnHeader();
this.columnHeader10 = new System.Windows.Forms.ColumnHeader();
this.txtBuyTotal = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.txtTotDiff = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.txtCurrValue = new System.Windows.Forms.TextBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.chkAutoReload = new System.Windows.Forms.CheckBox();
this.lbUpdateTimes = new System.Windows.Forms.ListBox();
this.label4 = new System.Windows.Forms.Label();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.label5 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.SuspendLayout();
//
// lvMyStocks
//
this.lvMyStocks.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lvMyStocks.BackColor = System.Drawing.SystemColors.InactiveCaption;
this.lvMyStocks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader7,
this.columnHeader11,
this.columnHeader3,
this.columnHeader4,
this.columnHeader5,
this.columnHeader6,
this.columnHeader8,
this.columnHeader9,
this.columnHeader10});
this.lvMyStocks.GridLines = true;
this.lvMyStocks.HideSelection = false;
this.lvMyStocks.Location = new System.Drawing.Point(14, 43);
this.lvMyStocks.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.lvMyStocks.Name = "lvMyStocks";
this.lvMyStocks.Size = new System.Drawing.Size(1191, 369);
this.lvMyStocks.TabIndex = 0;
this.lvMyStocks.UseCompatibleStateImageBehavior = false;
this.lvMyStocks.View = System.Windows.Forms.View.Details;
this.lvMyStocks.DrawColumnHeader += new System.Windows.Forms.DrawListViewColumnHeaderEventHandler(this.lvMyStocks_DrawColumnHeader);
//
// columnHeader1
//
this.columnHeader1.Name = "columnHeader1";
this.columnHeader1.Text = "Stock Name";
this.columnHeader1.Width = 120;
//
// columnHeader2
//
this.columnHeader2.Name = "columnHeader2";
this.columnHeader2.Text = "Buy Price";
this.columnHeader2.Width = 80;
//
// columnHeader7
//
this.columnHeader7.Name = "columnHeader7";
this.columnHeader7.Text = "Market price";
this.columnHeader7.Width = 100;
//
// columnHeader11
//
this.columnHeader11.Name = "columnHeader11";
this.columnHeader11.Text = "Price Diff";
this.columnHeader11.Width = 100;
//
// columnHeader3
//
this.columnHeader3.Name = "columnHeader3";
this.columnHeader3.Text = "Amount Stk";
this.columnHeader3.Width = 100;
//
// columnHeader4
//
this.columnHeader4.Name = "columnHeader4";
this.columnHeader4.Text = "Buy Date";
this.columnHeader4.Width = 100;
//
// columnHeader5
//
this.columnHeader5.Name = "columnHeader5";
this.columnHeader5.Text = "Value diff";
this.columnHeader5.Width = 100;
//
// columnHeader6
//
this.columnHeader6.Name = "columnHeader6";
this.columnHeader6.Text = "Value diff %";
this.columnHeader6.Width = 80;
//
// columnHeader8
//
this.columnHeader8.Name = "columnHeader8";
this.columnHeader8.Text = "Market Date";
this.columnHeader8.Width = 100;
//
// columnHeader9
//
this.columnHeader9.Name = "columnHeader9";
this.columnHeader9.Text = "Current value";
this.columnHeader9.Width = 80;
//
// columnHeader10
//
this.columnHeader10.Name = "columnHeader10";
this.columnHeader10.Text = "Owned days";
//
// txtBuyTotal
//
this.txtBuyTotal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.txtBuyTotal.Location = new System.Drawing.Point(186, 428);
this.txtBuyTotal.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.txtBuyTotal.Name = "txtBuyTotal";
this.txtBuyTotal.ReadOnly = true;
this.txtBuyTotal.Size = new System.Drawing.Size(114, 27);
this.txtBuyTotal.TabIndex = 1;
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label1.Location = new System.Drawing.Point(64, 425);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(101, 21);
this.label1.TabIndex = 2;
this.label1.Text = "Bought Totalt";
//
// label2
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label2.Location = new System.Drawing.Point(307, 425);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(55, 21);
this.label2.TabIndex = 4;
this.label2.Text = "TotDiff";
//
// txtTotDiff
//
this.txtTotDiff.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.txtTotDiff.Location = new System.Drawing.Point(377, 428);
this.txtTotDiff.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.txtTotDiff.Name = "txtTotDiff";
this.txtTotDiff.ReadOnly = true;
this.txtTotDiff.Size = new System.Drawing.Size(114, 27);
this.txtTotDiff.TabIndex = 3;
//
// label3
//
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label3.Location = new System.Drawing.Point(582, 425);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(105, 21);
this.label3.TabIndex = 6;
this.label3.Text = "Current Value";
//
// txtCurrValue
//
this.txtCurrValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.txtCurrValue.Location = new System.Drawing.Point(709, 428);
this.txtCurrValue.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.txtCurrValue.Name = "txtCurrValue";
this.txtCurrValue.ReadOnly = true;
this.txtCurrValue.Size = new System.Drawing.Size(114, 27);
this.txtCurrValue.TabIndex = 5;
//
// timer1
//
this.timer1.Interval = 150000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// chkAutoReload
//
this.chkAutoReload.AutoSize = true;
this.chkAutoReload.Location = new System.Drawing.Point(15, 9);
this.chkAutoReload.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.chkAutoReload.Name = "chkAutoReload";
this.chkAutoReload.Size = new System.Drawing.Size(148, 24);
this.chkAutoReload.TabIndex = 7;
this.chkAutoReload.Text = "Automatic Reload";
this.chkAutoReload.UseVisualStyleBackColor = true;
this.chkAutoReload.CheckedChanged += new System.EventHandler(this.chkAutoReload_CheckedChanged);
//
// lbUpdateTimes
//
this.lbUpdateTimes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lbUpdateTimes.FormattingEnabled = true;
this.lbUpdateTimes.ItemHeight = 20;
this.lbUpdateTimes.Location = new System.Drawing.Point(16, 500);
this.lbUpdateTimes.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.lbUpdateTimes.Name = "lbUpdateTimes";
this.lbUpdateTimes.Size = new System.Drawing.Size(137, 124);
this.lbUpdateTimes.TabIndex = 8;
//
// label4
//
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(14, 472);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(97, 20);
this.label4.TabIndex = 9;
this.label4.Text = "LatestUpdate";
//
// numericUpDown1
//
this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.numericUpDown1.Location = new System.Drawing.Point(161, 593);
this.numericUpDown1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(119, 27);
this.numericUpDown1.TabIndex = 10;
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
//
// label5
//
this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(160, 569);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(132, 20);
this.label5.TabIndex = 11;
this.label5.Text = "Uppdatering (min)";
//
// frmMyStocks
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1217, 651);
this.Controls.Add(this.label5);
this.Controls.Add(this.numericUpDown1);
this.Controls.Add(this.label4);
this.Controls.Add(this.lbUpdateTimes);
this.Controls.Add(this.chkAutoReload);
this.Controls.Add(this.label3);
this.Controls.Add(this.txtCurrValue);
this.Controls.Add(this.label2);
this.Controls.Add(this.txtTotDiff);
this.Controls.Add(this.label1);
this.Controls.Add(this.txtBuyTotal);
this.Controls.Add(this.lvMyStocks);
this.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.Name = "frmMyStocks";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "frmMyStocks";
this.Shown += new System.EventHandler(this.frmMyStocks_Shown);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ListView lvMyStocks;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.ColumnHeader columnHeader5;
private System.Windows.Forms.ColumnHeader columnHeader6;
private System.Windows.Forms.ColumnHeader columnHeader7;
private System.Windows.Forms.ColumnHeader columnHeader8;
private System.Windows.Forms.ColumnHeader columnHeader9;
private System.Windows.Forms.ColumnHeader columnHeader10;
private System.Windows.Forms.TextBox txtBuyTotal;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtTotDiff;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtCurrValue;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.CheckBox chkAutoReload;
private System.Windows.Forms.ListBox lbUpdateTimes;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ColumnHeader columnHeader11;
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.Label label5;
}
}

134
MyStocks/frmMyStocks.cs Normal file
View File

@ -0,0 +1,134 @@
using StockDal.Interface;
using StockDomain;
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 RepositoryPattern
{
public partial class frmMyStocks : Form
{
Color hdrColor;
private readonly IStockMemberRepository _stockMemberRepository;
private readonly IStockMarketRepository _stockMarketRepository;
public decimal BoughtSum { get; set; }
public decimal TotalDiff { get; set; }
public decimal CurrentSum { get; set; }
public Dictionary<string, DiTraderStockRow> Stocks { get; set; }
public IEnumerable<StockMember> CurrentStocks { get; set; }
public frmMyStocks(IStockMemberRepository stockMemberRepository, IStockMarketRepository stockMarketRepository)
{
hdrColor = Color.CadetBlue;
InitializeComponent();
_stockMemberRepository = stockMemberRepository;
_stockMarketRepository = stockMarketRepository;
numericUpDown1.Value = timer1.Interval / 60000;
numericUpDown1.Enabled = false;
}
private void ReloadData()
{
CurrentStocks = _stockMemberRepository.GetStocks();
lvMyStocks.Items.Clear();
BoughtSum = 0m;
TotalDiff = 0m;
CurrentSum = 0m;
foreach (var stock in CurrentStocks)
{
stock.ActValue = Stocks[stock.StockId.Trim()].LatestPrice;
stock.ActDate = DateTime.Today;
_stockMemberRepository.UpdateActPrice(stock.Id, stock.ActValue);
AddItemToListView(stock);
}
txtBuyTotal.Text = BoughtSum.ToString();
txtBuyTotal.Refresh();
txtCurrValue.Text = CurrentSum.ToString();
txtCurrValue.Refresh();
txtTotDiff.Text = TotalDiff.ToString();
txtTotDiff.Refresh();
}
private void TotalReload()
{
_stockMarketRepository.LoadStockMarketList();
Stocks = _stockMarketRepository.StockMarketList;
ReloadData();
lbUpdateTimes.Items.Add(DateTime.Now.ToLongTimeString());
}
private void lvMyStocks_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
using (Brush hBr = new SolidBrush(hdrColor))
{
e.Graphics.FillRectangle(hBr, e.Bounds);
e.DrawText();
}
}
private void AddItemToListView(StockMember currStock)
{
var lv = lvMyStocks.Items.Add(currStock.StockId);
lv.SubItems.Add(currStock.BuyValue.ToString());
var currValue = lv.SubItems.Add(currStock.ActValue.ToString());
//var saveBcolor = currValue.BackColor;
//var valueLevel = currStock.ActValue - currStock.BuyValue;
//currValue.ForeColor = valueLevel > 5 ? Color.Red : saveBcolor;
var priceDiff = currStock.ActValue - currStock.BuyValue;
lv.SubItems.Add(priceDiff.ToString());
lv.SubItems.Add(currStock.PostAmount.ToString());
lv.SubItems.Add(currStock.BuyDate.ToString());
var buyValue = currStock.PostAmount * currStock.BuyValue;
var actValue = currStock.PostAmount * currStock.ActValue;
var diffValue = actValue - buyValue;
var diffproc = diffValue / buyValue * 100;
BoughtSum += buyValue;
TotalDiff += diffValue;
CurrentSum += actValue;
var lvs = lv.SubItems.Add(diffValue.ToString());
lv.SubItems.Add(Math.Round(diffproc, 2).ToString());
lv.SubItems.Add(currStock.ActDate.ToString());
lv.SubItems.Add(actValue.ToString());
var owned = (DateTime.Today - currStock.BuyDate).TotalDays;
lv.SubItems.Add(owned.ToString());
if (diffValue < 0)
{
lv.BackColor = Color.Pink;
}
else
{
lv.BackColor = Color.LightGreen;
}
}
private void frmMyStocks_Shown(object sender, EventArgs e)
{
ReloadData();
}
private void timer1_Tick(object sender, EventArgs e)
{
TotalReload();
}
private void chkAutoReload_CheckedChanged(object sender, EventArgs e)
{
timer1.Enabled = chkAutoReload.Checked;
numericUpDown1.Enabled = chkAutoReload.Checked;
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
timer1.Interval = Convert.ToInt32(numericUpDown1.Value * 60000);
}
}
}

60
MyStocks/frmMyStocks.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>

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

@ -0,0 +1,377 @@

namespace RepositoryPattern
{
partial class frmRegisterStock
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cmbStockChoser = new System.Windows.Forms.ComboBox();
this.btnClose = new System.Windows.Forms.Button();
this.lblStockExtId = new System.Windows.Forms.Label();
this.txtStockExtId = new System.Windows.Forms.TextBox();
this.txtBuyPrice = new System.Windows.Forms.TextBox();
this.lblBuyPrice = new System.Windows.Forms.Label();
this.txtBuyDate = new System.Windows.Forms.TextBox();
this.lblBuyDate = new System.Windows.Forms.Label();
this.txtBoughtAmount = new System.Windows.Forms.TextBox();
this.lblBoughtAmount = new System.Windows.Forms.Label();
this.txtActValue = new System.Windows.Forms.TextBox();
this.lblActValue = new System.Windows.Forms.Label();
this.txtActDate = new System.Windows.Forms.TextBox();
this.lblActDate = new System.Windows.Forms.Label();
this.txtActAmount = new System.Windows.Forms.TextBox();
this.lblRemaining = new System.Windows.Forms.Label();
this.txtSoldPrice = new System.Windows.Forms.TextBox();
this.lblSoldValue = new System.Windows.Forms.Label();
this.txtSoldDate = new System.Windows.Forms.TextBox();
this.lblSoldDate = new System.Windows.Forms.Label();
this.txtComment = new System.Windows.Forms.TextBox();
this.lblComment = new System.Windows.Forms.Label();
this.btnSaveStock = new System.Windows.Forms.Button();
this.lwRegBuffer = new System.Windows.Forms.ListView();
this.Stock = new System.Windows.Forms.ColumnHeader();
this.Price = new System.Windows.Forms.ColumnHeader();
this.Number = new System.Windows.Forms.ColumnHeader();
this.Comment = new System.Windows.Forms.ColumnHeader();
this.btnSaveToDB = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// cmbStockChoser
//
this.cmbStockChoser.FormattingEnabled = true;
this.cmbStockChoser.Location = new System.Drawing.Point(38, 39);
this.cmbStockChoser.Name = "cmbStockChoser";
this.cmbStockChoser.Size = new System.Drawing.Size(179, 23);
this.cmbStockChoser.TabIndex = 0;
this.cmbStockChoser.SelectedIndexChanged += new System.EventHandler(this.cmbStockChoser_SelectedIndexChanged);
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(347, 567);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 23);
this.btnClose.TabIndex = 1;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// lblStockExtId
//
this.lblStockExtId.AutoSize = true;
this.lblStockExtId.Location = new System.Drawing.Point(38, 78);
this.lblStockExtId.Name = "lblStockExtId";
this.lblStockExtId.Size = new System.Drawing.Size(62, 15);
this.lblStockExtId.TabIndex = 2;
this.lblStockExtId.Text = "StockExtId";
//
// txtStockExtId
//
this.txtStockExtId.Location = new System.Drawing.Point(153, 75);
this.txtStockExtId.Name = "txtStockExtId";
this.txtStockExtId.Size = new System.Drawing.Size(269, 23);
this.txtStockExtId.TabIndex = 3;
//
// txtBuyPrice
//
this.txtBuyPrice.Location = new System.Drawing.Point(153, 104);
this.txtBuyPrice.Name = "txtBuyPrice";
this.txtBuyPrice.Size = new System.Drawing.Size(111, 23);
this.txtBuyPrice.TabIndex = 5;
//
// lblBuyPrice
//
this.lblBuyPrice.AutoSize = true;
this.lblBuyPrice.Location = new System.Drawing.Point(38, 107);
this.lblBuyPrice.Name = "lblBuyPrice";
this.lblBuyPrice.Size = new System.Drawing.Size(56, 15);
this.lblBuyPrice.TabIndex = 4;
this.lblBuyPrice.Text = "Buy price";
//
// txtBuyDate
//
this.txtBuyDate.Location = new System.Drawing.Point(153, 133);
this.txtBuyDate.Name = "txtBuyDate";
this.txtBuyDate.Size = new System.Drawing.Size(142, 23);
this.txtBuyDate.TabIndex = 7;
//
// lblBuyDate
//
this.lblBuyDate.AutoSize = true;
this.lblBuyDate.Location = new System.Drawing.Point(38, 136);
this.lblBuyDate.Name = "lblBuyDate";
this.lblBuyDate.Size = new System.Drawing.Size(73, 15);
this.lblBuyDate.TabIndex = 6;
this.lblBuyDate.Text = "Bought Date";
//
// txtBoughtAmount
//
this.txtBoughtAmount.Location = new System.Drawing.Point(153, 162);
this.txtBoughtAmount.Name = "txtBoughtAmount";
this.txtBoughtAmount.Size = new System.Drawing.Size(111, 23);
this.txtBoughtAmount.TabIndex = 9;
this.txtBoughtAmount.TextChanged += new System.EventHandler(this.txtBoughtAmount_TextChanged);
//
// lblBoughtAmount
//
this.lblBoughtAmount.AutoSize = true;
this.lblBoughtAmount.Location = new System.Drawing.Point(38, 165);
this.lblBoughtAmount.Name = "lblBoughtAmount";
this.lblBoughtAmount.Size = new System.Drawing.Size(93, 15);
this.lblBoughtAmount.TabIndex = 8;
this.lblBoughtAmount.Text = "Bought Number";
//
// txtActValue
//
this.txtActValue.Location = new System.Drawing.Point(153, 191);
this.txtActValue.Name = "txtActValue";
this.txtActValue.Size = new System.Drawing.Size(111, 23);
this.txtActValue.TabIndex = 11;
//
// lblActValue
//
this.lblActValue.AutoSize = true;
this.lblActValue.Location = new System.Drawing.Point(38, 194);
this.lblActValue.Name = "lblActValue";
this.lblActValue.Size = new System.Drawing.Size(76, 15);
this.lblActValue.TabIndex = 10;
this.lblActValue.Text = "Current price";
//
// txtActDate
//
this.txtActDate.Location = new System.Drawing.Point(153, 220);
this.txtActDate.Name = "txtActDate";
this.txtActDate.Size = new System.Drawing.Size(142, 23);
this.txtActDate.TabIndex = 13;
//
// lblActDate
//
this.lblActDate.AutoSize = true;
this.lblActDate.Location = new System.Drawing.Point(38, 223);
this.lblActDate.Name = "lblActDate";
this.lblActDate.Size = new System.Drawing.Size(61, 15);
this.lblActDate.TabIndex = 12;
this.lblActDate.Text = "Value date";
//
// txtActAmount
//
this.txtActAmount.Location = new System.Drawing.Point(153, 249);
this.txtActAmount.Name = "txtActAmount";
this.txtActAmount.Size = new System.Drawing.Size(111, 23);
this.txtActAmount.TabIndex = 15;
//
// lblRemaining
//
this.lblRemaining.AutoSize = true;
this.lblRemaining.Location = new System.Drawing.Point(38, 252);
this.lblRemaining.Name = "lblRemaining";
this.lblRemaining.Size = new System.Drawing.Size(109, 15);
this.lblRemaining.TabIndex = 14;
this.lblRemaining.Text = "Remaining number";
//
// txtSoldPrice
//
this.txtSoldPrice.Location = new System.Drawing.Point(153, 278);
this.txtSoldPrice.Name = "txtSoldPrice";
this.txtSoldPrice.Size = new System.Drawing.Size(111, 23);
this.txtSoldPrice.TabIndex = 17;
//
// lblSoldValue
//
this.lblSoldValue.AutoSize = true;
this.lblSoldValue.Location = new System.Drawing.Point(38, 281);
this.lblSoldValue.Name = "lblSoldValue";
this.lblSoldValue.Size = new System.Drawing.Size(59, 15);
this.lblSoldValue.TabIndex = 16;
this.lblSoldValue.Text = "Sold price";
//
// txtSoldDate
//
this.txtSoldDate.Location = new System.Drawing.Point(153, 307);
this.txtSoldDate.Name = "txtSoldDate";
this.txtSoldDate.Size = new System.Drawing.Size(142, 23);
this.txtSoldDate.TabIndex = 19;
//
// lblSoldDate
//
this.lblSoldDate.AutoSize = true;
this.lblSoldDate.Location = new System.Drawing.Point(38, 310);
this.lblSoldDate.Name = "lblSoldDate";
this.lblSoldDate.Size = new System.Drawing.Size(57, 15);
this.lblSoldDate.TabIndex = 18;
this.lblSoldDate.Text = "Sold Date";
//
// txtComment
//
this.txtComment.Location = new System.Drawing.Point(153, 336);
this.txtComment.Multiline = true;
this.txtComment.Name = "txtComment";
this.txtComment.Size = new System.Drawing.Size(269, 72);
this.txtComment.TabIndex = 21;
//
// lblComment
//
this.lblComment.AutoSize = true;
this.lblComment.Location = new System.Drawing.Point(39, 339);
this.lblComment.Name = "lblComment";
this.lblComment.Size = new System.Drawing.Size(61, 15);
this.lblComment.TabIndex = 20;
this.lblComment.Text = "Comment";
//
// btnSaveStock
//
this.btnSaveStock.Location = new System.Drawing.Point(39, 385);
this.btnSaveStock.Name = "btnSaveStock";
this.btnSaveStock.Size = new System.Drawing.Size(75, 23);
this.btnSaveStock.TabIndex = 23;
this.btnSaveStock.Text = "Register";
this.btnSaveStock.UseVisualStyleBackColor = true;
this.btnSaveStock.Click += new System.EventHandler(this.btnSaveStock_Click);
//
// lwRegBuffer
//
this.lwRegBuffer.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.Stock,
this.Price,
this.Number,
this.Comment});
this.lwRegBuffer.GridLines = true;
this.lwRegBuffer.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.lwRegBuffer.HideSelection = false;
this.lwRegBuffer.Location = new System.Drawing.Point(39, 427);
this.lwRegBuffer.Name = "lwRegBuffer";
this.lwRegBuffer.Size = new System.Drawing.Size(383, 119);
this.lwRegBuffer.TabIndex = 24;
this.lwRegBuffer.UseCompatibleStateImageBehavior = false;
this.lwRegBuffer.View = System.Windows.Forms.View.Details;
this.lwRegBuffer.DrawColumnHeader += new System.Windows.Forms.DrawListViewColumnHeaderEventHandler(this.lwRegBuffer_DrawColumnHeader);
//
// Stock
//
this.Stock.Name = "Stock";
this.Stock.Text = "Stock";
this.Stock.Width = 120;
//
// Price
//
this.Price.Name = "Price";
this.Price.Text = "Price";
this.Price.Width = 80;
//
// Number
//
this.Number.Name = "Number";
this.Number.Text = "Number";
this.Number.Width = 80;
//
// Comment
//
this.Comment.Name = "Comment";
this.Comment.Text = "Comment";
this.Comment.Width = 120;
//
// btnSaveToDB
//
this.btnSaveToDB.Location = new System.Drawing.Point(266, 567);
this.btnSaveToDB.Name = "btnSaveToDB";
this.btnSaveToDB.Size = new System.Drawing.Size(75, 23);
this.btnSaveToDB.TabIndex = 25;
this.btnSaveToDB.Text = "Save";
this.btnSaveToDB.UseVisualStyleBackColor = true;
this.btnSaveToDB.Click += new System.EventHandler(this.btnSaveToDB_Click);
//
// frmRegisterStock
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(441, 602);
this.Controls.Add(this.btnSaveToDB);
this.Controls.Add(this.lwRegBuffer);
this.Controls.Add(this.btnSaveStock);
this.Controls.Add(this.txtComment);
this.Controls.Add(this.lblComment);
this.Controls.Add(this.txtSoldDate);
this.Controls.Add(this.lblSoldDate);
this.Controls.Add(this.txtSoldPrice);
this.Controls.Add(this.lblSoldValue);
this.Controls.Add(this.txtActAmount);
this.Controls.Add(this.lblRemaining);
this.Controls.Add(this.txtActDate);
this.Controls.Add(this.lblActDate);
this.Controls.Add(this.txtActValue);
this.Controls.Add(this.lblActValue);
this.Controls.Add(this.txtBoughtAmount);
this.Controls.Add(this.lblBoughtAmount);
this.Controls.Add(this.txtBuyDate);
this.Controls.Add(this.lblBuyDate);
this.Controls.Add(this.txtBuyPrice);
this.Controls.Add(this.lblBuyPrice);
this.Controls.Add(this.txtStockExtId);
this.Controls.Add(this.lblStockExtId);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.cmbStockChoser);
this.Name = "frmRegisterStock";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "frmRegisterStock";
this.Shown += new System.EventHandler(this.frmRegisterStock_Shown);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ComboBox cmbStockChoser;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Label lblStockExtId;
private System.Windows.Forms.TextBox txtStockExtId;
private System.Windows.Forms.TextBox txtBuyPrice;
private System.Windows.Forms.Label lblBuyPrice;
private System.Windows.Forms.TextBox txtBuyDate;
private System.Windows.Forms.Label lblBuyDate;
private System.Windows.Forms.TextBox txtBoughtAmount;
private System.Windows.Forms.Label lblBoughtAmount;
private System.Windows.Forms.TextBox txtActValue;
private System.Windows.Forms.Label lblActValue;
private System.Windows.Forms.TextBox txtActDate;
private System.Windows.Forms.Label lblActDate;
private System.Windows.Forms.TextBox txtActAmount;
private System.Windows.Forms.Label lblRemaining;
private System.Windows.Forms.TextBox txtSoldPrice;
private System.Windows.Forms.Label lblSoldValue;
private System.Windows.Forms.TextBox txtSoldDate;
private System.Windows.Forms.Label lblSoldDate;
private System.Windows.Forms.TextBox txtComment;
private System.Windows.Forms.Label lblComment;
private System.Windows.Forms.Button btnSaveStock;
private System.Windows.Forms.ListView lwRegBuffer;
private System.Windows.Forms.ColumnHeader Stock;
private System.Windows.Forms.ColumnHeader Price;
private System.Windows.Forms.ColumnHeader Number;
private System.Windows.Forms.ColumnHeader Comment;
private System.Windows.Forms.Button btnSaveToDB;
}
}

View File

@ -0,0 +1,129 @@
using StockDomain;
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 RepositoryPattern
{
public partial class frmRegisterStock : Form
{
Color hdr = Color.Red;
public Dictionary<string, DiTraderStockRow> Stocks { get; set; }
public List<StockMember> RegisteredStocks { get; set; } = new List<StockMember>();
public frmRegisterStock()
{
InitializeComponent();
}
private void LoadStockCombo()
{
if (Stocks.Count() > 0)
{
foreach (var key in Stocks.Keys)
{
cmbStockChoser.Items.Add(key);
}
}
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void frmRegisterStock_Shown(object sender, EventArgs e)
{
LoadStockCombo();
}
private void cmbStockChoser_SelectedIndexChanged(object sender, EventArgs e)
{
var stockChosen = Stocks[cmbStockChoser.SelectedItem.ToString()];
txtStockExtId.Text = stockChosen.StockName;
txtActValue.Text = stockChosen.LatestPrice.ToString();
txtActDate.Text = (DateTime.Today + stockChosen.TimeOfDay).ToString();
}
private void btnSaveStock_Click(object sender, EventArgs e)
{
AddValidateData();
RefreshListViewFromRegList();
}
private void RefreshListViewFromRegList()
{
lwRegBuffer.Items.Clear();
foreach (var currStock in RegisteredStocks)
{
AddItemToListView(currStock);
}
}
private void AddItemToListView(StockMember currStock)
{
var lv = lwRegBuffer.Items.Add(currStock.StockId);
lv.SubItems.Add(currStock.BuyValue.ToString());
lv.SubItems.Add(currStock.PostAmount.ToString());
lv.SubItems.Add(currStock.Comment);
//lv.BackColor = Color.Aquamarine;
}
private void AddValidateData()
{
var currentStock = new StockMember();
currentStock.StockId = cmbStockChoser.SelectedItem.ToString();
currentStock.StockExtId = txtStockExtId.Text;
currentStock.BuyValue = decimal.Parse(string.IsNullOrEmpty(txtBuyPrice.Text) ? "0" : txtBuyPrice.Text);
currentStock.PostAmount = long.Parse(string.IsNullOrEmpty(txtBoughtAmount.Text) ? "0" : txtBoughtAmount.Text);
currentStock.ActDate = DateTime.Parse(txtActDate.Text);
currentStock.BuyDate = string.IsNullOrWhiteSpace(txtBuyDate.Text) ? DateTime.Today : DateTime.Parse(txtBuyDate.Text);
currentStock.ActValue = decimal.Parse(string.IsNullOrEmpty(txtActValue.Text) ? "0" : txtActValue.Text);
currentStock.SoldDate = null; //DateTime.MaxValue;
currentStock.SoldValue = decimal.Parse("0");
currentStock.Comment = txtComment.Text;
RegisteredStocks.Add(currentStock);
initiateRegWin();
}
private void initiateRegWin()
{
txtStockExtId.Text = "";
txtBuyPrice.Text = "";
txtBuyDate.Text = "";
txtBoughtAmount.Text = "";
txtActValue.Text = "";
txtActDate.Text = "";
txtActAmount.Text = "";
txtSoldPrice.Text = "";
txtSoldDate.Text = "";
txtComment.Text = "";
}
private void btnSaveToDB_Click(object sender, EventArgs e)
{
}
private void txtBoughtAmount_TextChanged(object sender, EventArgs e)
{
txtActAmount.Text = txtBoughtAmount.Text;
}
private void lwRegBuffer_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
using (Brush hBr = new SolidBrush(hdr))
{
e.Graphics.FillRectangle(hBr, e.Bounds);
e.DrawText();
}
}
}
}

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>

16
MyStocks/packages.config Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Autofac" version="6.1.0" targetFramework="net472" />
<package id="Dapper" version="2.0.78" targetFramework="net472" />
<package id="HtmlAgilityPack" version="1.11.30" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="5.0.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
<package id="Selenium.WebDriver.ChromeDriver" version="88.0.4324.9600" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Data.SqlClient" version="4.8.2" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="5.0.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
</packages>

43
MyStocksApp.sln Normal file
View File

@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31005.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyStocks", "MyStocks\MyStocks.csproj", "{B72206DB-4BA5-4C74-B61D-8CCAB6DA9634}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockDal", "StockDal\StockDal.csproj", "{4A000259-9A8E-4A83-BDCF-40D06A2EE6CF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockDal.Interface", "StockDal.Interface\StockDal.Interface.csproj", "{3E23C2D6-3257-42B1-A6DF-F6F7B7E71B17}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockDomain", "StockDomain\StockDomain.csproj", "{A4B17E50-0FF3-4B94-81F8-E7AAB3D333DF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B72206DB-4BA5-4C74-B61D-8CCAB6DA9634}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B72206DB-4BA5-4C74-B61D-8CCAB6DA9634}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B72206DB-4BA5-4C74-B61D-8CCAB6DA9634}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B72206DB-4BA5-4C74-B61D-8CCAB6DA9634}.Release|Any CPU.Build.0 = Release|Any CPU
{4A000259-9A8E-4A83-BDCF-40D06A2EE6CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A000259-9A8E-4A83-BDCF-40D06A2EE6CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A000259-9A8E-4A83-BDCF-40D06A2EE6CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A000259-9A8E-4A83-BDCF-40D06A2EE6CF}.Release|Any CPU.Build.0 = Release|Any CPU
{3E23C2D6-3257-42B1-A6DF-F6F7B7E71B17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E23C2D6-3257-42B1-A6DF-F6F7B7E71B17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E23C2D6-3257-42B1-A6DF-F6F7B7E71B17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E23C2D6-3257-42B1-A6DF-F6F7B7E71B17}.Release|Any CPU.Build.0 = Release|Any CPU
{A4B17E50-0FF3-4B94-81F8-E7AAB3D333DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4B17E50-0FF3-4B94-81F8-E7AAB3D333DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4B17E50-0FF3-4B94-81F8-E7AAB3D333DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4B17E50-0FF3-4B94-81F8-E7AAB3D333DF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {782C8C8E-4779-4501-8551-F139EECBE385}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,20 @@
using StockDomain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StockDal.Interface
{
public interface IStockMarketRepository
{
Dictionary<string, DiTraderStockRow> StockMarketList { get; set; }
bool ViewBrowser { get; set; }
void Clean();
void LoadStockMarketList();
void LoadStockMarketList(bool viewBrowser);
void RefreshMarketList();
}
}

View File

@ -0,0 +1,15 @@
using StockDomain;
using System;
using System.Collections.Generic;
namespace StockDal.Interface
{
public interface IStockMemberRepository
{
IEnumerable<StockMember> GetStocks();
//bool Insert(StockMember stockMember);
void UpdateActPrice(int Id, decimal price);
bool Delete(string stockMemberId);
void InsertMany(List<StockMember> stockMembers);
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("StockDal.Interface")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StockDal.Interface")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3e23c2d6-3257-42b1-a6df-f6f7b7e71b17")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3E23C2D6-3257-42B1-A6DF-F6F7B7E71B17}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StockDal.Interface</RootNamespace>
<AssemblyName>StockDal.Interface</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="IStockMarketRepository.cs" />
<Compile Include="IStockMemberRepository.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StockDomain\StockDomain.csproj">
<Project>{a4b17e50-0ff3-4b94-81f8-e7aab3d333df}</Project>
<Name>StockDomain</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

18
StockDal/AppConnection.cs Normal file
View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RepositoryPattern
{
public class AppConnection
{
public static string ConnectionString => ConfigurationManager.ConnectionStrings["cn"].ConnectionString;
}
public class StockDBConnection
{
public static string ConnectionString => ConfigurationManager.ConnectionStrings["StockDB"].ConnectionString;
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("StockDal")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StockDal")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4a000259-9a8e-4a83-bdcf-40d06a2ee6cf")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

104
StockDal/StockDal.csproj Normal file
View File

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4A000259-9A8E-4A83-BDCF-40D06A2EE6CF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StockDal</RootNamespace>
<AssemblyName>StockDal</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dapper, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapper.2.0.78\lib\net461\Dapper.dll</HintPath>
</Reference>
<Reference Include="HtmlAgilityPack, Version=1.11.30.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.1.11.30\lib\Net45\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Selenium.WebDriverBackedSelenium, Version=3.141.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.WebDriverBackedSelenium.3.141.0\lib\net45\Selenium.WebDriverBackedSelenium.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.ConfigurationManager, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Configuration.ConfigurationManager.5.0.0\lib\net461\System.Configuration.ConfigurationManager.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Data.OracleClient" />
<Reference Include="System.Data.SqlClient, Version=4.6.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SqlClient.4.8.2\lib\net461\System.Data.SqlClient.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Net" />
<Reference Include="System.Security" />
<Reference Include="System.Security.AccessControl, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.AccessControl.5.0.0\lib\net461\System.Security.AccessControl.dll</HintPath>
</Reference>
<Reference Include="System.Security.Permissions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Permissions.5.0.0\lib\net461\System.Security.Permissions.dll</HintPath>
</Reference>
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
</Reference>
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WebDriver, Version=3.141.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.WebDriver.3.141.0\lib\net45\WebDriver.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppConnection.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StockMarketRepository.cs" />
<Compile Include="StockMemberRepository.cs" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StockDal.Interface\StockDal.Interface.csproj">
<Project>{3e23c2d6-3257-42b1-a6df-f6f7b7e71b17}</Project>
<Name>StockDal.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\StockDomain\StockDomain.csproj">
<Project>{a4b17e50-0ff3-4b94-81f8-e7aab3d333df}</Project>
<Name>StockDomain</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,230 @@
using Newtonsoft.Json;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using StockDal.Interface;
using StockDomain;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StockDal
{
public class StockMarketRepository : IStockMarketRepository
{
public Dictionary<string, DiTraderStockRow> StockMarketList { get; set; }
public List<DiTraderStockRow> DumpObjects { get; set; } = new List<DiTraderStockRow>();
public DiTraderStockRow SaveRow { get; set; }
public StringBuilder TextResults { get; set; }
public bool ViewBrowser { get; set; }
public IWebDriver driver;
public StockMarketRepository()
{
ViewBrowser = false;
}
private void Find_Data()
{
TextResults = new StringBuilder();
IList<IWebElement> searchElements = driver.FindElements(By.TagName("tbody"));
foreach (IWebElement i in searchElements)
{
HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
var text = i.GetAttribute("innerHTML");
htmlDocument.LoadHtml(text);
var inputs = htmlDocument.DocumentNode.Descendants("tr").ToList();
foreach (var items in inputs)
{
HtmlAgilityPack.HtmlDocument htmlDocument1 = new HtmlAgilityPack.HtmlDocument();
htmlDocument1.LoadHtml(items.InnerHtml);
var tds = htmlDocument1.DocumentNode.Descendants("td").ToList();
var appendText = "";
var fNr = 0;
foreach (var item in tds)
{
var intext = item.InnerText.Replace("\r\n", "");
appendText += appendText.Length == 0 ? intext : " " + intext;
if (tds.Count == 10)
{
AddValueToListRow(fNr++, intext);
}
}
if (!string.IsNullOrEmpty(appendText))
{
TextResults.Append(appendText + "\r\n");
}
htmlDocument1 = null;
}
htmlDocument = null;
TextResults.Append("\r\n");
}
// var oxe = StockMarketList;
}
private void SaveLogging()
{
var output = JsonConvert.SerializeObject(DumpObjects, Formatting.Indented);
File.WriteAllText($"D:\\TimCoDemos\\DemoLogs\\Log{DateTime.Now.ToShortDateString()}.txt",output);
}
private void AddValueToListRow(int pos, string value)
{
switch (pos)
{
case 0:
{
SaveRow = new DiTraderStockRow();
SaveRow.StockName = value;
break;
}
case 1:
{
SaveRow.ProcChange = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
break;
}
case 2:
{
SaveRow.RealChange = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
break;
}
case 3:
{
SaveRow.BuyPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
break;
}
case 4:
{
SaveRow.SellPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
break;
}
case 5:
{
SaveRow.LatestPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
break;
}
case 6:
{
SaveRow.HighestPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
break;
}
case 7:
{
SaveRow.LowestPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
break;
}
case 8:
{
SaveRow.Volume = string.IsNullOrWhiteSpace(value) ? 0 : long.Parse(value.Replace(" ", ""));
break;
}
case 9:
{
SaveRow.TimeOfDay = value==""?TimeSpan.Parse("00:01"): TimeSpan.Parse(value);
//StockMarketList.Add(SaveRow.StockName, SaveRow);
try
{
StockMarketList.Add(SaveRow.StockName, SaveRow);
}
catch (ArgumentException ae)
{
try
{
StockMarketList.Add(SaveRow.StockName + "-2", SaveRow);
}
catch (Exception)
{
DumpObjects.Add(SaveRow);
}
}
break;
}
default:
break;
}
}
private void OpenBrowser(bool burl2 = false)
{
var driverService = ChromeDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;
if (ViewBrowser)
{
if (driver == null)
{
driver = new ChromeDriver(driverService);
}
}
else
{
if (driver == null)
{
var options = new ChromeOptions();
options.AddArgument("headless");
driver = new ChromeDriver(driverService, options);
}
}
try
{
//var url0 = "https://money.cnn.com/data/hotstocks/index.html";
var url = "https://trader.di.se/index.php/stocklist/index/2055?list=7126";
var url2 = "https://trader.di.se/index.php/stocklist/index/2055?list=7116";
//var url1 = "https://www.finansportalen.se/aktiekurser/";
driver.Navigate().GoToUrl(burl2 ? url2 : url);
}
catch
{
throw;
}
}
public void LoadStockMarketList()
{
StockMarketList = new Dictionary<string, DiTraderStockRow>();
DumpObjects = new List<DiTraderStockRow>();
OpenBrowser();
Find_Data();
OpenBrowser(true);
Find_Data();
if (DumpObjects.Any())
{
SaveLogging();
}
}
public void LoadStockMarketList(bool viewBrowser)
{
StockMarketList = new Dictionary<string, DiTraderStockRow>();
ViewBrowser = viewBrowser;
OpenBrowser();
Find_Data();
}
public void RefreshMarketList()
{
StockMarketList = new Dictionary<string, DiTraderStockRow>();
driver.Navigate().Refresh();
Find_Data();
}
public void Clean()
{
driver?.Quit();
}
}
}

View File

@ -0,0 +1,89 @@
using Dapper;
using RepositoryPattern;
using StockDal.Interface;
using StockDomain;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace StockDal
{
public class StockMemberRepository : IStockMemberRepository
{
public bool Delete(string stockMemberId)
{
throw new NotImplementedException();
}
public void InsertMany(List<StockMember> stockMembers)
{
using (IDbConnection db = new SqlConnection(StockDBConnection.ConnectionString))
{
if (db.State == ConnectionState.Closed)
db.Open();
db.Execute(
@"INSERT INTO [dbo].[StockMember]
(StockId
,StockExtId
,BuyValue
,BuyDate
,ActValue
,ActDate
,SoldValue
,SoldDate
,Comment
,PostAmount)
VALUES
(@StockId
,@StockExtId
,@BuyValue
,@BuyDate
,@ActValue
,@ActDate
,@SoldValue
,@SoldDate
,@Comment
,@PostAmount)
", stockMembers);
}
}
public void UpdateActPrice(int Id, decimal price)
{
using (IDbConnection db = new SqlConnection(StockDBConnection.ConnectionString))
{
if (db.State == ConnectionState.Closed)
db.Open();
db.Execute(
@"UPDATE [dbo].[StockMember]
SET ActValue = @val,
ActDate = @date
WHERE Id = @id
", new { val = price, date = DateTime.Today, id = Id });
}
}
IEnumerable<StockMember> IStockMemberRepository.GetStocks()
{
using (IDbConnection db = new SqlConnection(StockDBConnection.ConnectionString))
{
if (db.State == ConnectionState.Closed)
db.Open();
return db.Query<StockMember>(@"SELECT Id
,StockId
,StockExtId
,BuyValue
,BuyDate
,ActValue
,ActDate
,SoldValue
,SoldDate
,Comment
,PostAmount
FROM dbo.StockMember", commandType: CommandType.Text);
}
}
}
}

13
StockDal/packages.config Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Dapper" version="2.0.78" targetFramework="net472" />
<package id="HtmlAgilityPack" version="1.11.30" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
<package id="Selenium.WebDriver" version="3.141.0" targetFramework="net472" />
<package id="Selenium.WebDriverBackedSelenium" version="3.141.0" targetFramework="net472" />
<package id="System.Configuration.ConfigurationManager" version="5.0.0" targetFramework="net472" />
<package id="System.Data.SqlClient" version="4.8.2" targetFramework="net472" />
<package id="System.Security.AccessControl" version="5.0.0" targetFramework="net472" />
<package id="System.Security.Permissions" version="5.0.0" targetFramework="net472" />
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net472" />
</packages>

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StockDomain
{
public class DiTraderStockRow
{
public string StockName { get; set; }
public decimal ProcChange { get; set; }
public decimal RealChange { get; set; }
public decimal BuyPrice { get; set; }
public decimal SellPrice { get; set; }
public decimal LatestPrice { get; set; }
public decimal HighestPrice { get; set; }
public decimal LowestPrice { get; set; }
public long Volume { get; set; }
public TimeSpan TimeOfDay { get; set; }
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("StockDomain")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StockDomain")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a4b17e50-0ff3-4b94-81f8-e7aab3d333df")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A4B17E50-0FF3-4B94-81F8-E7AAB3D333DF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StockDomain</RootNamespace>
<AssemblyName>StockDomain</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DiTraderStockRow.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StockMember.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StockDomain
{
public class StockMember
{
public int Id { get; set; }
public string StockId { get; set; }
public string StockExtId { get; set; }
public decimal BuyValue { get; set; }
public DateTime BuyDate { get; set; }
public decimal ActValue { get; set; }
public DateTime ActDate { get; set; }
public long ActAmount { get; set; }
public decimal SoldValue { get; set; }
public DateTime? SoldDate { get; set; }
// public string PostId { get; set; }
public string Comment { get; set; }
public long PostAmount { get; set; }
}
}