Jump to content

Record Locking


ShadowMage
 Share

Recommended Posts

Looking for a bit of advice. I have an quoting system that I built for my company. This system allows our estimators to produce quotes for skylight systems. Currently, there is no limit to how many people can be viewing or editing a quote. What I'm wondering is what is the best way to lock a quote so that only one person can modify it at a time? I thought about creating a field in the database called Locked which will hold a value of 0 or 1 (1 being locked, 0 being not locked). This way, when an estimator loads a quote, the field can be updated to hold a 1. The problem is how do I reset it to 0?Anyone have any ideas how this could be accomplished? Or ideas on other ways to accomplish a locking procedure? Thanks in advance.

Link to comment
Share on other sites

Locking is an old issue with programming, every time you read or write to a file (or databases), it will get and release a lock. If this is a big enough issue then the users just may have to deal with locking and unlocking themselves. They can open a read-only view, but if they want to edit it they hit another button that will get the lock and let them start editing it. If they save or cancel then it releases the lock. If they got a lock but never released it then someone else trying to edit it gets to call them up and tell them to open it and release the lock, and eventually they'll figure it out. You can use timestamps so that you can show when the lock was given. You may be able to automate it by releasing every lock a user has if they navigate to another page, but that will stop people from being able to use multiple windows at once if that's something they're doing now.

Link to comment
Share on other sites

Locking is an old issue with programming, every time you read or write to a file (or databases), it will get and release a lock.
Yep. I get that. I'm more worried about people overwriting changes that have already been made, though. Not two people trying to write at the same time. Since this is all form based, if Fred and Rita open the same quote at the same time, they'll both have identical data. Fred changes field A and saves. Rita now changes field B and saves. Rita just overwrote the change Fred made to field A because the form she has loaded still has the original data from before Fred's save.
If this is a big enough issue then the users just may have to deal with locking and unlocking themselves. They can open a read-only view, but if they want to edit it they hit another button that will get the lock and let them start editing it. If they save or cancel then it releases the lock. If they got a lock but never released it then someone else trying to edit it gets to call them up and tell them to open it and release the lock, and eventually they'll figure it out. You can use timestamps so that you can show when the lock was given. You may be able to automate it by releasing every lock a user has if they navigate to another page, but that will stop people from being able to use multiple windows at once if that's something they're doing now.
Currently, it isn't a big issue, but it's something I've been thinking about. We don't have very many estimators at the moment, but that may change. And obviously, that could make this a bigger issue.So the manual locking is currently the only option then? If automating it when they navigate to another page will prevent the use of multiple windows, I can't do that because that is something they're currently doing.
Link to comment
Share on other sites

Guest So Called

I'll add a bit of brainstorming for you... How about when any record is initially called up you make it read-only mode, and provide an edit button. When Fred clicks Edit it sets a Locked field in your database including username and time/date. Fred can start work changing the record. If in the middle of that Rita wants to edit the record she clicks Edit, but gets an error message "Cannot edit: record locked by Fred at such and so time/date." Rita won't be able to edit it until Fred clicks a button Save. If Fred leaves it locked then Rita will be able to phone Fred or the IT department and have the problem addressed. Or if she waits until Fred saves his work, then she can hit Edit and begin her own changes.

Link to comment
Share on other sites

You can do something like they have here, where it notifies you when someone posts to a thread you're looking at. You can keep track of when people are making changes, when people are viewing things, and warn them if they try to save a change to something that has been updated after they started viewing it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...