Transactions on Forms


Author
Message
Tim Dol
Tim Dol
StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)
Group: Forum Members
Posts: 340, Visits: 1.4K
I have a requirement to use transactions on one of my entry forms. Note: I am not using the MaintnenaceFormToolStrip. I have three business objects on a form and some of the fields are bound to controls etc... Pretty standard form.

Do I simply start the transaction in the FORM 'BeforeSave' event on the Form and then commit the transaction in the FORM 'AfterSave' event?

Any assistance would be appeciated.

Thanks,

Tim

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
You can, or you could create a method that is called versus calling the Save directly on the form first.  For example, you would create a method that starts the transactions, calls the Save() or the BOs directly, and the commit the transactions after the save.
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
There is a nice sample in the help file with the topic "Using Transactional Processing"

Public Sub SaveAllOnTransaction()
    '-- Add a try around the transaction processing
    '   This enables the process to call TransactionRollback()
    '   if anything bad happens during the transaction process.
    Try
        '-- Start the transaction
        BusinessLayer.TransactionBegin("", Data.IsolationLevel.ReadCommitted)
       
        '-- Save the business objects on the transaction
        Me.Customers.Save(True)
        Me.Orders.Save(True)
        Me.OrderItems.Save(True)
       
        '-- When business objects are saved on the transaction, the
        '   pending changes to their internal DataTables are NOT saved
        '   until TransactionEnd() is called...
        '-- Call transaction end to commit the transaction queries and
        '   accept the pending changes on all of the business objects
        '   that participated in the transaction.
        BusinessLayer.TransactionCommitt("")
   
    Catch ex As Exception
        '-- If an exception occurs during the saving of the records, then
        '   abort the transaction.
        BusinessLayer.TransactionRollback("")
    End Try
End Sub

 

Edhy Rijo

Tim Dol
Tim Dol
StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)
Group: Forum Members
Posts: 340, Visits: 1.4K
Thanks for the help guys, I was able to get things working except for handling of broken rules. Using the example, what if there were broken rules on the orders table - Me.Orders.Save(True) after the transaction was started.  Would you first check all for broken rules on all business objects before calling 'SaveAllOnTransaction' or check the status of each save within the transactions and perform a rollback if a broken rule is found?  At first I thought it would be pretty simple to implement transactions at the form level but I lost some of the power of StataFrame with form level events etc...

Let me know if I'm missing the ball on this or if you have any suggestions on how to handle broken rules etc.. when using transactions.

Thanks

Tim

Tim Dol
Tim Dol
StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)StrataFrame User (408 reputation)
Group: Forum Members
Posts: 340, Visits: 1.4K
Just wondering if I'm headed in the right direction dealing with Transactions within forms. Any input would be appreciated.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search