Exemplo n.º 1
0
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(txtDescripcion.Text) || txtDescripcion.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TipoGanadoEdicion_MsgDescripcionRequerida;
                    txtDescripcion.Focus();
                }
                else if (cmbSexo.SelectedItem == null)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TipoGanadoEdicion_MsgSexoRequerida;
                    cmbSexo.Focus();
                }
                else if (string.IsNullOrWhiteSpace(txtPesoMinimo.Text) || txtPesoMinimo.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TipoGanadoEdicion_MsgPesoMinimoRequerida;
                    txtPesoMinimo.Focus();
                }
                else if (string.IsNullOrWhiteSpace(txtPesoMaximo.Text) || txtPesoMaximo.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TipoGanadoEdicion_MsgPesoMaximoRequerida;
                    txtPesoMaximo.Focus();
                }
                else if (!iudPesoSalida.Value.HasValue || iudPesoSalida.Value.Value == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TipoGanadoEdicion_MsgPesoSalidaRequerida;
                    iudPesoSalida.Focus();
                }
                else if (Contexto.PesoMaximo < Contexto.PesoMinimo)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TipoGanadoEdicion_MsgPesoMaximoMenorPesoMinimoRequerida;
                    txtPesoMaximo.Focus();
                }
                else if (cmbActivo.SelectedItem == null)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TipoGanadoEdicion_MsgActivoRequerida;
                    cmbActivo.Focus();
                }
                else
                {
                    int    tipoGanadoId = Extensor.ValorEntero(txtTipoGanadoID.Text);
                    string descripcion  = txtDescripcion.Text.Trim();

                    var            tipoGanadoPL = new TipoGanadoPL();
                    TipoGanadoInfo tipoGanado   = tipoGanadoPL.ObtenerPorDescripcion(descripcion);

                    if (tipoGanado != null && (tipoGanadoId == 0 || tipoGanadoId != tipoGanado.TipoGanadoID))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.TipoGanadoEdicion_MsgDescripcionExistente, tipoGanado.TipoGanadoID);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(txtTrampaID.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TrampaEdicion_MsgTrampaIDRequerida;
                    txtTrampaID.Focus();
                }
                else if (string.IsNullOrWhiteSpace(txtDescripcion.Text) || Contexto.Descripcion == string.Empty)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TrampaEdicion_MsgDescripcionRequerida;
                    txtDescripcion.Focus();
                }
                else if (Contexto.Organizacion == null || Contexto.Organizacion.OrganizacionID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TrampaEdicion_MsgOrganizacionIDRequerida;
                    skAyudaOrganizacion.AsignarFoco();
                }
                else if (cmbTipoTrampa.SelectedItem == null)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TrampaEdicion_MsgTipoTrampaRequerida;
                    cmbTipoTrampa.Focus();
                }
                else if (string.IsNullOrWhiteSpace(txtHostName.Text) || Contexto.HostName == string.Empty)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TrampaEdicion_MsgHostNameRequerida;
                    txtHostName.Focus();
                }
                else if (cmbActivo.SelectedItem == null)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TrampaEdicion_MsgActivoRequerida;
                    cmbActivo.Focus();
                }
                else
                {
                    int    trampaId    = Extensor.ValorEntero(txtTrampaID.Text);
                    string descripcion = txtDescripcion.Text.TrimEnd();

                    var        trampaPL = new TrampaPL();
                    TrampaInfo trampa   = trampaPL.ObtenerPorDescripcion(descripcion);

                    if (trampa != null && (trampaId == 0 || trampaId != trampa.TrampaID))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.TrampaEdicion_MsgDescripcionExistente, trampa.TrampaID);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
Exemplo n.º 3
0
 /// <summary>
 /// utilizaremos el evento PreviewTextInput para validar Numeros
 /// </summary>
 /// <param name="sender">objeto que implementa el método</param>
 /// <param name="e">argumentos asociados</param>
 /// <returns></returns>
 private void TxtSoloNumerosPreviewTextInput(object sender, TextCompositionEventArgs e)
 {
     e.Handled = Extensor.ValidarSoloNumeros(e.Text);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Valida que el control solo acepte números y letras.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TxtValidarNumerosLetrasSinAcentosPreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
 {
     e.Handled = Extensor.ValidarNumerosLetrasSinAcentos(e.Text);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Metodo que se invoca cuando la ayuda de seleccion de producto se des-selecciona
        /// </summary>
        /// <param name="sender">Objeto que invoco el evento</param>
        /// <param name="e">Parametros del evento</param>
        private void skAyudaProducto_LostFocus(object sender, RoutedEventArgs e)
        {
            this.EnvioAlimento.Producto = (ProductoInfo)this.skAyudaProducto.Contexto;
            this.EnvioAlimento.Producto.UsuarioModificacionID = int.Parse(Application.Current.Properties["UsuarioID"].ToString());
            if (this.EnvioAlimento.Producto.ProductoId > 0)
            {
                if (this.EnvioAlimento.Producto.SubFamilia != null)
                {
                    this.EnvioAlimento.Producto.SubfamiliaId = this.EnvioAlimento.Producto.SubFamilia.SubFamiliaID;
                }

                if (this.EnvioAlimento.Producto.SubfamiliaId != int.Parse(this.cmbSubFamilia.SelectedValue.ToString()))
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.EnvioDeAlimento_MsgProductoSubFamilia, MessageBoxButton.OK, MessageImage.Warning);
                    this.EnvioAlimento.Producto = new ProductoInfo {
                        ProductoId = 0, UsuarioModificacionID = int.Parse(Application.Current.Properties["UsuarioID"].ToString())
                    };
                    skAyudaProducto.Contexto = new ProductoInfo {
                        SubfamiliaId = (int)cmbSubFamilia.SelectedValue, UsuarioModificacionID = int.Parse(Application.Current.Properties["UsuarioID"].ToString())
                    };
                    this.skAyudaProducto.LimpiarCampos();

                    return;
                }

                if (this.EnvioAlimento.Producto.ManejaLote)
                {
                    this.OcultarLote(System.Windows.Visibility.Visible);
                }

                FiltroAlmacenProductoEnvio filtro = new FiltroAlmacenProductoEnvio
                {
                    ProductoID = this.EnvioAlimento.Producto.ProductoId,
                    UsaurioID  = Extensor.ValorEntero(Application.Current.Properties["UsuarioID"].ToString()),
                    Cantidad   = false,
                    Activo     = true
                };

                List <AlmacenInfo> lstAlmacenes = this._envioAlimentoPL.ObtenerAlmacenesProducto(filtro);
                if (lstAlmacenes == null)
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.EnvioDeAlimento_MsgProductoSinAlmacen, MessageBoxButton.OK, MessageImage.Stop);
                    this.EnvioAlimento.Producto = new ProductoInfo {
                        ProductoId = 0, SubfamiliaId = (int)this.cmbSubFamilia.SelectedValue
                    };
                    lstAlmacenes           = new List <AlmacenInfo>();
                    cmbAlmacen.ItemsSource = lstAlmacenes;
                    this.skAyudaProducto.LimpiarCampos();
                    cmbAlmacen.IsEnabled = false;
                    return;
                }

                filtro.Cantidad = true;
                lstAlmacenes    = this._envioAlimentoPL.ObtenerAlmacenesProducto(filtro);
                if (lstAlmacenes == null)
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.EnvioDeAlimento_MsgProductoSinInventario, MessageBoxButton.OK, MessageImage.Stop);
                    this.EnvioAlimento.Producto = new ProductoInfo {
                        ProductoId = 0, SubfamiliaId = (int)this.cmbSubFamilia.SelectedValue
                    };
                    lstAlmacenes           = new List <AlmacenInfo>();
                    cmbAlmacen.ItemsSource = lstAlmacenes;
                    this.skAyudaProducto.LimpiarCampos();
                    cmbAlmacen.IsEnabled = false;
                    return;
                }

                if (lstAlmacenes != null && lstAlmacenes.Count > 0)
                {
                    if (lstAlmacenes.Count > 1)
                    {
                        lstAlmacenes.Insert(0, new AlmacenInfo
                        {
                            AlmacenID   = 0,
                            Descripcion = Properties.Resources.cbo_Seleccione
                        });
                    }
                    else
                    {
                        this.CargarInformacionProducto(lstAlmacenes.FirstOrDefault().AlmacenID, lstAlmacenes.FirstOrDefault().Descripcion);
                    }
                    this.cmbAlmacen.IsEnabled    = true;
                    this.cmbAlmacen.ItemsSource  = lstAlmacenes;
                    this.cmbAlmacen.SelectedItem = lstAlmacenes.FirstOrDefault();
                    if (lstAlmacenes.Count == 1)
                    {
                        this.txtCantidadEnvio.Focus();
                    }
                    else
                    {
                        this.cmbAlmacen.Focus();
                    }
                }
                else
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.EnvioAlimento_MsgProductoSinInventario, MessageBoxButton.OK, MessageImage.Stop);
                    this.EnvioAlimento.Producto = new ProductoInfo {
                        ProductoId = 0, SubfamiliaId = (int)this.cmbSubFamilia.SelectedValue
                    };

                    lstAlmacenes           = new List <AlmacenInfo>();
                    cmbAlmacen.ItemsSource = lstAlmacenes;
                    this.skAyudaProducto.LimpiarCampos();
                    cmbAlmacen.IsEnabled = false;
                    this.skAyudaProducto.LimpiarCampos();
                    this.skAyudaProducto.txtClave.Focus();
                }
            }
            else
            {
                cmbAlmacen.ItemsSource = new List <AlmacenInfo>();
                cmbAlmacen.IsEnabled   = false;
                skAyudaProducto.LimpiarCampos();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(txtSupervisorEnfermeriaID.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.SupervisorEnfermeriaEdicion_MsgSupervisorEnfermeriaIDRequerida;
                    txtSupervisorEnfermeriaID.Focus();
                }
                else if (Contexto.Organizacion.OrganizacionID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.SupervisorEnfermeriaEdicion_MsgOrganizacicionRequerida;
                    skAyudaOrganizacion.AsignarFoco();
                }
                else if (Contexto.Enfermeria.EnfermeriaID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.SupervisorEnfermeriaEdicion_MsgEnfermeriaIDRequerida;
                    skAyudaEnfermeria.AsignarFoco();
                }
                else if (Contexto.Operador.OperadorID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.SupervisorEnfermeriaEdicion_MsgOperadorIDRequerida;
                    skAyudaOperador.AsignarFoco();
                }
                else if (cmbActivo.SelectedItem == null)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.SupervisorEnfermeriaEdicion_MsgActivoRequerida;
                    cmbActivo.Focus();
                }
                else
                {
                    int supervisorEnfermeriaId = Extensor.ValorEntero(txtSupervisorEnfermeriaID.Text);

                    var supervisorEnfermeriaBL = new SupervisorEnfermeriaBL();
                    SupervisorEnfermeriaInfo supervisorEnfermeria = supervisorEnfermeriaBL.ObtenerPorEnfermeriaOperador(Contexto);

                    if (supervisorEnfermeria != null && (supervisorEnfermeriaId == 0 || supervisorEnfermeriaId != supervisorEnfermeria.SupervisorEnfermeriaID))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.SupervisorEnfermeriaEdicion_MsgDescripcionExistente, supervisorEnfermeria.SupervisorEnfermeriaID);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Evento para validar que solo se puedan introducir solo letras
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TxtSoloLetrasAcentoyNumerosPreviewTextInput(object sender, TextCompositionEventArgs e)
 {
     e.Handled = Extensor.ValidarNumerosLetrasConAcentosGuion(e.Text);
 }
        /// <summary>
        /// Evento para exportar la configuracion de las formulas a excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnExportar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!String.IsNullOrEmpty(skAyudaOrganizacion.Clave))
                {
                    var dlg = new Microsoft.Win32.SaveFileDialog
                    {
                        FileName   = "ConfiguracionFormulas",
                        DefaultExt = ".xlsx",
                        Filter     = "Excel files (.xlsx)|*.xlsx"
                    };

                    // Show save file dialog box
                    var result = dlg.ShowDialog();

                    // Process save file dialog box results
                    if (result != true)
                    {
                        return;
                    }

                    // Save document
                    string nombreArchivo          = dlg.FileName;
                    var    configuracionFormulaPL = new ConfiguracionFormulaPL();
                    var    configuracionImportar  = new ConfiguracionFormulaInfo
                    {
                        NombreArchivo  = nombreArchivo,
                        OrganizacionID = Extensor.ValorEntero(skAyudaOrganizacion.Clave)
                    };

                    bool configuracionFormulaInfo =
                        configuracionFormulaPL.ExportarArchivo(configuracionImportar);

                    if (!configuracionFormulaInfo)
                    {
                        return;
                    }

                    //Guardado correctamente
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.ConfigurarFormula_ExportoCorrectamente,
                                      MessageBoxButton.OK, MessageImage.Correct);
                    LimpiarControles();
                }
                else
                {
                    //Favor de seleccionar una organizacion
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.ConfigurarFormula_SeleccionarOrganizacion,
                                      MessageBoxButton.OK,
                                      MessageImage.Stop);
                }
            }
            catch (ExcepcionDesconocida ex)
            {
                Logger.Error(ex);
                //Favor de seleccionar una organizacion
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  (ex.InnerException == null ? ex.Message : ex.InnerException.Message),
                                  MessageBoxButton.OK,
                                  MessageImage.Stop);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                //Favor de seleccionar una organizacion
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.ConfigurarFormula_ExportarError,
                                  MessageBoxButton.OK,
                                  MessageImage.Stop);
            }
        }
Exemplo n.º 9
0
 private void TxtAceptaNumerosLetrasParentesisPreviewTextInput(object sender, TextCompositionEventArgs e)
 {
     e.Handled = Extensor.ValidarSoloLetrasYNumerosConGuionParentesis(e.Text);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Valida que solo se puedan agregar letras
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ValidarLetrasConAncento(object sender, TextCompositionEventArgs e)
 {
     e.Handled = Extensor.ValidarLetrasConAcentos(e.Text);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Valida la entrada de texto permitiendo letras y puntos
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ValidarNumerosLetrasConPunto(object sender, TextCompositionEventArgs e)
 {
     e.Handled = Extensor.ValidarSoloLetrasYNumerosConPunto(e.Text);
 }
Exemplo n.º 12
0
 /// <summary>
 /// utilizaremos el evento PreviewTextInput para validar letras y acentos
 /// </summary>
 /// <param name="sender">objeto que implementa el método</param>
 /// <param name="e">argumentos asociados</param>
 /// <returns></returns>
 private void TxtValidarLetrasConAcentosPreviewTextInput(object sender, TextCompositionEventArgs e)
 {
     e.Handled = Extensor.ValidarLetrasConAcentos(e.Text);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(txtDescripcion.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CamionEdicion_MsgDescripcionRequerida;
                    txtDescripcion.Focus();
                }
                else if (string.IsNullOrWhiteSpace(txtEconomico.Text) || txtEconomico.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CamionEdicion_MsgEconomicoNoValido;
                    txtEconomico.Focus();
                }
                else if (Contexto.MarcaID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CamionEdicion_MsgMarcaNoValido;
                    cmbMarca.Focus();
                }
                else if (string.IsNullOrWhiteSpace(txtModelo.Text) || txtModelo.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CamionEdicion_MsgModeloNoValido;
                    txtModelo.Focus();
                }
                else if (string.IsNullOrWhiteSpace(skAyudaProveedor.Clave) || string.IsNullOrWhiteSpace(skAyudaProveedor.Descripcion))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CamionEdicion_MsgProveedorNoValido;
                    skAyudaProveedor.AsignarFoco();
                }
                else if (string.IsNullOrWhiteSpace(txtColor.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CamionEdicion_MsgColorNoValido;
                    txtColor.Focus();
                }
                else if (Contexto.Boletinado && string.IsNullOrWhiteSpace(Contexto.ObservacionesEnviar))
                {
                    if (string.IsNullOrWhiteSpace(Contexto.ObservacionesObtener))
                    {
                        resultado = false;
                        mensaje   = Properties.Resources.CamionEdicion_MsgObservacionesNoValido;
                        txtObservacionesEnviar.Focus();
                    }
                }


                else
                {
                    int    camionId    = Extensor.ValorEntero(txtCamionId.Text);
                    string descripcion = txtDescripcion.Text;

                    var        camionPL       = new CamionPL();
                    CamionInfo camionBusqueda = camionPL.ObtenerPorDescripcion(descripcion);

                    if (camionBusqueda != null && (camionId == 0 || camionId != camionBusqueda.CamionID))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.CamionEdicion_MsgDescripcionExistente,
                                                  camionBusqueda.CamionID);
                        txtDescripcion.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }

            return(resultado);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(txtTipoCambioID.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TipoCambioEdicion_MsgTipoCambioIDRequerida;
                    txtTipoCambioID.Focus();
                }
                else if (Contexto.Moneda == null || Contexto.Moneda.MonedaID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TipoCambioEdicion_MsgDescripcionRequerida;
                    cmbMoneda.Focus();
                }
                else if (!dtuCambio.Value.HasValue || Contexto.Cambio == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TipoCambioEdicion_MsgCambioRequerida;
                    dtuCambio.Focus();
                }
                else if (!dtpFecha.SelectedDate.HasValue)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TipoCambioEdicion_MsgFechaRequerida;
                    dtpFecha.Focus();
                }
                else if (cmbActivo.SelectedItem == null)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.TipoCambioEdicion_MsgActivoRequerida;
                    cmbActivo.Focus();
                }
                else
                {
                    int    tipoCambioId = Extensor.ValorEntero(txtTipoCambioID.Text);
                    string descripcion  = Contexto.Moneda.Descripcion;

                    var            tipoCambioPL = new TipoCambioPL();
                    TipoCambioInfo tipoCambio   = tipoCambioPL.ObtenerPorDescripcionFecha(descripcion, Contexto.Fecha);

                    if (tipoCambio != null && (tipoCambioId == 0 || tipoCambioId != tipoCambio.TipoCambioId))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.TipoCambioEdicion_MsgDescripcionExistente, tipoCambio.TipoCambioId);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Valida solo numeros
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TxtClaveContableAceptaNumerosPreviewTextInput(object sender, TextCompositionEventArgs e)
 {
     e.Handled = !Extensor.ValidarNumeros(e.Text);
 }
Exemplo n.º 16
0
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(txtDescripcion.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.OrganizacionEdicion_MsgDescripcionRequerida;
                    txtDescripcion.Focus();
                }
                else if (cmbTipoOrganizacion.SelectedItem == null || Contexto.TipoOrganizacion.TipoOrganizacionID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.OrganizacionEdicion_MsgTipoOrganizacionRequerida;
                    cmbTipoOrganizacion.Focus();
                }
                else if (cmbIva.SelectedItem == null || Contexto.Iva.IvaID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.OrganizacionEdicion_MsgIvaRequerida;
                    cmbIva.Focus();
                }
                else
                {
                    int    organizacionId = Extensor.ValorEntero(txtOrganizacionId.Text);
                    string descripcion    = txtDescripcion.Text.Trim();

                    if (skAyudaZona.Clave != string.Empty && !skAyudaZona.Clave.Equals("0"))
                    {
                        Contexto.Zona.ZonaID = Convert.ToInt32(skAyudaZona.Clave);
                    }
                    else
                    {
                        Contexto.Zona.ZonaID = null;
                    }


                    var organizacionPL            = new OrganizacionPL();
                    OrganizacionInfo organizacion = organizacionPL.ObtenerPorDescripcion(descripcion);

                    if (organizacion != null && (organizacionId == 0 || organizacionId != organizacion.OrganizacionID))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.OrganizacionEdicion_MsgDescripcionExistente,
                                                  organizacion.OrganizacionID);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }

            return(resultado);
        }
 /// <summary>
 /// Verifica que los caracteres permitidos sean numeros.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtCantidadProgramada_PreviewTextInput(object sender, TextCompositionEventArgs e)
 {
     e.Handled = Extensor.ValidarSoloNumeros(e.Text);
 }
Exemplo n.º 18
0
        private void BtnAgregar_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (ValidarCamposObligatorios())
                {
                    if (ValidarCorralDentroDelGrid())
                    {
                        if (ValidarTipoTraspaso())
                        {
                            if (ValidaCabezasLote())
                            {
                                if (GridOrganizacionesTraspaso.Items.Count == 0)
                                {
                                    GridOrganizacionesTraspaso.ItemsSource = listadoDeTraspaso;
                                }
                                var detalle = new InterfaceSalidaTraspasoDetalleInfo
                                {
                                    Lote                = Contexto.LoteInfo,
                                    Corral              = Contexto.CorralInfo,
                                    TipoGanado          = Contexto.TipoGanado,
                                    PesoProyectado      = Contexto.TipoGanado.PesoSalida,
                                    GananciaDiaria      = Contexto.LoteProyecion.GananciaDiaria,
                                    DiasEngorda         = Contexto.DiasEngorda,
                                    Formula             = Contexto.Formula,
                                    DiasFormula         = Contexto.DiasFormula,
                                    Cabezas             = Contexto.CabezasEnvio,
                                    Registrado          = false,
                                    OrganizacionDestino = Contexto.OrganizacionDestino,
                                    TraspasoGanado      = Contexto.TraspasoGanado,
                                    SacrificioGanado    = Contexto.SacrificioGanado,
                                    UsuarioCreacionID   = Contexto.UsuarioModificacionID == null ? Contexto.UsuarioCreacionID : Contexto.UsuarioModificacionID.Value
                                };
                                var item = Extensor.ClonarInfo(detalle) as InterfaceSalidaTraspasoDetalleInfo;
                                listadoDeTraspaso.Add(item);

                                Habilitar(false);

                                Contexto.LoteInfo             = new LoteInfo();
                                Contexto.CorralInfo           = new CorralInfo();
                                Contexto.LoteProyecion        = new LoteProyeccionInfo();
                                Contexto.TipoGanado           = new TipoGanadoInfo();
                                Contexto.Formula              = new FormulaInfo();
                                Contexto.DiasEngorda          = 0;
                                Contexto.DiasFormula          = 0;
                                Contexto.CabezasEnvio         = 0;
                                skAyudaOrganizacion.IsEnabled = false;
                                TxtCorral.Focus();
                                //Inicializar();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.TraspasoGanadoGordo_MensajeErrorAlAgregarOrganizacion,
                                  MessageBoxButton.OK, MessageImage.Warning);
            }
        }
Exemplo n.º 19
0
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(txtDescripcion.Text) || txtDescripcion.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.MesesPorVencer_DescripcionRequerida;
                    txtDescripcion.Focus();
                }
                else
                {
                    int  mesTemporal = 0;
                    bool valido      = int.TryParse(txtDescripcion.Text.Trim(), out mesTemporal);
                    if (valido == false || (valido && mesTemporal <= 0))
                    {
                        resultado = false;
                        mensaje   = Properties.Resources.MesesPorVencer_DescripcionNoEntero;
                        txtDescripcion.Focus();
                    }
                    else if (cmbActivo.SelectedItem == null)
                    {
                        resultado = false;
                        mensaje   = Properties.Resources.MesesPorVencer_ActivoRequerida;
                        cmbActivo.Focus();
                    }
                    else
                    {
                        int    id          = Extensor.ValorEntero(txtID.Text);
                        string descripcion = txtDescripcion.Text.Trim();

                        var pl = new PlazoCreditoPL();
                        PlazoCreditoInfo info = pl.PlazoCredito_ObtenerPorDescripcion(Convert.ToInt32(descripcion).ToString());

                        if (info != null && (id == 0 || id != info.PlazoCreditoID))
                        {
                            resultado           = false;
                            mensaje             = string.Format(Properties.Resources.MesesPorVencer_DescripcionExistente, info.PlazoCreditoID);
                            txtDescripcion.Text = string.Empty;
                            txtDescripcion.Focus();
                        }
                        else
                        {
                            var config = pl.PlazoCredito_ValidarConfiguracion(id);
                            if (config.ConfiguracionCreditoID > 0)
                            {
                                resultado = false;
                                mensaje   = string.Format(Properties.Resources.MesesPorVencer_MesConfigurado, config.ConfiguracionCreditoID);
                            }
                            else
                            {
                                Contexto.Descripcion = Convert.ToInt32(descripcion).ToString();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(txtCuentaAlmacenSubFamiliaID.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CuentaAlmacenSubFamiliaEdicion_MsgCuentaAlmacenSubFamiliaIDRequerida;
                    txtCuentaAlmacenSubFamiliaID.Focus();
                }
                else if (Contexto.Almacen == null || Contexto.Almacen.AlmacenID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CuentaAlmacenSubFamiliaEdicion_MsgAlmacenIDRequerida;
                    skAyudaAlmacen.AsignarFoco();
                }
                else if (Contexto.SubFamilia == null || Contexto.SubFamilia.SubFamiliaID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CuentaAlmacenSubFamiliaEdicion_MsgSubFamiliaIDRequerida;
                    skAyudaSubFamilia.AsignarFoco();
                }
                else if (Contexto.CuentaSAP == null || Contexto.CuentaSAP.CuentaSAPID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CuentaAlmacenSubFamiliaEdicion_MsgCuentaSAPIDRequerida;
                    skAyudaCuentaSAP.AsignarFoco();
                }
                else if (cmbActivo.SelectedItem == null)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.CuentaAlmacenSubFamiliaEdicion_MsgActivoRequerida;
                    cmbActivo.Focus();
                }
                else
                {
                    int cuentaAlmacenSubFamiliaId = Extensor.ValorEntero(txtCuentaAlmacenSubFamiliaID.Text);

                    var cuentaAlmacenSubFamiliaBL = new CuentaAlmacenSubFamiliaBL();
                    IList <CuentaAlmacenSubFamiliaInfo> cuentasAlmacen = cuentaAlmacenSubFamiliaBL.ObtenerCostosSubFamilia(Contexto.Almacen.AlmacenID);

                    CuentaAlmacenSubFamiliaInfo cuentaAlmacenSubFamilia =
                        cuentasAlmacen.FirstOrDefault(
                            cuenta => cuenta.SubFamilia.SubFamiliaID == Contexto.SubFamilia.SubFamiliaID);

                    if (cuentaAlmacenSubFamilia != null && (cuentaAlmacenSubFamiliaId == 0 || cuentaAlmacenSubFamiliaId != cuentaAlmacenSubFamilia.CuentaAlmacenSubFamiliaID))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.CuentaAlmacenSubFamiliaEdicion_MsgDescripcionExistente, cuentaAlmacenSubFamilia.CuentaAlmacenSubFamiliaID);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
Exemplo n.º 21
0
 /// <summary>
 /// Evento que se ejecuta cuando te captura una tecla en los TextBox para manejar solamente números
 /// </summary>
 private void TextBox_ValidarSoloNumeros(object sender, TextCompositionEventArgs e)
 {
     e.Handled = Extensor.ValidarSoloNumeros(e.Text);
 }
Exemplo n.º 22
0
        /// <summary>
        /// Evento para Editar un registro
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnEditar_Click(object sender, RoutedEventArgs e)
        {
            var botonEditar = (Button)e.Source;

            try
            {
                var indicadorProductoBoletaInfoSelecionado = (IndicadorProductoBoletaInfo)Extensor.ClonarInfo(botonEditar.CommandParameter);
                if (indicadorProductoBoletaInfoSelecionado != null)
                {
                    var indicadorProductoBoletaEdicion = new IndicadorProductoBoletaEdicion(indicadorProductoBoletaInfoSelecionado)
                    {
                        ucTitulo = { TextoTitulo = Properties.Resources.IndicadorProductoBoleta_Editar_Titulo }
                    };
                    MostrarCentrado(indicadorProductoBoletaEdicion);
                    Buscar();
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.IndicadorProductoBoleta_ErrorEditar, MessageBoxButton.OK, MessageImage.Error);
            }
        }
 /// <summary>
 /// Validar caracteres especiales
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TxtDestino_OnPreviewTextInput(object sender, TextCompositionEventArgs e)
 {
     e.Handled = Extensor.ValidarSoloLetrasYNumerosConPunto(e.Text);
 }
Exemplo n.º 24
0
        /// <summary>
        /// Valida que los campos requeridos contengan valor
        /// </summary>
        /// <returns></returns>
        private bool ValidaCamposGuardar()
        {
            var guardar = true;
            var mensaje = string.Empty;


            if (Contexto.ProductoId == 0)
            {
                guardar = false;
                txtProductoId.Focus();
                mensaje = Properties.Resources.ProductoEdicion_CodigoMayorCero;
            }
            else
            if (string.IsNullOrWhiteSpace(Contexto.ProductoDescripcion))
            {
                guardar = false;
                txtDescripcion.Focus();
                mensaje = Properties.Resources.ProductoEdicion_Descripcion_Requerida;
            }
            else
            {
                int familiaId = Extensor.ValorEntero(Convert.ToString(cboFamilia.SelectedValue));
                if (familiaId == 0)
                {
                    guardar = false;
                    cboFamilia.Focus();
                    mensaje = Properties.Resources.ProductoEdicion_Familia_Requerida;
                }
                else
                {
                    int subFamiliaId = Extensor.ValorEntero(Convert.ToString(cboSubFamilia.SelectedValue));
                    if (subFamiliaId == 0)
                    {
                        guardar = false;
                        cboSubFamilia.Focus();
                        mensaje = Properties.Resources.ProductoEdicion_SubFamilia_Requeria;
                    }
                    else
                    {
                        int unidadId = Extensor.ValorEntero(Convert.ToString(cboUnidad.SelectedValue));
                        if (unidadId == 0)
                        {
                            guardar = false;
                            cboUnidad.Focus();
                            mensaje = Properties.Resources.ProductoEdicion_Unidad_Requerida;
                        }
                    }
                }
            }
            if (guardar)
            {
                var          productoPL = new ProductoPL();
                ProductoInfo producto   = productoPL.ObtenerPorDescripcion(Contexto.ProductoDescripcion);
                if (producto != null && Contexto.UsuarioModificacionID == null)
                {
                    mensaje = string.Format(Properties.Resources.ProductoEdicion_Descripcion_Existente,
                                            producto.ProductoId);
                    txtDescripcion.Focus();
                    guardar = false;
                }
                if (producto == null)
                {
                    producto = productoPL.ObtenerPorIDSinActivo(Contexto);
                }
                if (producto != null && Contexto.UsuarioModificacionID == null)
                {
                    mensaje = string.Format(Properties.Resources.ProductoEdicion_Codigo_Existente,
                                            producto.Descripcion);
                    txtProductoId.Focus();
                    guardar = false;
                }

                producto = productoPL.ObtenerPorMaterialSAP(Contexto.MaterialSAP);
                if (producto != null && Contexto.ProductoId != producto.ProductoId)
                {
                    mensaje = string.Format(Properties.Resources.ProductoEdicion_Material_Existente,
                                            producto.ProductoId);
                    txtMaterialSAP.Focus();
                    guardar = false;
                }
            }
            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(guardar);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Guarda el envio de alimento
        /// </summary>
        /// <param name="sender">Objeto que invoco el evento</param>
        /// <param name="e">Parametros del evento</param>
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (this.ValidarCamposVacios())
                {
                    if (EnvioAlimento.Destino != null && skAyudaDestino.Clave != EnvioAlimento.Destino.OrganizacionID.ToString())
                    {
                        EnvioAlimento.Destino = (OrganizacionInfo)skAyudaDestino.DataContext;
                        EnvioAlimento.Destino.ListaTiposOrganizacion = _tiposOrganizacionDestino;
                    }
                    if (EnvioAlimento.Producto != null && skAyudaProducto.Clave != EnvioAlimento.Producto.ProductoId.ToString())
                    {
                        EnvioAlimento.Producto.ProductoId = ((ProductoInfo)skAyudaDestino.DataContext).ProductoId;
                        if (EnvioAlimento.Producto != null)
                        {
                            EnvioAlimento.Producto.SubfamiliaId = int.Parse(cmbSubFamilia.SelectedValue.ToString());
                        }
                    }

                    if (this.ValidarCuentasContables())
                    {
                        int productoId = this.EnvioAlimento.Producto.ProductoId;
                        FiltroAlmacenProductoEnvio filtro = new FiltroAlmacenProductoEnvio
                        {
                            ProductoID = this.EnvioAlimento.Producto.ProductoId,
                            UsaurioID  = Extensor.ValorEntero(Application.Current.Properties["UsuarioID"].ToString()),
                            Cantidad   = false,
                            Activo     = true
                        };
                        List <AlmacenInfo> lstAlmacenes = this._envioAlimentoPL.ObtenerAlmacenesProducto(filtro);

                        if (lstAlmacenes == null)
                        {
                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.EnvioDeAlimento_MsgProductoSinAlmacen, MessageBoxButton.OK, MessageImage.Stop);
                            this.EnvioAlimento.Producto = new ProductoInfo {
                                ProductoId = 0, SubfamiliaId = (int)this.cmbSubFamilia.SelectedValue
                            };


                            lstAlmacenes           = new List <AlmacenInfo>();
                            cmbAlmacen.ItemsSource = lstAlmacenes;
                            this.skAyudaProducto.LimpiarCampos();
                            cmbAlmacen.IsEnabled = false;
                            return;
                        }

                        string error;
                        if (ValidarSalidaExcede(out error))
                        {
                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], error, MessageBoxButton.OK, MessageImage.Stop);

                            cmbAlmacen.SelectedIndex    = 0;
                            this.EnvioAlimento.Cantidad = 0;
                            this.EnvioAlimento.Importe  = 0;
                            this.EnvioAlimento.Piezas   = 0;
                            this.txtCantidadEnvio.Text  = string.Empty;
                            this.txtImporte.Text        = string.Empty;
                            this.txtPiezas.Text         = string.Empty;
                            return;
                        }
                        this.EnvioAlimento.Producto.ProductoId = productoId;
                        EnvioAlimentoInfo confirmacionEnvio = this._envioAlimentoPL.RegistrarEnvioAlimento(this.EnvioAlimento);
                        if (confirmacionEnvio.Folio != 0 && confirmacionEnvio.Poliza != null)
                        {
                            if (confirmacionEnvio.Poliza != null)
                            {
                                new ExportarPoliza().ImprimirPoliza(confirmacionEnvio.Poliza, string.Format("{0} {1}", "Poliza", TipoPoliza.SalidaTraspaso));
                            }

                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], string.Format(Properties.Resources.EnvioAlimento_MsgDatosGaurdados, confirmacionEnvio.Folio), MessageBoxButton.OK, MessageImage.Correct);
                            this.LimparPantalla();
                            this.InicializaContexto();
                            cmbSubFamilia.SelectedValue = 0;
                            this.EnvioAlimento.Destino.ListaTiposOrganizacion = _tiposOrganizacionDestino;
                            this.skAyudaDestino.txtClave.Focus();
                        }
                        else
                        {
                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.EnvioAlimento_MsgErrorGuardar, MessageBoxButton.OK, MessageImage.Error);
                        }
                    }
                }
            }
            catch (Exception excepcion)
            {
                Logger.Error(excepcion);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.EnvioAlimento_MsgErrorGuardar, MessageBoxButton.OK, MessageImage.Error);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(txtAlmacenID.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.AlmacenEdicion_MsgAlmacenIDRequerida;
                    txtAlmacenID.Focus();
                }
                else if (string.IsNullOrWhiteSpace(Contexto.Descripcion))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.AlmacenEdicion_MsgDescripcionRequerida;
                    txtDescripcion.Focus();
                }
                else if (string.IsNullOrWhiteSpace(Contexto.CodigoAlmacen))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.AlmacenEdicion_MsgCodigoAlmacenRequerida;
                    txtCodigoAlmacen.Focus();
                }
                else if (Contexto.Organizacion == null || Contexto.Organizacion.OrganizacionID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.AlmacenEdicion_MsgOrganizacionIDRequerida;
                    skAyudaOrganizacion.AsignarFoco();
                }

                else if (Contexto.TipoAlmacen.TipoAlmacenID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.AlmacenEdicion_MsgTipoAlmacenIDRequerida;
                    cmbTipoAlmacen.Focus();
                }
                else if (validaProveedor && (Contexto.Proveedor == null || Contexto.Proveedor.ProveedorID == 0))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.AlmacenEdicion_MsgProveedorRequerido;
                    skAyudaProveedor.AsignarFoco();
                }
                else if (cmbActivo.SelectedItem == null)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.AlmacenEdicion_MsgActivoRequerida;
                    cmbActivo.Focus();
                }
                else if (validaProveedor)
                {
                    if (Contexto.AlmacenID == 0 && Contexto.Proveedor != null && Contexto.Proveedor.ProveedorID > 0)
                    {
                        var proveedorAlmacenPL   = new ProveedorAlmacenPL();
                        var proveedorAlmacenInfo = new ProveedorAlmacenInfo
                        {
                            Proveedor = Contexto.Proveedor,
                            Almacen   = new AlmacenInfo
                            {
                                TipoAlmacenID = Contexto.TipoAlmacen.TipoAlmacenID
                            },
                            Activo = EstatusEnum.Activo
                        };
                        ProveedorAlmacenInfo proveedorAlmacen =
                            proveedorAlmacenPL.ObtenerPorProveedorTipoAlmacen(proveedorAlmacenInfo);
                        if (proveedorAlmacen != null)
                        {
                            resultado = false;
                            mensaje   = Properties.Resources.AlmacenEdicion_MsgProveedorAlmacenExistente;
                            skAyudaProveedor.AsignarFoco();
                        }
                    }
                }
                else
                {
                    int    almacenId   = Extensor.ValorEntero(txtAlmacenID.Text);
                    string descripcion = txtDescripcion.Text;

                    var         almacenPL = new AlmacenPL();
                    AlmacenInfo almacen   = almacenPL.ObtenerPorDescripcion(descripcion);

                    if (almacen == null)
                    {
                        return(true);
                    }

                    if (almacen.TipoAlmacen.TipoAlmacenID != Contexto.TipoAlmacen.TipoAlmacenID && almacen.Organizacion.OrganizacionID == Contexto.Organizacion.OrganizacionID)
                    {
                        bool tieneProductos = almacenPL.ValidarProductosEnAlmacen(almacen);
                        if (tieneProductos)
                        {
                            mensaje   = Properties.Resources.AlmacenEdicion_MsgTipoAlmacenCambio;
                            resultado = false;
                        }
                    }

                    if ((almacenId == 0 || almacenId != almacen.AlmacenID) && almacen.Organizacion.OrganizacionID == Contexto.Organizacion.OrganizacionID)
                    {
                        resultado = false;
                        mensaje   = string.Format(
                            Properties.Resources.AlmacenEdicion_MsgDescripcionExistente, almacen.AlmacenID);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(skAyudaOrganizacion.Clave) ||
                    string.IsNullOrWhiteSpace(skAyudaOrganizacion.Descripcion))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.PrecioGanadoEdicion_MsgOrganizacionIDRequerida;
                    skAyudaOrganizacion.AsignarFoco();
                }
                else if (cmbTipoGanado.SelectedItem == null || Contexto.TipoGanado.TipoGanadoID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.PrecioGanadoEdicion_MsgTipoGanadoIDRequerida;
                    cmbTipoGanado.Focus();
                }

                else if (!dtuPrecio.Value.HasValue || Contexto.Precio == 0 || Validation.GetErrors(dtuPrecio).Count > 0) //string.IsNullOrWhiteSpace(txtPrecio.Text) || txtPrecio.Text == "0")
                {
                    resultado = false;
                    mensaje   = Validation.GetErrors(dtuPrecio).Count > 0
                                  ? Validation.GetErrors(dtuPrecio)[0].ErrorContent.ToString()
                                  : Properties.Resources.PrecioGanadoEdicion_MsgPrecioRequerida;
                    dtuPrecio.Focus();
                }
                else if (!dtpFechaVigencia.SelectedDate.HasValue)//string.IsNullOrWhiteSpace(txtFechaVigencia.Text) || txtFechaVigencia.Text == "0")
                {
                    resultado = false;
                    mensaje   = Properties.Resources.PrecioGanadoEdicion_MsgFechaVigenciaRequerida;
                    dtpFechaVigencia.Focus();
                }
                else if (cmbActivo.SelectedItem == null)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.PrecioGanadoEdicion_MsgActivoRequerida;
                    cmbActivo.Focus();
                }
                else
                {
                    int precioGanadoId = Extensor.ValorEntero(txtPrecioGanadoID.Text);

                    var precioGanadoPL            = new PrecioGanadoPL();
                    PrecioGanadoInfo precioGanado = precioGanadoPL.ObtenerPorOrganizacionTipoGanado(Contexto);

                    if (precioGanado != null && (precioGanadoId == 0 || precioGanadoId != precioGanado.PrecioGanadoID))
                    {
                        resultado = false;
                        string organizacion = skAyudaOrganizacion.Descripcion;
                        string tipoGanado   = ((TipoGanadoInfo)cmbTipoGanado.SelectedItem).Descripcion;
                        mensaje = string.Format(Properties.Resources.PrecioGanadoEdicion_MsgDescripcionExistente, organizacion, tipoGanado, precioGanado.PrecioGanadoID);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
Exemplo n.º 28
0
 //Evento PreviewTextInput de txtCorralDestino
 private void txtCorralDestino_PreviewTextInput(object sender, TextCompositionEventArgs e)
 {
     e.Handled = Extensor.ValidarSoloLetrasYNumeros(e.Text);
 }
Exemplo n.º 29
0
 private void TxtDescripcionAceptaNumerosLetrasPreviewTextInput(object sender, TextCompositionEventArgs e)
 {
     e.Handled = Extensor.ValidarNumerosLetrasSinAcentos(e.Text);
 }
        /// <summary>
        /// Metodo que valida los datos para guardar
        /// </summary>
        /// <returns></returns>
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                if (string.IsNullOrWhiteSpace(txtProblemaTratamientoID.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ProblemaTratamientoEdicion_MsgProblemaTratamientoIDRequerida;
                    txtProblemaTratamientoID.Focus();
                }
                else if (Contexto.Tratamiento.Organizacion == null || Contexto.Tratamiento.Organizacion.OrganizacionID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ProblemaTratamientoEdicion_MsgErorrSinOrganizacion;
                    skAyudaOrganizacion.AsignarFoco();
                }
                else if (Contexto.Problema == null || Contexto.Problema.ProblemaID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ProblemaTratamientoEdicion_MsgProblemaIDRequerida;
                    skAyudaProblema.AsignarFoco();
                }
                else if (Contexto.Tratamiento.Sexo == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ProblemaTratamientoEdicion_MsgSexoRequerida;
                    cmbSexo.Focus();
                }
                else if (Contexto.Tratamiento == null || Contexto.Tratamiento.CodigoTratamiento == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ProblemaTratamientoEdicion_MsgTratamientoIDRequerida;
                    //skAyudaTratamiento.AsignarFoco();
                    ituTratamiento.Focus();
                }
                else if (Contexto.Tratamiento == null || Contexto.Tratamiento.TratamientoID == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ProblemaTratamientoEdicion_MsgTratamientoIDRequerida;
                    //skAyudaTratamiento.AsignarFoco();
                    ituTratamiento.Focus();
                }
                else if (!ituDias.Value.HasValue || (ituDias.Value.HasValue && ituDias.Value.Value == 0) || Contexto.Dias == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ProblemaTratamientoEdicion_MsgDiasRequerida;
                    ituDias.Focus();
                }
                else if (!ituOrden.Value.HasValue || (ituOrden.Value.HasValue && ituOrden.Value.Value == 0) || Contexto.Orden == 0)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ProblemaTratamientoEdicion_MsgOrdenRequerida;
                    ituOrden.Focus();
                }

                else if (cmbActivo.SelectedItem == null)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ProblemaTratamientoEdicion_MsgActivoRequerida;
                    cmbActivo.Focus();
                }
                else
                {
                    int problemaTratamientoId = Extensor.ValorEntero(txtProblemaTratamientoID.Text);
                    Contexto.ProblemaID = Contexto.Problema.ProblemaID;

                    var problemaTratamientoBL = new ProblemaTratamientoBL();
                    ProblemaTratamientoInfo problemaTratamiento =
                        problemaTratamientoBL.ObtenerProblemaTratamientoExiste(Contexto);

                    if (problemaTratamiento != null && (problemaTratamientoId == 0 || problemaTratamientoId != problemaTratamiento.ProblemaTratamientoID))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.ProblemaTratamientoEdicion_MsgDescripcionExistente, problemaTratamiento.ProblemaTratamientoID);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }