Inelastic scattering of electrons by crystals. I. The theory of small-angle in elastic scattering