Exemplo n.º 1
0
        private void TxtPreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            if (TxtCp.Text.Length >= 5)
            {
                e.Handled = true;
                return;
            }

            e.Handled = VerificationUtilities.IsNumber(e.Text);
            TxtCp.Text.Trim();
        }
Exemplo n.º 2
0
        public bool GetRelexInfo(DataFromTexto datos, int errores)
        {
            try
            {
                int startIndex = datos.TextoStr.IndexOf("RELACIONES EXTERIORES");

                if (startIndex != -1)
                {
                    string tempString = datos.TextoStr.Substring(startIndex);

                    int endIndex = tempString.IndexOf("NO");

                    if (endIndex != -1)
                    {
                        tempString = tempString.Substring(endIndex + 3);

                        string permisoRelex = tempString.Substring(0, tempString.IndexOf(' '));

                        datos.PermisoRelex = permisoRelex;

                        Match largeDate = Regex.Match(tempString, largeDateRegex);

                        if (largeDate.Value != null)
                        {
                            DateTime fechaRegex = Convert.ToDateTime(largeDate.Value.ToString().Replace("DEL", "DE"));
                            datos.FechaPermisoRelex = fechaRegex.ToString("dd/MM/yyyy");
                        }
                        else
                        {
                            tempString = tempString.Substring(tempString.IndexOf(' ') + 1).Replace("DE FECHA ", "");

                            string[] completeText = tempString.Split(' ');


                            string fechaRelex = String.Format(completeText[0] + "{0}" + this.SetMonthLanguaje(completeText[1]) + "{0}" + completeText[2], "-");

                            DateTime dt = Convert.ToDateTime(fechaRelex, new CultureInfo("es-ES"));
                            datos.FechaPermisoRelex = dt.ToString("dd/MM/yyyy");
                        }

                        Console.WriteLine(String.Format("{0}    {1}", datos.Id, datos.FechaPermisoRelex));

                        try
                        {
                            tempString = tempString.Substring(tempString.IndexOf("NO")).Replace("NO ", "");

                            //string expedienteRelex = tempString.Substring(0, tempString.IndexOf(' '));
                            //datos.ExpedienteRelex = expedienteRelex;

                            string originalSinGuion = StringUtilities.ReplaceDoubleSpaces(Regex.Replace(datos.Texto, "--+", "-"));

                            startIndex = datos.Texto.IndexOf("EXPEDIENTE NO.");

                            string[] orgString = datos.Texto.Substring(startIndex).Replace("EXPEDIENTE NO. ", "").Split(new[] { " ", "" }, StringSplitOptions.RemoveEmptyEntries);

                            char[] expediente = orgString[0].ToCharArray();


                            if (!VerificationUtilities.IsNumber(Char.ToString(expediente[0])))
                            {
                                datos.ExpedienteRelex = orgString[0];
                            }
                            else
                            {
                                datos.ExpedienteRelex = "0";
                            }
                        }
                        catch (Exception)
                        {
                            datos.ExpedienteRelex = "0";
                        }


                        // datos.TipoFedatarios = tempString.Substring(0, indezNum);

                        this.SetRelexInfo(datos);
                    }
                }
                else
                {
                    //MessageBox.Show(datos.Id.ToString());
                }
            }
            catch (ArgumentOutOfRangeException) {
                //MessageBox.Show(datos.Id.ToString() + "Error");
                return(false);
            }
            catch (FormatException)
            {
                //MessageBox.Show(datos.Id.ToString() + "Error");
                return(false);
            }
            return(true);
        }
 private void Txt_PreviewTextInput(object sender, TextCompositionEventArgs e)
 {
     e.Handled = VerificationUtilities.IsNumber(e.Text);
 }