Please I need someone to help me complete this line of code that is commented below. the idea is to prevent Any sales onse quantity of product is 0.
Here is the code:
private void CheckQuantity(int recordID)
{
SqlConnection sqlConnection1 = new SqlConnection("Your Connection String");
SqlCommand cmd = new SqlCommand();
Object returnValue;
cmd.CommandText = "SELECT [qty] FROM [Product] WHERE [RecordID] = @RecordID";
cmd.Parameters.Add(new SqlParameter("@RecordID", System.Data.SqlDbType.Int));
cmd.Parameters [ "@RecordID" ].Value = recordID;
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
returnValue = cmd.ExecuteScalar();
sqlConnection1.Close();
if (Convert.ToInt32(returnValue) < 2)
{
ErrorLabel.Text = "Sorry, the item is out of stock.";
}
else
{
//process the order
}
}
Go to the complete details ...