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); } }
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); } }
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); } }
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); } }
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()); } }
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()); } }
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()); } }
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()); } }
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()); } }
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>()); } }