Microscopic Theory of Band and Local States in Ionic Crystals