Ejemplo n.º 1
0
        private void button6_Click(object sender, EventArgs e)
        {
            busca1 ingresartemp = new busca1();

            ingresartemp.Nombre    = textBox5.Text;
            ingresartemp.Apellido  = textBox6.Text;
            ingresartemp.Nit       = textBox7.Text;
            ingresartemp.Direccion = textBox8.Text;

            lbuscar.Add(ingresartemp);
            dataGridView1.DataSource = null;
            dataGridView1.Refresh();
            dataGridView1.DataSource = lbuscar;
            dataGridView1.Refresh();
        }
Ejemplo n.º 2
0
        private void button4_Click(object sender, EventArgs e)
        {
            string fileName = @"C:\Users\usuario\source\repos\DanySoproyectoFinal\DanySoproyectoFinal\bin\Debug\buscar.txt";

            FileStream   stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            StreamReader reader = new StreamReader(stream);

            //Se cargan los datos del archivo a la lista de clientes
            while (reader.Peek() > -1)
            {
                //Leer los datos y guardarlos en un temporal
                //osea la lista en meses
                busca1 productotemp = new busca1();
                productotemp.Nombre    = reader.ReadLine();
                productotemp.Apellido  = reader.ReadLine();
                productotemp.Nit       = reader.ReadLine();
                productotemp.Direccion = reader.ReadLine();

                //Agregar a la lista el temporal
                lbuscar.Add(productotemp);
            }
            reader.Close();

            //Se recorre la lista de clientes
            for (int i = 0; i < lbuscar.Count; i++)
            {
                //Si se el dato a buscar es igual al dato de la lista mostrarlo en los textbox
                if (lbuscar[i].Nombre == textBox9.Text)
                {
                    textBox5.Text = lbuscar[i].Nombre;
                    textBox6.Text = lbuscar[i].Apellido;
                    textBox7.Text = lbuscar[i].Nit;
                    textBox8.Text = lbuscar[i].Direccion;



                    //Guardar en que posicion se encontró el dato para utilizarla mas adelante al momento de modificar
                    posicionmodificar = i;
                }
            }
        }