I am working with a project in C# using WPF, connected to a SQL Server database. I can insert data into a table, delete, update and select.
For example I have a table with a column Parts and another Quantity. 
I have these sample values: Parts: Tires and Quantity: 3. 
What I want to do is when I once choose the tires, the quantity would become 2; i.e, Quantity(2). Thanks to everyone!
The code-behind is:
{
    SqlConnection conn = new SqlConnection("Server = localhost;Database = autoser; Integrated Security = true");
    conn.Open();
    SqlCommand cmd = new SqlCommand("SELECT Part FROM autoparts WHERE Part LIKE '%" + txtpart.Text + "%'", conn);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataTable dt = new DataTable("dtkerkimi");                          
    da.Fill(dt);
    datag.ItemsSource = dt.DefaultView;
    SqlDataAdapter adapt = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    adapt.Fill(ds);
    conn.Close();
    int count = ds.Tables[0].Rows.Count;
    if (count == 0)
    {
        MessageBox.Show("There isn't a part that you are looking for!");
    }
    else
    {
        MessageBox.Show("Congrats");
    }
}
 
     
     
    