private void btnAceptar_Click(object sender, EventArgs e) { if (Validaciones()) { Persona p1 = new Persona(); p1.Nombre = txtNombre.Text.Trim(); p1.Apellido_Paterno = txtApellidoPa.Text.Trim(); p1.Apellido_Materno = txtApellidoMa.Text.Trim(); p1.Edad = int.Parse(txtEdad.Text.Trim()); p1.Cumple = dtCumple.Value; p1.Sexo = txtSexo.Text.Trim(); if (id == null) { AccesoSql.AgregarPersona(p1); } else { p1.Id = (int)id; AccesoSql.ModificarPersona(p1); this.Close(); } Limpiar(); } }
private void EliminarPer(int id) { if (MessageBox.Show("Seguro de eliminar", "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { AccesoSql.EliminarPerosna(id); Refrescar(); } }
private void Buscar(string bus) { if (int.TryParse(bus, out int num)) { } else { var buscar = AccesoSql.Buscar(bus); dgDatosPer.DataSource = buscar; } }
private void CargarCampos(int id) { Persona p = AccesoSql.ObtenerPorId(id); txtNombre.Text = p.Nombre; txtApellidoPa.Text = p.Apellido_Paterno; txtApellidoMa.Text = p.Apellido_Materno; txtEdad.Text = p.Edad.ToString(); if (p.Sexo == "Hombre") { txtSexo.SelectedIndex = 0; } else if (p.Sexo == "Mujer") { txtSexo.SelectedIndex = 1; } else if (p.Sexo == "Otro") { txtSexo.SelectedIndex = 2; } dtCumple.Value = p.Cumple; }
private void Refrescar() { dgDatosPer.DataSource = AccesoSql.ObtenerPersonas(); }