Let $F = ax^2 + bxy + cy^2$ be a binary quadratic form over $\mathbb{Z}$. We say $D = b^2 - 4ac$ is the discriminant of $F$. If $D$ is not a square integer and gcd($a, b, c) = 1$, we say $ax^2 + bxy + cy^2$ is primitive.
Is the following proposition true? If yes, how do we prove it?
Proposition Let $D$ be a non-square integer such that $D \equiv 0$ (mod $4$) or $D \equiv 1$ (mod $4$). By this question, there exists an order $R$ of a quadratic number field $K$ such that the discriminant of $R$ is $D$. Let $ax^2 + bxy + cy^2$ be a binary quadratic form whose discriminant is $D$. Then $I = \mathbb{Z}a + \mathbb{Z}\frac{(-b + \sqrt{D})}{2}$ is an ideal of $R$. Moreover, $I$ is invertible if and only if $ax^2 + bxy + cy^2$ is primitive.