/// <summary> /// Método obtener el reporte Operacion de Sanidad /// </summary> /// <param name="encabezado"></param> /// <param name="organizacion"></param> /// <returns></returns> private List <ReporteDetalleCorteModel> ObtenerReporteDetalleCorte(ReporteEncabezadoInfo encabezado, OrganizacionInfo organizacion) { try { var reporteDetalleCortePl = new ReporteDetalleCortePL(); DateTime fechaIni = DtpFechaInicial.SelectedDate.HasValue ? DtpFechaInicial.SelectedDate.Value : new DateTime(); DateTime fechaFin = DtpFechaFinal.SelectedDate.HasValue ? DtpFechaFinal.SelectedDate.Value : fechaIni; int idUsuario = AuxConfiguracion.ObtenerUsuarioLogueado(); List <ReporteDetalleCorteModel> resultadoInfo = reporteDetalleCortePl.ObtenerReporteDetalleCorte(encabezado, organizacion.OrganizacionID, fechaIni, fechaFin, idUsuario, TipoMovimiento.Corte.GetHashCode()); return(resultadoInfo); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Método para consultar Reporte /// </summary> /// <returns></returns> private void Consultar() { try { if (cmbOrganizacion.SelectedIndex > 0) { var organizacion = (OrganizacionInfo)cmbOrganizacion.SelectedItem; var organizacionPl = new OrganizacionPL(); organizacion = organizacionPl.ObtenerPorIdConIva(organizacion.OrganizacionID); var encabezado = new ReporteEncabezadoInfo() { TituloReporte = Properties.Resources.ReporteDetalleCorte_TituloReporteDetalle, TituloPeriodo = "Del " + DtpFechaInicial.Text + " al " + DtpFechaFinal.Text, Organizacion = string.Format(Properties.Resources.Reporte_NombreEmpresa, organizacion.Division), }; List <ReporteDetalleCorteModel> resultadoInfo = ObtenerReporteDetalleCorte(encabezado, organizacion); if (resultadoInfo == null || !resultadoInfo.Any()) { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteDetalleCorte_MsgSinInformacion, MessageBoxButton.OK, MessageImage.Warning); LimpiarCampos(true); return; } DtpFechaInicial.IsEnabled = false; DtpFechaFinal.IsEnabled = false; var documento = new ReportDocument(); var reporte = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "\\Reporte\\ReporteDetalleCorte.rpt"); documento.Load(reporte); documento.DataSourceConnections.Clear(); documento.SetDataSource(resultadoInfo); documento.Refresh(); var forma = new ReportViewer(documento, encabezado.TituloReporte); forma.MostrarReporte(); forma.Show(); } else { ; } } catch (Exception ex) { Logger.Error(ex); MessageBoxResult result = SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteMedicamentosAplicados_FalloCargarReporte, MessageBoxButton.OK, MessageImage.Error); } }
/// <summary> /// Obtener reporte detale del corte /// </summary> /// <param name="encabezado"></param> /// <param name="organizacionID"></param> /// <param name="fechaInicial"></param> /// <param name="fechaFinal"></param> /// <param name="idUsuario"></param> /// <returns></returns> internal List <ReporteDetalleCorteModel> ObtenerReporteDetalleCorte(ReporteEncabezadoInfo encabezado, int organizacionID, DateTime fechaInicial, DateTime fechaFinal, int idUsuario, int TipoMovimientoID) { List <ReporteDetalleCorteModel> lista; try { Logger.Info(); var ReporteDetalleCorteDAL = new ReporteDetalleCorteDAL(); List <ReporteDetalleCorteDatos> datosReporte = ReporteDetalleCorteDAL.ObtenerParametrosDatosReporteDetalleCorte(organizacionID, fechaInicial, fechaFinal, idUsuario, TipoMovimientoID); if (datosReporte == null) { return(null); } lista = GenerarDatosReporteGeneral(datosReporte, encabezado); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } return(lista); }
/// <summary> /// Obtiene la lista para mostrar en el grid /// </summary> private void ObtenerReporteGrid() { try { int organizacionId = AuxConfiguracion.ObtenerOrganizacionUsuario(); var organizacionPl = new OrganizacionPL(); var organizacion = organizacionPl.ObtenerPorIdConIva(organizacionId); var nombreOrganizacion = organizacion != null ? organizacion.Division : String.Empty; var encabezado = new ReporteEncabezadoInfo { Titulo = Properties.Resources.ReporteAuxiliarDeInventarioCorral_TituloReporte, Organizacion = Properties.Resources.ReportesSukarneAgroindustrial_Titulo + " (" + nombreOrganizacion + ")" }; List <AuxiliarDeInventarioInfo> resultadoInfo = ObtenerReporte(); if (resultadoInfo != null && resultadoInfo.Count > 0) { foreach (var dato in resultadoInfo) { dato.Titulo = encabezado.Titulo; dato.Organizacion = encabezado.Organizacion; dato.FechaInicio = DateTime.Now; } var documento = new ReportDocument(); var reporte = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "\\Reporte\\RptReporteAuxiliarDeInventarioPorCorral.rpt"); documento.Load(reporte); documento.DataSourceConnections.Clear(); documento.SetDataSource(resultadoInfo); documento.Refresh(); var forma = new ReportViewer(documento, encabezado.Titulo); forma.MostrarReporte(); forma.Show(); } else { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteAuxiliarInventario_MsgNoExistenDatosReporte, MessageBoxButton.OK, MessageImage.Warning); } } catch (ExcepcionGenerica) { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.RecepcionReporteAuxiliarInventario_ErrorBuscar, MessageBoxButton.OK, MessageImage.Error); } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.RecepcionReporteAuxiliarInventario_ErrorBuscar, MessageBoxButton.OK, MessageImage.Error); } }
/// <summary> /// Metodo para obtener los datos del informe /// El TipoFecha esta a la espera de 1.-Fecha Llegada, 2.-Fecha Entrada y 3.-Fecha Pesaje /// </summary> /// <param name="encabezado"></param> /// <param name="tipoTratamiento"></param> /// <param name="organizacionId"></param> /// <param name="fechaIni"></param> /// <param name="fechaFin"></param> /// <returns></returns> private List <ReporteBitacoraLlegadaInfo> ObtenerReporteBitacoraLlegada(ReporteEncabezadoInfo encabezado, int organizacionId, int tipoFecha, DateTime fechaIni, DateTime fechaFin) { try { var reporteBitacoraLlegadaPL = new ReporteBitacoraLlegadaPL(); List <ReporteBitacoraLlegadaInfo> resultadoInfo = reporteBitacoraLlegadaPL.ObtenerReporteBitacoraLlegada(encabezado, organizacionId, tipoFecha, fechaIni, fechaFin); return(resultadoInfo); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene los datos del reporte /// </summary> /// <param name="encabezado"></param> /// <param name="organizacionID"></param> /// <param name="fechaInicial"></param> /// <param name="fechaFinal"></param> /// <param name="idUsuario"></param> /// <returns></returns> public List <ReporteDetalleCorteModel> ObtenerReporteDetalleCorte(ReporteEncabezadoInfo encabezado, int organizacionID, DateTime fechaInicial, DateTime fechaFinal, int idUsuario, int TipoMovimientoID) { List <ReporteDetalleCorteModel> lista; try { Logger.Info(); var reporteBl = new ReporteDetalleCorteBL(); lista = reporteBl.ObtenerReporteDetalleCorte(encabezado, organizacionID, fechaInicial, fechaFinal, idUsuario, TipoMovimientoID); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } return(lista); }
/// <summary> /// Obtiene la informacion del reporte bitacora llegada /// El TipoFecha esta a la espera de 1.-Fecha Llegada, 2.-Fecha Entrada y 3.-Fecha Pesaje /// </summary> /// <param name="encabezado"></param> /// <param name="organizacionId"></param> /// <param name="tipoFecha"></param> /// <param name="fechaIni"></param> /// <param name="fechaFin"></param> /// <returns></returns> public List <ReporteBitacoraLlegadaInfo> ObtenerReporteBitacoraLlegada(ReporteEncabezadoInfo encabezado, int organizacionId, int tipoFecha, DateTime fechaIni, DateTime fechaFin) { List <ReporteBitacoraLlegadaInfo> lista; try { Logger.Info(); var reporteReporteBitacoraLlegadaBL = new ReporteBitacoraLlegadaBL(); lista = reporteReporteBitacoraLlegadaBL.ObtenerReporteBitacoraLlegada(encabezado, organizacionId, tipoFecha, fechaIni, fechaFin); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } return(lista); }
/// <summary> /// Obtiene Reporte de Medicamentos Aplicados exclusivamente para el repoorte de Medicamentos Aplicados /// </summary> /// <param name="encabezado"></param> /// <param name="organizacionID"></param> /// <param name="fechaInicial"></param> /// <param name="fechaFinal"></param> /// <param name="tipoTratamiento"></param> /// <returns></returns> public List <ReporteMedicamentosAplicadosModel> ObtenerReporteMedicamentoCabezasAplicados(ReporteEncabezadoInfo encabezado, int organizacionID, DateTime fechaInicial, DateTime fechaFinal, int tipoTratamiento) { List <ReporteMedicamentosAplicadosModel> lista; try { Logger.Info(); var reporteMedicamentosAplicadosBL = new ReporteMedicamentosAplicadosBL(); lista = reporteMedicamentosAplicadosBL.ObtenerReporteMedicamentoCabezasAplicados(encabezado, organizacionID, fechaInicial, fechaFinal, tipoTratamiento); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } return(lista); }
/// <summary> /// Obtiene los datos al reporte de medicamentos aplicados /// </summary> /// <param name="encabezado"></param> /// <param name="organizacionID"></param> /// <param name="fechaInicial"></param> /// <param name="fechaFinal"></param> /// <param name="tipoTratamiento"></param> /// <returns></returns> internal List <ReporteMedicamentosAplicadosModel> ObtenerReporteMedicamentosAplicados(ReporteEncabezadoInfo encabezado, int organizacionID, DateTime fechaInicial, DateTime fechaFinal, int tipoTratamiento) { List <ReporteMedicamentosAplicadosModel> lista; try { Logger.Info(); var reporteMedicamentosAplicadosDAL = new ReporteMedicamentosAplicadosDAL(); List <ReporteMedicamentosAplicadosDatos> datosReporte = reporteMedicamentosAplicadosDAL.ObtenerParametrosDatosMedicamentosAplicados(organizacionID, fechaInicial, fechaFinal); if (datosReporte == null) { return(null); } lista = tipoTratamiento == 0 ? GenerarDatosReporteGeneral(datosReporte, encabezado) : GenerarDatosReporte(datosReporte, tipoTratamiento, encabezado); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } return(lista); }
/// <summary> /// Método para exportar a excel /// </summary> /// <returns></returns> private void Consultar() { try { DateTime fechaIni = DtpFechaInicial.SelectedDate.HasValue ? DtpFechaInicial.SelectedDate.Value : new DateTime(); DateTime fechaFin = DtpFechaFinal.SelectedDate.HasValue ? DtpFechaFinal.SelectedDate.Value : fechaIni; var organizacionInfo = (OrganizacionInfo)cmbOrganizacion.SelectedItem; int organizacionId = organizacionInfo.OrganizacionID; List <ReporteOperacionSanidadInfo> resultadoInfo = ObtenerReporteOperacionSanidad(organizacionId, fechaIni, fechaFin); if (resultadoInfo == null || !resultadoInfo.Any()) { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteOperacionSanidad_MsgSinInformacion, MessageBoxButton.OK, MessageImage.Warning); LimpiarCampos(); return; } var organizacionPl = new OrganizacionPL(); var organizacion = organizacionPl.ObtenerPorIdConIva(organizacionId); DtpFechaInicial.IsEnabled = false; DtpFechaFinal.IsEnabled = false; var nombreOrganizacion = organizacion != null ? organizacion.Division : String.Empty; var encabezado = new ReporteEncabezadoInfo { Titulo = Properties.Resources.ReporteOperadoresSanidad_TituloReporte, FechaInicio = fechaIni, FechaFin = fechaFin, Organizacion = Properties.Resources.ReportesSukarneAgroindustrial_Titulo + " (" + nombreOrganizacion + ")" }; foreach (var dato in resultadoInfo) { dato.Titulo = encabezado.Titulo; dato.FechaInicio = encabezado.FechaInicio; dato.FechaFin = encabezado.FechaFin; dato.Organizacion = encabezado.Organizacion; } var documento = new ReportDocument(); var reporte = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "\\Reporte\\RptReporteOperacionSanidad.rpt"); documento.Load(reporte); documento.DataSourceConnections.Clear(); documento.SetDataSource(resultadoInfo); documento.Refresh(); var forma = new ReportViewer(documento, encabezado.Titulo); forma.MostrarReporte(); forma.Show(); } catch (ExcepcionServicio ex) { Logger.Error(ex); SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteIndicadoresSanidad_FalloCargarReporte, MessageBoxButton.OK, MessageImage.Error); } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteIndicadoresSanidad_FalloCargarReporte, MessageBoxButton.OK, MessageImage.Error); } }
/// <summary> /// Obtiene la lista para mostrar en el grid /// </summary> private void ObtenerReporte() { try { int tipoProcesoId = cmbTipoProceso.SelectedItem != null ? (int)cmbTipoProceso.SelectedValue : 0; string tipoProcesoString = cmbTipoProceso.SelectedItem != null ? ((TipoProcesoInfo)cmbTipoProceso.SelectedItem).Descripcion.Trim() : String.Empty; DateTime fechaIni; DateTime fechaFin; if (DtpFechaInicial.SelectedDate == null && DtpFechaFinal.SelectedDate == null) { fechaIni = DateTime.Now.Date.AddMonths(-3); fechaFin = DateTime.Now.Date; } else if (DtpFechaInicial.SelectedDate != null && DtpFechaFinal.SelectedDate == null) { fechaIni = DtpFechaInicial.SelectedDate.Value; fechaFin = DtpFechaInicial.SelectedDate.Value; } else { fechaIni = DtpFechaInicial.SelectedDate.HasValue ? DtpFechaInicial.SelectedDate.Value : fechaMinima; fechaFin = DtpFechaFinal.SelectedDate.HasValue ? DtpFechaFinal.SelectedDate.Value : DateTime.Today; } var organizacionSeleccionada = (OrganizacionInfo)cmbOrganizacion.SelectedItem; var organizacionId = organizacionSeleccionada.OrganizacionID; List <ReporteInventarioInfo> resultadoInfo = ObtenerReporteInventario(organizacionId, tipoProcesoId, fechaIni, fechaFin); if (resultadoInfo != null && resultadoInfo.Count > 0) { cmbTipoProceso.IsEnabled = false; DtpFechaInicial.IsEnabled = false; DtpFechaFinal.IsEnabled = false; var organizacionPl = new OrganizacionPL(); var organizacion = organizacionPl.ObtenerPorIdConIva(organizacionId); var nombreOrganizacion = organizacion != null ? organizacion.Division : String.Empty; var encabezado = new ReporteEncabezadoInfo { Titulo = Properties.Resources.ReporteResumenInventario_TituloReporte, FechaInicio = fechaIni, FechaFin = fechaFin, Organizacion = Properties.Resources.ReportesSukarneAgroindustrial_Titulo + " (" + nombreOrganizacion + ")" }; foreach (var dato in resultadoInfo) { dato.TipoProceso = tipoProcesoString; dato.Titulo = encabezado.Titulo + " " + dato.TipoProceso; dato.FechaInicio = encabezado.FechaInicio; dato.FechaFin = encabezado.FechaFin; dato.Organizacion = encabezado.Organizacion; } var documento = new ReportDocument(); var reporte = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "\\Reporte\\RptReporteResumenInventarioDeGanado.rpt"); documento.Load(reporte); documento.DataSourceConnections.Clear(); documento.SetDataSource(resultadoInfo); documento.Refresh(); var forma = new ReportViewer(documento, encabezado.Titulo); forma.MostrarReporte(); forma.Show(); } else { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.RecepcionReporteInventario_MsgSinInformacion, MessageBoxButton.OK, MessageImage.Warning); } } catch (ExcepcionGenerica) { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.RecepcionReporteInventario_ErrorBuscar, MessageBoxButton.OK, MessageImage.Error); } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.RecepcionReporteInventario_ErrorBuscar, MessageBoxButton.OK, MessageImage.Error); } }
/// <summary> /// Método para exportar a excel /// </summary> /// <returns></returns> private void Consultar() { try { DateTime fechaIni = DtpFechaInicial.SelectedDate.HasValue ? DtpFechaInicial.SelectedDate.Value : new DateTime(); DateTime fechaFin = DtpFechaFinal.SelectedDate.HasValue ? DtpFechaFinal.SelectedDate.Value : fechaIni; var orgCombo = (OrganizacionInfo)cmbOrganizacion.SelectedItem; int organizacionId = orgCombo.OrganizacionID; string strTitulo = Properties.Resources.ReporteMedicamentosAplicadosSanidad_TituloReporte; int almacenId = 0; if (almacenSeleccionadoInfo != null) { almacenId = almacenSeleccionadoInfo.AlmacenID; strTitulo += "(" + almacenSeleccionadoInfo.Descripcion + ")"; } var tipoMovimiento = (TipoMovimientoInfo)cmbTipoMovimiento.SelectedItem; int tipoTratamiento = 0; if (tipoMovimiento != null) { tipoTratamiento = tipoMovimiento.TipoMovimientoID; } var organizacionPl = new OrganizacionPL(); var organizacion = organizacionPl.ObtenerPorIdConIva(organizacionId); var nombreOrganizacion = organizacion != null ? organizacion.Division : String.Empty; var encabezado = new ReporteEncabezadoInfo() { Titulo = strTitulo, FechaInicio = fechaIni, FechaFin = fechaFin, Organizacion = Properties.Resources.ReportesSukarneAgroindustrial_Titulo + " (" + nombreOrganizacion + ")" }; List <ReporteMedicamentosAplicadosModel> resultadoInfo = ObtenerReporteMedicamentosAplicadosSanidad(encabezado, tipoTratamiento, organizacionId, almacenId, fechaIni, fechaFin); if (resultadoInfo == null || !resultadoInfo.Any()) { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteOperacionSanidad_MsgSinInformacion, MessageBoxButton.OK, MessageImage.Warning); LimpiarCampos(true); return; } DtpFechaInicial.IsEnabled = false; DtpFechaFinal.IsEnabled = false; cmbTipoMovimiento.IsEnabled = false; skAyudaAlmacen.IsEnabled = false; foreach (var dato in resultadoInfo) { dato.Organizacion = encabezado.Organizacion; dato.Titulo = encabezado.Titulo; dato.FechaFin = encabezado.FechaFin; dato.FechaInicio = encabezado.FechaInicio; dato.Id = tipoTratamiento; } var documento = new ReportDocument(); var reporte = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "\\Reporte\\RptReporteMedicamentosAplicadosSanidad.rpt"); documento.Load(reporte); documento.DataSourceConnections.Clear(); documento.SetDataSource(resultadoInfo); documento.Refresh(); var forma = new ReportViewer(documento, encabezado.Titulo); forma.MostrarReporte(); forma.Show(); } catch (Exception ex) { Logger.Error(ex); MessageBoxResult result = SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteMedicamentosAplicados_FalloCargarReporte, MessageBoxButton.OK, MessageImage.Error); } }
/// <summary> /// Método para exportar a excel /// </summary> /// <returns></returns> private void Consultar() { try { ParametroGeneralPL parametroGeneralPl = new ParametroGeneralPL(); ParametroGeneralInfo estandarInfo = parametroGeneralPl.ObtenerPorClaveParametro(ParametrosEnum.EstandarTiempo.ToString()); ParametroGeneralInfo porcMinimoInfo = parametroGeneralPl.ObtenerPorClaveParametro(ParametrosEnum.PorcMinimo.ToString()); ParametroGeneralInfo porcMaximoInfo = parametroGeneralPl.ObtenerPorClaveParametro(ParametrosEnum.PorcMaximo.ToString()); if (estandarInfo == null || porcMaximoInfo == null || porcMaximoInfo == null) { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteBitacoraLlegada_MsgParametrosNoEncontrados, MessageBoxButton.OK, MessageImage.Warning); return; } int organizacionId = organizacionSeleccionada.OrganizacionID; int tipoFecha = 1; if (rbFechaEntrada.IsChecked == true) { tipoFecha = 2; } else if (rbFechaPesaje.IsChecked == true) { tipoFecha = 3; } DateTime fechaIni = DtpFechaInicial.SelectedDate.HasValue ? DtpFechaInicial.SelectedDate.Value : new DateTime(); DateTime fechaFin = DtpFechaFinal.SelectedDate.HasValue ? DtpFechaFinal.SelectedDate.Value : fechaIni; var organizacionPl = new OrganizacionPL(); var organizacion = organizacionPl.ObtenerPorIdConIva(organizacionId); var nombreOrganizacion = organizacion != null ? organizacion.Descripcion : String.Empty; var encabezado = new ReporteEncabezadoInfo() { Titulo = Properties.Resources.ReporteBitacoraLlegada_Titulo, FechaInicio = fechaIni, FechaFin = fechaFin, //Organizacion = Properties.Resources.ReportesSukarneAgroindustrial_Titulo + " (" + nombreOrganizacion + ")" Organizacion = nombreOrganizacion }; List <ReporteBitacoraLlegadaInfo> resultadoInfo = ObtenerReporteBitacoraLlegada(encabezado, organizacionId, tipoFecha, fechaIni, fechaFin); if (resultadoInfo == null || !resultadoInfo.Any()) { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteBitacoraLlegada_MsgSinInformacion, MessageBoxButton.OK, MessageImage.Warning); LimpiarCampos(true); return; } string [] arrEstandar = estandarInfo.Valor.Split(':'); TimeSpan Estandar = new TimeSpan(int.Parse(arrEstandar[0]), int.Parse(arrEstandar[1]), int.Parse(arrEstandar[2])); int PorcMinimo = int.Parse(porcMinimoInfo.Valor); int PorcMaximo = int.Parse(porcMaximoInfo.Valor); double DestaraMenosTiempoEstandarMasEstandar; DtpFechaInicial.IsEnabled = false; DtpFechaFinal.IsEnabled = false; foreach (var dato in resultadoInfo) { dato.Organizacion = encabezado.Organizacion; dato.Titulo = encabezado.Titulo; dato.FechaFin = encabezado.FechaFin; dato.FechaInicio = encabezado.FechaInicio; DestaraMenosTiempoEstandarMasEstandar = dato.LlegadaDestara.Subtract(dato.TiempoEstandar).Add(Estandar).TotalSeconds; if (dato.TiempoEstandar.TotalSeconds == 0 || (DestaraMenosTiempoEstandarMasEstandar / dato.TiempoEstandar.TotalSeconds) * 100 >= PorcMaximo) { dato.Indicador = 1; //Rojo } else if ((DestaraMenosTiempoEstandarMasEstandar / dato.TiempoEstandar.TotalSeconds) * 100 > PorcMinimo) { dato.Indicador = 2; //Amarillo } else { dato.Indicador = 3;//Verde } } var documento = new ReportDocument(); var reporte = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "\\Reporte\\RptReporteBitacoraLlegada.rpt"); documento.Load(reporte); documento.DataSourceConnections.Clear(); documento.SetDataSource(resultadoInfo); documento.Refresh(); var forma = new ReportViewer(documento, encabezado.Titulo); forma.MostrarReporte(); forma.Show(); } catch (Exception ex) { Logger.Error(ex); MessageBoxResult result = SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteBitacoraLlegada_MsgErrorExportarExcel, MessageBoxButton.OK, MessageImage.Error); } }
/// <summary> /// Obtiene los datos del reporte de manera general /// </summary> /// <param name="datosReporte"></param> /// <param name="encabezado"></param> /// <returns></returns> private List <ReporteMedicamentosAplicadosModel> GenerarDatosReporteGeneral(IEnumerable <ReporteMedicamentosAplicadosDatos> datosReporte, ReporteEncabezadoInfo encabezado) { var lista = new List <ReporteMedicamentosAplicadosModel>(); var productos = (from prod in datosReporte group prod by prod.ProductoID into prodAgru let reporteMedicamentosAplicadosDatos = prodAgru.FirstOrDefault() where reporteMedicamentosAplicadosDatos != null let conteoCabezas = prodAgru.Count() let cantidadProducto = prodAgru.Sum(pro => pro.Cantidad) let importe = ObtenerImporte(prodAgru, cantidadProducto) select new ReporteMedicamentosAplicadosModel { TipoTratamiento = reporteMedicamentosAplicadosDatos.TipoTratamiento, Cabezas = conteoCabezas, Cantidad = cantidadProducto, Codigo = reporteMedicamentosAplicadosDatos.ProductoID, Descripcion = reporteMedicamentosAplicadosDatos.Producto, Precio = reporteMedicamentosAplicadosDatos.Precio, Importe = importe, Unidad = reporteMedicamentosAplicadosDatos.Unidad, UnidadCabeza = Math.Round(cantidadProducto / conteoCabezas, 2), ImporteCabeza = Math.Round(importe / conteoCabezas, 2), Contar = prodAgru.Sum(registro => registro.Contar) }).ToList(); lista.AddRange(productos); //lista.Add(totalTratamiento); return(lista); }
/// <summary> /// Metodo para obtener los datos del informe /// </summary> /// <param name="encabezado"></param> /// <param name="tipoTratamiento"></param> /// <param name="organizacionId"></param> /// <param name="fechaIni"></param> /// <param name="fechaFin"></param> /// <returns></returns> private List <ReporteMedicamentosAplicadosModel> ObtenerReporteMedicamentosAplicadosSanidad(ReporteEncabezadoInfo encabezado, int tipoTratamiento, int organizacionId, int almacenId, DateTime fechaIni, DateTime fechaFin) { try { var reporteMedicamentosAplicadosPL = new ReporteMedicamentosAplicadosPL(); List <ReporteMedicamentosAplicadosModel> resultadoInfo = reporteMedicamentosAplicadosPL.ObtenerReporteMedicamentosAplicadosSanidad(encabezado, organizacionId, almacenId, fechaIni, fechaFin, tipoTratamiento); return(resultadoInfo); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Genera los datos del reporte Medicamentos Aplicados por tipo de tratamiento /// </summary> /// <param name="datosReporte"></param> /// <param name="tipoTratamiento"></param> /// <param name="encabezado"></param> /// <returns></returns> private List <ReporteMedicamentosAplicadosModel> GenerarDatosReporteMedicamentos(IEnumerable <ReporteMedicamentosAplicadosDatos> datosReporte, int tipoTratamiento, ReporteEncabezadoInfo encabezado) { var lista = new List <ReporteMedicamentosAplicadosModel>(); var agrupadoTratamientos = (from medi in datosReporte where medi.TipoTratamientoID == tipoTratamiento group medi by medi.TipoTratamiento into mediAgru select mediAgru); foreach (var agrupadoTratamiento in agrupadoTratamientos) { IGrouping <string, ReporteMedicamentosAplicadosDatos> tratamiento = agrupadoTratamiento; var productos = (from prod in agrupadoTratamiento group prod by prod.ProductoID into prodAgru let reporteMedicamentosAplicadosDatos = prodAgru.FirstOrDefault() where reporteMedicamentosAplicadosDatos != null let conteoCabezas = prodAgru.Count() let cantidadProducto = prodAgru.Sum(pro => pro.Cantidad) let importe = ObtenerImporte(prodAgru, cantidadProducto) select new ReporteMedicamentosAplicadosModel { TipoTratamiento = tratamiento.Key, Cabezas = conteoCabezas, Cantidad = cantidadProducto, Codigo = reporteMedicamentosAplicadosDatos.ProductoID, Descripcion = reporteMedicamentosAplicadosDatos.Producto, Precio = reporteMedicamentosAplicadosDatos.Precio, Importe = importe, Unidad = reporteMedicamentosAplicadosDatos.Unidad, UnidadCabeza = Math.Round(cantidadProducto / conteoCabezas, 2), ImporteCabeza = Math.Round(importe / conteoCabezas, 2), AnimalID = reporteMedicamentosAplicadosDatos.AnimalID }).ToList(); lista.AddRange(productos); var totalTratamiento = new ReporteMedicamentosAplicadosModel { TipoTratamiento = ConstantesBL.Total, Cabezas = productos.Sum(totales => totales.Cabezas), Cantidad = productos.Sum(total => total.Cantidad), Importe = productos.Sum(totales => totales.Importe) }; } return(lista); }
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); } }
/// <summary> /// Genera la informacion y muestra el reporte /// </summary> private void GenerarReporte() { try { DateTime fechaIni = DtpFechaInicial.SelectedDate.HasValue ? DtpFechaInicial.SelectedDate.Value : new DateTime(); DateTime fechaFin = DtpFechaFinal.SelectedDate.HasValue ? DtpFechaFinal.SelectedDate.Value : fechaIni; var loteId = 0; //if (txtLote.Text != string.Empty) if (Contexto.AlmacenInventarioLote != null) { //loteId = int.Parse(txtLote.Text); loteId = Contexto.AlmacenInventarioLote.AlmacenInventarioLoteId; } var reportePl = new ReporteInventarioMateriaPrimaPL(); IList <ReporteInventarioMateriaPrimaInfo> resultadoInfo = reportePl.GenerarReporteInventario(Contexto.Almacen.Organizacion.OrganizacionID, Contexto.Producto.ProductoId, Contexto.Almacen.AlmacenID, loteId, fechaIni, fechaFin); if (resultadoInfo == null) { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteAuxiliarInventarioMateriaPrima_MsgSinInformacion, MessageBoxButton.OK, MessageImage.Warning); return; } var organizacionPl = new OrganizacionPL(); var organizacion = organizacionPl.ObtenerPorIdConIva(Contexto.Almacen.Organizacion.OrganizacionID); var nombreOrganizacion = organizacion != null ? organizacion.Division : String.Empty; var encabezado = new ReporteEncabezadoInfo { Titulo = Properties.Resources.ReporteAuxiliarInventarioMateriaPrima_TituloReporte, FechaInicio = fechaIni, FechaFin = fechaFin, Organizacion = Properties.Resources.ReportesSukarneAgroindustrial_Titulo + " (" + nombreOrganizacion + ")" }; foreach (var dato in resultadoInfo) { dato.Titulo = encabezado.Titulo; dato.FechaInicio = encabezado.FechaInicio; dato.FechaFin = encabezado.FechaFin; dato.Organizacion = encabezado.Organizacion; } var documento = new ReportDocument(); var reporte = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "\\Reporte\\RptReporteInventarioMateriaPrimas.rpt"); documento.Load(reporte); documento.DataSourceConnections.Clear(); documento.SetDataSource(resultadoInfo); documento.Refresh(); var forma = new ReportViewer(documento, encabezado.Titulo) { rptReportViewerControl = { ToggleSidePanel = Constants.SidePanelKind.None } }; forma.MostrarReporte(); forma.Show(); } catch (ExcepcionServicio ex) { Logger.Error(ex); SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteAuxiliarInventarioMateriaPrima_FalloCargarReporte, MessageBoxButton.OK, MessageImage.Error); } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteAuxiliarInventarioMateriaPrima_FalloCargarReporte, MessageBoxButton.OK, MessageImage.Error); } }
/// <summary> /// Método para mostrar el reporte /// </summary> /// <returns></returns> private void MostrarReporte() { try { OrganizacionInfo organizacionSeleccionada = (OrganizacionInfo)cmbOrganizacion.SelectedItem; int organizacionId = organizacionSeleccionada.OrganizacionID; IList <ReporteCorralesEnfermeriaInfo> resultadoInfo = ObtenerReporteCorralesEnfermeria(); if (resultadoInfo == null || resultadoInfo.Count == 0) { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteCorralesEnfermeria_MsgNoExistenDatosReporte, MessageBoxButton.OK, MessageImage.Warning); LimpiarCampos(); return; } DateTime fecha = DtpFechaInicial.SelectedDate.HasValue ? DtpFechaInicial.SelectedDate.Value : DateTime.Today; var organizacionPl = new OrganizacionPL(); var organizacion = organizacionPl.ObtenerPorIdConIva(organizacionId); var nombreOrganizacion = organizacion != null ? organizacion.Division : String.Empty; var encabezado = new ReporteEncabezadoInfo() { Titulo = Properties.Resources.ReporteCorralesEnfermeria_TituloReporte, FechaInicio = fecha, Organizacion = Properties.Resources.ReportesSukarneAgroindustrial_Titulo + " (" + nombreOrganizacion + ")" }; foreach (var dato in resultadoInfo) { dato.Titulo = encabezado.Titulo; dato.Fecha = encabezado.FechaInicio; dato.Organizacion = encabezado.Organizacion; } var documento = new ReportDocument(); var reporte = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "\\Reporte\\rptReporteInventarioCorralesEnfermeria.rpt"); documento.Load(reporte); documento.DataSourceConnections.Clear(); documento.SetDataSource(resultadoInfo); documento.Refresh(); var forma = new ReportViewer(documento, encabezado.Titulo); forma.MostrarReporte(); forma.Show(); } catch (ExcepcionServicio ex) { Logger.Error(ex); SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteCorralesEnfermeria_FalloMostrarReporte, MessageBoxButton.OK, MessageImage.Warning); } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.ReporteCorralesEnfermeria_FalloMostrarReporte, MessageBoxButton.OK, MessageImage.Error); } }
/// <summary> /// Generar reporte general /// </summary> /// <param name="datosReporte"></param> /// <param name="encabezado"></param> /// <returns></returns> private List <ReporteDetalleCorteModel> GenerarDatosReporteGeneral(IEnumerable <ReporteDetalleCorteDatos> datosReporte, ReporteEncabezadoInfo encabezado) { var lista = new List <ReporteDetalleCorteModel>(); var productos = (from prod in datosReporte group prod by prod.AreteID into prodAgru let reporteDetalleCorteDatos = prodAgru.FirstOrDefault() where reporteDetalleCorteDatos != null select new ReporteDetalleCorteModel { AreteId = reporteDetalleCorteDatos.AreteID, Descripcion = reporteDetalleCorteDatos.Descripcion, CorralOrigen = reporteDetalleCorteDatos.CorralOrigen, CorralDestino = reporteDetalleCorteDatos.CorralDestino, PesoOrigen = reporteDetalleCorteDatos.PesoOrigen, PesoCorte = reporteDetalleCorteDatos.PesoCorte, Merma = reporteDetalleCorteDatos.Merma, Temperatura = reporteDetalleCorteDatos.Temperatura, Titulo = encabezado.Titulo, TituloReporte = encabezado.TituloReporte, Organizacion = encabezado.Organizacion, Fecha = encabezado.TituloPeriodo, FechaInicio = reporteDetalleCorteDatos.FecInicial, FechaFin = reporteDetalleCorteDatos.FecFinal, FolioEntrada = reporteDetalleCorteDatos.FolioEntrada, }).ToList(); lista.AddRange(productos); return(lista); }