Ejemplo n.º 1
0
 private void update_rejilla()
 {
     using (var db = new personasEntities())
     {
         var lt = from per in db.persona
                  select per;
         dgv_show_datos.DataSource = lt.ToList();
     }
 }
Ejemplo n.º 2
0
 private void llenar_form()
 {
     bt_registrar.Text = "Actualizar";
     lb_titulo.Text    = "Actualizar registro";
     using (var contexto = new personasEntities()){
         ta              = contexto.persona.Find(this.id);//obtiene el registro de la tabla persona, linq
         ct_nombre.Text  = ta.nombre;
         ct_correo.Text  = ta.correo;
         dtp_fecha.Value = ta.fecha_nacimiento;
     }
 }
Ejemplo n.º 3
0
        private void bt_delete_Click(object sender, EventArgs e)
        {
            if (!si)
            {
                MessageBox.Show("Seleccione un registro a borrar.");
                si = false;
                return;
            }
            int?id = getID();

            if (id != null)
            {
                using (var con = new personasEntities()){
                    persona per = con.persona.Find(id);
                    con.persona.Remove(per);
                    con.SaveChanges();
                }
                update_rejilla(); si = false;
            }
        }
Ejemplo n.º 4
0
 private void bt_registrar_Click(object sender, EventArgs e)
 {
     using (var contexto = new personasEntities()){
         if (id == null)
         {
             ta = new persona(); // nombre de la tabla en la DB
         }
         ta.nombre           = ct_nombre.Text.ToString().Trim();
         ta.correo           = ct_correo.Text.ToString().Trim();
         ta.fecha_nacimiento = dtp_fecha.Value;
         if (id == null)
         {
             contexto.persona.Add(ta);//agregamos
         }
         else
         {
             contexto.Entry(ta).State = System.Data.Entity.EntityState.Modified;
         }
         contexto.SaveChanges();
         //int i = await salvar(contexto);
         MessageBox.Show("todo salio bien", " Genial ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
 }
Ejemplo n.º 5
0
 private async Task <int> salvar(personasEntities contexto)
 {
     return(await contexto.SaveChangesAsync());
 }