The problem of optimal control for time-varying linear systems with fixed endpoints of trajectories is considered. A corresponding quadratic objective functional depends on the control, the state of the object and on its integral. New technique of designing the PI controller for the automatic control systems with box constraints on values of control is proposed. The problem is solved by using Lagrange multipliers of a special type.