public ActionResult VentasPorProductos(ReporteVentasFiltrosModel reporteVentasFiltrosModel)
 {
     return PartialOrView(reporteVentasFiltrosModel);
 }
        public ActionResult GenerarVentasPorProducto(ReporteVentasFiltrosModel reporteVentasFiltrosModel)
        {
            DateTime? hasta = reporteVentasFiltrosModel.Hasta == null
                ? (DateTime?)null
                : reporteVentasFiltrosModel.Hasta.GetValueOrDefault().AddDays(1);

            var reporteFactory = new ReporteFactory();

            var rubro = Uow.Rubros.Obtener(r => r.RubroId == reporteVentasFiltrosModel.RubroId);
            var rubroDescripcion = rubro != null ? rubro.Descripcion : TodosText;

            var rubroId = reporteVentasFiltrosModel.RubroId.HasValue
                ? reporteVentasFiltrosModel.RubroId.Value.ToString()
                : null;

            reporteFactory
                .SetParametro("Desde", reporteVentasFiltrosModel.Desde.ToShortDateString(null))
                .SetParametro("Hasta", reporteVentasFiltrosModel.Hasta.ToShortDateString(null))
                .SetParametro("CuentaId", UsuarioActual.CuentaId.ToString())
                .SetParametro("RubroId", rubroId)
                .SetParametro("RubroDescripcion", rubroDescripcion);

            if (reporteVentasFiltrosModel.MostrarTotalGeneral)
            {
                var ventasPorProductoTotalGeneralDataSource =
                    Uow.Reportes.VentasPorProductoTotalGeneral(reporteVentasFiltrosModel.Desde,
                        hasta,
                        reporteVentasFiltrosModel.RubroId,
                        UsuarioActual.CuentaId);

                reporteFactory.SetPathCompleto(Server.MapPath("~/Reportes/VentasPorProductoTotalGeneral.rdl"))
                    .SetDataSource("VentasPorProductoTotalGeneralDataSet", ventasPorProductoTotalGeneralDataSource);
            }
            else
            {
                var ventasPorProductoDataSource = Uow.Reportes.VentasPorProducto(reporteVentasFiltrosModel.Desde,
                    hasta,
                    reporteVentasFiltrosModel.RubroId,
                    reporteVentasFiltrosModel.MaxiKioscoId,
                    UsuarioActual.CuentaId);

                var maxikiosco = Uow.MaxiKioscos.Obtener(m => m.MaxiKioscoId == reporteVentasFiltrosModel.MaxiKioscoId);
                var maxikioscoNombre = maxikiosco != null ? maxikiosco.Nombre : TodosText;

                reporteFactory
                    .SetParametro("MaxikioscoId", reporteVentasFiltrosModel.MaxiKioscoId.HasValue ? reporteVentasFiltrosModel.MaxiKioscoId.Value.ToString() : null)
                    .SetParametro("MaxikioscoNombre", maxikioscoNombre);

                reporteFactory.SetPathCompleto(Server.MapPath("~/Reportes/VentasPorProducto.rdl"))
                    .SetDataSource("VentasPorProductoDataSet", ventasPorProductoDataSource);

            }

            var ventasPorProductoRankingDataSource =
                Uow.Reportes.VentasPorProductoRanking(reporteVentasFiltrosModel.Desde,
                    hasta,
                    reporteVentasFiltrosModel.RubroId,
                    reporteVentasFiltrosModel.MaxiKioscoId,
                    UsuarioActual.CuentaId,
                    null);

            reporteFactory.SetDataSource("VentasPorProductoRankingDataSet", ventasPorProductoRankingDataSource);

            byte[] archivo = reporteFactory.Renderizar(reporteVentasFiltrosModel.ReporteTipo);

            return File(archivo, reporteFactory.MimeType);
        }
 public ActionResult VentasPorMaxikioscos(ReporteVentasFiltrosModel reporteVentasFiltrosModel)
 {
     return PartialOrView(reporteVentasFiltrosModel);
 }
        public ActionResult GenerarVentasPorMaxikiosco(ReporteVentasFiltrosModel reporteVentasFiltrosModel)
        {
            try
            {
                DateTime? hasta = reporteVentasFiltrosModel.Hasta == null
                                    ? (DateTime?)null
                                    : reporteVentasFiltrosModel.Hasta.GetValueOrDefault().AddDays(1);

                var ventasPorMaxikiosoDataSource =
                    Uow.Reportes.VentasPorMaxikiosco(reporteVentasFiltrosModel.Desde,
                        hasta,
                        UsuarioActual.CuentaId);

                var reporteFactory = new ReporteFactory();

                reporteFactory
                    .SetParametro("Desde", reporteVentasFiltrosModel.Desde.ToShortDateString())
                    .SetParametro("Hasta", reporteVentasFiltrosModel.Hasta.ToShortDateString())
                    .SetPathCompleto(Server.MapPath("~/Reportes/VentasPorMaxikiosco.rdl"))
                    .SetDataSource("VentasPorMaxikioscoDataSet", ventasPorMaxikiosoDataSource);

                byte[] archivo = reporteFactory.Renderizar(reporteVentasFiltrosModel.ReporteTipo);

                return File(archivo, reporteFactory.MimeType);
            }
            catch (Exception ex)
            {
                EventLogger.Log(ex);
                return null;
            }
        }