From a87f91b92119280f3593676abbcbb86c467a516d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Mon, 18 Jan 2021 21:48:24 +0100 Subject: [PATCH] Stock chosingcombo implemented in also created registerwindow --- RepositoryPattern/frmInitial.Designer.cs | 28 ++++++- RepositoryPattern/frmInitial.cs | 20 ++++- .../frmRegisterStock.Designer.cs | 73 +++++++++++++++++++ RepositoryPattern/frmRegisterStock.cs | 46 ++++++++++++ RepositoryPattern/frmRegisterStock.resx | 60 +++++++++++++++ 5 files changed, 223 insertions(+), 4 deletions(-) create mode 100644 RepositoryPattern/frmRegisterStock.Designer.cs create mode 100644 RepositoryPattern/frmRegisterStock.cs create mode 100644 RepositoryPattern/frmRegisterStock.resx diff --git a/RepositoryPattern/frmInitial.Designer.cs b/RepositoryPattern/frmInitial.Designer.cs index 5918520..81f4d82 100644 --- a/RepositoryPattern/frmInitial.Designer.cs +++ b/RepositoryPattern/frmInitial.Designer.cs @@ -39,8 +39,11 @@ namespace RepositoryPattern this.lblStockRows = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); this.chbShowBrowser = new System.Windows.Forms.CheckBox(); + this.gbStockMgmnt = new System.Windows.Forms.GroupBox(); + this.btnStockReg = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.gB1.SuspendLayout(); + this.gbStockMgmnt.SuspendLayout(); this.SuspendLayout(); // // dataGridView @@ -146,11 +149,31 @@ namespace RepositoryPattern this.chbShowBrowser.UseCompatibleTextRendering = true; this.chbShowBrowser.UseVisualStyleBackColor = true; // + // gbStockMgmnt + // + this.gbStockMgmnt.Controls.Add(this.btnStockReg); + this.gbStockMgmnt.Location = new System.Drawing.Point(411, 411); + this.gbStockMgmnt.Name = "gbStockMgmnt"; + this.gbStockMgmnt.Size = new System.Drawing.Size(257, 123); + this.gbStockMgmnt.TabIndex = 8; + this.gbStockMgmnt.TabStop = false; + // + // btnStockReg + // + this.btnStockReg.Location = new System.Drawing.Point(6, 9); + this.btnStockReg.Name = "btnStockReg"; + this.btnStockReg.Size = new System.Drawing.Size(96, 23); + this.btnStockReg.TabIndex = 0; + this.btnStockReg.Text = "Stock Purchase"; + this.btnStockReg.UseVisualStyleBackColor = true; + this.btnStockReg.Click += new System.EventHandler(this.btnStockReg_Click); + // // frmInitial // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 509); + this.ClientSize = new System.Drawing.Size(800, 546); + this.Controls.Add(this.gbStockMgmnt); this.Controls.Add(this.chbShowBrowser); this.Controls.Add(this.button1); this.Controls.Add(this.lblStockRows); @@ -167,6 +190,7 @@ namespace RepositoryPattern ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.gB1.ResumeLayout(false); this.gB1.PerformLayout(); + this.gbStockMgmnt.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -184,6 +208,8 @@ namespace RepositoryPattern private System.Windows.Forms.Label lblStockRows; private System.Windows.Forms.Button button1; private System.Windows.Forms.CheckBox chbShowBrowser; + private System.Windows.Forms.GroupBox gbStockMgmnt; + private System.Windows.Forms.Button btnStockReg; } } diff --git a/RepositoryPattern/frmInitial.cs b/RepositoryPattern/frmInitial.cs index d0b56a5..61f2fc6 100644 --- a/RepositoryPattern/frmInitial.cs +++ b/RepositoryPattern/frmInitial.cs @@ -17,7 +17,9 @@ namespace RepositoryPattern private readonly IStockMemberRepository _stockMemberRepository; private readonly IStockMarketRepository _stockMarketRepository; - public frmInitial(IProductRepository productRepository,IStockMemberRepository stockMemberRepository,IStockMarketRepository stockMarketRepository) + private frmRegisterStock regWindow; + + public frmInitial(IProductRepository productRepository, IStockMemberRepository stockMemberRepository, IStockMarketRepository stockMarketRepository) { InitializeComponent(); _productRepository = productRepository; @@ -34,8 +36,9 @@ namespace RepositoryPattern { if (rdbNorth.Checked) { - dataGridView.DataSource = _productRepository.GetProducts(); } - else if(rdbStock.Checked) + dataGridView.DataSource = _productRepository.GetProducts(); + } + else if (rdbStock.Checked) { dataGridView.DataSource = _stockMemberRepository.GetStocks(); } @@ -72,5 +75,16 @@ namespace RepositoryPattern lblStockRows.Text = stocklist.Count().ToString(); } } + + private void btnStockReg_Click(object sender, EventArgs e) + { + if (rdbStock.Checked) + { + _stockMarketRepository.LoadStockMarketList(); + regWindow = new frmRegisterStock(); + regWindow.Stocks = _stockMarketRepository.StockMarketList; + regWindow.ShowDialog(); + } + } } } diff --git a/RepositoryPattern/frmRegisterStock.Designer.cs b/RepositoryPattern/frmRegisterStock.Designer.cs new file mode 100644 index 0000000..250e3a1 --- /dev/null +++ b/RepositoryPattern/frmRegisterStock.Designer.cs @@ -0,0 +1,73 @@ + +namespace RepositoryPattern +{ + partial class frmRegisterStock + { + /// + /// 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.cmbStockChoser = new System.Windows.Forms.ComboBox(); + this.btnClose = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // cmbStockChoser + // + this.cmbStockChoser.FormattingEnabled = true; + this.cmbStockChoser.Location = new System.Drawing.Point(174, 45); + this.cmbStockChoser.Name = "cmbStockChoser"; + this.cmbStockChoser.Size = new System.Drawing.Size(179, 23); + this.cmbStockChoser.TabIndex = 0; + // + // btnClose + // + this.btnClose.Location = new System.Drawing.Point(374, 532); + 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); + // + // 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.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); + + } + + #endregion + + private System.Windows.Forms.ComboBox cmbStockChoser; + private System.Windows.Forms.Button btnClose; + } +} \ No newline at end of file diff --git a/RepositoryPattern/frmRegisterStock.cs b/RepositoryPattern/frmRegisterStock.cs new file mode 100644 index 0000000..e3905c0 --- /dev/null +++ b/RepositoryPattern/frmRegisterStock.cs @@ -0,0 +1,46 @@ +using StockDomain; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RepositoryPattern +{ + public partial class frmRegisterStock : Form + { + + public Dictionary Stocks { get; set; } + + public frmRegisterStock() + { + InitializeComponent(); + } + + private void LoadStockCombo() + { + if (Stocks.Count() > 0) + { + foreach(var key in Stocks.Keys) + { + cmbStockChoser.Items.Add(key); + } + } + + } + + private void btnClose_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void frmRegisterStock_Shown(object sender, EventArgs e) + { + LoadStockCombo(); + } + } +} diff --git a/RepositoryPattern/frmRegisterStock.resx b/RepositoryPattern/frmRegisterStock.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/RepositoryPattern/frmRegisterStock.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