Using full potential linearized augmented plane wave method and considering local spin density approximation, we study superconducting and magnetic properties in virtual-crystal doped MgCNi3. The electronic band structure, bulk modulus and its pressure derivative, magnetic moment and its variation rate are calculated. It is found that: for electron-doped Mg1-xAlxCNi3(0≤x≤0.5), the superconductivity and magnetic fluctuations decrease gradually with increasing doping. For hole-doped Mg1-xNaxCNi3 with x=0.12, a ferromagnetic phase transition occurs and superconductivity disappears. In the hole doping range of 0≤x<0.12, there is the unstable superconducting state with spin fluctuations.