Ejemplo n.º 1
0
        /// <summary>
        /// Método para guardar los valores del contexto
        /// </summary>
        private void Guardar()
        {
            bool guardar = ValidaGuardar();

            if (guardar)
            {
                try
                {
                    var trampaPL = new TrampaPL();
                    trampaPL.Guardar(Contexto);
                    SkMessageBox.Show(this, Properties.Resources.GuardadoConExito, MessageBoxButton.OK, MessageImage.Correct);
                    if (Contexto.TrampaID != 0)
                    {
                        confirmaSalir = false;
                        Close();
                    }
                    else
                    {
                        InicializaContexto();
                    }
                }
                catch (ExcepcionGenerica)
                {
                    SkMessageBox.Show(this, Properties.Resources.Trampa_ErrorGuardar, MessageBoxButton.OK, MessageImage.Error);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    SkMessageBox.Show(this, Properties.Resources.Trampa_ErrorGuardar, MessageBoxButton.OK, MessageImage.Error);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Metrodo Verificar si existen Trampas configuradas
        /// </summary>
        private bool ExistenTrampas()
        {
            var existeTrampa = false;
            var trampaPl     = new TrampaPL();

            try
            {
                var trampaInfo = new TrampaInfo
                {
                    Organizacion = new OrganizacionInfo {
                        OrganizacionID = organizacionID
                    },
                    TipoTrampa = (char)TipoTrampa.Enfermeria,
                    HostName   = Environment.MachineName
                };

                var trampaInfoResp = trampaPl.ObtenerTrampa(trampaInfo);

                if (trampaInfoResp != null)
                {
                    this.trampaInfo = trampaInfoResp;
                    existeTrampa    = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }

            return(existeTrampa);
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var trampaPL       = new TrampaPL();
            var organizacionPL = new OrganizacionPL();

            skAyudaTrampaOrigen.ObjetoNegocio        = trampaPL;
            skAyudaTrampaDestino.ObjetoNegocio       = trampaPL;
            skAyudaOrganizacionOrigen.ObjetoNegocio  = organizacionPL;
            skAyudaOrganizacionDestino.ObjetoNegocio = organizacionPL;

            skAyudaOrganizacionOrigen.AyudaConDatos += (o, args) =>
            {
                Contexto.TrampaOrigen.Organizacion.ListaTiposOrganizacion = ObtenerTipoOrganizacionGanadera();
            };
            skAyudaOrganizacionDestino.AyudaConDatos += (o, args) =>
            {
                Contexto.TrampaDestino.Organizacion.ListaTiposOrganizacion = ObtenerTipoOrganizacionGanadera();
            };

            skAyudaTrampaOrigen.AyudaConDatos += (o, args) =>
            {
                Contexto.TrampaOrigen.Organizacion.ListaTiposOrganizacion = ObtenerTipoOrganizacionGanadera();
            };
            skAyudaTrampaDestino.AyudaConDatos += (o, args) =>
            {
                Contexto.TrampaDestino.Organizacion.ListaTiposOrganizacion = ObtenerTipoOrganizacionGanadera();
            };
        }
Ejemplo n.º 4
0
        public void ObtenerTrampaPorId()
        {
            var        trampaPL = new TrampaPL();
            TrampaInfo trampa   = trampaPL.ObtenerPorID(1);

            Assert.IsNotNull(trampa);
            Assert.IsNotNull(trampa.Organizacion);
            Assert.IsTrue(trampa.Organizacion.Descripcion.Length > 0);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Obtiene la lista para mostrar en el grid
 /// </summary>
 private void ObtenerListaTrampa(int inicio, int limite)
 {
     try
     {
         if (ucPaginacion.ContextoAnterior != null)
         {
             bool contextosIguales = ucPaginacion.CompararObjetos(Contexto, ucPaginacion.ContextoAnterior);
             if (!contextosIguales)
             {
                 ucPaginacion.Inicio = 1;
                 inicio = 1;
             }
         }
         var        trampaPL = new TrampaPL();
         TrampaInfo filtros  = ObtenerFiltros();
         var        pagina   = new PaginacionInfo {
             Inicio = inicio, Limite = limite
         };
         ResultadoInfo <TrampaInfo> resultadoInfo = trampaPL.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 <Trampa>();
         }
     }
     catch (ExcepcionGenerica)
     {
         SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.Trampa_ErrorBuscar, MessageBoxButton.OK, MessageImage.Error);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.Trampa_ErrorBuscar, MessageBoxButton.OK, MessageImage.Error);
     }
 }
Ejemplo 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(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);
        }