Theory of the de Haas-van Alphen effect in quasi-two-dimensional conductors