From b41b2b0076fe160a767ac657ba7074751fc2e3aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Wed, 3 Mar 2021 22:28:18 +0100 Subject: [PATCH] New function sell stock started --- Helpers/Helpers.csproj | 7 + Helpers/StringExtensions.cs | 13 + StockDBEFApp.sln | 12 +- StockInfo/StockInfo.csproj | 3 +- StockInfo/Stocks.db-shm | Bin 0 -> 32768 bytes StockInfo/Stocks.db-wal | Bin 0 -> 4152 bytes StockInfo/frmInitial.Designer.cs | 13 + StockInfo/frmInitial.cs | 13 + StockInfo/frmRegisterStock.cs | 1 + StockInfo/frmSelling.Designer.cs | 415 +++++++++++++++++++++++++++++++ StockInfo/frmSelling.cs | 99 ++++++++ StockInfo/frmSelling.resx | 60 +++++ 12 files changed, 632 insertions(+), 4 deletions(-) create mode 100644 Helpers/Helpers.csproj create mode 100644 Helpers/StringExtensions.cs create mode 100644 StockInfo/Stocks.db-shm create mode 100644 StockInfo/Stocks.db-wal create mode 100644 StockInfo/frmSelling.Designer.cs create mode 100644 StockInfo/frmSelling.cs create mode 100644 StockInfo/frmSelling.resx diff --git a/Helpers/Helpers.csproj b/Helpers/Helpers.csproj new file mode 100644 index 0000000..f208d30 --- /dev/null +++ b/Helpers/Helpers.csproj @@ -0,0 +1,7 @@ + + + + net5.0 + + + diff --git a/Helpers/StringExtensions.cs b/Helpers/StringExtensions.cs new file mode 100644 index 0000000..b8978fc --- /dev/null +++ b/Helpers/StringExtensions.cs @@ -0,0 +1,13 @@ +using System; +using System.Globalization; + +namespace Helpers +{ + public static class StringExtensions + { + public static bool IsNumeric(this string s) + { + return float.TryParse(s, NumberStyles.Float | NumberStyles.Integer, CultureInfo.CurrentUICulture, out _); + } + } +} diff --git a/StockDBEFApp.sln b/StockDBEFApp.sln index 47568ef..01c6cad 100644 --- a/StockDBEFApp.sln +++ b/StockDBEFApp.sln @@ -7,11 +7,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatamodelLibrary", "Datamod EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataDomain", "DataDomain\DataDomain.csproj", "{D8057A61-F1CE-4467-9F9E-5E1DA180B3C4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockDAL", "StockDAL\StockDAL.csproj", "{E84394CB-98B8-48C0-A65F-008BC97E34A3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockDAL", "StockDAL\StockDAL.csproj", "{E84394CB-98B8-48C0-A65F-008BC97E34A3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockDAL.Interface", "StockDal.Interface\StockDAL.Interface.csproj", "{7B0D0A18-D071-40ED-8788-120D432D16D8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockDAL.Interface", "StockDal.Interface\StockDAL.Interface.csproj", "{7B0D0A18-D071-40ED-8788-120D432D16D8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockInfo", "StockInfo\StockInfo.csproj", "{EC122B56-FCE0-4BBD-956D-7BF46D617CF8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockInfo", "StockInfo\StockInfo.csproj", "{EC122B56-FCE0-4BBD-956D-7BF46D617CF8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Helpers", "Helpers\Helpers.csproj", "{5FEE920E-07B8-4185-A41F-1587643ECC26}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -39,6 +41,10 @@ Global {EC122B56-FCE0-4BBD-956D-7BF46D617CF8}.Debug|Any CPU.Build.0 = Debug|Any CPU {EC122B56-FCE0-4BBD-956D-7BF46D617CF8}.Release|Any CPU.ActiveCfg = Release|Any CPU {EC122B56-FCE0-4BBD-956D-7BF46D617CF8}.Release|Any CPU.Build.0 = Release|Any CPU + {5FEE920E-07B8-4185-A41F-1587643ECC26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5FEE920E-07B8-4185-A41F-1587643ECC26}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5FEE920E-07B8-4185-A41F-1587643ECC26}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5FEE920E-07B8-4185-A41F-1587643ECC26}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/StockInfo/StockInfo.csproj b/StockInfo/StockInfo.csproj index 3e2f4ca..35bf22d 100644 --- a/StockInfo/StockInfo.csproj +++ b/StockInfo/StockInfo.csproj @@ -1,4 +1,4 @@ - + WinExe @@ -25,6 +25,7 @@ + diff --git a/StockInfo/Stocks.db-shm b/StockInfo/Stocks.db-shm new file mode 100644 index 0000000000000000000000000000000000000000..0fff49c16dc1ff244e378c886b087910a6e8c9c8 GIT binary patch literal 32768 zcmeI)u?fOZ5C&jHw2s)M%LIy3m=zK`7qHDH?%)azVq^Ef0qljCGa|MrBi|3l!Q*iU z-vF1V^&~RwD~rD9sx0o?%kq3XT$@umKC1aURX*^4H|m|3+y3P9{B5yQ2oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0{Wt(i&_{2!VozU?dr6#fH)$eMm$S z6J5JCB>DmLEBFcc1RCOwM1#hSYZrRwapxgWHPKz0Y44po?f;zfJCDjwhMt1V$yESG zf$`Gb?Y%f@d|TaKKW-l=sqgG)$awQ}^f6WZ@Mi3-5cmONfkQCzI&e60E%H9{ETRgZ zgqK1w{3ZM+9fqz4KL?)&GsDNj`-XP!)g#a&&?C?z&?C?z&?E3a2vi3IkWMFP zf(8;(Lf^vN!irdI>YZJ&;N44@LPQY38ALKj6%m>>FRJADIn5v}VtJOR>=9P8D968# zNrt)pIGvs_%tS#KGc*e^rj-AZDgMq9f@qSdAB>NWbM@uD>ZUH{?d4wFh|nS6qz9Sr!R0Xlq*8J2d!gEHwe*Hq za5jp>9rHOXV~A`}K8FbtC99(Xn3_t`qy>aQu54(HZ8OLA4(B9@?UKV8l5@PpSp;*+ zIVeo!@`wN?CS25deaD1suM%Z$IS7a&Dj|uV`@D@YZ)0nbKf{X^u0g!1>x#E5{Dr^S z-}-B&Y(6Z2WHL_U7Tw#8+J?4keX{y>Dgb-hUV=7iCwhr>y;;0>LjstdPH?rAYQ3h3 zH}sudt?|frLnWxXt>Km~JO5SO7%8TBIoLIPs;Vwh&+xb?U4txLgSUnS5RDoR_p<@f zznouY7ltw-Jn`5CiJ@w@n-jU=+`uVQ8aQ1F7{egRi=TyCC1Sx|Fv`KK6ELApaxhYO zOZY_1h)b6(@9bHSFBI5CB*OE;O2_R?A~_}HQ?g2Z$j5G8YwMk+Sl}yG3ADXqjp>P4 zRrvW?&80y@GftxxyG30$vR&XSs~-1Xz%3sI+7sR<2#y#-aCC4<0L7xyk&AV$yx~w)LReX8V#}uhbe_%uct57*S~VJ%i*4h~YkO9+ + /// 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.lvSellCandidates = new System.Windows.Forms.ListView(); + this.StockName = new System.Windows.Forms.ColumnHeader(); + this.Buydate = new System.Windows.Forms.ColumnHeader(); + this.BuyPrice = new System.Windows.Forms.ColumnHeader(); + this.LeftNumber = new System.Windows.Forms.ColumnHeader(); + this.ActPrice = new System.Windows.Forms.ColumnHeader(); + this.TotalValue = new System.Windows.Forms.ColumnHeader(); + this.gbInfo = new System.Windows.Forms.GroupBox(); + this.txtBuyValue = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.txtBuyPrice = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.txtBuyNumber = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.txtBuyDate = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.txtStockId = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.txtId = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.gbSell = new System.Windows.Forms.GroupBox(); + this.btnConfirm = new System.Windows.Forms.Button(); + this.txtRemainingNo = new System.Windows.Forms.TextBox(); + this.label11 = new System.Windows.Forms.Label(); + this.txtSellValue = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.txtSoldAmount = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.txtSoldPrice = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.txtSoldDate = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.gbInfo.SuspendLayout(); + this.gbSell.SuspendLayout(); + this.SuspendLayout(); + // + // lvSellCandidates + // + this.lvSellCandidates.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.StockName, + this.Buydate, + this.BuyPrice, + this.LeftNumber, + this.ActPrice, + this.TotalValue}); + this.lvSellCandidates.FullRowSelect = true; + this.lvSellCandidates.HideSelection = false; + this.lvSellCandidates.Location = new System.Drawing.Point(13, 13); + this.lvSellCandidates.MultiSelect = false; + this.lvSellCandidates.Name = "lvSellCandidates"; + this.lvSellCandidates.Size = new System.Drawing.Size(519, 128); + this.lvSellCandidates.TabIndex = 0; + this.lvSellCandidates.UseCompatibleStateImageBehavior = false; + this.lvSellCandidates.View = System.Windows.Forms.View.Details; + this.lvSellCandidates.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lvSellCandidates_MouseUp); + // + // StockName + // + this.StockName.Name = "StockName"; + this.StockName.Text = "StockId"; + this.StockName.Width = 80; + // + // Buydate + // + this.Buydate.Name = "Buydate"; + this.Buydate.Text = "Date of Buy"; + this.Buydate.Width = 80; + // + // BuyPrice + // + this.BuyPrice.Name = "BuyPrice"; + this.BuyPrice.Text = "Price per stock"; + this.BuyPrice.Width = 80; + // + // LeftNumber + // + this.LeftNumber.Name = "LeftNumber"; + this.LeftNumber.Text = "Remaining Nr"; + this.LeftNumber.Width = 80; + // + // ActPrice + // + this.ActPrice.Name = "ActPrice"; + this.ActPrice.Text = "Price today"; + this.ActPrice.Width = 80; + // + // TotalValue + // + this.TotalValue.Name = "TotalValue"; + this.TotalValue.Text = "Value Today"; + this.TotalValue.Width = 80; + // + // gbInfo + // + this.gbInfo.Controls.Add(this.txtBuyValue); + this.gbInfo.Controls.Add(this.label6); + this.gbInfo.Controls.Add(this.txtBuyPrice); + this.gbInfo.Controls.Add(this.label5); + this.gbInfo.Controls.Add(this.txtBuyNumber); + this.gbInfo.Controls.Add(this.label4); + this.gbInfo.Controls.Add(this.txtBuyDate); + this.gbInfo.Controls.Add(this.label3); + this.gbInfo.Controls.Add(this.txtStockId); + this.gbInfo.Controls.Add(this.label2); + this.gbInfo.Controls.Add(this.txtId); + this.gbInfo.Controls.Add(this.label1); + this.gbInfo.Location = new System.Drawing.Point(13, 170); + this.gbInfo.Name = "gbInfo"; + this.gbInfo.Size = new System.Drawing.Size(276, 216); + this.gbInfo.TabIndex = 1; + this.gbInfo.TabStop = false; + this.gbInfo.Text = "Actual Stock"; + // + // txtBuyValue + // + this.txtBuyValue.Location = new System.Drawing.Point(116, 165); + this.txtBuyValue.Name = "txtBuyValue"; + this.txtBuyValue.ReadOnly = true; + this.txtBuyValue.Size = new System.Drawing.Size(73, 23); + this.txtBuyValue.TabIndex = 11; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(7, 168); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(58, 15); + this.label6.TabIndex = 10; + this.label6.Text = "Buy value"; + // + // txtBuyPrice + // + this.txtBuyPrice.Location = new System.Drawing.Point(116, 136); + this.txtBuyPrice.Name = "txtBuyPrice"; + this.txtBuyPrice.ReadOnly = true; + this.txtBuyPrice.Size = new System.Drawing.Size(73, 23); + this.txtBuyPrice.TabIndex = 9; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(7, 139); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(56, 15); + this.label5.TabIndex = 8; + this.label5.Text = "Buy price"; + // + // txtBuyNumber + // + this.txtBuyNumber.Location = new System.Drawing.Point(116, 107); + this.txtBuyNumber.Name = "txtBuyNumber"; + this.txtBuyNumber.ReadOnly = true; + this.txtBuyNumber.Size = new System.Drawing.Size(73, 23); + this.txtBuyNumber.TabIndex = 7; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(7, 110); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(93, 15); + this.label4.TabIndex = 6; + this.label4.Text = "Bought Number"; + // + // txtBuyDate + // + this.txtBuyDate.Location = new System.Drawing.Point(116, 78); + this.txtBuyDate.Name = "txtBuyDate"; + this.txtBuyDate.ReadOnly = true; + this.txtBuyDate.Size = new System.Drawing.Size(73, 23); + this.txtBuyDate.TabIndex = 5; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(7, 81); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(72, 15); + this.label3.TabIndex = 4; + this.label3.Text = "Bought date"; + // + // txtStockId + // + this.txtStockId.Location = new System.Drawing.Point(116, 49); + this.txtStockId.Name = "txtStockId"; + this.txtStockId.ReadOnly = true; + this.txtStockId.Size = new System.Drawing.Size(154, 23); + this.txtStockId.TabIndex = 3; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(7, 52); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(49, 15); + this.label2.TabIndex = 2; + this.label2.Text = "Stock Id"; + // + // txtId + // + this.txtId.Location = new System.Drawing.Point(116, 20); + this.txtId.Name = "txtId"; + this.txtId.ReadOnly = true; + this.txtId.Size = new System.Drawing.Size(73, 23); + this.txtId.TabIndex = 1; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(7, 23); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(48, 15); + this.label1.TabIndex = 0; + this.label1.Text = "Local Id"; + // + // gbSell + // + this.gbSell.Controls.Add(this.btnConfirm); + this.gbSell.Controls.Add(this.txtRemainingNo); + this.gbSell.Controls.Add(this.label11); + this.gbSell.Controls.Add(this.txtSellValue); + this.gbSell.Controls.Add(this.label10); + this.gbSell.Controls.Add(this.txtSoldAmount); + this.gbSell.Controls.Add(this.label9); + this.gbSell.Controls.Add(this.txtSoldPrice); + this.gbSell.Controls.Add(this.label8); + this.gbSell.Controls.Add(this.txtSoldDate); + this.gbSell.Controls.Add(this.label7); + this.gbSell.Location = new System.Drawing.Point(296, 170); + this.gbSell.Name = "gbSell"; + this.gbSell.Size = new System.Drawing.Size(236, 216); + this.gbSell.TabIndex = 2; + this.gbSell.TabStop = false; + this.gbSell.Text = "Sell decision"; + // + // btnConfirm + // + this.btnConfirm.Location = new System.Drawing.Point(121, 165); + this.btnConfirm.Name = "btnConfirm"; + this.btnConfirm.Size = new System.Drawing.Size(75, 23); + this.btnConfirm.TabIndex = 12; + this.btnConfirm.Text = "Confirm"; + this.btnConfirm.UseVisualStyleBackColor = true; + // + // txtRemainingNo + // + this.txtRemainingNo.Location = new System.Drawing.Point(121, 136); + this.txtRemainingNo.Name = "txtRemainingNo"; + this.txtRemainingNo.ReadOnly = true; + this.txtRemainingNo.Size = new System.Drawing.Size(73, 23); + this.txtRemainingNo.TabIndex = 11; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Location = new System.Drawing.Point(12, 139); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(80, 15); + this.label11.TabIndex = 10; + this.label11.Text = "Remaining Nr"; + // + // txtSellValue + // + this.txtSellValue.Location = new System.Drawing.Point(121, 107); + this.txtSellValue.Name = "txtSellValue"; + this.txtSellValue.ReadOnly = true; + this.txtSellValue.Size = new System.Drawing.Size(73, 23); + this.txtSellValue.TabIndex = 9; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(12, 110); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(56, 15); + this.label10.TabIndex = 8; + this.label10.Text = "Sell Value"; + // + // txtSoldAmount + // + this.txtSoldAmount.Location = new System.Drawing.Point(121, 78); + this.txtSoldAmount.Name = "txtSoldAmount"; + this.txtSoldAmount.Size = new System.Drawing.Size(73, 23); + this.txtSoldAmount.TabIndex = 7; + this.txtSoldAmount.TextChanged += new System.EventHandler(this.txtSoldAmount_TextChanged); + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(12, 81); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(77, 15); + this.label9.TabIndex = 6; + this.label9.Text = "Sold Number"; + // + // txtSoldPrice + // + this.txtSoldPrice.Location = new System.Drawing.Point(121, 49); + this.txtSoldPrice.Name = "txtSoldPrice"; + this.txtSoldPrice.Size = new System.Drawing.Size(73, 23); + this.txtSoldPrice.TabIndex = 5; + this.txtSoldPrice.TextChanged += new System.EventHandler(this.txtSoldPrice_TextChanged); + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(12, 52); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(71, 15); + this.label8.TabIndex = 4; + this.label8.Text = "Selling Price"; + // + // txtSoldDate + // + this.txtSoldDate.Location = new System.Drawing.Point(121, 20); + this.txtSoldDate.Name = "txtSoldDate"; + this.txtSoldDate.Size = new System.Drawing.Size(73, 23); + this.txtSoldDate.TabIndex = 3; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(12, 23); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(57, 15); + this.label7.TabIndex = 2; + this.label7.Text = "Sold Date"; + // + // frmSelling + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(544, 450); + this.Controls.Add(this.gbSell); + this.Controls.Add(this.gbInfo); + this.Controls.Add(this.lvSellCandidates); + this.Name = "frmSelling"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "frmSelling"; + this.Load += new System.EventHandler(this.frmSelling_Load); + this.gbInfo.ResumeLayout(false); + this.gbInfo.PerformLayout(); + this.gbSell.ResumeLayout(false); + this.gbSell.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ListView lvSellCandidates; + private System.Windows.Forms.ColumnHeader StockName; + private System.Windows.Forms.ColumnHeader Buydate; + private System.Windows.Forms.ColumnHeader BuyPrice; + private System.Windows.Forms.ColumnHeader LeftNumber; + private System.Windows.Forms.ColumnHeader ActPrice; + private System.Windows.Forms.ColumnHeader TotalValue; + private System.Windows.Forms.GroupBox gbInfo; + private System.Windows.Forms.TextBox txtStockId; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox txtId; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox txtBuyDate; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox txtBuyValue; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.TextBox txtBuyPrice; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox txtBuyNumber; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.GroupBox gbSell; + private System.Windows.Forms.Button btnConfirm; + private System.Windows.Forms.TextBox txtRemainingNo; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.TextBox txtSellValue; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.TextBox txtSoldAmount; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox txtSoldPrice; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.TextBox txtSoldDate; + private System.Windows.Forms.Label label7; + } +} \ No newline at end of file diff --git a/StockInfo/frmSelling.cs b/StockInfo/frmSelling.cs new file mode 100644 index 0000000..b0a85a8 --- /dev/null +++ b/StockInfo/frmSelling.cs @@ -0,0 +1,99 @@ +using DataDomain; +using Helpers; +using StockDAL.Interface; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace StockInfo +{ + public partial class frmSelling : Form + { + private readonly IStockRepository _stockRepository; + private List remainingStocks = new (); + public StockMember stkMemSelected { get; set; } = null; + + public frmSelling(IStockRepository stockRepository ) + { + InitializeComponent(); + _stockRepository = stockRepository; + } + + private void frmSelling_Load(object sender, EventArgs e) + { + remainingStocks = _stockRepository.GetAllRemainingStocks().ToList(); + foreach(var stock in remainingStocks) + { + var lvRow = lvSellCandidates.Items.Add(stock.StockId); + lvRow.Tag = stock.Id; + lvRow.SubItems.Add(stock.BuyDate.ToShortDateString()); + lvRow.SubItems.Add(stock.BuyValue.ToString()); + lvRow.SubItems.Add(stock.ActAmount.ToString()); + lvRow.SubItems.Add(stock.ActValue.ToString()); + lvRow.SubItems.Add((stock.ActValue * stock.ActAmount).ToString()); + } + } + + private void SelectStock(object tag) + { + //Debug.WriteLine($"selected item {(int)tag}"); + foreach(var remStk in remainingStocks) + { + if(remStk.Id == (int)tag) + { + stkMemSelected = remStk; + break; + } + } + + EditStockForSelling(stkMemSelected); + } + + private void EditStockForSelling(StockMember stkMemSelected) + { + txtId.Text = stkMemSelected.Id.ToString(); + txtStockId.Text = stkMemSelected.StockId; + txtBuyDate.Text = stkMemSelected.BuyDate.ToShortDateString(); + txtBuyNumber.Text = stkMemSelected.PostAmount.ToString(); + txtBuyPrice.Text = stkMemSelected.BuyValue.ToString(); + txtBuyValue.Text = (stkMemSelected.BuyValue * stkMemSelected.PostAmount).ToString(); + + txtSoldDate.Text = DateTime.Today.ToShortDateString(); + txtSoldPrice.Text = stkMemSelected.ActValue.ToString(); + txtSoldAmount.Text = stkMemSelected.ActAmount.ToString(); + } + + + private void lvSellCandidates_MouseUp(object sender, MouseEventArgs e) + { + var selRows = lvSellCandidates.SelectedItems; + SelectStock(selRows[0].Tag); + } + + private void txtSoldPrice_TextChanged(object sender, EventArgs e) + { + CalcNumberAndValue(); + } + + private void CalcNumberAndValue() + { + if (txtSoldPrice.Text.IsNumeric() && txtSoldAmount.Text.IsNumeric()) + { + txtSellValue.Text = (decimal.Parse(txtSoldPrice.Text) * long.Parse(txtSoldAmount.Text)).ToString(); + txtRemainingNo.Text = (stkMemSelected.PostAmount - long.Parse(txtSoldAmount.Text)).ToString(); + } + } + + private void txtSoldAmount_TextChanged(object sender, EventArgs e) + { + CalcNumberAndValue(); + } + } +} diff --git a/StockInfo/frmSelling.resx b/StockInfo/frmSelling.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/StockInfo/frmSelling.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