New editwindow , before connection

This commit is contained in:
2021-06-02 22:35:36 +02:00
parent 6c32c38296
commit dd0f9dde71
18 changed files with 1266 additions and 4 deletions

View File

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DataDomain\DataDomain.csproj" />
<ProjectReference Include="..\DatamodelLibrary\DatamodelLibrary.csproj" />
<ProjectReference Include="..\Helpers\Helpers.csproj" />
<ProjectReference Include="..\StockBL.Interface\StockBL.Interface.csproj" />
<ProjectReference Include="..\StockBL\StockBL.csproj" />
<ProjectReference Include="..\StockDal.Interface\StockDAL.Interface.csproj" />
<ProjectReference Include="..\StockDAL\StockDAL.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="frmEditStock.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HandleNewWindows
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

381
HandleNewWindows/frmEditStock.Designer.cs generated Normal file
View File

@ -0,0 +1,381 @@

namespace StockInfoCore
{
partial class frmEditStock
{
/// <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.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.btnSaveToDB = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.txtLatestSoldDate = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.txtLatestSoldPrice = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.txtStockName = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(437, 414);
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, 44);
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, 41);
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";
//
// btnSaveToDB
//
this.btnSaveToDB.Location = new System.Drawing.Point(347, 414);
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);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.txtLatestSoldDate);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.txtLatestSoldPrice);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(301, 81);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(255, 83);
this.groupBox1.TabIndex = 26;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Latest Sold";
//
// txtLatestSoldDate
//
this.txtLatestSoldDate.Location = new System.Drawing.Point(127, 52);
this.txtLatestSoldDate.Name = "txtLatestSoldDate";
this.txtLatestSoldDate.ReadOnly = true;
this.txtLatestSoldDate.Size = new System.Drawing.Size(111, 23);
this.txtLatestSoldDate.TabIndex = 9;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 55);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 15);
this.label2.TabIndex = 8;
this.label2.Text = "Sold date";
//
// txtLatestSoldPrice
//
this.txtLatestSoldPrice.Location = new System.Drawing.Point(127, 23);
this.txtLatestSoldPrice.Name = "txtLatestSoldPrice";
this.txtLatestSoldPrice.ReadOnly = true;
this.txtLatestSoldPrice.Size = new System.Drawing.Size(111, 23);
this.txtLatestSoldPrice.TabIndex = 7;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 26);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(59, 15);
this.label1.TabIndex = 6;
this.label1.Text = "Sold price";
//
// txtStockName
//
this.txtStockName.Location = new System.Drawing.Point(153, 12);
this.txtStockName.Name = "txtStockName";
this.txtStockName.Size = new System.Drawing.Size(269, 23);
this.txtStockName.TabIndex = 27;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(38, 15);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(46, 15);
this.label3.TabIndex = 28;
this.label3.Text = "StockId";
//
// frmEditStock
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(570, 452);
this.Controls.Add(this.label3);
this.Controls.Add(this.txtStockName);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.btnSaveToDB);
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.Name = "frmEditStock";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "frmRegisterStock";
this.Shown += new System.EventHandler(this.frmRegisterStock_Shown);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
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 btnSaveToDB;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox txtLatestSoldDate;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtLatestSoldPrice;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtStockName;
private System.Windows.Forms.Label label3;
}
}

View File

@ -0,0 +1,153 @@
using DataDomain;
using StockDAL.Interface;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StockInfoCore
{
public partial class frmEditStock : Form
{
Color hdr = Color.Red;
private readonly IStockRepository _stockRepository;
public int CurrentStockMember { get; set; }
//public Dictionary<string, DiTraderStockRow> Stocks { get; set; }
//public List<StockMember> RegisteredStocks { get; set; } = new List<StockMember>();
public frmEditStock(IStockRepository stockRepository)
{
InitializeComponent();
_stockRepository = stockRepository;
}
//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)
{
LoadStockData();
//LoadStockCombo();
}
private void LoadStockData()
{
var stockChosen = _stockRepository.GetStockMember(CurrentStockMember);
txtStockExtId.Text = stockChosen.StockExtId;
txtActValue.Text = stockChosen.ActValue.ToString();
//txtActDate.Text = (DateTime.Today + stockChosen.ActDate.Value.TimeOfDay).ToString();
var stockSold = _stockRepository.LatestSell(stockChosen.StockId.Trim());
if (stockSold != null)
{
if (stockSold.LatestSoldDate != null)
{
txtLatestSoldDate.Text = stockSold.LatestSoldDate.Value.ToString();
txtLatestSoldPrice.Text = stockSold.SoldStockPrice.ToString();
}
else
{
txtLatestSoldDate.Text = string.Empty;
txtLatestSoldPrice.Text = string.Empty;
}
}
else
{
txtLatestSoldDate.Text = string.Empty;
txtLatestSoldPrice.Text = string.Empty;
}
txtBuyPrice.Text = stockChosen.BuyValue.ToString(); // = decimal.Parse(string.IsNullOrEmpty(txtBuyPrice.Text) ? "0" : txtBuyPrice.Text);
txtBoughtAmount.Text = stockChosen.PostAmount.ToString(); // = long.Parse(string.IsNullOrEmpty(txtBoughtAmount.Text) ? "0" : txtBoughtAmount.Text);
txtActDate.Text = stockChosen.ActDate.ToString(); // = DateTime.Parse(txtActDate.Text);
txtBuyDate.Text = stockChosen.BuyDate.ToString(); // = string.IsNullOrWhiteSpace(txtBuyDate.Text) ? DateTime.Today : DateTime.Parse(txtBuyDate.Text);
txtActValue.Text = stockChosen.ActValue.ToString(); // = decimal.Parse(string.IsNullOrEmpty(txtActValue.Text) ? "0" : txtActValue.Text);
txtActAmount.Text = stockChosen.ActAmount.ToString(); // = long.Parse(string.IsNullOrEmpty(txtActAmount.Text) ? "0" : txtActAmount.Text);
txtSoldDate.Text = stockChosen.SoldDate.ToString(); // = null; //DateTime.MaxValue;
txtSoldPrice.Text = stockChosen.SoldValue.ToString(); // = decimal.Parse("0");
txtComment.Text = stockChosen.Comment;
}
private void AddValidateData()
{
var currentStock = new StockMember();
currentStock.StockId = txtStockName.Text.Trim();
currentStock.StockExtId = txtStockExtId.Text;
currentStock.BuyValue = decimal.Parse(string.IsNullOrEmpty(txtBuyPrice.Text) ? "0" : txtBuyPrice.Text);
currentStock.PostAmount = long.Parse(string.IsNullOrEmpty(txtBoughtAmount.Text) ? "0" : txtBoughtAmount.Text);
currentStock.ActDate = DateTime.Parse(txtActDate.Text);
currentStock.BuyDate = string.IsNullOrWhiteSpace(txtBuyDate.Text) ? DateTime.Today : DateTime.Parse(txtBuyDate.Text);
currentStock.ActValue = decimal.Parse(string.IsNullOrEmpty(txtActValue.Text) ? "0" : txtActValue.Text);
currentStock.ActAmount = long.Parse(string.IsNullOrEmpty(txtActAmount.Text) ? "0" : txtActAmount.Text);
currentStock.SoldDate = DateTime.Parse(txtSoldDate.Text);
currentStock.SoldValue = decimal.Parse(txtSoldPrice.Text);
currentStock.Comment = txtComment.Text;
//RegisteredStocks.Add(currentStock);
try
{
_stockRepository.SaveStockMember(currentStock);
initiateRegWin();
}
catch (Exception ex)
{
MessageBox.Show($"Problems with update :{ex.Message}");
}
}
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)
{
AddValidateData();
}
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>

View File

@ -5,7 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="System.Data.SQLite" Version="1.0.113.7" /> <PackageReference Include="System.Data.SQLite" Version="1.0.114" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -6,7 +6,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.33" /> <PackageReference Include="HtmlAgilityPack" Version="1.11.33" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="90.0.4430.2400" /> <PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="91.0.4472.1900" />
<PackageReference Include="Selenium.WebDriverBackedSelenium" Version="3.141.0" /> <PackageReference Include="Selenium.WebDriverBackedSelenium" Version="3.141.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" /> <PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
</ItemGroup> </ItemGroup>

View File

@ -20,6 +20,15 @@ namespace StockDAL
} }
} }
public StockMember GetStockMember(int stockMemberId)
{
using var context = new StockContext();
var entity = (from stk in context.Stocks
where stk.Id == stockMemberId
select stk).FirstOrDefault();
return entity;
}
public void UpdateActualPrice(int id, decimal price) public void UpdateActualPrice(int id, decimal price)
{ {
using var context = new StockContext(); using var context = new StockContext();

View File

@ -11,6 +11,7 @@ namespace StockDAL.Interface
{ {
IEnumerable<StockMember> GetAllRemainingStocks(); IEnumerable<StockMember> GetAllRemainingStocks();
IEnumerable<StockMember> GetAllStocks(); IEnumerable<StockMember> GetAllStocks();
StockMember GetStockMember(int stockMemberId);
void InsertMany(List<StockMember> stockMembers); void InsertMany(List<StockMember> stockMembers);
LatestSoldStock LatestSell(string StockName); LatestSoldStock LatestSell(string StockName);
void RemoveAllStocks(); void RemoveAllStocks();

View File

@ -6,7 +6,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.33" /> <PackageReference Include="HtmlAgilityPack" Version="1.11.33" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="90.0.4430.2400" /> <PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="91.0.4472.1900" />
<PackageReference Include="Selenium.WebDriverBackedSelenium" Version="3.141.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,3 +1,4 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using System; using System;
@ -10,6 +11,7 @@ namespace StockInfoCore
{ {
static class Program static class Program
{ {
public static IConfiguration Configuration;
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>

View File

@ -25,6 +25,12 @@
<ProjectReference Include="..\StockDAL\StockDAL.csproj" /> <ProjectReference Include="..\StockDAL\StockDAL.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Update="frmEditStock.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="Stocks.db"> <None Update="Stocks.db">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

View File

@ -31,6 +31,7 @@ namespace StockInfoCore
services.AddTransient<frmBackup>(); services.AddTransient<frmBackup>();
services.AddTransient<frmRegisterStock>(); services.AddTransient<frmRegisterStock>();
services.AddTransient<frmEditStock>();
services.AddTransient<frmMyStocks>(); services.AddTransient<frmMyStocks>();
services.AddTransient<frmSelling>(); services.AddTransient<frmSelling>();
services.AddTransient<frmPerson>(); services.AddTransient<frmPerson>();

Binary file not shown.

381
StockInfoCore/frmEditStock.Designer.cs generated Normal file
View File

@ -0,0 +1,381 @@

namespace StockInfoCore
{
partial class frmEditStock
{
/// <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.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.btnSaveToDB = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.txtLatestSoldDate = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.txtLatestSoldPrice = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.txtStockName = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(437, 414);
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, 44);
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, 41);
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";
//
// btnSaveToDB
//
this.btnSaveToDB.Location = new System.Drawing.Point(347, 414);
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);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.txtLatestSoldDate);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.txtLatestSoldPrice);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(301, 81);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(255, 83);
this.groupBox1.TabIndex = 26;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Latest Sold";
//
// txtLatestSoldDate
//
this.txtLatestSoldDate.Location = new System.Drawing.Point(127, 52);
this.txtLatestSoldDate.Name = "txtLatestSoldDate";
this.txtLatestSoldDate.ReadOnly = true;
this.txtLatestSoldDate.Size = new System.Drawing.Size(111, 23);
this.txtLatestSoldDate.TabIndex = 9;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 55);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 15);
this.label2.TabIndex = 8;
this.label2.Text = "Sold date";
//
// txtLatestSoldPrice
//
this.txtLatestSoldPrice.Location = new System.Drawing.Point(127, 23);
this.txtLatestSoldPrice.Name = "txtLatestSoldPrice";
this.txtLatestSoldPrice.ReadOnly = true;
this.txtLatestSoldPrice.Size = new System.Drawing.Size(111, 23);
this.txtLatestSoldPrice.TabIndex = 7;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 26);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(59, 15);
this.label1.TabIndex = 6;
this.label1.Text = "Sold price";
//
// txtStockName
//
this.txtStockName.Location = new System.Drawing.Point(153, 12);
this.txtStockName.Name = "txtStockName";
this.txtStockName.Size = new System.Drawing.Size(269, 23);
this.txtStockName.TabIndex = 27;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(38, 15);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(46, 15);
this.label3.TabIndex = 28;
this.label3.Text = "StockId";
//
// frmEditStock
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(570, 452);
this.Controls.Add(this.label3);
this.Controls.Add(this.txtStockName);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.btnSaveToDB);
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.Name = "frmEditStock";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "frmRegisterStock";
this.Shown += new System.EventHandler(this.frmRegisterStock_Shown);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
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 btnSaveToDB;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox txtLatestSoldDate;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtLatestSoldPrice;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtStockName;
private System.Windows.Forms.Label label3;
}
}

View File

@ -0,0 +1,153 @@
using DataDomain;
using StockDAL.Interface;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StockInfoCore
{
public partial class frmEditStock : Form
{
Color hdr = Color.Red;
private readonly IStockRepository _stockRepository;
public int CurrentStockMember { get; set; }
//public Dictionary<string, DiTraderStockRow> Stocks { get; set; }
//public List<StockMember> RegisteredStocks { get; set; } = new List<StockMember>();
public frmEditStock(IStockRepository stockRepository)
{
InitializeComponent();
_stockRepository = stockRepository;
}
//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)
{
LoadStockData();
//LoadStockCombo();
}
private void LoadStockData()
{
var stockChosen = _stockRepository.GetStockMember(CurrentStockMember);
txtStockExtId.Text = stockChosen.StockExtId;
txtActValue.Text = stockChosen.ActValue.ToString();
//txtActDate.Text = (DateTime.Today + stockChosen.ActDate.Value.TimeOfDay).ToString();
var stockSold = _stockRepository.LatestSell(stockChosen.StockId.Trim());
if (stockSold != null)
{
if (stockSold.LatestSoldDate != null)
{
txtLatestSoldDate.Text = stockSold.LatestSoldDate.Value.ToString();
txtLatestSoldPrice.Text = stockSold.SoldStockPrice.ToString();
}
else
{
txtLatestSoldDate.Text = string.Empty;
txtLatestSoldPrice.Text = string.Empty;
}
}
else
{
txtLatestSoldDate.Text = string.Empty;
txtLatestSoldPrice.Text = string.Empty;
}
txtBuyPrice.Text = stockChosen.BuyValue.ToString(); // = decimal.Parse(string.IsNullOrEmpty(txtBuyPrice.Text) ? "0" : txtBuyPrice.Text);
txtBoughtAmount.Text = stockChosen.PostAmount.ToString(); // = long.Parse(string.IsNullOrEmpty(txtBoughtAmount.Text) ? "0" : txtBoughtAmount.Text);
txtActDate.Text = stockChosen.ActDate.ToString(); // = DateTime.Parse(txtActDate.Text);
txtBuyDate.Text = stockChosen.BuyDate.ToString(); // = string.IsNullOrWhiteSpace(txtBuyDate.Text) ? DateTime.Today : DateTime.Parse(txtBuyDate.Text);
txtActValue.Text = stockChosen.ActValue.ToString(); // = decimal.Parse(string.IsNullOrEmpty(txtActValue.Text) ? "0" : txtActValue.Text);
txtActAmount.Text = stockChosen.ActAmount.ToString(); // = long.Parse(string.IsNullOrEmpty(txtActAmount.Text) ? "0" : txtActAmount.Text);
txtSoldDate.Text = stockChosen.SoldDate.ToString(); // = null; //DateTime.MaxValue;
txtSoldPrice.Text = stockChosen.SoldValue.ToString(); // = decimal.Parse("0");
txtComment.Text = stockChosen.Comment;
}
private void AddValidateData()
{
var currentStock = new StockMember();
currentStock.StockId = txtStockName.Text.Trim();
currentStock.StockExtId = txtStockExtId.Text;
currentStock.BuyValue = decimal.Parse(string.IsNullOrEmpty(txtBuyPrice.Text) ? "0" : txtBuyPrice.Text);
currentStock.PostAmount = long.Parse(string.IsNullOrEmpty(txtBoughtAmount.Text) ? "0" : txtBoughtAmount.Text);
currentStock.ActDate = DateTime.Parse(txtActDate.Text);
currentStock.BuyDate = string.IsNullOrWhiteSpace(txtBuyDate.Text) ? DateTime.Today : DateTime.Parse(txtBuyDate.Text);
currentStock.ActValue = decimal.Parse(string.IsNullOrEmpty(txtActValue.Text) ? "0" : txtActValue.Text);
currentStock.ActAmount = long.Parse(string.IsNullOrEmpty(txtActAmount.Text) ? "0" : txtActAmount.Text);
currentStock.SoldDate = DateTime.Parse(txtSoldDate.Text);
currentStock.SoldValue = decimal.Parse(txtSoldPrice.Text);
currentStock.Comment = txtComment.Text;
//RegisteredStocks.Add(currentStock);
try
{
_stockRepository.SaveStockMember(currentStock);
initiateRegWin();
}
catch (Exception ex)
{
MessageBox.Show($"Problems with update :{ex.Message}");
}
}
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)
{
AddValidateData();
}
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>

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 16
VisualStudioVersion = 16.0.31205.134 VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockInfoCore", "StockInfoCore\StockInfoCore.csproj", "{99122CA3-5625-4004-BED6-5423873FACAC}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockInfoCore", "StockInfoCore\StockInfoCore.csproj", "{99122CA3-5625-4004-BED6-5423873FACAC}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataDomain", "DataDomain\DataDomain.csproj", "{3E7E4CBD-FDBE-4424-880E-0BA24D29B599}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataDomain", "DataDomain\DataDomain.csproj", "{3E7E4CBD-FDBE-4424-880E-0BA24D29B599}"
EndProject EndProject
@ -21,6 +21,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockBL", "StockBL\StockBL.
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockBL.Interface", "StockBL.Interface\StockBL.Interface.csproj", "{BEAD00C3-74AD-416B-9B36-EBE40DAFF16F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockBL.Interface", "StockBL.Interface\StockBL.Interface.csproj", "{BEAD00C3-74AD-416B-9B36-EBE40DAFF16F}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HandleNewWindows", "HandleNewWindows\HandleNewWindows.csproj", "{791F4A63-F1CD-410A-9E9C-071DA8E32880}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -63,6 +65,10 @@ Global
{BEAD00C3-74AD-416B-9B36-EBE40DAFF16F}.Debug|Any CPU.Build.0 = Debug|Any CPU {BEAD00C3-74AD-416B-9B36-EBE40DAFF16F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BEAD00C3-74AD-416B-9B36-EBE40DAFF16F}.Release|Any CPU.ActiveCfg = Release|Any CPU {BEAD00C3-74AD-416B-9B36-EBE40DAFF16F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BEAD00C3-74AD-416B-9B36-EBE40DAFF16F}.Release|Any CPU.Build.0 = Release|Any CPU {BEAD00C3-74AD-416B-9B36-EBE40DAFF16F}.Release|Any CPU.Build.0 = Release|Any CPU
{791F4A63-F1CD-410A-9E9C-071DA8E32880}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{791F4A63-F1CD-410A-9E9C-071DA8E32880}.Debug|Any CPU.Build.0 = Debug|Any CPU
{791F4A63-F1CD-410A-9E9C-071DA8E32880}.Release|Any CPU.ActiveCfg = Release|Any CPU
{791F4A63-F1CD-410A-9E9C-071DA8E32880}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE