Esempio n. 1
0
        /*public Utiles()
         * {
         * }*/
        #region "Conversiones"
        public static string digito_verificador(long rut)
        {
            long   Digito;
            long   Contador;
            long   Multiplo;
            long   Acumulador;
            string RutDigito;

            Contador   = 2;
            Acumulador = 0;

            while (rut != 0)
            {
                Multiplo   = (rut % 10) * Contador;
                Acumulador = Acumulador + Multiplo;
                rut        = rut / 10;
                Contador   = Contador + 1;
                if (Contador == 8)
                {
                    Contador = 2;
                }
            }

            Digito    = 11 - (Acumulador % 11);
            RutDigito = Digito.ToString().Trim();
            if (Digito == 10)
            {
                RutDigito = "K";
            }
            if (Digito == 11)
            {
                RutDigito = "0";
            }
            return(RutDigito);
        }
Esempio n. 2
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Agencia != null)
         {
             hashCode = hashCode * 59 + Agencia.GetHashCode();
         }
         if (Numero != null)
         {
             hashCode = hashCode * 59 + Numero.GetHashCode();
         }
         if (Digito != null)
         {
             hashCode = hashCode * 59 + Digito.GetHashCode();
         }
         if (Saldo != null)
         {
             hashCode = hashCode * 59 + Saldo.GetHashCode();
         }
         if (Cliente != null)
         {
             hashCode = hashCode * 59 + Cliente.GetHashCode();
         }
         if (Transacoes != null)
         {
             hashCode = hashCode * 59 + Transacoes.GetHashCode();
         }
         return(hashCode);
     }
 }
Esempio n. 3
0
        public static string GetDigit(int ID)
        {
            int    Digito;
            int    Contador;
            int    Multiplo;
            int    Acumulador;
            string RutDigito;

            Contador   = 2;
            Acumulador = 0;

            while (ID != 0)
            {
                Multiplo   = (ID % 10) * Contador;
                Acumulador = Acumulador + Multiplo;
                ID         = ID / 10;
                Contador   = Contador + 1;
                if (Contador == 8)
                {
                    Contador = 2;
                }
            }
            Digito    = 11 - (Acumulador % 11);
            RutDigito = Digito.ToString().Trim();
            if (Digito == 10)
            {
                RutDigito = "K";
            }
            if (Digito == 11)
            {
                RutDigito = "0";
            }
            return(RutDigito);
        }
Esempio n. 4
0
    //
    // TODO: Agregar aquí la lógica del constructor
    //
    public String digitoVerificador(int rut)
    {
        int    Digito;
        int    Contador;
        int    Multiplo;
        int    Acumulador;
        String RutDigito;

        Contador   = 2;
        Acumulador = 0;

        while (rut != 0)
        {
            Multiplo   = (rut % 10) * Contador;
            Acumulador = Acumulador + Multiplo;
            rut        = rut / 10;
            Contador   = Contador + 1;
            if (Contador == 8)
            {
                Contador = 2;
            }
        }

        Digito    = 11 - (Acumulador % 11);
        RutDigito = Digito.ToString().Trim();
        if (Digito == 10)
        {
            RutDigito = "K";
        }
        if (Digito == 11)
        {
            RutDigito = "0";
        }
        return(RutDigito);
    }
Esempio n. 5
0
        private static string digitoVerificador(Int64 rut)
        {
            Int64  Digito;
            int    Contador;
            Int64  Multiplo;
            Int64  Acumulador;
            string RutDigito;

            Contador   = 2;
            Acumulador = 0;

            while (rut != 0)
            {
                Multiplo   = (rut % 10) * Contador;
                Acumulador = Acumulador + Multiplo;
                rut        = rut / 10;
                Contador   = Contador + 1;
                if (Contador == 8)
                {
                    Contador = 2;
                }
            }

            Digito    = 11 - (Acumulador % 11);
            RutDigito = Digito.ToString().Trim();
            if (Digito == 10)
            {
                RutDigito = "K";
            }
            if (Digito == 11)
            {
                RutDigito = "0";
            }
            return(RutDigito);
        }
Esempio n. 6
0
        /// <summary>
        ///Esse é o Modulo 11 responsável pelo Nosso Número
        /// </summary>
        /// <param name="Valor">Valor a ser inserido para retorno do DV</param>
        /// <param name="Base">Base que pode variar de 2 a 9 </param>
        /// <returns></returns>
        private static string Modulo11(string Valor, int Base, bool Resto)
        {
            int Contador, Peso, Digito, Soma;

            Soma = 0;
            Peso = 2;
            string retorno = string.Empty;

            for (Contador = Valor.Length - 1; Contador >= 0; Contador--)
            {
                Soma = Soma + (int.Parse(Valor[Contador].ToString()) * Peso);
                if (Peso < Base)
                {
                    Peso = Peso + 1;
                }
                else
                {
                    Peso = 2;
                }
            }
            if (Resto)
            {
                retorno = (Soma % 11).ToString();
            }
            else
            {
                Digito = 11 - (Soma % 11);
                if (Digito > 9)
                {
                    Digito = 0;
                }
                retorno = Digito.ToString();
            }
            return(retorno);
        }
Esempio n. 7
0
        public static string GetDigit(this int Id)
        {
            int    Digito;
            int    Contador;
            int    Multiplo;
            int    Acumulador;
            string RutDigito;

            Contador   = 2;
            Acumulador = 0;

            while (Id != 0)
            {
                Multiplo    = (Id % 10) * Contador;
                Acumulador += Multiplo;
                Id         /= 10;
                Contador   += 1;
                if (Contador == 8)
                {
                    Contador = 2;
                }
            }
            Digito    = 11 - (Acumulador % 11);
            RutDigito = Digito.ToString(CultureInfo.InvariantCulture).Trim();
            if (Digito == 10)
            {
                RutDigito = "K";
            }
            if (Digito == 11)
            {
                RutDigito = "0";
            }
            return(RutDigito);
        }
Esempio n. 8
0
        public string Calcular(string valor)
        {
            int    Digito, Soma = 0, Peso = 2, m1;
            string m2;

            for (int i = valor.Length; i > 0; i--)
            {
                m1 = (Convert.ToInt32(Common.Mid(valor, i, 1)) * Peso);
                m2 = m1.ToString();

                for (int j = 1; j <= m2.Length; j++)
                {
                    Soma += Convert.ToInt32(Common.Mid(m2, j, 1));
                }

                if (Peso == 2)
                {
                    Peso = 1;
                }
                else
                {
                    Peso = Peso + 1;
                }
            }
            Digito = ((10 - (Soma % 10)) % 10);

            return(Digito.ToString());
        }
Esempio n. 9
0
        public string Calcular(string valor)
        {
            int Digito, Soma = 0, Peso = 2;

            for (int i = valor.Length; i > 0; i--)
            {
                Soma = Soma + (Convert.ToInt32(Common.Mid(valor, i, 1)) * Peso);
                if (Peso == _baseCalculo)
                {
                    Peso = 2;
                }
                else
                {
                    Peso = Peso + 1;
                }
            }
            if (((Soma % 11) == 0) || ((Soma % 11) == 10) || ((Soma % 11) == 1))
            {
                Digito = 1;
            }
            else
            {
                Digito = 11 - (Soma % 11);
            }
            return(Digito.ToString());
        }
        public DecomposicaoChaveAcesso(string chave)
        {
            _erros = new List <string>();
            Chave  = chave;

            if (string.IsNullOrWhiteSpace(chave) || chave.Length != 44)
            {
                AdicionarErro("A chave informada é inválida. A chave deve conter 44 dígitos.");
                return;
            }

            Estado         = ObterParte(ObterEstado, "Estado");
            DataEmissao    = ObterParte(ObterDataEmissao, "Data de emissão (ano e mês)");
            Emitente       = ObterParte(ObterCnpjEmitente, "CNPJ do emitente");
            Modelo         = ObterParte(ObterModelo, "Modelo");
            Serie          = ObterParte(ObterSerie, "Série");
            Numero         = ObterParte(ObterNumero, "Número");
            FormaEmissao   = ObterParte(ObterFormaEmissao, "Forma de emissão");
            CodigoNumerico = ObterParte(ObterCodigoNumerico, "Código numerico");
            Digito         = ObterParte(ObterDigito, "Dígito verificador");

            if (Digito.ToString() != new CalculadoraDigitoVerificadorChaveAcesso().Calcular(chave).ToString())
            {
                AdicionarErro("A chave informada contem um dígito verificador inválido.");
            }
        }
Esempio n. 11
0
    public static bool validarRut(string campoValidar)
    {
        bool resultado = true;

        campoValidar = campoValidar.Replace("-", "");

        string digitoVerificador = campoValidar.Substring(campoValidar.Length - 1);
        string sinDigito         = campoValidar.Substring(0, campoValidar.Length - 1);

        if (validarNumero(sinDigito))
        {
            int rut = Convert.ToInt32(sinDigito);

            int    Digito;
            int    Contador;
            int    Multiplo;
            int    Acumulador;
            String RutDigito;

            Contador   = 2;
            Acumulador = 0;

            while (rut != 0)
            {
                Multiplo   = (rut % 10) * Contador;
                Acumulador = Acumulador + Multiplo;
                rut        = rut / 10;
                Contador   = Contador + 1;
                if (Contador == 8)
                {
                    Contador = 2;
                }
            }

            Digito    = 11 - (Acumulador % 11);
            RutDigito = Digito.ToString().Trim();
            if (Digito == 10)
            {
                RutDigito = "K";
            }
            if (Digito == 11)
            {
                RutDigito = "0";
            }

            if (RutDigito != digitoVerificador)
            {
                resultado = false;
            }
        }
        else
        {
            resultado = false;
        }

        return(resultado);
    }
Esempio n. 12
0
 public ChaveAcesso(Estado estado, DateTime dataEmissao, Cnpj emitente, Modelo modelo, UInt16 serie, UInt32 numero, FormaEmissao formaEmissao, UInt32 codigoNumerico)
 {
     Estado         = estado;
     DataEmissao    = dataEmissao;
     Emitente       = emitente;
     Modelo         = modelo;
     Serie          = serie;
     Numero         = numero;
     FormaEmissao   = formaEmissao;
     CodigoNumerico = codigoNumerico;
     Chave          = MontarChaveSemDigito();
     Digito         = (byte)new CalculadoraDigitoVerificadorChaveAcesso().Calcular(Chave);
     Chave         += Digito.ToString();
 }
Esempio n. 13
0
    public static bool validaRut(String tur)
    {
        int    rut = 0;
        int    Digito;
        int    Contador;
        int    Multiplo;
        int    Acumulador;
        string RutDigito, digito;

        try
        {
            rut    = Convert.ToInt32(tur.Substring(0, tur.IndexOf("-")));
            digito = tur.Substring(tur.IndexOf("-") + 1, 1);

            Contador   = 2;
            Acumulador = 0;

            while (rut != 0)
            {
                Multiplo   = (rut % 10) * Contador;
                Acumulador = Acumulador + Multiplo;
                rut        = rut / 10;
                Contador   = Contador + 1;
                if (Contador == 8)
                {
                    Contador = 2;
                }
            }

            Digito    = 11 - (Acumulador % 11);
            RutDigito = Digito.ToString().Trim();
            if (Digito == 10)
            {
                RutDigito = "K";
            }
            if (Digito == 11)
            {
                RutDigito = "0";
            }

            return(RutDigito == digito);
        }
        catch (Exception ex)
        {
            Console.WriteLine(Convert.ToString(ex));
            return(false);
        }
    }
Esempio n. 14
0
        public static bool IsValidRut(string RutConDV)
        {
            try
            {
                RutConDV = RutConDV.Replace(".", ""); //Quita puntos si los tiene
                if (RutConDV.Trim().Length == 0)
                {
                    return(true);
                }

                if (!RutConDV.Contains("-"))
                {
                    RutConDV = RutConDV.Substring(0, RutConDV.Length - 1) + "-" + RutConDV.Substring(RutConDV.Length - 1);
                }

                int Digito; int Contador; int Multiplo; int Acumulador; string RutDigito;
                Contador   = 2;
                Acumulador = 0;
                int    rut = int.Parse(RutConDV.Substring(0, RutConDV.IndexOf("-")));
                string dv  = RutConDV.Substring(RutConDV.IndexOf("-") + 1);
                while (rut != 0)
                {
                    Multiplo   = (rut % 10) * Contador;
                    Acumulador = Acumulador + Multiplo;
                    rut        = rut / 10;
                    Contador   = Contador + 1;
                    if (Contador == 8)
                    {
                        Contador = 2;
                    }
                }
                Digito    = 11 - (Acumulador % 11);
                RutDigito = Digito.ToString().Trim();
                if (Digito == 10)
                {
                    RutDigito = "K";
                }
                if (Digito == 11)
                {
                    RutDigito = "0";
                }
                return(dv.ToUpper() == RutDigito);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 15
0
        public bool verificaRut(int rut, string dv)
        {
            int Digito;
            int Contador;
            int Multiplo;
            int Acumulador;
            string RutDigito;

            Contador = 2;
            Acumulador = 0;

            while (rut != 0)
            {
                Multiplo = (rut % 10) * Contador;
                Acumulador = Acumulador + Multiplo;
                rut = rut / 10;
                Contador = Contador + 1;

                if (Contador == 8)
                {
                    Contador = 2;
                }
            }

            Digito = 11 - (Acumulador % 11);
            RutDigito = Digito.ToString().Trim();
            if (Digito == 10)
            {
                RutDigito = "K";
            }
            if (Digito == 11)
            {
                RutDigito = "0";
            }

            if (RutDigito.ToString() == dv.ToString())
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Returns true if Conta instances are equal
        /// </summary>
        /// <param name="other">Instance of Conta to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Conta other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Agencia == other.Agencia ||
                     Agencia != null &&
                     Agencia.Equals(other.Agencia)
                     ) &&
                 (
                     Numero == other.Numero ||
                     Numero != null &&
                     Numero.Equals(other.Numero)
                 ) &&
                 (
                     Digito == other.Digito ||
                     Digito != null &&
                     Digito.Equals(other.Digito)
                 ) &&
                 (
                     Saldo == other.Saldo ||
                     Saldo != null &&
                     Saldo.Equals(other.Saldo)
                 ) &&
                 (
                     Cliente == other.Cliente ||
                     Cliente != null &&
                     Cliente.Equals(other.Cliente)
                 ) &&
                 (
                     Transacoes == other.Transacoes ||
                     Transacoes != null &&
                     Transacoes.SequenceEqual(other.Transacoes)
                 ));
        }
Esempio n. 17
0
        /// <summary>
        /// Validación del rut
        /// </summary>
        /// <returns>Retorna true cuando el rut es correcto, de lo contrario false.</returns>
        internal bool ValidaRut()
        {
            Int32 Rut  = 0;
            bool  lret = false;

            int Digito;
            int Contador;
            int Multiplo;
            int Acumulador;

            Contador   = 2;
            Acumulador = 0;

            while (Rut != 0)
            {
                Multiplo   = (Rut % 10) * Contador;
                Acumulador = Acumulador + Multiplo;
                Rut        = Rut / 10;
                Contador++;
                if (Contador == 8)
                {
                    Contador = 2;
                }
            }
            Digito = 11 - (Acumulador % 11);

            if (Digito == 10)
            {
                lret = "K" == _dv ? true : false;
            }
            else
            if (Digito == 11)
            {
                lret = "0" == _dv ? true : false;
            }
            else
            {
                lret = Digito.ToString() == _dv.ToString() ? true : false;
            }
            return(lret);
        }
Esempio n. 18
0
        private bool ValidarRut(string strRut)
        {
            int    Digito;
            int    Contador;
            int    Multiplo;
            int    Acumulador;
            string RutDigito;

            strRut = ClearRut(strRut);
            string digitoVerificador = strRut.Substring(strRut.Length - 1).ToUpper();
            int    rut = int.Parse(strRut.Substring(0, strRut.Length - 1));

            Contador   = 2;
            Acumulador = 0;

            while (rut != 0)
            {
                Multiplo   = (rut % 10) * Contador;
                Acumulador = Acumulador + Multiplo;
                rut        = rut / 10;
                Contador   = Contador + 1;
                if (Contador == 8)
                {
                    Contador = 2;
                }
            }

            Digito    = 11 - (Acumulador % 11);
            RutDigito = Digito.ToString().Trim();

            if (Digito == 10)
            {
                RutDigito = "K";
            }
            else if (Digito == 11)
            {
                RutDigito = "0";
            }

            return(RutDigito == digitoVerificador);
        }
Esempio n. 19
0
        public static string digitoVerificador(string strRut)
        {
            int    rut;
            int    Digito;
            int    Contador;
            int    Multiplo;
            int    Acumulador;
            string RutDigito;

            if (strRut == "")
            {
                return("");
            }
            rut        = Convert.ToInt32(strRut);
            Contador   = 2;
            Acumulador = 0;
            while (rut != 0)
            {
                Multiplo   = (rut % 10) * Contador;
                Acumulador = Acumulador + Multiplo;
                rut        = rut / 10;
                Contador   = Contador + 1;
                if (Contador == 8)
                {
                    Contador = 2;
                }
            }
            Digito    = 11 - (Acumulador % 11);
            RutDigito = Digito.ToString().Trim();
            if (Digito == 10)
            {
                RutDigito = "K";
            }
            if (Digito == 11)
            {
                RutDigito = "0";
            }
            return(RutDigito);
        }
Esempio n. 20
0
        public static String calculaDVNFe(String ChaveAcesso)
        {
            Int32 Peso = 2, Soma = 0, Contador, Digito;

            for (Contador = (ChaveAcesso.Length - 1); Contador >= 0; Contador--)
            {
                Soma = Soma + (Convert.ToInt32(ChaveAcesso[Contador].ToString()) * Peso);
                if (Peso < 9)
                {
                    Peso++;
                }
                else
                {
                    Peso = 2;
                }
            }
            Digito = 11 - (Soma % 11);
            if (Digito > 9)
            {
                Digito = 0;
            }
            return(Digito.ToString());
        }
Esempio n. 21
0
    public bool ValidaRut(string rutCompleto)
    {
        rutCompleto = rutCompleto.Replace(".", "");
        rutCompleto = rutCompleto.Replace("-", "");
        rutCompleto = rutCompleto.Substring(0, rutCompleto.Length - 1) + '-' + rutCompleto.Substring(rutCompleto.Length - 1);

        string[] rutSeparado = null;
        rutSeparado = rutCompleto.Split(new char[] { '-' });
        if (rutSeparado.Length != 2)//|| rutCompleto.IndexOf('.')!=0)
        {
            return(false);
        }
        else
        {
            int resultado;
            int.TryParse(rutSeparado[0].ToString().Replace(".", ""), out resultado);
            if (resultado <= 0)
            {
                return(false);
            }
            else
            {
                int rut = int.Parse(rutSeparado[0].ToString());

                int    Digito;
                int    Contador;
                int    Multiplo;
                int    Acumulador;
                string RutDigito;
                Contador   = 2;
                Acumulador = 0;
                while (rut != 0)
                {
                    Multiplo   = (rut % 10) * Contador;
                    Acumulador = Acumulador + Multiplo;
                    rut        = rut / 10;
                    Contador   = Contador + 1;
                    if (Contador == 8)
                    {
                        Contador = 2;
                    }
                }
                Digito    = 11 - (Acumulador % 11);
                RutDigito = Digito.ToString().Trim();
                if (Digito == 10)
                {
                    RutDigito = "K";
                }
                if (Digito == 11)
                {
                    RutDigito = "0";
                }
                if (RutDigito.ToUpper() != rutSeparado[1].ToString().Trim().ToUpper())
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
    }
        //public static bool validarRut(string rut)
        //{

        //    bool validacion = false;
        //    try
        //    {
        //        rut = rut.ToUpper();
        //        rut = rut.Replace(".", "");
        //        rut = rut.Replace("-", "");
        //        int rutAux = int.Parse(rut.Substring(0, rut.Length - 1));

        //        char dv = char.Parse(rut.Substring(rut.Length - 1, 1));

        //        int m = 0, s = 1;
        //        for (; rutAux != 0; rutAux /= 10)
        //        {
        //            s = (s + rutAux % 10 * (9 - m++ % 6)) % 11;
        //        }
        //        if (dv == (char)(s != 0 ? s + 47 : 75))
        //        {
        //            validacion = true;
        //        }
        //    }
        //    catch (Exception)
        //    {
        //    }
        //    return validacion;
        //}

        public static bool validarRut(string rut)
        {
            int Digito;
            int Contador;
            int Multiplo;
            int Acumulador;
            string RutDigito;
            char dv;
            int rutAux = 0;

            rut = rut.ToUpper();
            rut = rut.Replace(".", "");
            rut = rut.Replace("-", "");
            rut = rut.Replace("_", "");
            rut = rut.Replace(",", "");
            int cantidad = rut.Length;
            
                rutAux = int.Parse(rut.Substring(0, rut.Length - 1));
          
           


            dv = char.Parse(rut.Substring(rut.Length - 1, 1));

            Contador = 2;
            Acumulador = 0;

            while (rutAux != 0)
            {
                Multiplo = (rutAux % 10) * Contador;
                Acumulador = Acumulador + Multiplo;
                rutAux = rutAux / 10;
                Contador = Contador + 1;

                if (Contador == 8)
                {
                    Contador = 2;
                }
            }

            Digito = 11 - (Acumulador % 11);
            RutDigito = Digito.ToString().Trim();
            if (Digito == 10)
            {
                RutDigito = "K";
            }
            if (Digito == 11)
            {
                RutDigito = "0";
            }


            if (RutDigito.ToString() == dv.ToString())
            {
                return true;
            }
            else
            {
                return false;
            }

        }
Esempio n. 23
0
        public string Get(string rutw)
        {
            rutw = rutw.Replace("k", "K");
            string        msgValido = "Rut invalido.";
            StringBuilder sb        = new StringBuilder();
            StringWriter  sw        = new StringWriter(sb);

            try
            {
                if (rutw.IndexOf("-") == -1)
                {
                    msgValido = "Por favor ingrese el Guión del dígito verificador(ej: 12345678 - 9).";
                    using (JsonWriter writer = new JsonTextWriter(sw))
                    {
                        writer.Formatting = Formatting.Indented;

                        writer.WriteStartObject();
                        writer.WritePropertyName("msgValido");

                        writer.WriteValue(msgValido);


                        writer.WriteEndObject();
                    }


                    return(sb.ToString());
                }
                //sustrae el rut sin el digito verificador a un entero y elimina los "."
                int rut = Int32.Parse(rutw.Substring(0, (rutw.IndexOf("-"))).Replace(".", ""));

                string dv = rutw.Substring(rutw.IndexOf("-") + 1, 1);

                int    Digito;
                int    Contador;
                int    Multiplo;
                int    Acumulador;
                string RutDigito;

                Contador   = 2;
                Acumulador = 0;

                while (rut != 0)
                {
                    Multiplo   = (rut % 10) * Contador;
                    Acumulador = Acumulador + Multiplo;
                    rut        = rut / 10;
                    Contador   = Contador + 1;

                    if (Contador == 8)
                    {
                        Contador = 2;
                    }
                }



                Digito    = 11 - (Acumulador % 11);
                RutDigito = Digito.ToString().Trim();
                if (Digito == 10)
                {
                    RutDigito = "K";
                }
                if (Digito == 11)
                {
                    RutDigito = "0";
                }


                // Si el código verificador coincide con el rut, será Valido
                //de forma contraria, se mostrará como NO Valido.
                if (RutDigito.ToString() == dv.ToString())
                {
                    msgValido = "El Rut es Valido.";
                }
                else
                {
                    msgValido = "El Rut NO ES Valido.";
                }

                using (JsonWriter writer = new JsonTextWriter(sw))
                {
                    writer.Formatting = Formatting.Indented;

                    writer.WriteStartObject();
                    writer.WritePropertyName("msgValido");

                    writer.WriteValue(msgValido);


                    writer.WriteEndObject();
                }

                return(sb.ToString());
            }
            catch (Exception e)
            {
                msgValido = "El Rut NO ES Valido.";
                using (JsonWriter writer = new JsonTextWriter(sw))
                {
                    writer.Formatting = Formatting.Indented;

                    writer.WriteStartObject();
                    writer.WritePropertyName("msgValido");

                    writer.WriteValue(msgValido);


                    writer.WriteEndObject();
                }

                return(sb.ToString());
            }
        }