I would advise against actually applying a database lock to the record. Better to add some new fields, e.g. LockDateTime and LockUser, and fill these when the browser loads the page and clear them when the browser leaves the page.
You can then handle the client halting by looking at the new fields the next time a user wants to see the same invoice. For example:
- if another user requests a locked invoice, compare the current Date/Time to the LockDateTime field and if its more than, say, 20 mins ago (you need to decide a reasonable interval for your users) allow the new user to view it and update the LockDateTime and LockUser with new values
- if the same user request the invoice again, let them view it and update the LockDateTime.
You can also schedule a database job to clear out the values in LockDateTime and LockUser at suitable intervals (again you need to decide what is reasonable for your application).
hth
Phil
|