public static void Delete(int?id) { using (DeliveryEntidades db = new DeliveryEntidades()) { using (var transaction = db.Database.BeginTransaction()) { try { PRODUCTO p = db.PRODUCTO.Find(id); db.Entry(p).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine("No se ha podido eliminar el producto " + ex.Message); transaction.Rollback(); throw ex; } } } }
public static void Delete(int?id) { using (DeliveryEntidades db = new DeliveryEntidades()) { using (var transaction = db.Database.BeginTransaction()) { try { CAB_FACTURA Materia = db.CAB_FACTURA.Find(id); db.Entry(Materia).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine("No se ha podido eliminar la cabeza de factura " + ex.Message); transaction.Rollback(); throw ex; } } } }
public static void Update(CAB_FACTURA cf) { using (DeliveryEntidades db = new DeliveryEntidades()) { using (var transaction = db.Database.BeginTransaction()) { try { db.CAB_FACTURA.Attach(cf); db.Entry(cf).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine("No se ha podido actualizar la materia " + ex.Message); transaction.Rollback(); throw ex; } } } }
public static void Delete(int?id) { using (DeliveryEntidades db = new DeliveryEntidades()) { using (var transaction = db.Database.BeginTransaction()) { try { CLIENTE cliente = db.CLIENTE.Find(id); db.Entry(cliente).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); Console.WriteLine("Error al eliminar " + ex.Message); throw ex; } } } }
public static bool Update(CLIENTE cliente) { using (DeliveryEntidades db = new DeliveryEntidades()) { using (var transaction = db.Database.BeginTransaction()) { try { db.CLIENTE.Attach(cliente); db.Entry(cliente).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); transaction.Commit(); return(true); } catch (Exception ex) { Console.WriteLine("Error al actualizar alumno " + ex.Message); return(false); } } } }
public static bool Update(PRODUCTO p) { using (DeliveryEntidades db = new DeliveryEntidades()) { using (var transaction = db.Database.BeginTransaction()) { try { db.PRODUCTO.Attach(p); db.Entry(p).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); transaction.Commit(); return(true); } catch (Exception ex) { Console.WriteLine("No se ha podido actualizar el producto " + ex.Message); transaction.Rollback(); return(false); } } } }