Beispiel #1
0
        private void txtMensaje_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
        {
            if (e.Key == Windows.System.VirtualKey.Enter && !String.IsNullOrWhiteSpace(txtMensaje.Text))
            {
                Mensaje mensaje;
                if (inTema)
                {
                    mensaje = new MensajeATema();
                    ((MensajeATema)mensaje).Receptor = TemaSelected;
                }
                else
                {
                    mensaje = new MensajeAUsuario();
                    ((MensajeAUsuario)mensaje).Receptor = UserSelected;
                }
                mensaje.Emisor = new Usuario()
                {
                    ID = SesionActiva.ObtenerInstancia().Usuario.ID
                };
                mensaje.Fecha   = DateTime.Now;
                mensaje.Texto   = txtMensaje.Text;
                txtMensaje.Text = "";

                chatBL.EnviarMensaje(mensaje);

                if (inTema)
                {
                    Chat = chatBL.ObtenerChat(TemaSelected.ID);
                }
                else
                {
                    Chat = chatBL.ObtenerChat(SesionActiva.ObtenerInstancia().Usuario.ID, UserSelected.ID);
                }
                OnPropertyChanged("Chat");
            }
        }
        public string IniciarSesion(string nombreUsuario)
        {
            string mensaje = "";

            try
            {
                Usuario usuarioSesion = GetUsuario(nombreUsuario);
                Rol     rolSesion     = GetRol(nombreUsuario);
                if (rolSesion != null)
                {
                    List <Formulario> formulariosSesion = GetFormularios(rolSesion.NombreRol);
                    if (formulariosSesion.Count == 0)
                    {
                        return(mensaje = "Sus credenciales estan ok."
                                         + "El usuario esta registrado en el sistema,\n"
                                         + "pero el rol asignado no posee formularios habilitados");//solo entraria por este caso si se creara el rol y no se le diera permiso
                    }
                    rolSesion.FormulariosHabilitados = formulariosSesion;
                    usuarioSesion.RolDelUsuario      = rolSesion;
                }
                sesionActiva = new SesionActiva(usuarioSesion);
            }
            catch (Exception ex)
            {
                if (ex is System.InvalidOperationException)
                {
                    return(mensaje = "Sus credenciales estan ok,\n"
                                     + "pero no tiene permiso para usar este sistema");
                }
                else
                {
                    return(ex.ToString());
                }
            }
            return(mensaje);
        }
Beispiel #3
0
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                switch (accion.Descripcion)
                {
                case "Agregar Tema":
                    if (AreFieldsFilled() && IsDateValid())
                    {
                        crudTema = new Tema(SesionActiva.ObtenerInstancia().Usuario)
                        {
                            Titulo        = txtTitulo.Text,
                            Descripcion   = txtDescripcion.Text,
                            FechaCreacion = DateTime.Now.Date,
                            FechaCierre   = dpFechaCierre.Date.Date
                        };

                        if (cbTodos.IsChecked == true)
                        {
                            crudTema.EveryoneCanEdit = true;
                        }
                        else
                        {
                            crudTema.EveryoneCanEdit = false;
                        }
                        foreach (UsuarioListViewItem item in lvUsuarios.Items)
                        {
                            if (item.IsSelected)
                            {
                                crudTema.Usuarios.Add(item.Usuario);
                            }
                        }
                        temaBL.Insertar(crudTema);
                        RefreshTemasListView();
                        TemaMode();
                        if (Temas[0] != null)
                        {
                            Selected = Temas[0];
                        }
                    }
                    break;

                case "Modificar Tema":
                    if (AreFieldsFilled() && IsDateValid())
                    {
                        crudTema = new Tema()
                        {
                            ID            = Selected.ID,
                            Titulo        = txtTitulo.Text,
                            Descripcion   = txtDescripcion.Text,
                            FechaCreacion = Selected.FechaCreacion.Date,
                            FechaCierre   = dpFechaCierre.Date.Date,
                            Estado        = Selected.Estado
                        };

                        if (cbTodos.IsChecked == true)
                        {
                            crudTema.EveryoneCanEdit = true;
                        }
                        else
                        {
                            crudTema.EveryoneCanEdit = false;
                        }
                        foreach (UsuarioListViewItem item in lvUsuarios.Items)
                        {
                            if (item.IsSelected)
                            {
                                crudTema.Usuarios.Add(item.Usuario);
                            }
                        }
                        temaBL.Modificar(crudTema);
                        RefreshTemasListView();
                        if (Temas[0] != null)
                        {
                            Selected = Temas[0];
                        }
                        TemaMode();
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                DisplayError(ex.Message);
            }
        }
Beispiel #4
0
        private void DetailsMode()
        {
            tbOpcionMasVotada.Text = "";
            btnVotar.Content       = "Votar";
            bool canVote = true;

            spFormulario.MaxHeight             = 0;
            spDetails.MaxHeight                = double.PositiveInfinity;
            spDetailAsistire.MaxHeight         = 0;
            spDetailDoDont.MaxHeight           = 0;
            spDetailRegla.MaxHeight            = 0;
            spDetailVotacionMultiple.MaxHeight = 0;
            spDetailOpciones.MaxHeight         = 0;
            lvDetailOpciones.SelectionMode     = ListViewSelectionMode.Single;
            lvComentarios.SelectionMode        = ListViewSelectionMode.None;
            if (Selected != null)
            {
                switch (_selected.GetType().Name)
                {
                case "Asistire":
                    opciones = CreateListViewOpciones(((Asistire)_selected).Opciones);
                    lvDetailOpciones.ItemsSource = opciones;
                    canVote            = CanVote(_selected);
                    btnVotar.IsEnabled = canVote;

                    if (!canVote)
                    {
                        ShowVotedOption();
                    }

                    tbFechaEvento.Text             = ((Asistire)_selected).FechaEvento.ToString();
                    tbFechaLimiteConfirmacion.Text = ((Asistire)_selected).FechaLimiteConfirmacion.ToString();
                    tbLugar.Text = ((Asistire)_selected).Lugar;

                    spDetailAsistire.MaxHeight         = double.PositiveInfinity;
                    spDetailOpciones.MaxHeight         = double.PositiveInfinity;
                    spDetailDoDont.MaxHeight           = 0;
                    spDetailRegla.MaxHeight            = 0;
                    spDetailVotacionMultiple.MaxHeight = 0;

                    break;

                case "DoDont":
                    opciones = CreateListViewOpciones(((DoDont)_selected).Opciones);
                    lvDetailOpciones.ItemsSource = opciones;
                    rbDo.IsChecked     = ((DoDont)_selected).Tipo == "Do" ? true : false;
                    rbDont.IsChecked   = ((DoDont)_selected).Tipo == "Don't" ? true : false;
                    canVote            = CanVote(_selected);
                    btnVotar.IsEnabled = canVote;

                    if (!canVote)
                    {
                        ShowVotedOption();
                    }

                    spDetailDoDont.MaxHeight           = double.PositiveInfinity;
                    spDetailOpciones.MaxHeight         = double.PositiveInfinity;
                    spDetailAsistire.MaxHeight         = 0;
                    spDetailRegla.MaxHeight            = 0;
                    spDetailVotacionMultiple.MaxHeight = 0;
                    break;

                case "FAQ":
                    //marcar comentario correcto
                    spDetailAsistire.MaxHeight         = 0;
                    spDetailDoDont.MaxHeight           = 0;
                    spDetailRegla.MaxHeight            = 0;
                    spDetailVotacionMultiple.MaxHeight = 0;
                    canVote                     = _selected.isOpen() && _selected.Owner.ID == SesionActiva.ObtenerInstancia().Usuario.ID&& ((FAQ)_selected).RespuestaCorrecta.ID == 0;
                    btnVotar.IsEnabled          = canVote;
                    lvComentarios.SelectionMode = ListViewSelectionMode.Single;
                    if (!canVote)
                    {
                        ShowVotedComment();
                    }
                    btnVotar.Content = "Seleccionar respuesta correcta";

                    break;

                case "PropuestaGenerica":
                    spDetailAsistire.MaxHeight         = 0;
                    spDetailDoDont.MaxHeight           = 0;
                    spDetailRegla.MaxHeight            = 0;
                    spDetailVotacionMultiple.MaxHeight = 0;
                    canVote            = false;
                    btnVotar.IsEnabled = canVote;

                    break;

                case "Regla":
                    opciones = CreateListViewOpciones(((Regla)_selected).Opciones);
                    lvDetailOpciones.ItemsSource = opciones;
                    slDetailRelevancia.Value     = ((Regla)_selected).Relevancia;
                    canVote            = CanVote(_selected);
                    btnVotar.IsEnabled = canVote;

                    if (!canVote)
                    {
                        ShowVotedOption();
                    }

                    spDetailAsistire.MaxHeight         = 0;
                    spDetailDoDont.MaxHeight           = 0;
                    spDetailOpciones.MaxHeight         = double.PositiveInfinity;
                    spDetailRegla.MaxHeight            = double.PositiveInfinity;
                    spDetailVotacionMultiple.MaxHeight = 0;
                    break;

                case "Votacion":
                    opciones = CreateListViewOpciones(((Votacion)_selected).Opciones);
                    lvDetailOpciones.ItemsSource = opciones;
                    canVote            = CanVote(_selected);
                    btnVotar.IsEnabled = canVote;

                    if (!canVote)
                    {
                        ShowVotedOption();
                    }

                    spDetailAsistire.MaxHeight         = 0;
                    spDetailDoDont.MaxHeight           = 0;
                    spDetailRegla.MaxHeight            = 0;
                    spDetailVotacionMultiple.MaxHeight = 0;
                    spDetailOpciones.MaxHeight         = double.PositiveInfinity;
                    break;

                case "VotacionMultiple":
                    opciones = CreateListViewOpciones(((VotacionMultiple)_selected).Opciones);
                    lvDetailOpciones.ItemsSource           = opciones;
                    tbDetailMaxOpcionesSeleccionables.Text = ((VotacionMultiple)_selected).MaxOpcionesSeleccionables.ToString();
                    canVote            = CanVote(_selected);
                    btnVotar.IsEnabled = canVote;

                    lvDetailOpciones.SelectionMode = ListViewSelectionMode.Multiple;
                    if (!canVote)
                    {
                        foreach (var item in lvDetailOpciones.Items)
                        {
                            if (((OpcionListViewItem)item).Opcion.Votantes.FindIndex(x => x.ID == SesionActiva.ObtenerInstancia().Usuario.ID) != -1)
                            {
                                lvDetailOpciones.SelectedItems.Add(item);
                            }
                        }
                    }
                    if (!_selected.isOpen())
                    {
                        int count = 0;
                        foreach (OpcionListViewItem item in lvDetailOpciones.Items)
                        {
                            if (item.Opcion.Votantes.Count > count)
                            {
                                count = item.Opcion.Votantes.Count;
                                tbOpcionMasVotada.Text = "Opción mas votada: " + item.Opcion.Descripcion;
                            }
                        }
                    }

                    spDetailAsistire.MaxHeight         = 0;
                    spDetailDoDont.MaxHeight           = 0;
                    spDetailRegla.MaxHeight            = 0;
                    spDetailVotacionMultiple.MaxHeight = double.PositiveInfinity;
                    spDetailOpciones.MaxHeight         = double.PositiveInfinity;

                    break;

                default:
                    break;
                }
            }
        }
Beispiel #5
0
        private void FormularioMode()
        {
            Usuario owner = SesionActiva.ObtenerInstancia().Usuario;

            lvFormularioOpciones.ItemsSource = null;
            spFormulario.MaxHeight           = double.PositiveInfinity;
            spDetails.MaxHeight                    = 0;
            spFormularioAsistire.MaxHeight         = 0;
            spFormularioRegla.MaxHeight            = 0;
            spFormularioVotacionMultiple.MaxHeight = 0;
            spFormularioOpciones.MaxHeight         = 0;
            switch (cbTipoIniciativa.SelectedValue)
            {
            case "Asistire":
                crudIniciativa = Asistire.NuevaInstancia(owner);
                lvFormularioOpciones.ItemsSource = ((Asistire)crudIniciativa).Opciones;
                tbFechaEvento.Text             = "";
                tbFechaLimiteConfirmacion.Text = "";
                tbLugar.Text = "";

                spFormularioAsistire.MaxHeight         = double.PositiveInfinity;
                spFormularioRegla.MaxHeight            = 0;
                spFormularioVotacionMultiple.MaxHeight = 0;
                spFormularioOpciones.MaxHeight         = 0;
                break;

            case "DoDont":
                crudIniciativa = DoDont.NuevaInstancia(owner);
                lvFormularioOpciones.ItemsSource = ((DoDont)crudIniciativa).Opciones;

                if (cbTipoIniciativa.SelectedItem.ToString() == "Do")
                {
                    ((DoDont)crudIniciativa).Tipo = "Do";
                }
                else
                {
                    ((DoDont)crudIniciativa).Tipo = "Don't";
                }


                spFormularioAsistire.MaxHeight         = 0;
                spFormularioRegla.MaxHeight            = 0;
                spFormularioVotacionMultiple.MaxHeight = 0;
                spFormularioOpciones.MaxHeight         = 0;
                break;

            case "FAQ":
                crudIniciativa = new FAQ(owner);
                //marcar comentario correcto
                spFormularioAsistire.MaxHeight         = 0;
                spFormularioRegla.MaxHeight            = 0;
                spFormularioVotacionMultiple.MaxHeight = 0;
                spFormularioOpciones.MaxHeight         = 0;
                break;

            case "PropuestaGenerica":
                crudIniciativa = new PropuestaGenerica(owner);

                spFormularioAsistire.MaxHeight         = 0;
                spFormularioRegla.MaxHeight            = 0;
                spFormularioVotacionMultiple.MaxHeight = 0;
                spFormularioOpciones.MaxHeight         = 0;
                break;

            case "Regla":
                crudIniciativa = Regla.NuevaInstancia(owner);
                lvFormularioOpciones.ItemsSource = ((Regla)crudIniciativa).Opciones;

                spFormularioAsistire.MaxHeight         = 0;
                spFormularioRegla.MaxHeight            = double.PositiveInfinity;
                spFormularioVotacionMultiple.MaxHeight = 0;
                spFormularioOpciones.MaxHeight         = 0;
                break;

            case "Votacion":
                crudIniciativa = new Votacion(owner);
                spFormularioOpciones.MaxHeight = double.PositiveInfinity;

                spFormularioAsistire.MaxHeight         = 0;
                spFormularioRegla.MaxHeight            = 0;
                spFormularioVotacionMultiple.MaxHeight = 0;
                break;

            case "VotacionMultiple":
                crudIniciativa = new VotacionMultiple(owner);

                spFormularioOpciones.MaxHeight         = double.PositiveInfinity;
                spFormularioAsistire.MaxHeight         = 0;
                spFormularioRegla.MaxHeight            = 0;
                spFormularioVotacionMultiple.MaxHeight = double.PositiveInfinity;
                break;

            default:
                break;
            }
        }