That's not as true anymore. If you did some interesting independent-research projects as an undergrad, which you got published as conference papers, that strongly overrides your undergrad course grades nowadays, at most schools. Basically publications trump everything, and grades are only used if you don't have any publications.