A Study of Solar Flare Effects on the Geomagnetic Field Components during Solar Cycles 23 and 24