Error converting data type varchar to bigint

You have database and application problems, requiring a re-write.

Tell your boss the code is terrible and maintenance might be more expensive than rewriting it. That code is guaranteed to be buggy.

My recommendation:
Use this to create an n-tier separation. Leave the database alone, create new stored procedures and perform this logic in the application (c#): http://systemdotpersistence.blogspot.com