public static void Delete(int?id) { using (emmcomerseEntities db = new emmcomerseEntities()) { using (var transaction = db.Database.BeginTransaction()) { try { CuerpoFactura CuerpoFactura = db.CuerpoFactura.Find(id); db.Entry(CuerpoFactura).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } } } }
public static void Update(CuerpoFactura CuerpoFactura) { using (emmcomerseEntities db = new emmcomerseEntities()) { using (var transaction = db.Database.BeginTransaction()) { try { db.CuerpoFactura.Attach(CuerpoFactura); db.Entry(CuerpoFactura).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } } } }
public static void Update(ProductoEnCarrito ProductoEnCarrito) { using (emmcomerseEntities db = new emmcomerseEntities()) { using (var transaction = db.Database.BeginTransaction()) { try { db.ProductoEnCarrito.Attach(ProductoEnCarrito); db.Entry(ProductoEnCarrito).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } } } }
public static void Delete(int?id) { using (emmcomerseEntities db = new emmcomerseEntities()) { using (var transaction = db.Database.BeginTransaction()) { try { ProductoEnCarrito ProductoEnCarrito = db.ProductoEnCarrito.Find(id); db.Entry(ProductoEnCarrito).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); transaction.Commit(); ProductoBLL.Update(ProductoEnCarrito.prd_id, (-1 * ProductoEnCarrito.prd_cnt)); } catch (Exception ex) { transaction.Rollback(); throw ex; } } } }
public static void Update(int prd_id, int?cantidad) { using (emmcomerseEntities db = new emmcomerseEntities()) { using (var transaction = db.Database.BeginTransaction()) { try { Producto p = db.Producto.Find(prd_id); p.prd_cnt -= cantidad; db.Producto.Attach(p); db.Entry(p).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } } } }