Prepared for stock edit function + corrected bug , "not possible to buy new stock"!

This commit is contained in:
2021-05-24 22:49:23 +02:00
parent 27db60bbb2
commit 6c32c38296
3 changed files with 31 additions and 2 deletions

View File

@ -64,10 +64,12 @@ namespace StockInfoCore
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(12, 16);
this.dataGridView.MultiSelect = false;
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(871, 360);
this.dataGridView.TabIndex = 0;
this.dataGridView.SelectionChanged += new System.EventHandler(this.dataGridView_SelectionChanged);
//
// lblTotalRecords
//

View File

@ -35,6 +35,7 @@ namespace StockInfoCore
private readonly frmPersonShareConnect _personShareConnect;
private readonly frmBackup _backupWindow;
bool loading = false;
//private frmRegisterStock regWindow;
//private frmMyStocks stockWindow;
//private frmSelling sellWindow;
@ -88,10 +89,12 @@ namespace StockInfoCore
private void ReloadData()
{
loading = true;
var allStocks = _stockRepository.GetAllStocks();
dataGridView.DataSource = allStocks;
// SaveStocks(allStocks);
lblTotalRecords.Text = $"Total records: {dataGridView.RowCount}";
loading = false;
}
@ -264,5 +267,15 @@ namespace StockInfoCore
// backupWindow = new frmBackup(_backupRepository, _backupRoutines);
_backupWindow.ShowDialog();
}
private void dataGridView_SelectionChanged(object sender, EventArgs e)
{
if (!loading)
{
//MessageBox.Show($"{((DataGridView)sender).SelectedRows.ToString()} eventargs = {e.ToString()}" );
int id = Convert.ToInt32(dataGridView.Rows[dataGridView.CurrentRow.Index].Cells[0].Value);
MessageBox.Show($"Vald rads id = {id}");
}
}
}
}

View File

@ -56,10 +56,24 @@ namespace StockInfoCore
txtActDate.Text = (DateTime.Today + stockChosen.TimeOfDay).ToString();
var stockSold = _stockRepository.LatestSell(stockChosen.StockName.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;
}
}
private void btnSaveStock_Click(object sender, EventArgs e)