From dd0f9dde71c50068bbe1c4826c65a714795650d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Wed, 2 Jun 2021 22:35:36 +0200 Subject: [PATCH] New editwindow , before connection --- HandleNewWindows/HandleNewWindows.csproj | 25 ++ HandleNewWindows/Program.cs | 23 ++ HandleNewWindows/frmEditStock.Designer.cs | 381 +++++++++++++++++++ HandleNewWindows/frmEditStock.cs | 153 ++++++++ HandleNewWindows/frmEditStock.resx | 60 +++ SqliteBackups/SqliteBackups.csproj | 2 +- StockDAL/StockDAL.csproj | 2 +- StockDAL/StockRepository.cs | 9 + StockDal.Interface/IStockRepository.cs | 1 + StockDal.Interface/StockDAL.Interface.csproj | 3 +- StockInfoCore/Program.cs | 2 + StockInfoCore/StockInfoCore.csproj | 6 + StockInfoCore/StockInfoDISetup.cs | 1 + StockInfoCore/Stocks.db | Bin 40960 -> 40960 bytes StockInfoCore/frmEditStock.Designer.cs | 381 +++++++++++++++++++ StockInfoCore/frmEditStock.cs | 153 ++++++++ StockInfoCore/frmEditStock.resx | 60 +++ StockInfoCoreApp.sln | 8 +- 18 files changed, 1266 insertions(+), 4 deletions(-) create mode 100644 HandleNewWindows/HandleNewWindows.csproj create mode 100644 HandleNewWindows/Program.cs create mode 100644 HandleNewWindows/frmEditStock.Designer.cs create mode 100644 HandleNewWindows/frmEditStock.cs create mode 100644 HandleNewWindows/frmEditStock.resx create mode 100644 StockInfoCore/frmEditStock.Designer.cs create mode 100644 StockInfoCore/frmEditStock.cs create mode 100644 StockInfoCore/frmEditStock.resx diff --git a/HandleNewWindows/HandleNewWindows.csproj b/HandleNewWindows/HandleNewWindows.csproj new file mode 100644 index 0000000..f202d6a --- /dev/null +++ b/HandleNewWindows/HandleNewWindows.csproj @@ -0,0 +1,25 @@ + + + + WinExe + net5.0-windows + true + + + + + + + + + + + + + + + Form + + + + \ No newline at end of file diff --git a/HandleNewWindows/Program.cs b/HandleNewWindows/Program.cs new file mode 100644 index 0000000..14cb0b2 --- /dev/null +++ b/HandleNewWindows/Program.cs @@ -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 + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.SetHighDpiMode(HighDpiMode.SystemAware); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/HandleNewWindows/frmEditStock.Designer.cs b/HandleNewWindows/frmEditStock.Designer.cs new file mode 100644 index 0000000..dad1b6c --- /dev/null +++ b/HandleNewWindows/frmEditStock.Designer.cs @@ -0,0 +1,381 @@ + +namespace StockInfoCore +{ + partial class frmEditStock + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/HandleNewWindows/frmEditStock.cs b/HandleNewWindows/frmEditStock.cs new file mode 100644 index 0000000..1a46ffd --- /dev/null +++ b/HandleNewWindows/frmEditStock.cs @@ -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 Stocks { get; set; } + //public List RegisteredStocks { get; set; } = new List(); + + 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(); + } + } + } +} diff --git a/HandleNewWindows/frmEditStock.resx b/HandleNewWindows/frmEditStock.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/HandleNewWindows/frmEditStock.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SqliteBackups/SqliteBackups.csproj b/SqliteBackups/SqliteBackups.csproj index 596e5c1..d163e1f 100644 --- a/SqliteBackups/SqliteBackups.csproj +++ b/SqliteBackups/SqliteBackups.csproj @@ -5,7 +5,7 @@ - + diff --git a/StockDAL/StockDAL.csproj b/StockDAL/StockDAL.csproj index dfc2f83..ac384ca 100644 --- a/StockDAL/StockDAL.csproj +++ b/StockDAL/StockDAL.csproj @@ -6,7 +6,7 @@ - + diff --git a/StockDAL/StockRepository.cs b/StockDAL/StockRepository.cs index d9f82e1..a4310c4 100644 --- a/StockDAL/StockRepository.cs +++ b/StockDAL/StockRepository.cs @@ -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) { using var context = new StockContext(); diff --git a/StockDal.Interface/IStockRepository.cs b/StockDal.Interface/IStockRepository.cs index c5de78e..29189c5 100644 --- a/StockDal.Interface/IStockRepository.cs +++ b/StockDal.Interface/IStockRepository.cs @@ -11,6 +11,7 @@ namespace StockDAL.Interface { IEnumerable GetAllRemainingStocks(); IEnumerable GetAllStocks(); + StockMember GetStockMember(int stockMemberId); void InsertMany(List stockMembers); LatestSoldStock LatestSell(string StockName); void RemoveAllStocks(); diff --git a/StockDal.Interface/StockDAL.Interface.csproj b/StockDal.Interface/StockDAL.Interface.csproj index 8229020..0899596 100644 --- a/StockDal.Interface/StockDAL.Interface.csproj +++ b/StockDal.Interface/StockDAL.Interface.csproj @@ -6,7 +6,8 @@ - + + diff --git a/StockInfoCore/Program.cs b/StockInfoCore/Program.cs index cb4315a..4c93c4f 100644 --- a/StockInfoCore/Program.cs +++ b/StockInfoCore/Program.cs @@ -1,3 +1,4 @@ +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using System; @@ -10,6 +11,7 @@ namespace StockInfoCore { static class Program { + public static IConfiguration Configuration; /// /// The main entry point for the application. /// diff --git a/StockInfoCore/StockInfoCore.csproj b/StockInfoCore/StockInfoCore.csproj index f440ce9..baacf5a 100644 --- a/StockInfoCore/StockInfoCore.csproj +++ b/StockInfoCore/StockInfoCore.csproj @@ -25,6 +25,12 @@ + + + Form + + + PreserveNewest diff --git a/StockInfoCore/StockInfoDISetup.cs b/StockInfoCore/StockInfoDISetup.cs index 06a48b4..3ab959a 100644 --- a/StockInfoCore/StockInfoDISetup.cs +++ b/StockInfoCore/StockInfoDISetup.cs @@ -31,6 +31,7 @@ namespace StockInfoCore services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/StockInfoCore/Stocks.db b/StockInfoCore/Stocks.db index 4a88d8a081743d122beca6fff5f1c7f676c5625f..f3f0c8313e046d827ffe94eb9049eebb9025c6cd 100644 GIT binary patch delta 1950 zcmah~T}&KR6uvY2%hH|Qc7@q-?UwC^zm^^D%$*r_w%IlPgV89O7<~|*G#Vr7OEuBNHya;}2{E}KZ9 zJ@uE&D!a6xz6g{l~&xepfaDtPDq z-sj<>DDY|E<$%s@ac^^@T$CDnxl<2&+^GFPqF%0ckcT3|YuFHwvM3W2Mx+w2|gS*M$G`p5iy z^$&YK*mKnTR&|%}XWt7xUsa*1oq68zrk8lW_q^nZy9?as&NGfK7w7zl2{M1V)AN@e zIYgaZV2D6?KZ8Qe&7om4MlFG*I*e1rpQOm5tis8aBWY?LWC(AXA3hwS>ydK`he|H$ z>qAW?7jnr3k+GPB53eVi`kD;uZ4Z%%1<+!xP~+~?H86fdm}BWRi&~8{f)QjaW;tUC zQkO-FVi5eI$|0|jlfaTlEXJ4O*=4Po8)`z*OMyyBRZQll&X3I;LthyCa|vuCgCsSK zMcgqlJCd83oUS`wev)(|VwU|8Jyki_a)J^K7Vn_TY8hR}qNEO6{dZab=zFJQ+1ZC2 zjy4paAbk>tSV~N1*tmyiSy&XJm*dw`&K6Knhx2OtMX?94*)GLm#^V*+MIw~R zg|oHr%2Eu{i@U)UjrParVxnPMHY#0gCQGGv7Zg5TjP&oYZK*ZUG{s7_h3PgrnMvfm zf*!BHl)WJoB0_knQOpj}wi_7aO*(3fO3-=QCf7JpCRP_UcaJ_W_8n)g2mYHFcz@AB~M6=30e3 h&6#J;@o*X9BK?{cuK`2)?}tR-o8B4&3I3R${s*({uygL?yd$F`{=Odh&va7vsek5{@2xU3J;CCVgr8z3=^g-}n1|ulKfX_qJ`* ze6<51KjxxWs z{HNaLMtcL}0ryy2Uhu!8!87^O@1jQ#^M<+0r04^BgB~F}XXyOM)C$$<_>LN=eLJ=9 z5Sdf-S9*a~d>?$1KE7(p+iHJS*b*8YFd?5B__vXirOg4Erkasq&Q^f zYQT|;9L*wuMpWSlh1jkxcG%*CqNtJ#9~L>FmRg%-NgfOuJOLaqctnw<4lGV3B~6)~ zKM}p8l`w?EY}6tbt4Rq`GfBVeDM}a1;dvGIFS1S?#}bAwb5ZduF2Uk?R<**4>!jK* zbFq#KYDu;rSZ3>rEG118EvBT3D(P4yamdcsK@S|RE>lp$k`C(+Bd`W8@seziaG3KE z0h^jE+fy`EN)XL;f5mr{L>^N*%;`F8%tv8mKF5?1koc?fwQzX>`^(~*l7PnpwXn6I z9xB_wnj)$2bD`(o{5}FSw#dU12>x}3_#h5Dkc#$4jTQpLHlzijs+9*YCIsn$8hA0o z*}Ve@?ktZml>$n8hM#{u|I1D|jLw*u#GyD=VN)LzYO~2@}q`}^5P`uJ$!vEf8 z>n-3-?e_k*O}L@aJ^ZUb?;iVqev+oq`4#FMb5-781p~wSF|L#S-br; ikjXWQ-G|HZ?ce@~UkyhX@~6xc#~}#tJ{N#|?({FxJ}m+O diff --git a/StockInfoCore/frmEditStock.Designer.cs b/StockInfoCore/frmEditStock.Designer.cs new file mode 100644 index 0000000..dad1b6c --- /dev/null +++ b/StockInfoCore/frmEditStock.Designer.cs @@ -0,0 +1,381 @@ + +namespace StockInfoCore +{ + partial class frmEditStock + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/StockInfoCore/frmEditStock.cs b/StockInfoCore/frmEditStock.cs new file mode 100644 index 0000000..1a46ffd --- /dev/null +++ b/StockInfoCore/frmEditStock.cs @@ -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 Stocks { get; set; } + //public List RegisteredStocks { get; set; } = new List(); + + 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(); + } + } + } +} diff --git a/StockInfoCore/frmEditStock.resx b/StockInfoCore/frmEditStock.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/StockInfoCore/frmEditStock.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StockInfoCoreApp.sln b/StockInfoCoreApp.sln index 3b668a5..dc0e969 100644 --- a/StockInfoCoreApp.sln +++ b/StockInfoCoreApp.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.31205.134 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockInfoCore", "StockInfoCore\StockInfoCore.csproj", "{99122CA3-5625-4004-BED6-5423873FACAC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockInfoCore", "StockInfoCore\StockInfoCore.csproj", "{99122CA3-5625-4004-BED6-5423873FACAC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataDomain", "DataDomain\DataDomain.csproj", "{3E7E4CBD-FDBE-4424-880E-0BA24D29B599}" EndProject @@ -21,6 +21,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockBL", "StockBL\StockBL. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockBL.Interface", "StockBL.Interface\StockBL.Interface.csproj", "{BEAD00C3-74AD-416B-9B36-EBE40DAFF16F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HandleNewWindows", "HandleNewWindows\HandleNewWindows.csproj", "{791F4A63-F1CD-410A-9E9C-071DA8E32880}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution 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}.Release|Any CPU.ActiveCfg = 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 GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE