Charged particles in external fields as physical examples of quasi-exactly-solvable models: A unified treatment