After selling 2/5 he would be left with 3/5 and 3/4 of this gives us 9/20 of the initial amount.
So, if x is the number of cartons he had at the start, then (9/20-2/5)x=24.
((9-8)/20)x=24, x/20=24, x=480.
CHECK
2/5 of 480=192 sold in the morning. That leaves 288 and 3/4 of this is 216 cartons, which is 24 more than he sold in the morning.