示例#1
0
        private void btnBorrar_Click(object sender, EventArgs e)
        {
            Int32 indice = this.dgvGrilla.CurrentRow.Index;

            Persona p = new Persona(int.Parse(this.dtPersona.Rows[indice][0].ToString()),
                                    this.dtPersona.Rows[indice]["Apellido"].ToString(),
                                    this.dtPersona.Rows[indice]["Nombre"].ToString(),
                                    int.Parse(this.dtPersona.Rows[indice]["Edad"].ToString()));

            frmPersona frm = new frmPersona(p);

            frm.StartPosition = FormStartPosition.CenterScreen;

            if (frm.ShowDialog() == DialogResult.OK)
            {
                this.dtPersona.Rows[indice].Delete();
            }
        }
示例#2
0
        private void btnAlta_Click(object sender, EventArgs e)
        {
            frmPersona frm = new frmPersona();

            try
            {
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    DataRow fila = this.dtPersona.NewRow();

                    fila[1] = frm.Persona.Nombre;
                    fila["Apellido"] = frm.Persona.Apellido;
                    fila["Edad"] = frm.Persona.Edad;

                    this.dtPersona.Rows.Add(fila);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }