I'm facing a problem in my project. Basically its a small project for a retail store inbound section. The goods come in cartons and the user enters the carton ID in the UI to accept the carton. In the backend the carton details get updated in the table as received. Problem is that when 2 users are concurrently logged in and by mistake enter the same carton ID simultaneously none of them gets an error and the carton details are updated to twice the actual value. how do i avoid this situation?
basically i validate the carton by checking its current status in the db, which will be 'pending recv' if it has not been recvd yet. however the carton ID is being entered twice before the status gets updated. for both the guys the carton gets validated correctly and then a lot of incorrect updates happen. The architecture is client-server, multiple clients, single server.
please suggest some solution for this, i'll see if i can implement it.