Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/01/2012, 03:18
htmorales
 
Fecha de Ingreso: enero-2012
Mensajes: 3
Antigüedad: 12 años, 11 meses
Puntos: 0
Respuesta: C Sharp Generador de CURP validado Parte 1

Código:
        public static string RemoverSignosAcentos(string Texto)
        {
            string ConSignos = "áàäéèëíìïóòöúùuÁÀÄÉÈËÍÌÏÓÒÖÚÙÜçÇ";
            string SinSignos = "aaaeeeiiiooouuuAAAEEEIIIOOOUUUcC";
            var textoSinAcentos = string.Empty;

            foreach (var caracter in Texto)
            {
                var indexConAcento = ConSignos.IndexOf(caracter);
                if (indexConAcento > -1)
                    textoSinAcentos = textoSinAcentos + (SinSignos.Substring(indexConAcento, 1));
                else
                    textoSinAcentos = textoSinAcentos + (caracter);
            }
            return textoSinAcentos;
        }

        public string SiglasEstado(string Estado)
        {
            string Siglas=null;
            switch (Estado)
            {
                case "AGUASCALIENTES":
                case "01":
                case "1":
                    Siglas="AS";
                    break;
                case "BAJA CALIFORNIA": 
                case "02":
                case "2":
                    Siglas="BC";
                    break;
                case "BAJA CALIFORNIA SUR": 
                case "03":
                case "3":
                    Siglas="BS";
                    break;
                case "CAMPECHE":  
                case "04":
                case "4":
                    Siglas="CC";
                    break;
                case "COAHUILA": 
                case "05":
                case "5":
                    Siglas="CL";
                    break;
                case "COLIMA": 
                case "06":
                case "6":
                    Siglas="CM";
                    break;
                case "CHIAPAS": 
                case "07":
                case "7":
                    Siglas="CS";
                    break;
                case "CHIHUAHUA": 
                case "08":
                case "8":
                    Siglas="CH";
                    break;
                case "DISTRITO FEDERAL": 
                case "09":
                case "9":
                    Siglas="DF";
                    break;
                case "DURANGO":
                case "10":
                    Siglas="DG";
                    break;
                case "GUANAJUATO":
                case "11":
                    Siglas="GT";
                    break;
                case "GUERRERO":
                case "12":
                    Siglas="GR";
                    break;
                case "HIDALGO":
                case "13":
                    Siglas="HG";
                    break;
                case "JALISCO":
                case "14":
                    Siglas="JC";
                    break;
                case "MEXICO":
                case "15":
                    Siglas="MC";
                    break;
                case "MICHOACAN":
                case "16":
                    Siglas="MN";
                    break;
                case "MORELOS":
                case "17":
                    Siglas="MS";
                    break;
                case "NAYARIT":
                case "18":
                    Siglas="NT";
                    break;
                case "NUEVO LEON":
                case "19":
                    Siglas="NL";
                    break;
                case "OAXACA":
                case "20":
                    Siglas="OC";
                    break;
                case "PUEBLA":
                case "21":
                    Siglas="PL";
                    break;
                case "QUERETARO":
                case "22":
                    Siglas="QT";
                    break;
                case "QUINTANA ROO":
                case "23":
                    Siglas="QR";
                    break;
                case "SAN LUIS POTOSI":
                case "24":
                    Siglas="SP";
                    break;
                case "SINALOA":
                case "25":
                    Siglas="SL";
                    break;
                case "SONORA":
                case "26":
                    Siglas="SR";
                    break;
                case "TABASCO":
                case "27":
                    Siglas="TC";
                    break;
                case "TAMAULIPAS":
                case "28":
                    Siglas="TS";
                    break;
                case "TLAXCALA":
                case "29":
                    Siglas="TL";
                    break;
                case "VERACRUZ":
                case "30":
                    Siglas="VZ";
                    break;
                case "YUCATAN":
                case "31":
                    Siglas="YN";
                    break;
                case "ZACATECAS":
                case "32":
                    Siglas="ZS";
                    break;
                case "NACIDO EXTRANJERO":
                case "33":
                    Siglas = "NE";
                    break;
                default:
                    Siglas = "##";
                    break;
            }
            return Siglas;
        }

        public bool VerificaFecha(object inValue)
        {
            bool bValid;
            try
            {
                DateTime myDT = DateTime.Parse(inValue.ToString());
                bValid = true;
            }
            catch (Exception e)
            {
                bValid = false;
            }
            return bValid;
        }

        public string FechaCortaYMD(string FechaLargaDMY)
        {
            string YMD = "";
            if (FechaLargaDMY.Length == 10)
            {
                String Y = FechaLargaDMY.Substring(8, 2);
                String M = FechaLargaDMY.Substring(3, 2);
                String D = FechaLargaDMY.Substring(0, 2);
                YMD = Y + M + D;
            }
            return YMD;
        }

        public Boolean EsPalabraInapropiada(string Texto)
        {
            Boolean Concordancia = false;
            string [] Maja= { "BACA", "LOCO", "BAKA", "LOKA", "BUEI", "LOKO", "BUEY", "MAME", "CACA", "MAMO", "CACO", "MEAR", 
                            "CAGA", "MEAS", "CAGO", "MEON", "CAKA", "MIAR", "CAKO", "MION", "COGE", "MOCO", "COGI", "MOKO",
                            "COJA", "MULA", "COJE", "MULO", "COJI", "NACA,", "COJO", "NACO", "COLA", "PEDA", "CULO", "PEDO",
                            "FALO", "PENE", "FETO", "PIPI", "GETA", "PITO", "GUEI", "POPO", "GUEY", "PUTA", "JETA", "PUTO",
                            "JOTO", "QULO", "KACA", "RATA", "KACO", "ROBA", "KAGA", "ROBE", "KAGO", "ROBO", "KAKA", "RUIN",
                            "KAKO", "SENO", "KOGE", "TETA", "KOGI", "VACA", "KOJA", "VAGA", "KOJE", "VAGO", "KOJI", "VAKA",
                            "KOJO", "VUEI", "KOLA", "VUEY", "KULO", "WUEI", "LILO", "WUEY", "LOCA "};
            foreach (string xMaja in Maja)
            {
                if (Texto == xMaja)
                {
                    Concordancia = true;
                    break;
                }
            }
            return Concordancia;
        }
    }
}
(Sólo Pega ambas partes de la Clase)
Ya no generé el Tema "C Sharp Generador de CURP validado Parte 2", mejor lo hice de esta manera.
Saludos...