Ejemplo n.º 1
0
 /// <summary>
 /// Metodo para Guardar/Modificar una entidad Accion.
 /// </summary>
 /// <param name="Info">informacion del nivel del alerta que se guardara</param>
 internal int Guardar(NivelAlertaInfo Info)
 {
     try
     {
         Logger.Info();
         var NivelAlertaDAL = new NivelAlertaDAL();
         int result         = Info.NivelAlertaId;
         if (Info.NivelAlertaId == 0)
         {
             result = NivelAlertaDAL.Crear(Info);
         }
         else
         {
             NivelAlertaDAL.Actualizar(Info);
         }
         return(result);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Metodo para cargar el comboBox de Nivel de Alertas
 /// </summary>
 private void CargaComboNivelAlerta()
 {
     try
     {
         var nivelAlertaPl = new RolPL();
         var nivelAlerta   = new NivelAlertaInfo
         {
             NivelAlertaId = 0,
             Descripcion   = Properties.Resources.cbo_Seleccione,
         };
         IList <NivelAlertaInfo> listaNivelAlerta = nivelAlertaPl.NivelAlertaInfo();
         listaNivelAlerta.Insert(0, nivelAlerta);
         cmbNivel.ItemsSource  = listaNivelAlerta;
         cmbNivel.SelectedItem = nivelAlerta;
         if (Contexto.NivelAlerta.Descripcion == null || Contexto.NivelAlerta.NivelAlertaId == 0)
         {
             Contexto.NivelAlerta = nivelAlerta;
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         SkMessageBox.Show(this, Properties.Resources.ClienteNuevo_ErrorMetodoPago, MessageBoxButton.OK,
                           MessageImage.Error);
     }
 }
        ///<summary>
        /// Metodo para limpiar los campos despues de un registro
        /// </summary>
        private void LimpiarCampos()
        {
            InicializaContexto();
            accionesDgAux.Clear();
            gridDatos.ItemsSource = null;
            var accion = new AccionInfo
            {
                AccionID    = 0,
                Descripcion = Properties.Resources.cbo_Seleccione,
            };

            cmbAcciones.SelectedItem = accion;

            var alerta = new AlertaInfo
            {
                AlertaID    = 0,
                Descripcion = Properties.Resources.cbo_Seleccione,
            };

            cmbAlerta.SelectedItem = alerta;

            var nivelAlerta = new NivelAlertaInfo
            {
                NivelAlertaId = 0,
                Descripcion   = Properties.Resources.cbo_Seleccione,
            };

            cmbNivelAlerta.SelectedItem = nivelAlerta;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Metodo para Crear un registro de NivelAlerta
 /// </summary>
 /// <param name="info">Valores de la entidad que será creada</param>
 internal int Crear(NivelAlertaInfo info)
 {
     try
     {
         Logger.Info();
         Dictionary <string, object> parameters = AuxNivelAlertaDAL.ObtenerParametrosCrear(info);
         int result = Create("NivelAlerta_Crear", parameters);
         return(result);
     }
     catch (SqlException ex)
     {
         Logger.Error(ex);
         throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex);
     }
     catch (DataException ex)
     {
         Logger.Error(ex);
         throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
 /// <summary>
 /// Metodo para cargar el comboBox de Nivel de Alertas
 /// </summary>
 private void CargaComboNivelAlerta()
 {
     try
     {
         var nivelAlertaPl = new RolPL();
         var nivelAlerta   = new NivelAlertaInfo
         {
             NivelAlertaId = 0,
             Descripcion   = Properties.Resources.cbo_Seleccione,
         };
         IList <NivelAlertaInfo> listaNivelAlerta = nivelAlertaPl.NivelAlertaInfo();
         listaNivelAlerta.Insert(0, nivelAlerta);
         cmbNivelAlerta.ItemsSource  = listaNivelAlerta;
         cmbNivelAlerta.SelectedItem = nivelAlerta;
         if (Contexto.ConfiguracionAlertas.NivelAlerta.Descripcion != null || Contexto.ConfiguracionAlertas.NivelAlerta.NivelAlertaId != 0)
         {
             cmbNivelAlerta.SelectedItem = Contexto.ConfiguracionAlertas.NivelAlerta;
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         SkMessageBox.Show(this, Properties.Resources.ConfiguracionAlerta_ErrorConsultarTodasLasNivelDeAlertaActivas,
                           MessageBoxButton.OK, MessageImage.Error);
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Se toma el usuario el cual creo y se encuentra logeado.
 /// </summary>
 public void InicializaContexto()
 {
     Contexto = new NivelAlertaInfo
     {
         UsuarioCreacionID = AuxConfiguracion.ObtenerUsuarioLogueado(),
     };
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Constructor para editar un nivel.
 /// </summary>
 public NivelAlertaNuevo(NivelAlertaInfo Nivel)
 {
     InitializeComponent();
     Nivel.UsuarioModificacionID = AuxConfiguracion.ObtenerUsuarioLogueado();
     AuxInactivo = Nivel.Activo;
     Contexto    = Nivel;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// cargo al usuario que esta logeado.
        /// </summary>
        public NivelAlertaNuevo()
        {
            InitializeComponent();

            Contexto = new NivelAlertaInfo
            {
                UsuarioCreacionID = AuxConfiguracion.ObtenerUsuarioLogueado(),
            };
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Evento que se ejecuta mientras se esta cerrando la ventana
 /// </summary>
 /// <param name="e"></param>
 protected override void OnClosing(CancelEventArgs e)
 {
     if (confirmaSalir)
     {
         MessageBoxResult result = SkMessageBox.Show(this, Properties.Resources.Msg_CerrarSinGuardar, MessageBoxButton.YesNo, MessageImage.Question);
         if (result == MessageBoxResult.Yes)
         {
             Contexto = null;
         }
         else
         {
             e.Cancel = true;
         }
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Obtiene lista de nivel de alerta
 /// </summary>
 /// <param name="inicio"></param>
 /// <param name="limite"></param>
 private void ObtenerListaNivelAlerta(int inicio, int limite)
 {
     try
     {
         if (ucPaginacion.ContextoAnterior != null)
         {
             bool contextosIguales = ucPaginacion.CompararObjetos(Contexto, ucPaginacion.ContextoAnterior);
             if (!contextosIguales)
             {
                 ucPaginacion.Inicio = 1;
                 inicio = 1;
             }
         }
         // se crean los filtros para le paginado  para posterior mandar llamar el SP.
         var             nivelAlertaPL = new NivelAlertaPL();
         NivelAlertaInfo filtros       = ObtenerFiltros();
         var             pagina        = new PaginacionInfo {
             Inicio = inicio, Limite = limite
         };
         ResultadoInfo <NivelAlertaInfo> resultadoInfo = nivelAlertaPL.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 <NivelAlerta>();
         }
     }
     catch (ExcepcionGenerica)
     {
         SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.NivelAlerta_ErrorBuscar,
                           MessageBoxButton.OK, MessageImage.Error);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.NivelAlerta_ErrorBuscar,
                           MessageBoxButton.OK, MessageImage.Error);
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Obtiene registros por descripcion
 /// </summary>
 /// <param name="Descripcion"></param>
 /// <returns></returns>
 internal NivelAlertaInfo ObtenerPorDescripcion(String Descripcion)
 {
     try
     {
         Dictionary <string, object> parameters = AuxNivelAlertaDAL.ObtenerPorDescripcion(Descripcion);
         DataSet         ds     = Retrieve("NivelAlerta_ObtenerPoDescripcion", parameters);
         NivelAlertaInfo result = null;
         if (ValidateDataSet(ds))
         {
             result = MapNivelAlertaDAL.ObtenerPorDescripcion(ds);
         }
         return(result);
     }
     catch (SqlException ex)
     {
         Logger.Error(ex);
         throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex);
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Metodo para Guardar la Accion
 /// </summary>
 /// <param name="Info">informacion del nivel de alerta a registrar</param>
 public int Guardar(NivelAlertaInfo Info)
 {
     try
     {
         Logger.Info();
         var NivelAlertaBL = new NivelAlertaBL();
         int Resultado     = NivelAlertaBL.Guardar(Info);
         return(Resultado);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Obtener Alertas por descripcion
 /// </summary>
 /// <param name="Descripcion">descripcion del nivel de alerta que se buscara</param>
 /// <returns>nivel de alerta encontrado con la descripcion especificada</returns>
 public NivelAlertaInfo ObtenerPorDescripcion(string Descripcion)
 {
     try
     {
         Logger.Info();
         var             NivelALertaBL = new NivelAlertaBL();
         NivelAlertaInfo result        = NivelALertaBL.ObtenerPorDescripcion(Descripcion);
         return(result);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Obtiene parametros para crear
 /// </summary>
 /// <param name="info">Valores de la entidad</param>
 /// <returns></returns>
 internal static Dictionary <string, object> ObtenerParametrosCrear(NivelAlertaInfo info)
 {
     try
     {
         Logger.Info();
         var parametros =
             new Dictionary <string, object>
         {
             { "@Descripcion", info.Descripcion.Trim() },
             { "@Activo", info.Activo },
             { "@UsuarioCreacionID", info.UsuarioCreacionID },
         };
         return(parametros);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Ejemplo n.º 15
0
 /// <summary>
 /// obtenemos por descripcion, este paso es para no repepetir  niveles.
 /// </summary>
 /// <param name="ds"></param>
 /// <returns></returns>
 internal static NivelAlertaInfo ObtenerPorDescripcion(DataSet ds)
 {
     try
     {
         Logger.Info();
         DataTable       dt = ds.Tables[ConstantesDAL.DtDatos];
         NivelAlertaInfo EntidadNivelAlerta =
             (from info in dt.AsEnumerable()
              select
              new NivelAlertaInfo
         {
             NivelAlertaId = info.Field <int>("NivelAlertaID"),
             Descripcion = info.Field <string>("Descripcion"),
             Activo = info.Field <bool>("Activo").BoolAEnum()
         }).First();
         return(EntidadNivelAlerta);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Metodo para actualizar un registro de Cliente
 /// </summary>
 /// <param name="info">Valores de la entidad que se actualizarán</param>
 internal void Actualizar(NivelAlertaInfo info)
 {
     try
     {
         Logger.Info();
         Dictionary <string, object> parameters = AuxNivelAlertaDAL.ObtenerParametrosActualizar(info);
         Update("NivelAlerta_Actualizar", parameters);
     }
     catch (SqlException ex)
     {
         Logger.Error(ex);
         throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex);
     }
     catch (DataException ex)
     {
         Logger.Error(ex);
         throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Obtiene un lista paginada
 /// </summary>
 /// <param name="pagina">informacion de paginacion usada para la consulta</param>
 /// <param name="filtro">filtro o condiciones de la busqueda</param>
 /// <returns>regresa la lista de alertas que cumplen con las condiciones establecidas por el filtro</returns>
 public ResultadoInfo <NivelAlertaInfo> ObtenerPorPagina(PaginacionInfo pagina, NivelAlertaInfo filtro)
 {
     try
     {
         Logger.Info();
         var NivelAlertaBL = new NivelAlertaBL();
         ResultadoInfo <NivelAlertaInfo> result = NivelAlertaBL.ObtenerPorPagina(pagina, filtro);
         return(result);
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Obtiene un lista paginada
 /// </summary>
 /// <param name="pagina"></param>
 /// <param name="filtro"></param>
 /// <returns></returns>
 internal ResultadoInfo <NivelAlertaInfo> ObtenerPorPagina(PaginacionInfo pagina, NivelAlertaInfo filtro)
 {
     try
     {
         Dictionary <string, object> parameters = AuxNivelAlertaDAL.ObtenerParametrosPorPagina(pagina, filtro);
         DataSet ds = Retrieve("NivelAlerta_ObtenerPorPagina", parameters);
         ResultadoInfo <NivelAlertaInfo> result = null;
         if (ValidateDataSet(ds))
         {
             result = MapNivelAlertaDAL.ObtenerPorPagina(ds);
         }
         return(result);
     }
     catch (SqlException ex)
     {
         Logger.Error(ex);
         throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex);
     }
     catch (DataException ex)
     {
         Logger.Error(ex);
         throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Ejemplo n.º 19
0
        //Metodo de validar al guardar el nivel de alerta.
        private bool ValidaGuardar()
        {
            bool   resultado = true;
            string mensaje   = string.Empty;

            try
            {
                // si esta en blanco manda un mensaje que es requerido el campo descripcion.
                if (string.IsNullOrWhiteSpace(Contexto.Descripcion) && txtDescripcion.Text.Trim() == string.Empty)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.NivelAlertaEdicion_MsgDescripcionRequerida;
                    txtDescripcion.Focus();
                }
                else if (cmbActivo.SelectedItem == null)
                {
                    resultado = false;
                    mensaje   = Properties.Resources.NivelAlertaEdicion_MsgActivoRequerida;
                    cmbActivo.Focus();
                }
                else
                {
                    // se realiza la busqueda por descripcion para no editar y asignarle una descripcion igual a una ya existente.
                    int             NivelAlertaID = Contexto.NivelAlertaId;
                    var             NivelAlertaPL = new NivelAlertaPL();
                    NivelAlertaInfo NivelALerta   = NivelAlertaPL.ObtenerPorDescripcion(Contexto.Descripcion.Trim());

                    //Obtiene un contador de los niveles que se encuentran deshabilitados
                    int nivelesAlertaDesactivados = NivelAlertaPL.NivelesAlertaDesactivados();

                    //validacion si la descripcion del nivel registrado ya existe
                    if (NivelALerta != null && (NivelAlertaID == 0 || NivelAlertaID != NivelALerta.NivelAlertaId))
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.NivelAlertaEdicion_MsgDescripcionExistente, NivelALerta.NivelAlertaId);
                    }
                    //validacion para cuando se crea un nuevo registro activo pero hay un registro previo desactivado
                    else if (nivelesAlertaDesactivados > 0 && Contexto.Activo == EstatusEnum.Activo && Contexto.NivelAlertaId == 0)
                    {
                        resultado = false;
                        mensaje   = string.Format(Properties.Resources.NivelAlertaCreacion_MsgInactivos);
                    }
                    //validacion para cuando editas un nivel alerta
                    else if (Contexto.Activo == EstatusEnum.Inactivo && Contexto.NivelAlertaId != 0)
                    {
                        //validacion para cuando editas un nivel alerta pero solo modificas su descripcion
                        //(AuxInactivo guarda en valor original en cuanto se cargan los datos del nivel a editar
                        if (AuxInactivo != Contexto.Activo)
                        {
                            int verificarAsignacionNivelAlerta = NivelAlertaPL.VerificarAsignacionNivelAlerta(NivelAlertaID);
                            //verifica si el nivel seleccionado no a sido asignado
                            if (verificarAsignacionNivelAlerta > 0)
                            {
                                resultado = false;
                                mensaje   = string.Format(Properties.Resources.NivelAlertaEdicion_MsgAsignado);
                            }
                        }
                    }
                    //validacion cuando un inactivo quiere pasar a activo...
                    else if (AuxInactivo != EstatusEnum.Activo && Contexto.NivelAlertaId != 0)
                    {
                        int habilitarPrimerRegistro = NivelAlertaPL.NivelAlerta_ActivarPrimerNivelDesactivado(NivelAlertaID);
                        //Si regresa 0 no es el primero deshabilitado si regresa > 0 es el primero deshabilitado
                        if (habilitarPrimerRegistro == 0)
                        {
                            resultado = false;
                            mensaje   = string.Format(Properties.Resources.NivelAlertaActivacion_MsgActivar);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }

            if (!string.IsNullOrWhiteSpace(mensaje))
            {
                SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning);
            }
            return(resultado);
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Obtiene parametros para obtener lista paginada
 /// </summary>
 /// <param name="pagina"></param>
 /// <param name="filtro"></param>
 /// <returns></returns>
 internal static Dictionary <string, object> ObtenerParametrosPorPagina(PaginacionInfo pagina, NivelAlertaInfo filtro)
 {
     try
     {
         Logger.Info();
         var parametros =
             new Dictionary <string, object>
         {
             { "@Descripcion", string.IsNullOrWhiteSpace(filtro.Descripcion) ? string.Empty : filtro.Descripcion.Trim() },
             { "@Activo", filtro.Activo },
             { "@Inicio", pagina.Inicio },
             { "@Limite", pagina.Limite }
         };
         return(parametros);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }