There are 2 system stored procedures to help you with this:
first you can to run this stored proc against the master
db to grant the user a login to the db server (effectively allows them to connect to it)
EXEC sp_grantlogin 'domain\user'
then you run this one against each database to grant access to each database
EXEC sp_grantdbaccess 'domain\user', 'user'
I'm afraid I can't give you the c# code to run these stored procs, someone else will have to help you there.