I am working on a C# application where the main part of my program is about stock and items available on stock. What I want to do is when I choose an item from stock the quantity should deduct, I know how to deduct the quantity.
Problem is this: when the quantity reaches the value 0, the deduct should stop and application should return a message that notice me about that.
My code that I tried is this:
private void btn_Click(object sender, RoutedEventArgs e)
{
SqlConnection con = new SqlConnection("server = localhost; database= test;Integrated Security = true");
con.Open();
try
{
SqlCommand cmd = new SqlCommand("Update so set quantity where quantity = 0 And name Like '%" + txt.Text + "%'", con);
}
catch
{
MessageBox.Show("There isn't any part left that you are looking for");
}
finally
{
con.Close();
}
}