Well it could be a few things.
1. Try turning off the laptop (off not sleep or hibernate) and let it charge the battery for a while. Then turn it on and see if it will charge when on or not. Sometimes they need time to charge for the first time before they will work correctly.
2. If it is an aftermarket battery you bought, and not OEM one, that could be your problem. It may just be flawed (happens a lot with aftermarket ones). If that is the case, the only resolution is to return the battery and purchase an OEM one.
3. Try charging when the laptop is completely powered off (not sleep or hibernate, but off). If it will charge then, the problem is likely the charger and it will need replacing. Not charging while running the device is a common issue for a bad charger.
4. It could be the charging circuit. If that is the case, then you will need to have a tech look at the laptop.