From ec71d60a2a930b0a2fe0053b704d1e0729d5f92e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Mon, 18 Jan 2021 22:47:53 +0100 Subject: [PATCH] Loading combo for chosing stock , fill in actual values --- .../frmRegisterStock.Designer.cs | 253 +++++++++++++++++- RepositoryPattern/frmRegisterStock.cs | 8 + 2 files changed, 258 insertions(+), 3 deletions(-) diff --git a/RepositoryPattern/frmRegisterStock.Designer.cs b/RepositoryPattern/frmRegisterStock.Designer.cs index 250e3a1..30430b0 100644 --- a/RepositoryPattern/frmRegisterStock.Designer.cs +++ b/RepositoryPattern/frmRegisterStock.Designer.cs @@ -31,19 +31,42 @@ namespace RepositoryPattern { this.cmbStockChoser = new System.Windows.Forms.ComboBox(); this.btnClose = new System.Windows.Forms.Button(); + this.lblStockExtId = new System.Windows.Forms.Label(); + this.txtStockExtId = new System.Windows.Forms.TextBox(); + this.txtBuyPrice = new System.Windows.Forms.TextBox(); + this.lblBuyPrice = new System.Windows.Forms.Label(); + this.txtBuyDate = new System.Windows.Forms.TextBox(); + this.lblBuyDate = new System.Windows.Forms.Label(); + this.txtBoughtAmount = new System.Windows.Forms.TextBox(); + this.lblBoughtAmount = new System.Windows.Forms.Label(); + this.txtActValue = new System.Windows.Forms.TextBox(); + this.lblActValue = new System.Windows.Forms.Label(); + this.txtActDate = new System.Windows.Forms.TextBox(); + this.lblActDate = new System.Windows.Forms.Label(); + this.txtActAmount = new System.Windows.Forms.TextBox(); + this.lblRemaining = new System.Windows.Forms.Label(); + this.txtSoldPrice = new System.Windows.Forms.TextBox(); + this.lblSoldValue = new System.Windows.Forms.Label(); + this.txtSoldDate = new System.Windows.Forms.TextBox(); + this.lblSoldDate = new System.Windows.Forms.Label(); + this.txtComment = new System.Windows.Forms.TextBox(); + this.lblComment = new System.Windows.Forms.Label(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.btnSaveStock = new System.Windows.Forms.Button(); this.SuspendLayout(); // // cmbStockChoser // this.cmbStockChoser.FormattingEnabled = true; - this.cmbStockChoser.Location = new System.Drawing.Point(174, 45); + this.cmbStockChoser.Location = new System.Drawing.Point(38, 39); this.cmbStockChoser.Name = "cmbStockChoser"; this.cmbStockChoser.Size = new System.Drawing.Size(179, 23); this.cmbStockChoser.TabIndex = 0; + this.cmbStockChoser.SelectedIndexChanged += new System.EventHandler(this.cmbStockChoser_SelectedIndexChanged); // // btnClose // - this.btnClose.Location = new System.Drawing.Point(374, 532); + this.btnClose.Location = new System.Drawing.Point(347, 567); this.btnClose.Name = "btnClose"; this.btnClose.Size = new System.Drawing.Size(75, 23); this.btnClose.TabIndex = 1; @@ -51,17 +74,219 @@ namespace RepositoryPattern this.btnClose.UseVisualStyleBackColor = true; this.btnClose.Click += new System.EventHandler(this.btnClose_Click); // + // lblStockExtId + // + this.lblStockExtId.AutoSize = true; + this.lblStockExtId.Location = new System.Drawing.Point(38, 78); + this.lblStockExtId.Name = "lblStockExtId"; + this.lblStockExtId.Size = new System.Drawing.Size(62, 15); + this.lblStockExtId.TabIndex = 2; + this.lblStockExtId.Text = "StockExtId"; + // + // txtStockExtId + // + this.txtStockExtId.Location = new System.Drawing.Point(153, 75); + this.txtStockExtId.Name = "txtStockExtId"; + this.txtStockExtId.Size = new System.Drawing.Size(269, 23); + this.txtStockExtId.TabIndex = 3; + // + // txtBuyPrice + // + this.txtBuyPrice.Location = new System.Drawing.Point(153, 104); + this.txtBuyPrice.Name = "txtBuyPrice"; + this.txtBuyPrice.Size = new System.Drawing.Size(111, 23); + this.txtBuyPrice.TabIndex = 5; + // + // lblBuyPrice + // + this.lblBuyPrice.AutoSize = true; + this.lblBuyPrice.Location = new System.Drawing.Point(38, 107); + this.lblBuyPrice.Name = "lblBuyPrice"; + this.lblBuyPrice.Size = new System.Drawing.Size(56, 15); + this.lblBuyPrice.TabIndex = 4; + this.lblBuyPrice.Text = "Buy price"; + // + // txtBuyDate + // + this.txtBuyDate.Location = new System.Drawing.Point(153, 133); + this.txtBuyDate.Name = "txtBuyDate"; + this.txtBuyDate.Size = new System.Drawing.Size(142, 23); + this.txtBuyDate.TabIndex = 7; + // + // lblBuyDate + // + this.lblBuyDate.AutoSize = true; + this.lblBuyDate.Location = new System.Drawing.Point(38, 136); + this.lblBuyDate.Name = "lblBuyDate"; + this.lblBuyDate.Size = new System.Drawing.Size(73, 15); + this.lblBuyDate.TabIndex = 6; + this.lblBuyDate.Text = "Bought Date"; + // + // txtBoughtAmount + // + this.txtBoughtAmount.Location = new System.Drawing.Point(153, 162); + this.txtBoughtAmount.Name = "txtBoughtAmount"; + this.txtBoughtAmount.Size = new System.Drawing.Size(111, 23); + this.txtBoughtAmount.TabIndex = 9; + // + // 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"; + // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.ItemHeight = 15; + this.listBox1.Location = new System.Drawing.Point(39, 467); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(383, 94); + this.listBox1.TabIndex = 22; + // + // btnSaveStock + // + this.btnSaveStock.Location = new System.Drawing.Point(39, 424); + this.btnSaveStock.Name = "btnSaveStock"; + this.btnSaveStock.Size = new System.Drawing.Size(75, 23); + this.btnSaveStock.TabIndex = 23; + this.btnSaveStock.Text = "Register"; + this.btnSaveStock.UseVisualStyleBackColor = true; + // // frmRegisterStock // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(471, 567); + this.ClientSize = new System.Drawing.Size(441, 602); + this.Controls.Add(this.btnSaveStock); + this.Controls.Add(this.listBox1); + this.Controls.Add(this.txtComment); + this.Controls.Add(this.lblComment); + this.Controls.Add(this.txtSoldDate); + this.Controls.Add(this.lblSoldDate); + this.Controls.Add(this.txtSoldPrice); + this.Controls.Add(this.lblSoldValue); + this.Controls.Add(this.txtActAmount); + this.Controls.Add(this.lblRemaining); + this.Controls.Add(this.txtActDate); + this.Controls.Add(this.lblActDate); + this.Controls.Add(this.txtActValue); + this.Controls.Add(this.lblActValue); + this.Controls.Add(this.txtBoughtAmount); + this.Controls.Add(this.lblBoughtAmount); + this.Controls.Add(this.txtBuyDate); + this.Controls.Add(this.lblBuyDate); + this.Controls.Add(this.txtBuyPrice); + this.Controls.Add(this.lblBuyPrice); + this.Controls.Add(this.txtStockExtId); + this.Controls.Add(this.lblStockExtId); this.Controls.Add(this.btnClose); this.Controls.Add(this.cmbStockChoser); this.Name = "frmRegisterStock"; this.Text = "frmRegisterStock"; this.Shown += new System.EventHandler(this.frmRegisterStock_Shown); this.ResumeLayout(false); + this.PerformLayout(); } @@ -69,5 +294,27 @@ namespace RepositoryPattern private System.Windows.Forms.ComboBox cmbStockChoser; private System.Windows.Forms.Button btnClose; + private System.Windows.Forms.Label lblStockExtId; + private System.Windows.Forms.TextBox txtStockExtId; + private System.Windows.Forms.TextBox txtBuyPrice; + private System.Windows.Forms.Label lblBuyPrice; + private System.Windows.Forms.TextBox txtBuyDate; + private System.Windows.Forms.Label lblBuyDate; + private System.Windows.Forms.TextBox txtBoughtAmount; + private System.Windows.Forms.Label lblBoughtAmount; + private System.Windows.Forms.TextBox txtActValue; + private System.Windows.Forms.Label lblActValue; + private System.Windows.Forms.TextBox txtActDate; + private System.Windows.Forms.Label lblActDate; + private System.Windows.Forms.TextBox txtActAmount; + private System.Windows.Forms.Label lblRemaining; + private System.Windows.Forms.TextBox txtSoldPrice; + private System.Windows.Forms.Label lblSoldValue; + private System.Windows.Forms.TextBox txtSoldDate; + private System.Windows.Forms.Label lblSoldDate; + private System.Windows.Forms.TextBox txtComment; + private System.Windows.Forms.Label lblComment; + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.Button btnSaveStock; } } \ No newline at end of file diff --git a/RepositoryPattern/frmRegisterStock.cs b/RepositoryPattern/frmRegisterStock.cs index e3905c0..896a115 100644 --- a/RepositoryPattern/frmRegisterStock.cs +++ b/RepositoryPattern/frmRegisterStock.cs @@ -42,5 +42,13 @@ namespace RepositoryPattern { LoadStockCombo(); } + + private void cmbStockChoser_SelectedIndexChanged(object sender, EventArgs e) + { + var stockChosen = Stocks[cmbStockChoser.SelectedItem.ToString()]; + txtStockExtId.Text = stockChosen.StockName; + txtActValue.Text = stockChosen.LatestPrice.ToString(); + txtActDate.Text = (DateTime.Today + stockChosen.TimeOfDay).ToString(); + } } }