Man shot after attempted armed robbery of undercover deputy