public static CAB_FACTURA Get(int?id)
 {
     using (DeliveryEntidades db = new DeliveryEntidades())
     {
         try
         {
             return(db.CAB_FACTURA.Find(id));
         }
         catch (Exception ex)
         {
             Console.WriteLine("No se ha podido retornar la cabeza de factura " + ex.Message);
             throw ex;
         }
     }
 }
 public static PRODUCTO Get(int?id)
 {
     using (DeliveryEntidades db = new DeliveryEntidades())
     {
         try
         {
             return(db.PRODUCTO.Find(id));
         }
         catch (Exception ex)
         {
             Console.WriteLine("No se ha podido retornar el producto " + ex.Message);
             throw ex;
         }
     }
 }
 public static List <CAB_FACTURA> List()
 {
     using (DeliveryEntidades db = new DeliveryEntidades())
     {
         try
         {
             return(db.CAB_FACTURA.ToList());
         }
         catch (Exception ex)
         {
             Console.WriteLine("No se ha podido retornar la lista de cabezas de factura " + ex.Message);
             throw ex;
         }
     }
 }
 public static List <CLIENTE> List()
 {
     using (DeliveryEntidades db = new DeliveryEntidades())
     {
         try
         {
             return(db.CLIENTE.ToList());
         }
         catch (Exception ex)
         {
             Console.WriteLine("Error al enviar la lista de clientes " + ex.Message);
             throw ex;
         }
     }
 }
 public static CLIENTE Get(int?id)
 {
     using (DeliveryEntidades db = new DeliveryEntidades())
     {
         try
         {
             return(db.CLIENTE.Find(id));
         }
         catch (Exception ex)
         {
             Console.WriteLine("Error al obtener cliente " + ex.Message);
             throw ex;
         }
     }
 }
 public static List <PRODUCTO> List()
 {
     using (DeliveryEntidades db = new DeliveryEntidades())
     {
         try
         {
             return(db.PRODUCTO.ToList());
         }
         catch (Exception ex)
         {
             Console.WriteLine("No se ha podido retornar la lista de productos " + ex.Message);
             throw ex;
         }
     }
 }
 public static void Create(PRODUCTO p)
 {
     using (DeliveryEntidades db = new DeliveryEntidades())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.PRODUCTO.Add(p);
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine("No se ha podido crear el producto " + ex.Message);
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
 public static void Create(CLIENTE c)
 {
     using (DeliveryEntidades db = new DeliveryEntidades())       //hace una conexion temporal a la bd
     {
         using (var transaction = db.Database.BeginTransaction()) //hace una transaccion
         {
             try
             {
                 db.CLIENTE.Add(c);      //agrega a la tabla ALUMNO el objeto (a)
                 db.SaveChanges();       //guarda los cambios en la bd
                 transaction.Commit();   //confirma los cambios
             }
             catch (Exception ex)
             {
                 Console.WriteLine("Error al crear cliente " + ex.Message);
                 transaction.Rollback(); //se revierte el estado de la bd a un estado anterior consistente en caso de error
                 throw ex;
             }
         }
     }
 }
 public static void Create(CAB_FACTURA cf)
 {
     using (DeliveryEntidades db = new DeliveryEntidades())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.CAB_FACTURA.Add(cf);
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine("No se ha podido crear la  cabeza de factura " + ex.Message);
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
 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 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 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 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);
             }
         }
     }
 }
        public static List <ESTADO_ENVIO> List()
        {
            DeliveryEntidades db = new DeliveryEntidades();

            return(db.ESTADO_ENVIO.ToList());
        }
Beispiel #17
0
        public static List <PRODUCTO_CATEGORIA> List()
        {
            DeliveryEntidades db = new DeliveryEntidades();

            return(db.PRODUCTO_CATEGORIA.ToList());
        }