public JsonResult BuscarXId(int ProductDetailId) { var ProductoDetalle = (from PD in db.ProductDetails join P in db.Products on PD.ProductoId equals P.ProductoId join M in db.Markers on PD.MarkerId equals M.MarkerId where PD.ProductDetailId == ProductDetailId select new { PD, P, M }).ToList(); EDProductPresentationPrice EDProductPresentationPrice = new EDProductPresentationPrice(); if (ProductoDetalle != null) { foreach (var item in ProductoDetalle) { EDProductPresentationPrice.ProductDetailId = item.PD.ProductDetailId; EDProductPresentationPrice.CodBarras = item.PD.CodBarras; EDProductPresentationPrice.ProductoId = item.PD.ProductoId; EDProductPresentationPrice.NombreProducto = item.P.NombreProducto; EDProductPresentationPrice.MarkerId = item.PD.MarkerId; EDProductPresentationPrice.NombreFabricante = item.M.NombreFabricante; FuncUsuarios FuncUsuarios = new FuncUsuarios(); EDProductPresentationPrice.ListaPresentacion = FuncUsuarios.ListaProductPresentacion(EDProductPresentationPrice.ProductDetailId); EDProductPresentationPrice.Precio = FuncUsuarios.PrecioProducto(item.PD.ProductDetailId, EDProductPresentationPrice.ListaPresentacion[0].PresentationId); } } return(Json(EDProductPresentationPrice, JsonRequestBehavior.AllowGet)); }
public JsonResult BuscarXNombre(string NombreProducto) { var ProductoDetalle = (from PD in db.ProductDetails join P in db.Products on PD.ProductoId equals P.ProductoId join M in db.Markers on PD.MarkerId equals M.MarkerId where P.NombreProducto.Contains(NombreProducto) select new { PD, P, M }).ToList(); List <EDProductPresentationPrice> ListaEDProductPresentationPrice = new List <EDProductPresentationPrice>(); if (ProductoDetalle != null) { foreach (var item in ProductoDetalle) { EDProductPresentationPrice EDProductPresentationPrice = new EDProductPresentationPrice(); EDProductPresentationPrice.ProductDetailId = item.PD.ProductDetailId; EDProductPresentationPrice.CodBarras = item.PD.CodBarras; EDProductPresentationPrice.ProductoId = item.PD.ProductoId; EDProductPresentationPrice.NombreProducto = item.P.NombreProducto; EDProductPresentationPrice.MarkerId = item.PD.MarkerId; EDProductPresentationPrice.NombreFabricante = item.M.NombreFabricante; ListaEDProductPresentationPrice.Add(EDProductPresentationPrice); } } return(Json(ListaEDProductPresentationPrice, JsonRequestBehavior.AllowGet)); }
public JsonResult List() { List <EDProductPresentationPrice> EDProductPresentationPriceLista = new List <EDProductPresentationPrice>(); var Listaux = (from PPP in db.ProductPresentationPrices join PD in db.ProductDetails on PPP.ProductDetailId equals PD.ProductDetailId join P in db.Products on PD.ProductoId equals P.ProductoId join PR in db.Presentations on PPP.PresentationId equals PR.PresentationId join M in db.Markers on PD.MarkerId equals M.MarkerId select new { PPP, PD, P, PR, M }).ToList(); if (Listaux != null) { foreach (var item in Listaux) { EDProductPresentationPrice EDProductPresentationPrice = new EDProductPresentationPrice(); EDProductPresentationPrice.PrecioProductoId = item.PPP.PrecioProductoId; EDProductPresentationPrice.Precio = item.PPP.Precio; EDProductPresentationPrice.ProductoId = item.PD.ProductoId; EDProductPresentationPrice.NombreProducto = item.P.NombreProducto; EDProductPresentationPrice.PresentationId = item.PPP.PresentationId; EDProductPresentationPrice.NombrePresentacion = item.PR.NombrePresentacion; EDProductPresentationPrice.CantPresentacion = item.PR.CantPresentacion; EDProductPresentationPrice.MarkerId = item.M.MarkerId; EDProductPresentationPrice.ProductDetailId = item.PD.ProductDetailId; EDProductPresentationPrice.CodBarras = item.PD.CodBarras; EDProductPresentationPrice.NombreFabricante = item.M.NombreFabricante; EDProductPresentationPriceLista.Add(EDProductPresentationPrice); } } return(Json(EDProductPresentationPriceLista, JsonRequestBehavior.AllowGet)); }
public JsonResult Crear(EDProductPresentationPrice ProductoDetalle) { bool Probar = true; string Mensaje = ""; EDProductPresentationPrice EDProductPresentationPrice = new EDProductPresentationPrice(); EDProductPresentationPrice.PrecioProductoId = ProductoDetalle.PrecioProductoId; EDProductPresentationPrice.Precio = ProductoDetalle.Precio; EDProductPresentationPrice.PresentationId = ProductoDetalle.PresentationId; EDProductPresentationPrice.ProductDetailId = ProductoDetalle.ProductDetailId; try { ProductPresentationPrice ProductPresentationPrice = new ProductPresentationPrice(); ProductPresentationPrice.Precio = EDProductPresentationPrice.Precio; ProductPresentationPrice.PresentationId = EDProductPresentationPrice.PresentationId; ProductPresentationPrice.ProductDetailId = EDProductPresentationPrice.ProductDetailId; db.ProductPresentationPrices.Add(ProductPresentationPrice); db.SaveChanges(); Mensaje = " Registro Agregado con exito."; } catch (Exception) { Probar = false; Mensaje = " Se produjo un error al agregar el registro."; } return(Json(new { Probar, Mensaje }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetbyID(int?ID) { var PrecioProducto = (from PPP in db.ProductPresentationPrices join PD in db.ProductDetails on PPP.ProductDetailId equals PD.ProductDetailId join P in db.Products on PD.ProductoId equals P.ProductoId join M in db.Markers on PD.MarkerId equals M.MarkerId join PR in db.Presentations on PPP.PresentationId equals PR.PresentationId where PPP.PrecioProductoId == ID select new { PPP, PD, P, M, PR }).ToList(); EDProductPresentationPrice EDProductPresentationPrice = new EDProductPresentationPrice(); if (PrecioProducto != null) { foreach (var item in PrecioProducto) { FuncUsuarios FuncUsuarios = new FuncUsuarios(); List <EDPresentacion> ListaEDPresentacion = new List <EDPresentacion>(); List <EDPresentacion> ListaEDPresentacionNombre = new List <EDPresentacion>(); ListaEDPresentacionNombre = FuncUsuarios.ListaNombrePresentacion(); EDProductPresentationPrice.PrecioProductoId = item.PPP.PrecioProductoId; EDProductPresentationPrice.Precio = item.PPP.Precio; EDProductPresentationPrice.PresentationId = item.PPP.PresentationId; EDProductPresentationPrice.MarkerId = item.PD.MarkerId; EDProductPresentationPrice.NombreFabricante = item.M.NombreFabricante; EDProductPresentationPrice.ProductDetailId = item.PD.ProductDetailId; EDProductPresentationPrice.CodBarras = item.PD.CodBarras; EDProductPresentationPrice.ProductoId = item.PD.ProductoId; EDProductPresentationPrice.NombreProducto = item.P.NombreProducto; EDProductPresentationPrice.CantPresentacion = item.PR.CantPresentacion; EDProductPresentationPrice.NombrePresentacion = item.PR.NombrePresentacion; ListaEDPresentacion = FuncUsuarios.ListaPresentacion(EDProductPresentationPrice.NombrePresentacion); EDProductPresentationPrice.ListaPresentacion = ListaEDPresentacion; EDProductPresentationPrice.ListaNombrePresentacion = ListaEDPresentacionNombre; } } return(Json(EDProductPresentationPrice, JsonRequestBehavior.AllowGet)); }
public JsonResult Editar(EDProductPresentationPrice ProductoDetalle) { bool Probar = true; string Mensaje = ""; EDProductPresentationPrice EDProductPresentationPrice = new EDProductPresentationPrice(); EDProductPresentationPrice.PrecioProductoId = ProductoDetalle.PrecioProductoId; EDProductPresentationPrice.Precio = ProductoDetalle.Precio; EDProductPresentationPrice.PresentationId = ProductoDetalle.PresentationId; EDProductPresentationPrice.ProductDetailId = ProductoDetalle.ProductDetailId; ProductPresentationPrice ProductPresentationPrice = db.ProductPresentationPrices.Find(ProductoDetalle.PrecioProductoId); if (ProductPresentationPrice == null) { Probar = false; Mensaje = " No se encuentra el registro."; } else { try { ProductPresentationPrice.Precio = EDProductPresentationPrice.Precio; ProductPresentationPrice.PresentationId = EDProductPresentationPrice.PresentationId; ProductPresentationPrice.ProductDetailId = EDProductPresentationPrice.ProductDetailId; db.Entry(ProductPresentationPrice).State = EntityState.Modified; db.SaveChanges(); Mensaje = " Registro modificado con exito."; } catch (Exception e) { Probar = false; Mensaje = " Se produjo un error al modificar el registro."; } } return(Json(new { Probar, Mensaje }, JsonRequestBehavior.AllowGet)); }