Exemplo n.º 1
0
        protected virtual void btnAgregar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                this.listaAux.Add(frm.Persona);
                this.cargarListBox();

                this.conexion = new SqlConnection(Properties.Settings.Default.Conexion);
                this.conexion.Open();
                this.comando             = new SqlCommand();
                this.comando.Connection  = this.conexion;
                this.comando.CommandType = CommandType.Text;

                this.comando.CommandText = "INSERT INTO personas ([nombre],[apellido],[edad]) VALUES(@nombre,@apellido,@edad)";
                this.comando.Parameters.AddWithValue("@nombre", frm.Persona.nombre);
                this.comando.Parameters.AddWithValue("@apellido", frm.Persona.apellido);
                this.comando.Parameters.AddWithValue("@edad", Convert.ToInt32(frm.Persona.edad));
                this.comando.ExecuteNonQuery();
                this.conexion.Close();
            }
        }
Exemplo n.º 2
0
 protected override void btnModificar_Click(object sender, EventArgs e)
 {
     try
     {
         int        personaListIndex = this.lstVisor.SelectedIndex;
         int        dataRowIndex     = this.GetPersonRowIndex(personaListIndex);
         DataRow    fila             = this.tabla.Rows[dataRowIndex];
         frmPersona frmPersona       = new frmPersona(this.misPersonas[personaListIndex]);
         frmPersona.ShowDialog();
         if (frmPersona.DialogResult == DialogResult.OK)
         {
             fila[1] = frmPersona.Persona.nombre;
             fila[2] = frmPersona.Persona.apellido;
             fila[3] = frmPersona.Persona.edad.ToString();
             this.misPersonas[personaListIndex].nombre   = frmPersona.Persona.nombre;
             this.misPersonas[personaListIndex].apellido = frmPersona.Persona.apellido;
             this.misPersonas[personaListIndex].edad     = frmPersona.Persona.edad;
             this.ActualizarLista();
         }
     }
     catch (Exception x)
     {
         MessageBox.Show(x.Message + "\nEn metodo btnModificar_Click.");
     }
 }
        protected virtual void btnAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                frmPersona frm = new frmPersona();
                frm.StartPosition = FormStartPosition.CenterScreen;
                frm.ShowDialog();
                //implementar

                if (frm.DialogResult == DialogResult.OK)
                {
                    this.listaPersonas.Add(frm.Persona);
                    this.lstVisor.Items.Add(frm.Persona.ToString());
                }

                SqlConnection sqlC = new SqlConnection(Properties.Settings.Default.conexion);
                sqlC.Open();

                SqlCommand command = new SqlCommand();

                command.Connection  = sqlC;
                command.CommandType = CommandType.Text;
                command.CommandText = "INSERT INTO [personas_bd].[dbo].[personas] ([nombre],[apellido],[edad]) VALUES (@param1,@param2,@param3)";
                command.Parameters.AddWithValue("@param1", frm.Persona.nombre);
                command.Parameters.AddWithValue("@param2", frm.Persona.apellido);
                command.Parameters.AddWithValue("@param3", frm.Persona.edad);
                command.ExecuteNonQuery();

                sqlC.Close();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Exemplo n.º 4
0
        protected virtual void btnEliminar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;

            try
            {
                int index = this.lstVisor.SelectedIndex;
                this.lstVisor.Items.RemoveAt(index);

                SqlConnection sqlC = new SqlConnection(Properties.Settings.Default.conexion);
                sqlC.Open();

                SqlCommand command = new SqlCommand();


                command.Connection  = sqlC;
                command.CommandType = CommandType.Text;
                command.CommandText = "DELETE FROM [personas_bd].[dbo].[personas]([id]) WHERE (@param1)";
                command.Parameters.AddWithValue("@param1", index + 1);

                command.ExecuteNonQuery();
                sqlC.Close();
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Exemplo n.º 5
0
        protected virtual void btnEliminar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona(this.listaVisor[this.lstVisor.SelectedIndex]);
            int        id  = this.GetId(frm.Persona);

            try
            {
                this.Lista.RemoveAt(this.lstVisor.SelectedIndex);
                System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand();
                this.conexion.Open();
                command.Connection  = this.conexion;
                command.CommandType = CommandType.Text;
                command.CommandText = "delete from Personas where id = " + id;
                command.ExecuteNonQuery();
                this.conexion.Close();
                this.ActualizarLista();
            }
            catch (Exception f)
            {
                MessageBox.Show(f.Message);
            }

            this.ActualizarLista();
            this.btnEliminar.Click -= new EventHandler(this.btnEliminar_Click);

            //implementar
        }
Exemplo n.º 6
0
        protected virtual void btnModificar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona((Persona)lstVisor.SelectedItem);

            frm.StartPosition = FormStartPosition.CenterScreen;
            this.sql.Open();
            frm.ShowDialog();

            if (frm.DialogResult == DialogResult.OK)
            {
                this.lstVisor.SelectedItem = frm.Persona;

                try
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendFormat("update Personas set nombre='{0}',apellido='{1}',edad={2} where id={3}", frm.Persona.nombre, frm.Persona.apellido, frm.Persona.edad, this.lstVisor.SelectedIndex + 1);
                    SqlCommand com = new SqlCommand();
                    com.Connection  = this.sql;
                    com.CommandType = CommandType.Text;
                    com.CommandText = sb.ToString();
                    com.ExecuteNonQuery();
                }
                catch (Exception x)
                {
                    MessageBox.Show(x.ToString());
                }
            }

            this.sql.Close();
            this.ActualizarLista();
        }
Exemplo n.º 7
0
        protected virtual void btnModificar_Click(object sender, EventArgs e)
        {
            int        selectedIndex;
            Persona    auxPersona = this.listaAux[this.lstVisor.SelectedIndex];
            frmPersona frm        = new frmPersona(auxPersona);

            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                selectedIndex = this.lstVisor.SelectedIndex;
                auxPersona    = this.listaAux[this.lstVisor.SelectedIndex];

                this.conexion = new SqlConnection(Properties.Settings.Default.Conexion);
                this.conexion.Open();
                this.comando             = new SqlCommand();
                this.comando.Connection  = this.conexion;
                this.comando.CommandType = CommandType.Text;

                this.comando.CommandText = "UPDATE personas SET [nombre] = @nombre, [apellido] = @apellido, [edad] = @edad WHERE nombre = @nombre2 AND [apellido] = @apellido2 AND [edad] = @edad2";
                this.comando.Parameters.AddWithValue("@nombre", frm.Persona.nombre);
                this.comando.Parameters.AddWithValue("@apellido", frm.Persona.apellido);
                this.comando.Parameters.AddWithValue("@edad", frm.Persona.edad);
                this.comando.Parameters.AddWithValue("@nombre2", auxPersona.nombre);
                this.comando.Parameters.AddWithValue("@apellido2", auxPersona.apellido);
                this.comando.Parameters.AddWithValue("@edad2", auxPersona.edad);
                this.comando.ExecuteNonQuery();
                this.listaAux[selectedIndex] = frm.Persona;
                this.cargarListBox();
            }
        }
Exemplo n.º 8
0
        protected virtual void btnAgregar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                try
                {
                    using (this.conexionSql = new SqlConnection(Properties.Settings.Default.Conexion))
                    {
                        conexionSql.Open();
                        SqlCommand command = new SqlCommand();
                        command.Connection  = this.conexionSql;
                        command.CommandType = CommandType.Text;
                        command.CommandText = "INSERT INTO personas([nombre], [apellido], [edad]) VALUES (@nombre, @apellido, @edad)";
                        command.Parameters.AddWithValue("@nombre", frm.Persona.nombre);
                        command.Parameters.AddWithValue("@apellido", frm.Persona.apellido);
                        command.Parameters.AddWithValue("@edad", frm.Persona.Edad);
                        command.ExecuteNonQuery();
                    }
                }
                catch (Exception excep)
                {
                    MessageBox.Show(excep.Message);
                }

                this.listaAux.Add(frm.Persona);
                this.cargarListBox();
            }
        }
Exemplo n.º 9
0
        protected virtual void btnEliminar_Click(object sender, EventArgs e)
        {
            //lo quito para q no lo repita por cada seleccion en la lista
            //this.btnEliminar.Click -= new EventHandler(btnEliminar_Click);


            StringBuilder str      = new StringBuilder();
            SqlCommand    cmd      = new SqlCommand();
            SqlConnection conexion = new SqlConnection(Properties.Settings.Default.Conexion);

            conexion.Open();

            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;

            //implementar
            this.listaPersonas.Remove((Persona)this.lstVisor.SelectedItem);
            try
            {
                str.AppendFormat("delete from Personas where id={0}", this.lstVisor.SelectedIndex + 1);
                cmd.Connection  = conexion;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = str.ToString();
                cmd.ExecuteNonQuery();
                conexion.Close();
            }
            catch (Exception x)
            {
                conexion.Close();
                MessageBox.Show(x.Message);
            }
            this.ActualizarLista();
        }
        protected virtual void btnModificar_Click(object sender, EventArgs e)
        {
            int        indice = this.lstVisor.SelectedIndex;
            frmPersona frm    = new frmPersona(this.lista[indice]);

            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                this.lista[indice] = frm.Persona;
                try
                {
                    SqlConnection conexion = new SqlConnection(Properties.Settings.Default.conexion);
                    conexion.Open();
                    SqlCommand cmb = new SqlCommand();
                    cmb.Connection  = conexion;
                    cmb.CommandType = CommandType.Text;
                    cmb.CommandText = "UPDATE Personas SET nombre='" + frm.Persona.nombre + "',apellido='" + frm.Persona.apellido + "',edad=" + frm.Persona.edad + "WHERE id=" + (indice + 1);
                    cmb.ExecuteNonQuery();
                    conexion.Close();
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.Message);
                }
            }
            ActualizarLista();
        }
        protected virtual void btnEliminar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;

            //frm.ShowDialog();

            int selectedIndex = this.lstVisor.SelectedIndex;//esta mal usar selected index



            //if (frm.DialogResult == DialogResult.OK)
            //{
            this.listaAux.RemoveAt(selectedIndex);
            this.lstVisor.Items.Clear();
            for (int i = 0; i < listaAux.Count; i++)
            {
                this.lstVisor.Items.Add(listaAux[i].ToString());
            }
            //}

            this.btnModificar.Enabled = false;
            this.btnEliminar.Enabled  = false;
        }
Exemplo n.º 12
0
        protected void btnAgregar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;


            //implementar
            frm.ShowDialog();
            lstVisor.Items.Clear();

            if (frm.DialogResult == DialogResult.OK)
            {
                listaAux.Add(frm.Persona);
                ActualizarLista();

                //bd
                SqlCommand    comando = new SqlCommand();
                SqlConnection sql     = new SqlConnection(Properties.Settings.Default.conexion);

                sql.Open();
                comando.Connection = sql;

                comando.CommandType = CommandType.Text;

                comando.CommandText = $"INSERT INTO Personas(nombre,apellido,edad) VALUES('{frm.Persona.nombre}','{frm.Persona.apellido}',{frm.Persona.edad})";
                comando.ExecuteNonQuery();
                //TEXTO Q SE LE PASA AL COMMAND TEXT values('COMILLAS SIMPLES EN LOS STRING','APELLIDO',31) // listado dentro de un try catch
                //PROBLEMA: CONCATENAR CADENA..

                comando.Connection.Close();
            }
        }
Exemplo n.º 13
0
        protected virtual void btnAgregar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                this.lista.Add(frm.Persona);
                ActualizarLista();

                try
                {
                    conexion.Open();
                    System.Data.SqlClient.SqlCommand comando = new System.Data.SqlClient.SqlCommand();
                    comando.Connection  = conexion;
                    comando.CommandType = CommandType.Text;
                    comando.CommandText = "Insert into Personas(nombre,apellido,edad) values('" + frm.Persona.nombre + "','" + frm.Persona.apellido + "'," + frm.Persona.edad + ')';
                    comando.ExecuteNonQuery();
                    conexion.Close();
                }
                catch (Exception f)
                {
                    throw f;
                }
            }
        }
Exemplo n.º 14
0
        protected virtual void btnModificar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona(this.lista[this.lstVisor.SelectedIndex]);
            int        id;

            id = this.GetId(frm.Persona);
            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                this.lista[this.lstVisor.SelectedIndex] = frm.Persona;
                try
                {
                    conexion.Open();
                    System.Data.SqlClient.SqlCommand comando = new System.Data.SqlClient.SqlCommand();
                    comando.Connection  = conexion;
                    comando.CommandType = CommandType.Text;
                    comando.CommandText = "Update Personas set nombre='" + frm.Persona.nombre + "',apellido='" + frm.Persona.apellido + "',edad=" + frm.Persona.edad + "where id=" + id;
                    comando.ExecuteNonQuery();
                    conexion.Close();
                }
                catch (Exception f)
                {
                    throw f;
                }
                this.ActualizarLista();

                //implementar
            }
        }
Exemplo n.º 15
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;

            //implementar
            int indice = this.lstVisor.SelectedIndex;

            if (indice >= 0)
            {
                string consulta = $"DELETE FROM Personas WHERE id = {indice + 1}";
                try
                {
                    using (SqlConnection sql = new SqlConnection(Properties.Settings.Default.Conexion))
                    {
                        using (SqlCommand sqlCommand = new SqlCommand())
                        {
                            sqlCommand.Connection  = sql;
                            sqlCommand.CommandType = CommandType.Text;
                            sqlCommand.CommandText = consulta;
                            sql.Open();
                            sqlCommand.ExecuteNonQuery();
                        }
                    }
                }
                catch (Exception a)
                {
                    MessageBox.Show(a.ToString());
                }

                this.listaAux.Remove(listaAux[indice]);
                this.ActualizarLista();
            }
        }
Exemplo n.º 16
0
 protected virtual void btnEliminar_Click(object sender, EventArgs e)
 {
     if (lstVisor.SelectedIndex != -1)
     {
         frmPersona frmP = new frmPersona(this.lista[this.lstVisor.SelectedIndex]);
         int        id   = GetId(frmP.Persona);
         try
         {
             this.lista.Remove(frmP.Persona);
             SqlCommand comando = new SqlCommand();
             conexion.Open();
             comando.Connection  = conexion;
             comando.CommandType = CommandType.Text;
             comando.CommandText = "delete from Personas where id =" + id;
             comando.ExecuteNonQuery();
             conexion.Close();
             this.ActualizarLista();
         }
         catch (Exception f)
         {
             throw f;
         }
     }
     else
     {
         MessageBox.Show("Seleccione una persona.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        protected virtual void btnEliminar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;
            try
            {
                int j = this.lstVisor.SelectedIndex;
                frm.txtNombre.Text      = this.lista[j].nombre;
                frm.txtApellido.Text    = this.lista[j].apellido;
                frm.txtEdad.Text        = this.lista[j].edad.ToString();
                frm.txtNombre.Enabled   = false;
                frm.txtApellido.Enabled = false;
                frm.txtEdad.Enabled     = false;
                frm.ShowDialog();
                if (frm.DialogResult == DialogResult.OK)
                {
                    this.lista.RemoveAt(j);
                    this.lstVisor.Items.Clear();
                    for (int i = 0; i < lista.Count; i++)
                    {
                        this.lstVisor.Items.Add(lista[i].ToString());
                    }
                }
            }
            catch
            {
                btnEliminar.Enabled = false;
            }
            //implementar
        }
Exemplo n.º 18
0
        protected override void btnModificar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona(/*params*/);

            frm.StartPosition = FormStartPosition.CenterScreen;
            try
            {
                int j = this.lstVisor.SelectedIndex;
                frm.txtNombre.Text   = dataTable.Rows[j][1].ToString();
                frm.txtApellido.Text = dataTable.Rows[j][2].ToString();
                frm.txtEdad.Text     = dataTable.Rows[j][3].ToString();
                frm.ShowDialog();
                if (frm.DialogResult == DialogResult.OK)
                {
                    dataTable.Rows[j][1] = frm.txtNombre.Text;
                    dataTable.Rows[j][2] = frm.txtApellido.Text;
                    dataTable.Rows[j][3] = frm.txtEdad.Text;
                    this.lstVisor.Items.Clear();
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        lstVisor.Items.Add(dataTable.Rows[i][0].ToString() + dataTable.Rows[i][1].ToString() + dataTable.Rows[i][2].ToString() + dataTable.Rows[i][3].ToString());
                    }
                }
            }
            catch
            {
                btnModificar.Enabled = false;
            }

            //implementar
        }
Exemplo n.º 19
0
        protected virtual void btnAgregar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                listaPersonas.Add(frm.Persona);
                // lstVisor.Items.Add(frm.Persona);
                SqlConnection sql = new SqlConnection(Properties.Settings.Default.Conexion);
                sql.Open();

                SqlCommand com = new SqlCommand();
                com.Connection  = sql;
                com.CommandType = CommandType.Text;
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("Insert into Personas(nombre,apellido,edad) values('{0}','{1}','{2}')", frm.Persona.nombre, frm.Persona.apellido, frm.Persona.edad);
                com.CommandText = sb.ToString();
                com.ExecuteNonQuery();

                sql.Close();
            }
            this.ActualizarLista();
        }
        protected virtual void btnAgregar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                this.lista.Add(frm.Persona);
                try
                {
                    SqlConnection conexion = new SqlConnection(Properties.Settings.Default.conexion);
                    conexion.Open();
                    SqlCommand cmb = new SqlCommand();
                    cmb.Connection  = conexion;
                    cmb.CommandType = CommandType.Text;
                    cmb.CommandText = "INSERT INTO Personas(nombre,apellido,edad)VALUES('" + frm.Persona.nombre + "','" + frm.Persona.apellido + "'," + frm.Persona.edad + ")";
                    cmb.ExecuteNonQuery();
                    conexion.Close();
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.Message);
                }
            }
            ActualizarLista();
        }
Exemplo n.º 21
0
        protected virtual void btnAgregar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;

            //implementar
            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                StringBuilder str      = new StringBuilder();
                SqlCommand    cmd      = new SqlCommand();
                SqlConnection conexion = new SqlConnection(Properties.Settings.Default.Conexion);
                conexion.Open();
                this.listaPersonas.Add(frm.Persona);
                this.lstVisor.Items.Add(frm.Persona);
                try
                {
                    str.AppendFormat("insert into Personas(nombre,apellido,edad) values ('{0}','{1}','{2}')", frm.Persona.nombre, frm.Persona.apellido, frm.Persona.edad);
                    cmd.Connection  = conexion;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = str.ToString();
                    cmd.ExecuteNonQuery();
                    conexion.Close();
                }
                catch (Exception x)
                {
                    conexion.Close();
                    MessageBox.Show(x.Message);
                }
            }
        }
Exemplo n.º 22
0
        protected virtual void btnEliminar_Click(object sender, EventArgs e)
        {
            this.btnModificar.Click -= new System.EventHandler(this.btnModificar_Click);
            this.btnEliminar.Click  -= new System.EventHandler(this.btnEliminar_Click);

            Persona    aux = listaAux[this.lstVisor.SelectedIndex];
            frmPersona frm = new frmPersona(aux.apellido, aux.nombre, aux.Edad);

            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                try
                {
                    using (this.conexionSql = new SqlConnection(Properties.Settings.Default.Conexion))
                    {
                        conexionSql.Open();
                        SqlCommand command = new SqlCommand();
                        command.Connection  = this.conexionSql;
                        command.CommandType = CommandType.Text;
                        command.CommandText = "DELETE FROM personas WHERE id = " + aux.id + "";
                        command.ExecuteNonQuery();
                    }
                }
                catch (Exception excep)
                {
                    MessageBox.Show(excep.Message);
                }

                listaAux.Remove(aux);
            }
            this.cargarListBox();
        }
Exemplo n.º 23
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;

            //implementar
        }
Exemplo n.º 24
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona(/*params*/);

            frm.StartPosition = FormStartPosition.CenterScreen;

            //implementar
        }
Exemplo n.º 25
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;
            int index = this.lstVisor.SelectedIndex;

            if (index >= 0)
            {
                this.lista.Remove(lista[index]);
                this.ActualizarLista();
            }
        }
Exemplo n.º 26
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;

            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                this.lista.Add(frm.Persona);
                this.ActualizarLista();
            }
        }
Exemplo n.º 27
0
        protected virtual void btnModificar_Click(object sender, EventArgs e)
        {
            int        index = this.lstVisor.SelectedIndex;
            frmPersona frm   = new frmPersona(this.misPersonas.ElementAt(index));

            frm.Conexion      = this.Conexion;
            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                this.misPersonas[index]    = frm.Persona;
                this.lstVisor.Items[index] = frm.Persona.ToString();
            }
        }
Exemplo n.º 28
0
        protected override void btnModificar_Click(object sender, EventArgs e)
        {
            DataRow    fila       = this.tabla.Rows[this.lstVisor.SelectedIndex];
            frmPersona frmPersona = new frmPersona(new Persona(fila[1].ToString(), fila[2].ToString(), Convert.ToInt32(fila[3])));

            frmPersona.ShowDialog();
            if (frmPersona.DialogResult == DialogResult.OK)
            {
                fila["nombre"]   = frmPersona.Persona.nombre;
                fila["apellido"] = frmPersona.Persona.apellido;
                fila["edad"]     = frmPersona.Persona.edad;
                this.actualizarListBox();
            }
        }
Exemplo n.º 29
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            DataRow    row = this.dataTable.Rows[this.lstVisor.SelectedIndex];
            frmPersona frm = new frmPersona(new Entidades.Persona(row["nombre"].ToString(), row["apellido"].ToString(), int.Parse(row["edad"].ToString())));

            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                row["nombre"]   = frm.Persona.nombre;
                row["apellido"] = frm.Persona.nombre;
                row["edad"]     = frm.Persona.nombre;
            }
            this.ActualizarLista();
        }
Exemplo n.º 30
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.ShowDialog();

            if (frm.DialogResult == DialogResult.OK)
            {
                this.lstVisor.Items.Clear();
                this.listaAux.Add(frm.Persona);
                this.lstVisor.Items.Clear();
                this.MostrarLista(this.listaAux);
            }
        }