Пример #1
0
 //Metodo eliminar
 public void Eliminar()
 {
     try
     {
         using (var db = new Model_Personal())
         {
             db.Entry(this).State = EntityState.Deleted;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #2
0
 //Metodo guardar
 public void Guardar()
 {
     try
     {
         using (var db = new Model_Personal())
         {
             if (this.id_personal > 0)//cuando la llave primaria es identity solamante
             {
                 db.Entry(this).State = EntityState.Modified;
             }
             else
             {
                 db.Entry(this).State = EntityState.Added;
             }
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #3
0
 //metodo guardar
 public void Guardar()
 {
     try
     {
         using (var db = new Model_Personal())
         {
             if (this.id_tipo_pago_prestamo > 0)
             {
                 db.Entry(this).State = EntityState.Modified;
             }
             else
             {
                 db.Entry(this).State = EntityState.Added;
             }
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }