Prepared for stock edit function + corrected bug , "not possible to buy new stock"!
This commit is contained in:
2
StockInfoCore/frmInitial.Designer.cs
generated
2
StockInfoCore/frmInitial.Designer.cs
generated
@ -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
|
||||
//
|
||||
|
||||
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,9 +57,23 @@ namespace StockInfoCore
|
||||
var stockSold = _stockRepository.LatestSell(stockChosen.StockName.Trim());
|
||||
if (stockSold != null)
|
||||
{
|
||||
txtLatestSoldDate.Text = stockSold.LatestSoldDate.Value.ToString();
|
||||
txtLatestSoldPrice.Text = stockSold.SoldStockPrice.ToString();
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user