0

Tengo 2 WindowsForms Socios y Resultados. Socios:

 public partial class Socios : Form
{
    private FilterInfoCollection Dispositivos;
    private VideoCaptureDevice FuenteDeVideo;
    ManejadorDeDatos datos = new ManejadorDeDatos();
    DataSet ds = new DataSet();
    public Socios(string socios)
    {
        InitializeComponent();
        if (socios == "alta") {
            Dispositivos = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            panel1.Visible = false;
            btnBaja.Visible = false;
            btnModificar.Visible = false;
            if (Dispositivos.Count == 0)
            {
                MessageBox.Show("Conecte una cámara");
            }
            else
            {

                FuenteDeVideo = new VideoCaptureDevice(Dispositivos[0].MonikerString);
                FuenteDeVideo.NewFrame += (s, e) => pictureBox1.Image = (Bitmap)e.Frame.Clone();
                FuenteDeVideo.Start();
                pictureBox1.Visible = true;
            }
        } else if (socios == "baja") {
            btnModificar.Visible = false;
            btnGuardar.Visible = false;
            btnTomarFoto.Visible = false;
            txtNoCredencial.Enabled = false;

        } else if (socios == "consulta") {
            btnGuardar.Visible = false;
            btnTomarFoto.Visible = false;
            btnBaja.Visible = false;
            txtNoCredencial.Enabled = false;
        }
    }


    //Salir
    private void button10_Click(object sender, EventArgs e)
    {
        Principal principal = new Principal();
        principal.Show();
        this.Hide();
        if(FuenteDeVideo!=null)
        FuenteDeVideo.SignalToStop();
    }
    bool x=false;
    private void btnTomarFoto_Click(object sender, EventArgs e)
    {
        if (x == false)
        {
            if (txtNombre.Text == "" && txtAPaterno.Text == "" && txtAMaterno.Text == "")
            {
                MessageBox.Show("Debe ingresar el nombre completo para guardar la foto.");
            }
            else
            {
                pictureBox1.Image.Save("C:\Users\***\Pictures\photo.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
                x = true;
                FuenteDeVideo.Stop();
                MessageBox.Show("Foto capturada!");
            }
        }
        else {
            MessageBox.Show("Ya existe una foto.");
        }
    }
    private void btnMostrarLista_Click(object sender, EventArgs e)
    {
            Resultados resultados = new Resultados();
            resultados.Show();
    }

    public void Resultados(int IDSocio) {
        string sql = "SELECT * FROM CSocio WHERE IDSocio="+IDSocio;
        ds=datos.Consulta(sql, "IDSocio");
        Muestra(ds,"IDSocio");
    }

    public void Muestra(DataSet ds,string tabla) {
        txtAPaterno.Text = ds.Tables[tabla].Rows[0][1].ToString();
        this.Close();
        this.Show();
    }

    private void txtNoCredencial_MouseDoubleClick(object sender, MouseEventArgs e)
    {
        Tarjeta tarjeta = new Tarjeta();
    }
    public void tarjeta(string noTarjeta) {
        txtNoCredencial.Text = noTarjeta;
        this.Update();
    }

    private void btnBuscar_Click(object sender, EventArgs e)
    {

    }
}

--

 public partial class Resultados : Form
{
    ManejadorDeDatos datos = new ManejadorDeDatos();
    DataSet ds = new DataSet();

    public Resultados()
    {
        InitializeComponent();
    }

    private void Resultados_Load(object sender, EventArgs e)
    {

            string sql = "SELECT IDSocio,ApPaterno as Apellido_Paterno,ApMaterno as Apellido_Materno,Nombre FROM CSocio";
            ds = datos.Consulta(sql, "Socios");
            dataGridView1.DataSource = ds.Tables["Socios"];
            dataGridView1.Columns[0].Visible = false;

    }

    private void dataGridView1_SelectionChanged(object sender, EventArgs e)
    {
        Socios socios = new Socios("");
        try
        {
            int IDSocio = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString());
            socios.Resultados(IDSocio);
        }
        catch (Exception exe) {

        }
    }

    private void btnCerrar_Click(object sender, EventArgs e)
    {
        this.Close();
    }
}

Cuando doy click en Mostrar lista (Socios Form) se muestra el formulario Resultados con un gridview lleno de nombres, al seleccionar uno (dataGridView1_Selection_changed) deberia de escribir el resultado de la consulta en el textbox del formulario Socios pero no lo hace.

¿de alguna manera puedo actualizar el Form Socios?

2
  • Si que lo hace.. pero no al formulario anterior si no a uno nuevo... mira la pregunta que te marco, es el mismo problema
    – gbianchi
    el 21 feb. 2019 a las 22:26
  • Muchas gracias, tienes razón no me dí cuenta que estaba abriendo más formularios. el 21 feb. 2019 a las 23:23

0

Examina otras preguntas con la etiqueta o formula tu propia pregunta.