Exemple #1
0
        public ActionResult ListaEmbarque()
        {
            using (TripSystemEntities ts = new TripSystemEntities())
            {
                List <ListaDeEmbarque> Fields = new List <ListaDeEmbarque>();

                var result = (from c in ts.Excurcaos
                              join a in ts.Reservas
                              on c.ID equals a.ExcurcaoId
                              select new
                {
                    c.Titulo,
                    c.LocalPartida,
                    c.DataPartida,
                    c.DataRetorno,
                    a.Nome,
                    a.SobreNome,
                    a.Telefone,
                    a.Idade,
                    a.OrdemId,
                }).ToList();

                foreach (var fc in result)
                {
                    ListaDeEmbarque epc = new ListaDeEmbarque();
                    epc.Titulo       = fc.Titulo;
                    epc.LocalPartida = fc.LocalPartida;
                    epc.DataPartida  = fc.DataPartida;
                    epc.DataRetorno  = fc.DataRetorno;
                    epc.Nome         = fc.Nome;
                    epc.SobreNome    = fc.SobreNome;
                    epc.Telefone     = fc.Telefone;
                    epc.Idade        = fc.Idade;
                    epc.OrdemId      = fc.OrdemId;

                    Fields.Add(epc);
                }

                return(View("ListaEmbarque", Fields));
            }
        }
Exemple #2
0
        public ActionResult Report(string id)
        {
            LocalReport lr   = new LocalReport();
            string      path = Path.Combine(Server.MapPath("~/Report"), "ListaDeEmbarque.rdlc");

            if (System.IO.File.Exists(path))
            {
                lr.ReportPath = path;
            }
            else
            {
                return(View("Index"));
            }
            List <ListaDeEmbarque> cm = new List <ListaDeEmbarque>();

            using (TripSystemEntities dc = new TripSystemEntities())
            {
                var result = (from c in dc.Excurcaos
                              join a in dc.Reservas
                              on c.ID equals a.ExcurcaoId
                              select new
                {
                    c.Titulo,
                    c.LocalPartida,
                    c.DataPartida,
                    c.DataRetorno,
                    a.Nome,
                    a.SobreNome,
                    a.Telefone,
                    a.Idade,
                    a.OrdemId,
                }).ToList();

                foreach (var fc in result)
                {
                    ListaDeEmbarque epc = new ListaDeEmbarque();
                    epc.Titulo       = fc.Titulo;
                    epc.LocalPartida = fc.LocalPartida;
                    epc.DataPartida  = fc.DataPartida;
                    epc.DataRetorno  = fc.DataRetorno;
                    epc.Nome         = fc.Nome;
                    epc.SobreNome    = fc.SobreNome;
                    epc.Telefone     = fc.Telefone;
                    epc.Idade        = fc.Idade;
                    epc.OrdemId      = fc.OrdemId;

                    cm.Add(epc);
                }
            }

            ReportDataSource rd  = new ReportDataSource("MyDataSet", cm);
            ReportDataSource rd2 = new ReportDataSource("DataSet1", cm);

            lr.DataSources.Add(rd);
            lr.DataSources.Add(rd2);
            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));
        }