What do you want to "keep"? You are showing calculations as though you're trying to prove some math operation. Programming languages don't work like that.
You will have a function that accepts the changes, something with a signature like:
private void UpdateDatabase(int myItemID, int newValue)
{
}
At this point, you have the
newValue
, and before you update the database, you can just fetch a copy of the old value from the database. Use a query to get the value.
From there, you can do whatever math you want to, or log, or whatever turns your crank.
Cheers.