The pairing correlations in hot nuclei $^{162}$Dy are investigated in terms of the thermodynamical properties by covariant density functional theory. The heat capacities $C_V$ are evaluated in the canonical ensemble theory and the paring correlations are treated by a shell-model-like approach, in which the particle number is conserved exactly. A S-shaped heat capacity curve, which agrees qualitatively with the experimental data, has been obtained and analyzed in details. It is found that the one-pair-broken states play crucial roles in the appearance of the S shape of the heat capacity curve. Moreover, due to the effect of the particle-number conservation, the pairing gap varies smoothly with the temperature, which indicates a gradual transition from the superfluid to the normal state.