You have total declared within the btnOK_Click scope so total does not exist anywhere else.
while (quantity != 0)
Isn't this an infinite loop?