Superfluid-Mott-insulator transition of spin-2 cold bosons in an optical lattice in a magnetic field