A generalized Koszul theory and its relation to the classical theory