private void btnAceptar_Click(object sender, EventArgs e)
        {
            PokemonNegocio negocio = new PokemonNegocio();

            try
            {
                if (pokemon == null)
                {
                    pokemon = new Pokemon();
                }

                pokemon.Nombre    = txtNombre.Text.Trim();
                pokemon.ImagenURL = txtUrlImagen.Text.Trim();
                pokemon.Tipo      = (Tipo)cboTipo.SelectedItem;
                // pokemon.Precio = double.Parse(txtPrecio.Text);

                if (pokemon.Id == null)
                {
                    negocio.agregar(pokemon);
                }
                else
                {
                    negocio.modificar(pokemon);
                }

                Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            PokemonNegocio negocio = new PokemonNegocio();

            if (pokemon == null)
            {
                pokemon = new Pokemon();
            }

            pokemon.Nombre      = txtNombre.Text;
            pokemon.Descripcion = txtDescripcion.Text;
            pokemon.Tipo        = (Tipo)cboTipo.SelectedItem;
            pokemon.UrlImage    = txtImagen.Text;

            if (pokemon.Id == 0)
            {
                negocio.agregar(pokemon);
            }
            else
            {
                negocio.modificar(pokemon);
            }

            MessageBox.Show("Operacion realizada exitosamente", "Exito");
            Close();
        }
예제 #3
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            PokemonNegocio negocio = new PokemonNegocio();
            Validacion     val     = new Validacion();

            bool[] comprobacion = val.validacionesfrmAlta(txtNombre.Text, txtDescripcion.Text, txtUrlImage.Text, cboTipo.SelectedIndex);
            if (comprobacion[0] && comprobacion[1] && comprobacion[2] && comprobacion[3])
            {
                if (pokemon == null)
                {
                    pokemon = new Pokemon();
                }

                pokemon.Nombre      = txtNombre.Text;
                pokemon.Descripcion = txtDescripcion.Text;
                pokemon.UrlImage    = txtUrlImage.Text;
                pokemon.Tipo        = (Tipo)cboTipo.SelectedItem;

                if (pokemon.Id == 0)
                {
                    negocio.agregar(pokemon);
                }
                else
                {
                    negocio.modificar(pokemon);
                }



                MessageBox.Show("Operación efectuada exitosamente", "Exito");
                Close();
            }

            else
            {
                if (!comprobacion[0])
                {
                    txtNombre.BackColor = Color.Red;
                }
                if (!comprobacion[1])
                {
                    txtDescripcion.BackColor = Color.Red;
                }
                if (!comprobacion[2])
                {
                    txtUrlImage.BackColor = Color.Red;
                }
                if (!comprobacion[3])
                {
                    cboTipo.BackColor = Color.Red;
                }
                MessageBox.Show("Campos faltantes", "Error en la carga");
            }
        }
예제 #4
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            PokemonNegocio pokemonNegocio = new PokemonNegocio();

            // lo comento porque puede venir de afuera... y es un atributo del form
            //Pokemon pokemon = new Pokemon();
            try
            {
                if (pokemon == null)
                {
                    pokemon = new Pokemon();
                }

                pokemon.Nombre      = txtNombre.Text;
                pokemon.Descripcion = txtDesc.Text;
                pokemon.Tipo        = (Tipo)cboTipo.SelectedItem;
                pokemon.Evolucion   = (Pokemon)cboEvolucion.SelectedItem;

                // pokemon.Evolucion = new Pokemon();
                // pokemon.Evolucion.Id = (int)cboEvolucion.SelectedValue;

                if (pokemon.Id != 0)
                {
                    pokemonNegocio.modificar(pokemon);
                }
                else
                {
                    pokemonNegocio.agregarConSP(pokemon);
                }

                Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #5
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            //Pokemon nuevo = new Pokemon();
            PokemonNegocio pokemonNegocio = new PokemonNegocio();

            try
            {
                if (pokemon == null)
                {
                    pokemon = new Pokemon();
                }

                pokemon.Nombre      = txtNombre.Text;
                pokemon.Descripcion = txtDescripcion.Text;
                pokemon.Numero      = (int)numNumero.Value;
                pokemon.UrlImagen   = txtUrlImagen.Text;
                pokemon.Tipo        = (Elemento)cboTipo.SelectedItem;

                if (pokemon.Id == 0)
                {
                    pokemonNegocio.agregar(pokemon);
                    MessageBox.Show("agregado sin problema");
                }
                else
                {
                    pokemonNegocio.modificar(pokemon);
                    MessageBox.Show("modificado sin problema");
                }

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }