/// <summary>
        /// Método para validar los controles de la pantalla.
        /// </summary>
        /// <returns></returns>
        private bool ValidaGenerar()
        {
            try
            {
                bool   resultado = true;
                string mensaje   = string.Empty;

                DateTime?fechaIni = Contexto.FechaInicial;
                DateTime?fechaFin = Contexto.FechaFinal;

                if (organizacionSeleccionada == null || organizacionSeleccionada.OrganizacionID == 0)
                {
                    mensaje = Properties.Resources.ReporteBitacoraLlegada_MsgSelecioneOrganizacion;
                    skAyudaOrganizacion.AsignarFoco();
                }
                else if (fechaIni == null && fechaFin == null)
                {
                    mensaje = Properties.Resources.ReporteBitacoraLlegada_MsgSelecionePeriodo;
                    DtpFechaInicial.Focus();
                }
                else if (fechaIni == null)
                {
                    mensaje = Properties.Resources.ReporteBitacoraLlegada_MsgFechaIniRequerida;
                    DtpFechaInicial.Focus();
                }
                else if (fechaIni > DateTime.Today)
                {
                    mensaje = Properties.Resources.ReporteBitacoraLlegada_MsgFechaInicialMayorFechaActual;
                    DtpFechaInicial.Focus();
                }
                else if (fechaFin == null)
                {
                    mensaje = Properties.Resources.ReporteBitacoraLlegada_MsgFechaFinRequerida;
                    DtpFechaFinal.Focus();
                }
                else if (fechaFin < fechaIni)
                {
                    mensaje = Properties.Resources.ReporteBitacoraLlegada_MsgFechaInicialMayorFechaFinal;
                    DtpFechaFinal.Focus();
                }
                else if (fechaIni < fechaFin.Value.AddYears(-1))
                {
                    mensaje = Properties.Resources.ReporteBitacoraLlegada_MsgFechaInicialMenorAnio;
                    DtpFechaInicial.Focus();
                }

                if (!string.IsNullOrWhiteSpace(mensaje))
                {
                    resultado = false;
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], mensaje,
                                      MessageBoxButton.OK, MessageImage.Warning);
                }

                return(resultado);
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Método para validar los controles de la pantalla.
        /// </summary>
        /// <returns></returns>
        private bool ValidaGenerar()
        {
            try
            {
                bool   resultado = true;
                string mensaje   = string.Empty;

                DateTime?fechaIni = Contexto.FechaInicial;
                DateTime?fechaFin = Contexto.FechaFinal;

                if (fechaIni == null && fechaFin == null)
                {
                    mensaje = Properties.Resources.ReporteDetalleCorte_MsgSelecionePeriodo; //Debe selecionar un periodo.
                    DtpFechaInicial.Focus();
                }
                else if (fechaIni == null)
                {
                    mensaje = Properties.Resources.ReporteDetalleCorte_MsgFechaIniRequerida; //Debe capturar la fecha inicial.
                    DtpFechaInicial.Focus();
                }
                else if (fechaIni > DateTime.Today)
                {
                    mensaje = Properties.Resources.ReporteDetalleCorte_MsgFechaInicialMayorFechaActual; //El periodo de fechas no es válido, la fecha inicial no debe ser mayor a la actual.
                    DtpFechaInicial.Focus();
                }
                else if (fechaFin == null)
                {
                    mensaje = Properties.Resources.ReporteDetalleCorte_MsgFechaFinRequerida; //Debe capturar la fecha final.
                    DtpFechaFinal.Focus();
                }
                else if (fechaFin < fechaIni)
                {
                    mensaje = Properties.Resources.ReporteDetalleCorte_MsgFechaFinalMenorFechaInicial; //El periodo de fechas no es válido, la fecha final no debe ser menor a la inicial.
                    DtpFechaFinal.Focus();
                }
                else if (fechaIni < fechaFin.Value.AddYears(-1))
                {
                    mensaje = Properties.Resources.ReporteDetalleCorte_MsgFechaInicialMenorAnio; //Rango de fechas no permitido. Favor de ajustar al máximo de 1 año con respecto a la fecha final.
                    DtpFechaInicial.Focus();
                }

                if (!string.IsNullOrWhiteSpace(mensaje))
                {
                    resultado = false;
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], mensaje,
                                      MessageBoxButton.OK, MessageImage.Warning);
                }

                return(resultado);
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Método para validar los controles de la pantalla.
        /// </summary>
        /// <returns></returns>
        private bool ValidaBuscar(bool mostrar)
        {
            try
            {
                bool   resultado = true;
                string mensaje   = string.Empty;

                int      tipoProcesoId = Contexto.TipoProceso.TipoProcesoID;
                DateTime?fechaIni      = Contexto.FechaInicial;
                DateTime?fechaFin      = Contexto.FechaFinal;

                var organizacion = (OrganizacionInfo)cmbOrganizacion.SelectedItem;

                if (organizacion == null || organizacion.OrganizacionID == 0)
                {
                    mensaje = Properties.Resources.RecepcionReporteInventario_MsgSelecioneOrganizacion;
                    cmbOrganizacion.Focus();
                }

                if (tipoProcesoId < 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.RecepcionReporteInventario_MsgTipoProcesoRequerido;
                    cmbTipoProceso.Focus();
                }
                else if (fechaIni == null && fechaFin != null)
                {
                    mensaje = Properties.Resources.RecepcionReporteInventario_MsgSelecionePeriodo;
                    DtpFechaInicial.Focus();
                }
                else if (fechaIni != null && fechaFin == null)
                {
                    mensaje = Properties.Resources.RecepcionReporteInventario_MsgSelecionePeriodo;
                    DtpFechaInicial.Focus();
                }
                else
                if (fechaIni != null)
                {
                    fechaFin = Contexto.FechaFinal ?? fechaIni;

                    if (fechaIni > DateTime.Today)
                    {
                        mensaje = Properties.Resources.RecepcionReporteInventario_MsgFechaActual;
                        DtpFechaInicial.Focus();
                    }
                    else if (fechaIni < fechaMinima)
                    {
                        mensaje = string.Format(Properties.Resources.ReporteInventario_FechaMenorTresMeses, invervalo);
                        DtpFechaInicial.Focus();
                    }
                    else if (fechaFin < fechaIni)
                    {
                        mensaje = Properties.Resources.RecepcionReporteInventario_MsgFechaNoValida;
                        DtpFechaFinal.Focus();
                    }
                }
                if (fechaIni != null && fechaFin != null)
                {
                    fechaFin = Contexto.FechaFinal ?? fechaIni;

                    TimeSpan diasIntervalo = fechaFin.Value - fechaIni.Value;
                    if (diasIntervalo.Days > invervalo)
                    {
                        mensaje               = string.Format(Properties.Resources.ReporteInventario_FechaFueraIntervalo, invervalo);
                        Contexto.FechaFinal   = null;
                        Contexto.FechaInicial = null;
                    }
                }
                if (mostrar && !string.IsNullOrWhiteSpace(mensaje))
                {
                    resultado = false;
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], mensaje,
                                      MessageBoxButton.OK, MessageImage.Warning);
                }
                return(resultado);
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Método para validar los controles de la pantalla.
        /// </summary>
        /// <returns></returns>
        private bool ValidaGenerar()
        {
            bool resultado = true;

            try
            {
                string mensaje = string.Empty;

                DateTime?fechaIni = DtpFechaInicial.SelectedDate;
                DateTime?fechaFin = DtpFechaFinal.SelectedDate;

                //if (productoSeleccionado == null || productoSeleccionado.ProductoId == 0)
                if (Contexto.Producto == null || Contexto.Producto.ProductoId == 0)
                {
                    mensaje = Properties.Resources.ReporteAuxiliarInventarioMateriaPrima_MsgSelecioneProducto;
                    skAyudaProducto.Focus();
                }
                //else if (almacenSeleccionado == null || almacenSeleccionado.AlmacenID == 0)
                else if (Contexto.Almacen == null || Contexto.Almacen.AlmacenID == 0)
                {
                    mensaje = Properties.Resources.ReporteAuxiliarInventarioMateriaPrima_MsgSelecioneAlmacen;
                    skAyudaAlmacen.Focus();
                }
                else if (fechaIni == null && fechaFin == null)
                {
                    mensaje = Properties.Resources.ReporteAuxiliarInventarioMateriaPrima_MsgSelecionePeriodo;
                    DtpFechaInicial.Focus();
                }
                else if (fechaIni == null)
                {
                    mensaje = Properties.Resources.ReporteAuxiliarInventarioMateriaPrima_MsgFechaIniRequerida;
                    DtpFechaInicial.Focus();
                }
                else if (fechaIni > DateTime.Today)
                {
                    mensaje = Properties.Resources.ReporteAuxiliarInventarioMateriaPrima_MsgFechaInicialMayorFechaActual;
                    DtpFechaInicial.Focus();
                }
                else if (fechaFin == null)
                {
                    mensaje = Properties.Resources.ReporteAuxiliarInventarioMateriaPrima_MsgFechaFinRequerida;
                    DtpFechaFinal.Focus();
                }

                else if (fechaFin > DateTime.Today)
                {
                    mensaje = Properties.Resources.ReporteAuxiliarInventarioMateriaPrima_MsgFechaFinalMayorFechaActual;
                    DtpFechaInicial.Focus();
                }

                else if (fechaFin < fechaIni)
                {
                    mensaje = Properties.Resources.ReporteAuxiliarInventarioMateriaPrima_MsgFechaInicialMayorFechaFinal;
                    DtpFechaFinal.Focus();
                }

                if (!string.IsNullOrWhiteSpace(mensaje))
                {
                    resultado = false;
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], mensaje,
                                      MessageBoxButton.OK, MessageImage.Warning);
                }

                return(resultado);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.ReporteAuxiliarInventarioMateriaPrima_FalloValidaGenerar,
                                  MessageBoxButton.OK, MessageImage.Warning);
            }

            return(resultado);
        }
        /// <summary>
        /// Método para validar los controles de la pantalla.
        /// </summary>
        /// <returns></returns>
        private bool ValidaBuscar()
        {
            try
            {
                bool   resultado = true;
                string mensaje   = string.Empty;

                DateTime?fechaIni = Contexto.FechaInicial;
                DateTime?fechaFin = Contexto.FechaFinal;

                var organizacion = (OrganizacionInfo)cmbOrganizacion.SelectedItem;

                if (organizacion == null || organizacion.OrganizacionID == 0)
                {
                    mensaje = Properties.Resources.RecepcionReporteRecuperacionMerma_MsgSelecioneOrganizacion;
                    cmbOrganizacion.Focus();
                }

                if (fechaIni == null && fechaFin == null)
                {
                    mensaje = Properties.Resources.RecepcionReporteRecuperacionMerma_MsgSelecionePeriodo;
                    DtpFechaInicial.Focus();
                }
                else if (fechaIni == null)
                {
                    mensaje = Properties.Resources.RecepcionReporteRecuperacionMerma_MsgFechaIniRequerida;
                    DtpFechaInicial.Focus();
                }
                else if (fechaIni > DateTime.Today)
                {
                    mensaje = Properties.Resources.RecepcionReporteRecuperacionMerma_MsgFechaInicialMayorFechaActual;
                    DtpFechaInicial.Focus();
                }
                else if (fechaFin == null)
                {
                    mensaje = Properties.Resources.RecepcionReporteRecuperacionMerma_MsgFechaFinRequerida;
                    DtpFechaFinal.Focus();
                }
                else if (fechaFin < fechaIni)
                {
                    mensaje = Properties.Resources.RecepcionReporteRecuperacionMerma_MsgFechaFinalMenorFechaInicial;
                    DtpFechaFinal.Focus();
                }
                else if (fechaIni > fechaFin)
                {
                    mensaje = Properties.Resources.RecepcionReporteRecuperacionMerma_MsgFechaInicialMayorFechaFinal;
                    DtpFechaInicial.Focus();
                }
                else if (!ValidarPeriodoAnio())
                {
                    mensaje = Properties.Resources.RecepcionReporteRecuperacionMerma_MsgFechaFinalMayorAnio;
                    DtpFechaInicial.Focus();
                }
                if (!string.IsNullOrWhiteSpace(mensaje))
                {
                    resultado = false;
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], mensaje, MessageBoxButton.OK, MessageImage.Warning);
                }

                return(resultado);
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }