private void FormIncomeTransferManage_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (DialogResult == DialogResult.OK)
     {
         return;
     }
     //Clean up any potential entities that were inserted during window interactions.
     if (_unallocatedPayNum != 0)
     {
         //user is canceling out of the window and an unallocated transfer was made.
         ODException.SwallowAnyException(() => {
             Payments.Delete(_unallocatedPayNum);
             SecurityLogs.MakeLogEntry(Permissions.PaymentEdit, _patCur.PatNum, $"Automatic transfer deleted for payNum: {_unallocatedPayNum}.");
         });
     }
     if (_claimTransferResult != null)
     {
         //user is canceling out of the window and an claim transfer was made.
         if (_claimTransferResult.ListInsertedClaimProcs.Count > 0)
         {
             ODException.SwallowAnyException(() => {
                 ClaimProcs.DeleteMany(_claimTransferResult.ListInsertedClaimProcs);
                 SecurityLogs.MakeLogEntry(Permissions.PaymentEdit, _patCur.PatNum, $"Automatically transferred claimprocs deleted.");
             });
         }
         if (_claimTransferResult.ListInsertedPaySplits.Count > 0)
         {
             ODException.SwallowAnyException(() => {
                 List <long> listDistinctPayNums = _claimTransferResult.ListInsertedPaySplits.Select(x => x.PayNum).Distinct().ToList();
                 foreach (long payNum in listDistinctPayNums)
                 {
                     Payments.Delete(payNum);
                 }
                 SecurityLogs.MakeLogEntry(Permissions.PaymentEdit, _patCur.PatNum, $"Automatically transferred unearned from claimprocs deleted.");
             });
         }
     }
 }