private void button1_Click(object sender, EventArgs e) { int cont = 0; if (string.IsNullOrEmpty(tbx_nombre.Text)) { tbx_nombre.BackColor = Color.Red; cont++; } if (string.IsNullOrEmpty(tbx_precio.Text)) { tbx_precio.BackColor = Color.Red; cont++; } if (string.IsNullOrEmpty(tbx_desc.Text)) { tbx_desc.BackColor = Color.Red; cont++; } ///------------------------------------------------------ if (string.IsNullOrEmpty(tbx_Marca.Text)) { tbx_Marca.BackColor = Color.Red; cont++; } if (string.IsNullOrEmpty(tbx_Pegi.Text)) { tbx_Pegi.BackColor = Color.Red; cont++; } if (string.IsNullOrEmpty(tbx_Genero.Text)) { tbx_Genero.BackColor = Color.Red; cont++; } if (string.IsNullOrEmpty(tbx_Cant.Text)) { tbx_Cant.BackColor = Color.Red; cont++; } if (pictureBox1.Image == null) { error_portada.Visible = true; } ///--------------------------------------------------------- if (cont > 0) { MessageBox.Show("Falta ingresar campos"); } else { n_producto reg = new n_producto(); direccion = pictureBox1.ToString(); reg.AgregarProducto(tbx_id.Text, tbx_nombre.Text, tbx_Marca.Text, tbx_Genero.Text, tbx_Pegi.Text,tbx_Cant.Text, tbx_desc.Text, tbx_desc.Text, tbx_precio.Text); ///MessageBox.Show(direccion); File.Copy(nombre, Path.Combine(@"" + directory + "\\Portadas\\", Path.GetFileName(tbx_nombre.Text + ".jpg")), true); MessageBox.Show("Producto Agregado correctamente"); tbx_id.Text = "";tbx_nombre.Text = "";tbx_Marca.Text = "";tbx_Genero.Text = "";tbx_Pegi.Text = "";tbx_Cant.Text = "";tbx_desc.Text = "";tbx_desc.Text = "";tbx_precio.Text = ""; pictureBox1.Image = null; int resu; resu = reg.obtenercantidadderegistros(); resu = resu + 1; tbx_id.Text = resu.ToString(); } }