I think the ecu only remembers one radio code. If you fitted an RCD510 then you should have entered the radio code for that one. If your putting back the RCD310 then you will have to enter the radio code for that one.
No they don't write the radio codes Cab's handbook if you don't have it then contact a dealer with proof of ownership and they should give it to you free of charge.