public ActionResult Report(string id) { LocalReport lr = new LocalReport(); string path = Path.Combine(Server.MapPath("~/Reportes"), "ReporteCI.rdlc"); if (System.IO.File.Exists(path)) { lr.ReportPath = path; } else { return(View("Index")); } List <ReporteCI> cm = ReporteCIBLL.SelectAll(); ReportDataSource rd = new ReportDataSource("DataSet", cm); lr.DataSources.Add(rd); string reportType = id; string mimeType; string encoding; string fileNameExtension; string deviceInfo = "<DeviceInfo>" + " <OutputFormat>" + id + "</OutputFormat>" + " <PageWidth>8.5in</PageWidth>" + " <PageHeight>11in</PageHeight>" + " <MarginTop>0.5in</MarginTop>" + " <MarginLeft>1in</MarginLeft>" + " <MarginRight>1in</MarginRight>" + " <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] renderedBytes; renderedBytes = lr.Render( reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); return(File(renderedBytes, mimeType)); }
// // GET: /ReporteCI/ public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page) { IEnumerable <ReporteCI> listaDepartamento = ReporteCIBLL.SelectAll(); ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date"; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; var students = from s in listaDepartamento select s; if (!String.IsNullOrEmpty(searchString)) { students = students.Where(s => s.CarnetIdentidad.ToUpper().Contains(searchString.ToUpper()) || s.Empleado.ToString().ToUpper().Contains(searchString.ToUpper())); } switch (sortOrder) { case "name_desc": students = students.OrderByDescending(s => s.CarnetIdentidad); break; case "Date": students = students.OrderBy(s => s.Empleado); break; case "date_desc": students = students.OrderByDescending(s => s.CarnetIdentidad); break; default: // Name ascending students = students.OrderBy(s => s.Empleado); break; } return(View(students.ToList <ReporteCI>())); }