public void atualizarListaPessoa(int pagina)
        {
            try
            {
                using (ServicoCadastrosPrincipaisClient serv = new ServicoCadastrosPrincipaisClient())
                {
                    if (pagina == 0)
                    {
                        primeiroResultado = 0;
                    }
                    else if (pagina > 0)
                    {
                        primeiroResultado += QUANTIDADE_PAGINA;
                    }
                    else if (pagina < 0)
                    {
                        primeiroResultado -= QUANTIDADE_PAGINA;
                    }

                    List <PessoaDTO> listaServ = serv.selectPessoaPagina(primeiroResultado, QUANTIDADE_PAGINA, new PessoaDTO());

                    ListaPessoa.Clear();

                    foreach (PessoaDTO objAdd in listaServ)
                    {
                        ListaPessoa.Add(objAdd);
                    }
                    PessoaSelected = null;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        /// <summary>
        /// Funcao para carregar informacao de uma pessoa
        /// </summary>
        /// @param name="filename"> nome do ficheiro a carregar </param>
        /// @param name="perfil"> tipo de perfil a atribuir </param>
        /// <returns></returns>
        public static bool ListaPessoaLoadBinFile(string filename, int perfil)
        {
            // Auxiliary variables
            bool resultado = false;

            // Apply rule
            if (perfil > 0)
            {
                // Get access to the file
                try
                {
                    resultado = ListaPessoa.LoadBinFile(filename);
                } // Error Handling - Exceptions
                catch (FileNotFoundException f)
                {
                    throw new FileNotFoundException("Error! " + f.Message);
                }
                catch (SerializationException f)
                {
                    throw new SerializationException("Error! " + f.Message);
                }
                catch (IOException f)
                {
                    throw new IOException("Error! " + f.Message);
                }
                catch (Exception f)
                {
                    throw new Exception("Error! " + f.Message);
                }
            }
            return(resultado);
        }
Пример #3
0
        /// <summary>
        /// Funcao para guardar a pessoa inserida num ficheiro binario
        /// </summary>
        /// @param name="filename"> nome do ficheiro </param>
        /// @param name="perfil"> perfil da pessoa atribuida </param>
        /// <returns></returns>
        public static bool ListaPessoaSaveBinFile(string filename, int perfil)
        {
            // Varialvel aux
            bool resultado = false;

            if (perfil > 0)
            {
                try
                {
                    resultado = ListaPessoa.SaveBinFile(filename);
                }
                catch (FileNotFoundException f)
                {
                    throw new FileNotFoundException("Error! " + f.Message);
                }
                catch (SerializationException f)
                {
                    throw new SerializationException("Error! " + f.Message);
                }
                catch (IOException f)
                {
                    throw new IOException("Error! " + f.Message);
                }
                catch (Exception f)
                {
                    throw new Exception("Error! " + f.Message);
                }
            }
            return(resultado);
        }
Пример #4
0
        public void AtualizarListaPessoa(int pagina)
        {
            try
            {
                using (ServiceServidor Servico = new ServiceServidor())
                {
                    if (pagina == 0)
                    {
                        IndiceNavegacao = 0;
                    }
                    else if (pagina > 0 && ListaPessoa.Count == QuantidadePagina)
                    {
                        IndiceNavegacao += QuantidadePagina;
                    }
                    else if (pagina < 0 && IndiceNavegacao != 0)
                    {
                        IndiceNavegacao -= QuantidadePagina;
                    }

                    Pessoa Pessoa = new Pessoa();
                    if (!Filtro.Trim().Equals(""))
                    {
                        Pessoa.nome = Filtro;
                    }

                    IList <Pessoa> ListaServ = Servico.SelectPessoaPagina(IndiceNavegacao, true, QuantidadePagina, true, Pessoa);

                    ListaPessoa.Clear();

                    foreach (Pessoa objAdd in ListaServ)
                    {
                        ListaPessoa.Add(objAdd);
                    }
                    PessoaSelected = null;
                }
                QuantidadeCarregada = ListaPessoa.Count;
                ControlarNavegacao();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #5
0
        /// <summary>
        /// Funcao para inserir uma pessoa
        /// </summary>
        /// @param name="pessoa"> pessoa a inserir </param>
        /// @param name="perfil"> perfil a atribuir a essa pessoa </param>
        /// <returns></returns>
        public static bool InserirPessoa(Pessoa pessoa, int perfil)
        {
            // Varialvel aux
            bool resultado = false;

            if (perfil > 0)
            {
                try
                {
                    resultado = ListaPessoa.AddPessoa(pessoa);
                }

                catch (Exception e)
                {
                    throw new Exception("Error! " + e.Message);
                }
            }
            return(resultado);
        }
Пример #6
0
 /// <summary>
 /// Funcao para procurar pessoa por nome
 /// </summary>
 /// @param name="nome"> nome da pessoa a procurar </param>
 /// @param name="perfil"> perfil da pessoa a procurar </param>
 /// <returns></returns>
 public static Pessoa ProcurarPessoaNome(string nome, int perfil)
 {
     // Get access to the class
     if (perfil > 0)
     {
         try
         {
             return(ListaPessoa.ProcurarPessoaNome(nome));
         }
         catch (ArgumentException e)
         {
             throw new ArgumentException("Error! " + e.Message);
         }
         catch (Exception e)
         {
             throw new Exception("Error! " + e.Message);
         }
     }
     return(null);
 }