示例#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(txtNombre.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ChoferEdicion_MsgNombreRequerida;
                    txtNombre.Focus();
                }
                else if (string.IsNullOrWhiteSpace(txtApellidoPaterno.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ChoferEdicion_MsgApellidoPaternoRequerida;
                    txtApellidoPaterno.Focus();
                }
                else if (chkBoletinado.IsChecked == true && string.IsNullOrWhiteSpace(txtObservacionesRegistro.Text))
                {
                    resultado = false;
                    mensaje   = Properties.Resources.ChoferEdicion_MsgObservacionesRequerida;
                    txtObservacionesRegistro.Focus();
                }
                else
                {
                    int    choferId    = Extensor.ValorEntero(txtChoferId.Text);
                    string descripcion = string.Format("{0} {1} {2}", txtNombre.Text, txtApellidoPaterno.Text,
                                                       txtApellidoMaterno.Text);

                    var        choferPL = new ChoferPL();
                    ChoferInfo chofer   = choferPL.ObtenerPorDescripcion(descripcion);

                    if (chofer != null && (choferId == 0 || choferId != chofer.ChoferID))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.ChoferEdicion_MsgDescripcionExistente,
                                                  chofer.ChoferID);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
示例#2
0
        public void ChoferObtenerPorIdSinDatos()
        {
            var        pl = new ChoferPL();
            ChoferInfo info;

            try
            {
                info = pl.ObtenerPorID(10000000);
            }
            catch (Exception)
            {
                info = new ChoferInfo();
            }
            Assert.AreEqual(info, null);
        }
示例#3
0
        /// <summary>
        /// Obtiene la lista para mostrar en el grid
        /// </summary>
        private void ObtenerListaChofer(int inicio, int limite)
        {
            try
            {
                if (ucPaginacion.ContextoAnterior != null)
                {
                    bool contextosIguales = ucPaginacion.CompararObjetos(Contexto, ucPaginacion.ContextoAnterior);
                    if (!contextosIguales)
                    {
                        ucPaginacion.Inicio = 1;
                        inicio = 1;
                    }
                }

                var        choferPL = new ChoferPL();
                ChoferInfo filtros  = ObtenerFiltros();
                var        pagina   = new PaginacionInfo {
                    Inicio = inicio, Limite = limite
                };
                ResultadoInfo <ChoferInfo> resultadoInfo = choferPL.ObtenerPorPagina(pagina, filtros);
                if (resultadoInfo != null && resultadoInfo.Lista != null &&
                    resultadoInfo.Lista.Count > 0)
                {
                    gridDatos.ItemsSource       = resultadoInfo.Lista;
                    ucPaginacion.TotalRegistros = resultadoInfo.TotalRegistros;
                }
                else
                {
                    ucPaginacion.TotalRegistros = 0;
                    gridDatos.ItemsSource       = new List <Chofer>();
                }
            }
            catch (ExcepcionGenerica)
            {
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.Chofer_ErrorBuscar, MessageBoxButton.OK, MessageImage.Error);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.Chofer_ErrorBuscar, MessageBoxButton.OK, MessageImage.Error);
            }
        }
示例#4
0
        /// <summary>
        /// Método para guardar los valores del contexto
        /// </summary>
        private void Guardar()
        {
            bool guardar = ValidaGuardar();

            if (guardar)
            {
                try
                {
                    var choferPL = new ChoferPL();
                    choferPL.Guardar(Contexto);
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.GuardadoConExito, MessageBoxButton.OK,
                                      MessageImage.Correct);
                    if (Contexto.ChoferID != 0)
                    {
                        confirmaSalir = false;
                        Close();
                    }
                    else
                    {
                        InicializaContexto();
                        txtNombre.Focus();
                    }
                }
                catch (ExcepcionGenerica)
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.Chofer_ErrorGuardar, MessageBoxButton.OK,
                                      MessageImage.Error);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.Chofer_ErrorGuardar, MessageBoxButton.OK,
                                      MessageImage.Error);
                }
            }
        }
        public static TarjetaRecepcionGanadoInfo TraerEntradaGanado(EntradaGanadoInfo entradaGanadoInfo)
        {
            try
            {
                TarjetaRecepcionGanadoInfo result = null;
                var seguridad = (SeguridadInfo)ObtenerSeguridad();
                var entradaPl = new EntradaGanadoPL();
                var entradaGanadoCalidadPl = new EntradaGanadoCalidadPL();
                var operadorPL             = new OperadorPL();
                var choferPL = new ChoferPL();

                var jaulaPL = new JaulaPL();

                int folioEntrada   = entradaGanadoInfo.FolioEntrada;
                int organizacionId = seguridad.Usuario.Organizacion.OrganizacionID; //entradaGanadoInfo.OrganizacionID;

                entradaGanadoInfo = entradaPl.ObtenerPorFolioEntrada(folioEntrada, organizacionId);

                if (entradaGanadoInfo != null)
                {
                    var entradaGanadoCalidad =
                        entradaGanadoCalidadPl.ObtenerEntradaGanadoId(entradaGanadoInfo.EntradaGanadoID);

                    if (entradaGanadoCalidad == null)
                    {
                        result = new TarjetaRecepcionGanadoInfo
                        {
                            ConteoCapturado = false
                        };
                        return(result);
                    }
                    if (entradaGanadoCalidad.All(ent => ent.EntradaGanadoID == 0))
                    {
                        result = new TarjetaRecepcionGanadoInfo
                        {
                            ConteoCapturado = false
                        };
                        return(result);
                    }

                    int embarqueId = entradaGanadoInfo.EmbarqueID;
                    var embarquePL = new EmbarquePL();

                    var embarque = embarquePL.ObtenerPorID(embarqueId);

                    CorralInfo corral = TraerCorralPorEmbarque(embarque.FolioEmbarque);

                    result = new TarjetaRecepcionGanadoInfo
                    {
                        EntradaGanado   = entradaGanadoInfo,
                        Operador        = operadorPL.ObtenerPorID(entradaGanadoInfo.OperadorID),
                        Chofer          = choferPL.ObtenerPorID(entradaGanadoInfo.ChoferID),
                        Jaula           = jaulaPL.ObtenerPorID(entradaGanadoInfo.JaulaID),
                        Corral          = corral,
                        ConteoCapturado = true
                    };
                }

                return(result);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw;
            }
        }