Example #1
0
        private bool Validar()
        {
            bool valido = true;

            if (NombresTextbox.Text.Length == 0 || string.IsNullOrEmpty(NombresTextbox.Text) || string.IsNullOrWhiteSpace(NombresTextbox.Text))
            {
                valido = false;
                MessageBox.Show("Error, ciudad no válida. \nEl nombre está vacio.", "Fallo", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            else if (CiudadesBLL.Existe(NombresTextbox.Text))
            {
                valido = false;
                MessageBox.Show("Error, ciudad no válida. \nLa ciudad ya existe en la base de datos.", "Fallo", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            if (valido)
            {
                this.ciudad.Nombres = NombresTextbox.Text;
            }
            return(valido);
        }
Example #2
0
 private void BuscarButton_Click(object sender, RoutedEventArgs e)
 {
     if (!CiudadesBLL.Existe(Convert.ToInt32(CiudadIdTextbox.Text)))
     {
         MessageBox.Show("Error, ciudad no encontrada. \nLo sentimos, la ciudad no existe en la base de datos.", "Fallo", MessageBoxButton.OK, MessageBoxImage.Warning);
         Limpiar();
     }
     else
     {
         var ciudad = CiudadesBLL.Buscar(Convert.ToInt32(CiudadIdTextbox.Text));
         if (ciudad != null)
         {
             this.ciudad = ciudad;
         }
         else
         {
             this.ciudad = new Ciudades();
         }
         this.DataContext = this.ciudad;
     }
 }
Example #3
0
        private bool Validar()
        {
            bool esValido = true;

            if (CiudadesBLL.Existe(nombreTextBox.Text))
            {
                esValido = false;
                MessageBox.Show("Ha ocurrido un error, no puede repetir el nombre", "Error",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            ;            if (nombreTextBox.Text.Length == 0)
            {
                esValido = false;
                MessageBox.Show("Ha ocurrido un error, debe insertar un nombre", "Error",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            if (nombreTextBox.Text.Any(char.IsDigit))
            {
                esValido = false;
                MessageBox.Show("Ha ocurrido un error, no hay ciudades con numeros", "Error",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(esValido);
        }