Documentos de Académico
Documentos de Profesional
Documentos de Cultura
• Matricula: 2018-0552
Con Windows Forms en C#, crear una Agenda Digital con las siguientes
especificaciones:
• Id
• Nombres
• Apellidos
• Dirección
• Teléfono
• Sexo
• Email
• Agregar
• Actualizar
• Eliminar
• Salir
Al seleccionar un registro del Data Grid View, este debe mostrarse en las
cajas de texto (Text Box).
• Base de datos
• Nombre: David Perez
• Matricula: 2018-0552
Código en el programa:
• Nombre: David Perez
• Matricula: 2018-0552
• Nombre: David Perez
• Matricula: 2018-0552
• Programa ejecutándose
• Nombre: David Perez
• Matricula: 2018-0552
• Nombre: David Perez
• Matricula: 2018-0552
• Nombre: David Perez
• Matricula: 2018-0552
• Código
using System; using
System.Collections.Generic
; using
System.ComponentModel;
using System.Data; using
System.Data.OleDb; using
System.Drawing; using
System.Linq; using
System.Text; using
System.Threading.Tasks;
using
System.Windows.Forms;
namespace
AgendaDigital
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class conexion
{
public static OleDbConnection Conectar()
{
OleDbConnection cn = new
OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data
Source =|DataDirectory|\\lista.accdb");
cn.Open(); return cn;
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: esta línea de código carga datos en la tabla
'listaDataSet.lista' Puede moverla o quitarla según sea necesario.
this.listaTableAdapter.Fill(this.listaDataSet.lista);
conexion.Conectar();
MessageBox.Show("Base de datos conectada");
MessageBox.Show("Aviso, Para modificar o Eliminar una fila,hacerlo
dandole click a la celda del ID");
}
• Nombre: David Perez
• Matricula: 2018-0552
this.tableAdapterManager.UpdateAll(this.listaDataSet);
}
private void listaDataGridView_CellContentClick(object sender,
DataGridViewCellEventArgs e)
{
id.Text =
listaDataGridView.CurrentRow.Cells[0].Value.ToString();
nombre.Text = listaDataGridView.CurrentRow.Cells[1].Value.ToString();
apellido.Text =
listaDataGridView.CurrentRow.Cells[2].Value.ToString();
direcc.Text =
listaDataGridView.CurrentRow.Cells[3].Value.ToString();
telef.Text = listaDataGridView.CurrentRow.Cells[4].Value.ToString();
sexo.Text = listaDataGridView.CurrentRow.Cells[5].Value.ToString();
email.Text = listaDataGridView.CurrentRow.Cells[6].Value.ToString();
}
private void Agregar_Click(object sender, EventArgs e)
{
this.listaTableAdapter.INSERTAR(id.Text, nombre.Text,
apellido.Text, direcc.Text, telef.Text, sexo.Text, email.Text);
this.listaTableAdapter.Fill(this.listaDataSet.lista);
id.Clear(); nombre.Clear(); apellido.Clear();
direcc.Clear(); telef.Clear(); sexo.Clear(); email.Clear();
}
private void button2_Click(object sender, EventArgs e)
{
this.listaTableAdapter.ACTUALIZAR(id.Text, nombre.Text,
apellido.Text, direcc.Text, telef.Text, sexo.Text, email.Text,
id.Text);
this.listaTableAdapter.Fill(this.listaDataSet.lista);
id.Clear(); nombre.Clear(); apellido.Clear();
direcc.Clear(); telef.Clear(); sexo.Clear(); email.Clear();
}
private void button3_Click(object sender, EventArgs e)
{
this.listaTableAdapter.ELIMINAR(id.Text);
this.listaTableAdapter.Fill(this.listaDataSet.lista);
id.Clear(); nombre.Clear(); apellido.Clear();
direcc.Clear(); telef.Clear(); sexo.Clear(); email.Clear();
}
}
}