Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }