Exemplo n.º 1
0
        private void EliminarPok_Click(object sender, EventArgs e)
        {
            int i = Convert.ToInt32(txt_EliminarPok.Text);

            if (i >= 0)
            {
                /*byte[] datos = new byte[0];
                 *
                 * datos = (byte[])cn.Imagen_Mostrar(i)["foto"];
                 *
                 * System.IO.MemoryStream ms = new System.IO.MemoryStream(datos);
                 * Fotografia.Image = System.Drawing.Bitmap.FromStream(ms);*/



                cn.EliminarPokemonAdministrador(i);       //Eliminar datos
                MessageBox.Show("Pokemon Eliminado");     //Mensaje
                this.Hide();                              //Ocultar ventana actual
                ConsultaPokEnt v2 = new ConsultaPokEnt(); //Crear ventana
                v2.Show();                                // Mostrar ventana
            }
            else
            {
                MessageBox.Show("Ingrese un numero positivo"); //Mensaje
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();                              //Ocultar ventana actual
            ConsultaPokEnt m2 = new ConsultaPokEnt(); //Crear ventana

            m2.Show();                                // Mostrar ventana
        }
        private void button2_Click(object sender, EventArgs e)
        {
            //--------------------------------- VALIDACIONES DE ESCRITURA EN CAMPOS ---------------------------------
            if (validar_foto > 0)
            {
                int a = 0;
                while (a == 0)
                {
                    //------------- VALIDACIONES DE COMILLAS -------------
                    string p = "'";
                    int    validación_comilla = 0;
                    foreach (char c in ID_Tipo.Text)
                    {
                        if (c == p[0])          //Validar
                        {
                            validación_comilla++;
                        }
                    }
                    foreach (char c in Codigo_Tipo.Text)
                    {
                        if (c == p[0])          //Validar
                        {
                            validación_comilla++;
                        }
                    }
                    foreach (char c in Nombre_Pokemon.Text)
                    {
                        if (c == p[0])          //Validar
                        {
                            validación_comilla++;
                        }
                    }
                    if (validación_comilla > 0)
                    {
                        MessageBox.Show("¡Error! No debe ingresar información con comillas simples"); //Mensaje de error
                        break;
                    }

                    //------------- REGISTRO EN LA BASE DE DATOS -------------
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    picPokemon.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    int i = Convert.ToInt32(ID_pokemon.Text);

                    cn.ModificarPokemonAdministrador(i, Nombre_Pokemon.Text, ID_Tipo.Text, Codigo_Tipo.Text, Total.Text,
                                                     Salud.Text, Ataque.Text, Defensa.Text, Ataque_Especial.Text, Defensa_Especial.Text,
                                                     Velocidad.Text, Generacion.Text, comboBox1.Text, ms.GetBuffer()); //Ingresar datos

                    MessageBox.Show("Pokemon modificado correctamente");                                               //Mensaje

                    this.Hide();                                                                                       //Ocultar ventana
                    ConsultaPokEnt m2 = new ConsultaPokEnt();                                                          //Crear ventana
                    m2.Show();                                                                                         //Mostrar ventana

                    a++;
                }
            }
            else
            {
                MessageBox.Show("Ingrese una foto");
            }
        }