Necessary and sufficient dynamic programming conditions for optimal control problem with state constraints