private void inicializaContexto() { Contexto = new SalidaConCostoInfo { Organizacion = new OrganizacionInfo { TipoOrganizacion = new TipoOrganizacionInfo { TipoProceso = new TipoProcesoInfo() }, Iva = new IvaInfo { CuentaPagar = new CuentaInfo { TipoCuenta = new TipoCuentaInfo() }, CuentaRecuperar = new CuentaInfo { TipoCuenta = new TipoCuentaInfo() } } } }; }
private void generarReporte() { DateTime dtFechaInicial = new DateTime(DtpFechaInicial.SelectedDate.Value.Year, DtpFechaInicial.SelectedDate.Value.Month, DtpFechaInicial.SelectedDate.Value.Day); DateTime dtFechaFinal = new DateTime(DtpFechaFin.SelectedDate.Value.Year, DtpFechaFin.SelectedDate.Value.Month, DtpFechaFin.SelectedDate.Value.Day); int iOrganizacionID = int.Parse(skAyudaOrganizacion.Clave); int iTipoSalida = int.Parse(cmbTipoSalida.SelectedValue.ToString()); int iTipoProceso = int.Parse(cmbTipoProceso.SelectedValue.ToString()); String sVistaCostos = cmbVerCostos.Text; ReporteSalidaConCostosBL salidaBL = new ReporteSalidaConCostosBL(); Boolean bSalidaVentaMuerte = false; Boolean bDetallado = false; SalidaConCostoInfo salidas = new SalidaConCostoInfo(); if (sVistaCostos.ToUpper().Trim() == "DETALLADOS") { bDetallado = true; } ReporteSalidasConCostoParametrosInfo parametros = new ReporteSalidasConCostoParametrosInfo { OrganizacionID = iOrganizacionID, FechaInicial = dtFechaInicial, FechaFinal = dtFechaFinal, TipoSalida = iTipoSalida, TipoProceso = iTipoProceso, EsDetallado = bDetallado }; IList <ReporteSalidaConCostosInfo> resultadoInfo = salidaBL.obtenerReporte(parametros); if (resultadoInfo != null) { if (TipoMovimiento.Muerte.GetHashCode().ToString() == iTipoSalida.ToString() || TipoMovimiento.Muerte.GetHashCode().ToString() == iTipoSalida.ToString()) { bSalidaVentaMuerte = true; } foreach (ReporteSalidaConCostosInfo salida in resultadoInfo) { salida.esSalidaVentaOMuerte = bSalidaVentaMuerte; salida.esDetallado = bDetallado; salida.Leyenda = organizacionLocal.Descripcion; salida.RangoFechas = "De " + dtFechaInicial.Day.ToString().PadLeft(2, '0') + "-" + dtFechaInicial.Month.ToString().PadLeft(2, '0') + dtFechaInicial.Year.ToString() + " hasta" + dtFechaFinal.Day.ToString().PadLeft(2, '0') + "-" + dtFechaFinal.Month.ToString().PadLeft(2, '0') + dtFechaFinal.Year.ToString(); salida.NombreReporte = Properties.Resources.ReporteSalidaConCosto_NombreReporte; } var encabezado = new ReporteEncabezadoInfo { Titulo = Properties.Resources.ReporteSalidaConCosto_Titulo, FechaInicio = dtFechaInicial, FechaFin = dtFechaFinal, Organizacion = Properties.Resources.ReporteSalidaConCosto_Titulo + " (" + organizacionLocal.Division + ")" }; var documento = new ReportDocument(); String directorioBase = String.Empty; if (AppDomain.CurrentDomain.BaseDirectory.Substring(AppDomain.CurrentDomain.BaseDirectory.Length - 1, 1) == "\\") { directorioBase = AppDomain.CurrentDomain.BaseDirectory.Substring(0, AppDomain.CurrentDomain.BaseDirectory.Length - 1); } else { directorioBase = AppDomain.CurrentDomain.BaseDirectory.ToString(); } var reporte = String.Format("{0}{1}", directorioBase, "\\Reporte\\RptReporteSalidaConCostosDetallado.rpt"); documento.Load(reporte); documento.DataSourceConnections.Clear(); documento.SetDataSource(resultadoInfo); documento.Refresh(); var forma = new ReportViewer(documento, encabezado.Titulo); forma.MostrarReporte(); forma.Show(); for (int i = 0; i < resultadoInfo.Count; i++) { GC.SuppressFinalize(resultadoInfo[i]); } GC.SuppressFinalize(resultadoInfo); } else { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteSalidaConCosto_Msg_SinInformacion, MessageBoxButton.OK, MessageImage.Warning); } }