some time ago I read an opinion about how to handle modifying the contents of a database through a dialog (I suspect it was here on SO, but I was not able to find the relevant question). There are two possibilities:
start a transaction when showing the form, commit it on clicking OK and rollback on clicking Cancel.
read the relevant data from the database and cache it, do the required changes on the cached data and then update the DB with this data on clicking OK.
I am using the latter approach since the original comment recommended doing so, but I can't remember the reasoning behind it. I am currently reconsidering it because caching all the data seems to me a bit superfluous. Any thoughts/links on this topic?