Could someone please explain me this line of code? I was trying to cut it into smaller pieces, but it doesn't ring any bell for me. Thank you.
SqlTransaction transaction = cn.BeginTransaction(System.Data.IsolationLevel.ReadCommitted);
Your code snippet starts a new transaction with a Read Committed transaction isolation level. Isolation levels are a trait of transactions indicating how isolated the transaction is from the data modifications made by other simultaneous transactions.
See MSDN IsolationLevel Enumeration for more info on the
System.Data.IsolationLevel.ReadCommitted isolation level used in your example and for alternatives.
See MSDN Understanding Isolation Levels for more on isolation levels.