public static void Create(Usuario a)
 {
     using (emmcomerseEntities db = new emmcomerseEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 a.uso_rol = "Cliente";
                 db.Usuario.Add(a);
                 db.SaveChanges();
                 transaction.Commit();
                 Usuario u = GetUsuarioByUsu(a.uso_usu);
                 Cliente c = new Cliente();
                 c.uso_id = u.uso_id;
                 ClienteBLL.Create(c);
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
 public static void Create(CuerpoFactura a)
 {
     using (emmcomerseEntities db = new emmcomerseEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.CuerpoFactura.Add(a);
                 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
             {
                 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;
             }
         }
     }
 }
Example #6
0
 public static void Create(Producto a)
 {
     using (emmcomerseEntities db = new emmcomerseEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 a.prd_dateOfCreated = DateTime.Now;
                 db.Producto.Add(a);
                 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 Create(Cliente a)
 {
     using (emmcomerseEntities db = new emmcomerseEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 a.cln_tipo          = "Nuevo";
                 a.cln_dateOfCreated = DateTime.Now;
                 db.Cliente.Add(a);
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
 public static void Create(ProductoEnCarrito a)
 {
     using (emmcomerseEntities db = new emmcomerseEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 a.pcr_est           = "Pendiente";
                 a.pcr_dateOfCreated = DateTime.Now;
                 db.ProductoEnCarrito.Add(a);
                 db.SaveChanges();
                 transaction.Commit();
                 ProductoBLL.Update(a.prd_id, a.prd_cnt);
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
Example #10
0
 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;
             }
         }
     }
 }