The error message you get says "The string you tried to convert does not contain a number, so I can't convert it" - and that means that whatever the user has typed into
txt_salary.Text
isn't just digits - it may be
"12 34"
, or
"Hello"
, or
"$10,000"
, or perhaps
"10000.00"
Instead of using int.Parse, at the top of the method use int.TryParse instead:
int salary;
if !(int.TryParse(txt_salary.Text, out salary))
{
... Bad input by user, report it to him ...
return;
}
And also validate all other entry fields. You can then use the validated values in
salary
and such line confident that they will work.