Пример #1
0
        public bool ActualizarPedido(PedidoBE objPedido)
        {
            try
            {
                using (ContextDA objContextDA = new ContextDA())
                {
                    objContextDA.Entry(objPedido).State = EntityState.Modified;

                    objContextDA.SaveChanges();
                    return(true);
                }
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                    }
                }
                return(false);
            }
        }
Пример #2
0
 public bool GuardarDetalleVenta(DetalleVentaBE objDetalleVenta)// List<DetalleVentaBE> detalles
 {
     try
     {
         using (ContextDA objContextDA = new ContextDA())
         {
             objContextDA.DbDetalleVenta.Add(objDetalleVenta);
             //objContextDA.DbDetalleVenta.AddRange(detalles);
             objContextDA.SaveChanges();
         }
         return(true);
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
             }
         }
         return(false);
     }
 }
Пример #3
0
        public bool EliminarPedido(string IdPedido)
        {
            try
            {
                using (ContextDA objContextDA = new ContextDA())
                {
                    PedidoBE objPedido = objContextDA.DbPedido.Find(IdPedido);
                    objContextDA.DbPedido.Remove(objPedido);

                    objContextDA.SaveChanges();
                    return(true);
                }
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                    }
                }
                return(false);
            }
        }
Пример #4
0
        public bool GuardarCliente(ClienteBE objCliente, out string Dni)
        {
            try
            {
                using (ContextDA objContextDA = new ContextDA())
                {
                    objContextDA.DbCliente.Add(objCliente);
                    objContextDA.SaveChanges();
                }

                Dni = objCliente.Dni;
                return(true);
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                    }
                }

                Dni = "";
                return(false);
            }
        }
Пример #5
0
 public PedidoBE ObtenerPedido(string IdPedido)
 {
     try
     {
         using (ContextDA objContextDA = new ContextDA())
         {
             return(objContextDA.DbPedido.Find(IdPedido));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(new PedidoBE());
     }
 }
Пример #6
0
 public DetalleVentaBE ObtenerDetalleVenta(int NumDetalle)
 {
     try
     {
         using (ContextDA objContextDA = new ContextDA())
         {
             return(objContextDA.DbDetalleVenta.Find(NumDetalle));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(new DetalleVentaBE());
     }
 }
Пример #7
0
 public ClienteBE ObtenerCliente(string Dni)
 {
     try
     {
         using (ContextDA objContextDA = new ContextDA())
         {
             return(objContextDA.DbCliente.Find(Dni));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(new ClienteBE());
     }
 }
Пример #8
0
 public FarmaceuticoBE ObtenerFarmaceutico(string IdFarmaceutico)
 {
     try
     {
         using (ContextDA objContextDA = new ContextDA())
         {
             return(objContextDA.DbFarmaceutico.Find(IdFarmaceutico));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(new FarmaceuticoBE());
     }
 }
Пример #9
0
 public VentaBE ObtenerVenta(string IdVenta)
 {
     try
     {
         using (ContextDA objContextDA = new ContextDA())
         {
             return(objContextDA.DbVenta.Find(IdVenta));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(new VentaBE());
     }
 }
Пример #10
0
 public List <PedidoBE> ListarPedidos()
 {
     try
     {
         using (ContextDA objcontextDA = new ContextDA())
         {
             return(objcontextDA.DbPedido.ToList());
         }
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
             }
         }
         return(new List <PedidoBE>());
     }
 }