Sum Rules for Charmonium and Charmed Mesons in Quantum Chromodynamics