@Html.ActionLink("Details", "Details", new { id = item.idProducto }) |
@Html.ActionLink("Delete", "Delete", new { id = item.idProducto })
<a href="@Url.Action("ReporteProductoCategoria", "ReportesInternos", new { id = item.idProducto})">Click Here</a>;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ProyectoVentasMVCReport.Models;
using ProyectoVentasMVCReport.DataSet;
using System.Data.Entity;
using Microsoft.Reporting.WebForms;
namespace ProyectoVentasMVCReport.Controllers
{
public class ReportesInternosController : Controller
{
private Modelo db = new Modelo();
// GET: ReportesInternos
public ActionResult Index()
{
var producto = db.Producto.Include(p => p.Estado).Include(p => p.Tipo);
return View(producto.ToList());
}
public ActionResult ReporteProducto()
{
var producto = from p in db.Producto
join e in db.Estado on p.idEstado equals e.idEstado
join d in db.Tipo on p.idTipo equals d.idTipo
select new
{
p.nombreProducto,
p.descripcionProducto,
e.estado1,
d.descrpcion
};
//db.Producto.Include(p => p.Estado).Include(p => p.Tipo);
//IList<Producto> ct = db.Producto.ToList();
LocalReport lr = new LocalReport();
lr.ReportPath = Server.MapPath("~/Report/Producto.rdlc");
ReportDataSource reportDataSource = new ReportDataSource("Producto");
reportDataSource.Name = "Producto";
reportDataSource.Value = producto;
lr.DataSources.Add(reportDataSource);
string reportType = "PDF";
string mimeType;
string encoding;
string fileNameExtension = "pdf";
string[] streams;
Warning[] warnings;
byte[] renderedByte;
renderedByte = lr.Render(reportType, "", out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
Response.AddHeader("content.disposition","attachment;filename = student_report." + fileNameExtension);
return File(renderedByte, mimeType);
}
public ActionResult ReporteProductoCategoria(int id)
{
var pp = from ppp in db.Producto
where ppp.idProducto.Equals(id)
select ppp;
var producto = from p in pp
join c in db.Categorias on p.idProducto equals c.idProducto
select new
{
p.nombreProducto,
p.descripcionProducto,
p.idTipo,
p.idEstado,
c.idProducto,
};
//db.Producto.Include(p => p.Estado).Include(p => p.Tipo);
//IList<Producto> ct = db.Producto.ToList();
LocalReport lr = new LocalReport();
lr.ReportPath = Server.MapPath("~/Report/Productocat.rdlc");
ReportDataSource reportDataSource = new ReportDataSource("Productocat");
reportDataSource.Name = "Productocat";
reportDataSource.Value = producto;
lr.DataSources.Add(reportDataSource);
string reportType = "PDF";
string mimeType;
string encoding;
string fileNameExtension = "pdf";
string[] streams;
Warning[] warnings;
byte[] renderedByte;
renderedByte = lr.Render(reportType, "", out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
Response.AddHeader("content.disposition", "attachment;filename = student_report." + fileNameExtension);
return File(renderedByte, mimeType);
}
}
}
domingo, 21 de octubre de 2018
reporte c# mvc Report viewer
Suscribirse a:
Enviar comentarios
(
Atom
)
0 comentarios :
Publicar un comentario