Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
 private void EliminarPer(int id)
 {
     if (MessageBox.Show("Seguro de eliminar", "Eliminar", MessageBoxButtons.YesNo,
                         MessageBoxIcon.Information) == DialogResult.Yes)
     {
         AccesoSql.EliminarPerosna(id);
         Refrescar();
     }
 }
Beispiel #3
0
 private void Buscar(string bus)
 {
     if (int.TryParse(bus, out int num))
     {
     }
     else
     {
         var buscar = AccesoSql.Buscar(bus);
         dgDatosPer.DataSource = buscar;
     }
 }
Beispiel #4
0
        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;
        }
Beispiel #5
0
 private void Refrescar()
 {
     dgDatosPer.DataSource = AccesoSql.ObtenerPersonas();
 }