Exemplo n.º 1
0
        public ActionResult ERRelatorioDiarioAVista()
        {
            if (Session["idVendedor"] != null)
            {
                string        data    = DateTime.Now.ToString("dd-MM-yyyy");
                List <Vendas> Retorno = new List <Vendas>();
                VendasDAO     OV      = new VendasDAO();
                Retorno = OV.VendasDiariasAVista();

                ReportDocument rd = new ReportDocument();
                rd.Load(Path.Combine(Server.MapPath("~/Reports"), "RelatorioDiarioAVista.rpt"));
                rd.SetDataSource(Retorno);

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                try
                {
                    Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    stream.Seek(0, SeekOrigin.Begin);
                    return(File(stream, "application/pdf", "JeR_RelatorioAVista_" + data + ".pdf"));
                }
                catch (Exception e)
                {
                    throw;
                }
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }