C#C
C#3y ago
Wisch10

Is there a way to return or access a class object created inside a public partial class (form) from

I have a process that allows expenses to be added from a form, and a separate process to add an asset from a form. I would like to add a combination of the two if the expense is for an asset but to run the db inserts in the same function so that if one fails, both are rolled back. I created my second asset form to accept the values for price, purchase date, and payment type and have that only being generated when the expense type is an asset.

FrmAssetFromExpense frmAssetFromExpense = new(expenseDate, amount, type);
fromAssetFromExpense.ShowDialog();

Inside the new form for asset addition, all the items are in place to create the Asset class object from the values entered on the form.

Is there a way to return that Asset object to the main expense form to run a single sql insert?
Was this page helpful?