First-principles calculation of transport property in nano-devices under an external magnetic field