public DETALLE_PEDIDO Obtener(int id) //retornar es un objeto { var detalles_pedidos = new DETALLE_PEDIDO(); try { using (var db = new db_ventas()) { detalles_pedidos = db.DETALLE_PEDIDO //.Include("PRODUCTO.NOMBRE") .Where(x => x.IDPEDIDO == id) .SingleOrDefault(); } } catch (Exception ex) { throw; } return(detalles_pedidos); }
public bool BuscarDetallePedido(int idDetalle) { try { Modelo.DETALLE_PEDIDO detallePedido = ConectorDALC.ModeloAlmacen.DETALLE_PEDIDO.FirstOrDefault(e => e.IDDETALLEO == idDetalle); if (detallePedido != null) { return(true); } else { return(false); } } catch (Exception ex) { return(false); throw new ArgumentException("Error al buscar" + ex); } }
public bool AgregarDetallePedido() { try { Modelo.DETALLE_PEDIDO detallePedido = new Modelo.DETALLE_PEDIDO(); detallePedido.ORDEN_PEDIDO_NUMEROORDEN = NumeroOrden; detallePedido.PRODUCTO_CODIGO = CodigoProducto; detallePedido.CANTIDAD = Cantidad; ConectorDALC.ModeloAlmacen.DETALLE_PEDIDO.Add(detallePedido); ConectorDALC.ModeloAlmacen.SaveChanges(); return(true); } catch (Exception ex) { return(false); throw new ArgumentException("Error al agregar detalle de pedido: " + ex); } }
public bool EliminarDetallePedido(int idDetalle) { try { if (BuscarDetallePedido(idDetalle)) { Modelo.DETALLE_PEDIDO detallePedido = ConectorDALC.ModeloAlmacen.DETALLE_PEDIDO.FirstOrDefault(e => e.IDDETALLEO == idDetalle); ConectorDALC.ModeloAlmacen.DETALLE_PEDIDO.Remove(detallePedido); ConectorDALC.ModeloAlmacen.SaveChanges(); return(true); } else { return(false); } } catch (Exception ex) { return(false); throw new ArgumentException("Error al eliminar detalle de pedido: " + ex); } }