# Integrability of a differential condition

I'm reading "The variational principles of mechanics", written by C. Lanczos and he said that, if one have the condition $dq_3 = B_1 dq_1 + B_2 dq_2$ and one want to know if there is a finite relation between the $q_i$, on account the given condition, one must have the condition $$\frac{\partial B_1}{\partial q_2} = \frac{\partial B_2}{\partial q_1}$$.

What I don't understand is how the condition on the differentials imply the equality between the derivatives above.

The point is, under certain conditions(which are always satisfied in physics), we have $\frac{\partial^2 f}{\partial q_1 \partial q_2}=\frac{\partial^2 f}{\partial q_2 \partial q_1}$. Now for $dq_3$ to be integrable, there should be some f such that $B_1=\frac{\partial f}{\partial q_1}$ and $B_2=\frac{\partial f}{\partial q_2}$. But how can we check that? We can use the equation I mentioned:
$\frac{\partial^2 f}{\partial q_1 \partial q_2}=\frac{\partial^2 f}{\partial q_2 \partial q_1} \Rightarrow \frac{\partial B_2}{\partial q_1}=\frac{\partial B_1}{\partial q_2}$.