/// <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;

                DateTime fechaMinima       = DateTime.Now.AddDays(-90);
                DateTime fechaSeleccionada = DateTime.Now;

                try
                {
                    fechaSeleccionada = DtpFecha.SelectedDate.Value;
                }
                catch (Exception)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ReporteDetalleReimplante_ValidacionFechaInvalida;
                    DtpFecha.Focus();
                }

                if (fechaSeleccionada != null)
                {
                    if (fechaSeleccionada > DateTime.Today)
                    {
                        resultado = false;
                        mensaje   = Properties.Resources.ReporteDetalleReimplante_ValidacionFechaInvalida;
                        DtpFecha.Focus();
                    }
                    else if (fechaSeleccionada < fechaMinima)
                    {
                        resultado = false;
                        mensaje   = Properties.Resources.ReporteDetalleReimplante_ValidacionFechaFueraRango;
                        DtpFecha.Focus();
                    }
                }
                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);
            }
        }
Esempio n. 2
0
 private void BtnGuardarCompra_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(CbxTipoComprobante.Text))
     {
         MessageBox.Show("Seleccione Tipo de Comprobante", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         CbxTipoComprobante.Focus();
     }
     else if (string.IsNullOrEmpty(TxtSerie.Text))
     {
         MessageBox.Show("Digite Serie del Documento", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         TxtSerie.Focus();
     }
     else if (string.IsNullOrEmpty(TxtNumero.Text))
     {
         MessageBox.Show("Digite Número del Documento", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         TxtNumero.Focus();
     }
     else if (string.IsNullOrEmpty(DtpFecha.Text))
     {
         MessageBox.Show("Seleccione Fecha", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         DtpFecha.Focus();
     }
     else if (string.IsNullOrEmpty(TxtRucProveedor.Text))
     {
         MessageBox.Show("Ingrese un Proveedor", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         TxtRucProveedor.Focus();
     }
     else if (string.IsNullOrEmpty(TxtRazonSocial.Text))
     {
         MessageBox.Show("Proveedor Incorrecto", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         TxtRucProveedor.Focus();
     }
     else if (MLVDetalle.Items.Count == 0)
     {
         MessageBox.Show("El detalle no puede estar vacío, agrege items", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         TxtCodigo.Focus();
     }
     else
     {
         GuardarCompra();
     }
 }