My Sales Order in C# not working properly
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4378196/qty-control-in-c">Qty Control in C#</a>  </p>
</blockquote>



<p>I hope the mods don't mind reposting this again. The code below does not work the way it should. When the end user clicks the btQty button the quantity goes to -2. When it should be going by down by one (as sales are made). Here is the code  and thanks in advance..</p>

<pre><code>    cs.Open();
    int ret;
    string Query = "SELECT QTY from tblStock WHERE ID=1";
    SqlCommand cmd = new SqlCommand(Query, cs);
    string str = Convert.ToString(cmd.ExecuteScalar());
    if (str != "")
    {
        ret = Convert.ToInt32(cmd);
    }
    else
    {
        ret = -1; 
    }

    if (ret == 0)
    {
        lbqty.Text = "Not enough stocks.";
        dgUpdate();
    }

    else
    {
        cmd.CommandText = "UPDATE tblContacts SET QTY = QTY-1 WHERE ID=1";
        cmd.ExecuteNonQuery();
        if (ret == 1)
        {
            lbqty.Text = "Re-order. Remaining stocks: 1";
            dgUpdate();
        }
        else
        {
            txtQty.Text = "Remaining stocks: " + (ret - 1).ToString();
            lbqty.Text = "Remaining stocks: " + (ret - 1).ToString();
            dgUpdate();
        }
    }
    cs.Close();
</code></pre>
