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)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 16);
|
this.dataGridView.Location = new System.Drawing.Point(12, 16);
|
||||||
|
this.dataGridView.MultiSelect = false;
|
||||||
this.dataGridView.Name = "dataGridView";
|
this.dataGridView.Name = "dataGridView";
|
||||||
this.dataGridView.RowTemplate.Height = 25;
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
this.dataGridView.Size = new System.Drawing.Size(871, 360);
|
this.dataGridView.Size = new System.Drawing.Size(871, 360);
|
||||||
this.dataGridView.TabIndex = 0;
|
this.dataGridView.TabIndex = 0;
|
||||||
|
this.dataGridView.SelectionChanged += new System.EventHandler(this.dataGridView_SelectionChanged);
|
||||||
//
|
//
|
||||||
// lblTotalRecords
|
// lblTotalRecords
|
||||||
//
|
//
|
||||||
|
|||||||
@ -35,6 +35,7 @@ namespace StockInfoCore
|
|||||||
private readonly frmPersonShareConnect _personShareConnect;
|
private readonly frmPersonShareConnect _personShareConnect;
|
||||||
private readonly frmBackup _backupWindow;
|
private readonly frmBackup _backupWindow;
|
||||||
|
|
||||||
|
bool loading = false;
|
||||||
//private frmRegisterStock regWindow;
|
//private frmRegisterStock regWindow;
|
||||||
//private frmMyStocks stockWindow;
|
//private frmMyStocks stockWindow;
|
||||||
//private frmSelling sellWindow;
|
//private frmSelling sellWindow;
|
||||||
@ -88,10 +89,12 @@ namespace StockInfoCore
|
|||||||
|
|
||||||
private void ReloadData()
|
private void ReloadData()
|
||||||
{
|
{
|
||||||
|
loading = true;
|
||||||
var allStocks = _stockRepository.GetAllStocks();
|
var allStocks = _stockRepository.GetAllStocks();
|
||||||
dataGridView.DataSource = allStocks;
|
dataGridView.DataSource = allStocks;
|
||||||
// SaveStocks(allStocks);
|
// SaveStocks(allStocks);
|
||||||
lblTotalRecords.Text = $"Total records: {dataGridView.RowCount}";
|
lblTotalRecords.Text = $"Total records: {dataGridView.RowCount}";
|
||||||
|
loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -264,5 +267,15 @@ namespace StockInfoCore
|
|||||||
// backupWindow = new frmBackup(_backupRepository, _backupRoutines);
|
// backupWindow = new frmBackup(_backupRepository, _backupRoutines);
|
||||||
_backupWindow.ShowDialog();
|
_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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,10 +56,24 @@ namespace StockInfoCore
|
|||||||
txtActDate.Text = (DateTime.Today + stockChosen.TimeOfDay).ToString();
|
txtActDate.Text = (DateTime.Today + stockChosen.TimeOfDay).ToString();
|
||||||
var stockSold = _stockRepository.LatestSell(stockChosen.StockName.Trim());
|
var stockSold = _stockRepository.LatestSell(stockChosen.StockName.Trim());
|
||||||
if (stockSold != null)
|
if (stockSold != null)
|
||||||
|
{
|
||||||
|
if (stockSold.LatestSoldDate != null)
|
||||||
{
|
{
|
||||||
txtLatestSoldDate.Text = stockSold.LatestSoldDate.Value.ToString();
|
txtLatestSoldDate.Text = stockSold.LatestSoldDate.Value.ToString();
|
||||||
txtLatestSoldPrice.Text = stockSold.SoldStockPrice.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)
|
private void btnSaveStock_Click(object sender, EventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user