I think you are looking for something like this:
class MainForm()
{
private TransactionScope _scope;
public void SaveButton_Click()
{
_scope.Complete();
Close();
}
public MainForm()
{
_scope = new TransactionScope();
}
~MainForm()
{
_scope.Dispose();
}
}
However, I strongly advise you NOT to do this. Since you will possibly have to wait a long time for the user to complete the inputs, you will run into all kinds of problems with transaction lifetime and locked database records.
Depending on your needs, consider picking one of the following solutions instead:
If the user clicks cancel in MainForm, simply delete the created Transaction again.
Pass the inputted values from the Transaction Form to the Main Form and only save the Transaction if the user clicks the Main Form's Save button.