The scattering of electrons by atoms and crystals. I. A new theoretical approach