This is (what I believe) your problem is.
Since you bought it used, I don't think that's a G&P stock part, because that charging handle (and spring) look like they go on a G&G Blowback. The spring hooks onto the metal blowback piston on the G&G blowback gearboxes, and by pulling the charging handle, it pulls back the thing under the dust cover.
As for your dust cover, it's made to always be open to simulate a real M4 (that's where the bullet ejects), so you can't lock it up. You can fix this by adding your own latch, but it looks to me as if the parts you got aren't stock.
I might be wrong, but that's my 0.02