Theoretical study of the dissociation energy and the red and violet band systems of CN