private void BtnAdd_Click(object sender, EventArgs e) { TransactionsUpsert transactionsUpsert = new TransactionsUpsert(db, null); transactionsUpsert.InitializeManageTransaction(this); transactionsUpsert.ShowDialog(); }
private void BtnEdit_Click(object sender, EventArgs e) { try { var data = ((BindingSource)dvTransactions.DataSource).List; TransactionSet currentTransaction = null; int id = int.Parse(dvTransactions.Rows[selectedRowIndex].Cells[0].Value.ToString()); foreach (TransactionSet trans in data) { if (trans.Id == id) { currentTransaction = trans; break; } } TransactionsUpsert transactionsUpsert = new TransactionsUpsert(db, currentTransaction); transactionsUpsert.InitializeManageTransaction(this); transactionsUpsert.ShowDialog(); } catch (Exception ex) { Console.WriteLine(ex.Message); MessageBox.Show("Failed to edit transaction."); } }