Exemplo n.º 1
0
        public ActionResult Reporte(tbObjeto Objeto /*, int clte_Id, bool clte_EsPersonaNatural*/)
        {
            string              Fecha_factura       = "2019-03-15";
            string              clte_Identificacion = "0401199800256";
            string              fact_Codigo         = "2";
            int                 iTipoReporte        = Objeto.obj_Id;
            var                 list          = db.SDP_Acce_GetReportes().ToList();
            var                 GetUsuario    = GetUsuarioMetodo();
            var                 UsuarioName   = db.tbUsuario.Where(x => x.usu_Id == GetUsuario).Select(i => new { i.usu_Nombres, i.usu_Apellidos }).FirstOrDefault();
            ReportDocument      rd            = new ReportDocument();
            Stream              stream        = null;
            rptVentasExoneradas rptVentasE    = new rptVentasExoneradas();
            Reportes            ReporteVentas = new Reportes();

            var ReporteVentasExoneradasTableAdapter = new UDV_Vent_VentasExoneradasTableAdapter();

            try
            {
                ReporteVentasExoneradasTableAdapter.FillFiltros(ReporteVentas.UDV_Vent_VentasExoneradas, Fecha_factura, clte_Identificacion, fact_Codigo);

                rptVentasE.SetDataSource(ReporteVentas);
                rptVentasE.SetParameterValue("usuario", UsuarioName.usu_Nombres + " " + UsuarioName.usu_Apellidos);

                stream = rptVentasE.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);

                rptVentasE.Close();
                rptVentasE.Dispose();


                string fileName = "Reporte_PedidoEntreFechas.pdf";
                Response.AppendHeader("Content-Disposition", "inline; filename=" + fileName);
                return(File(stream, "application/pdf"));
            }
            catch (Exception Ex)
            {
                Ex.Message.ToString();
                throw;
            }
        }
        private void llenarListas()
        {
            var list        = db.SDP_Acce_GetReportes().ToList();
            var listCliente = db.tbCliente.Select(s => new
            {
                clte_Identificacion = s.clte_Identificacion,
                clte_Nombres        = s.clte_Nombres + " " + s.clte_Apellidos,
                clte_EsActivo       = s.clte_EsActivo
            }).Where(x => x.clte_EsActivo == true).ToList();
            var listSucursal = db.tbSucursales.ToList();
            var listCajeros  = db.tbUsuario.Select(s => new
            {
                usu_Id      = s.usu_Id,
                usu_Nombres = s.usu_Nombres + " " + s.usu_Apellidos
            }).ToList();

            ViewBag.obj_Id = new SelectList(list, "obj_Id", "obj_Pantalla");
            ViewBag.clte_Identificacion = new SelectList(listCliente, "clte_Identificacion", "clte_Nombres");
            ViewBag.suc_Id                = new SelectList(listSucursal, "suc_Id", "suc_Descripcion");
            ViewBag.fact_UsuarioCrea      = new SelectList(listCajeros, "usu_Id", "usu_Nombres");
            ViewBag.clte_Identificacion_  = new SelectList(listCliente, "clte_Identificacion", "clte_Nombres");
            ViewBag.clte_Identificacion_1 = new SelectList(listCliente, "clte_Identificacion", "clte_Nombres");
        }