private void ListInvoice()
 {
     try
     {
         notaCollectionDTO           = notaBLL.ReadAll();
         dataGridInvoice.ItemsSource = null;
         dataGridInvoice.ItemsSource = notaCollectionDTO;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Erro", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Consulta informações de privilegio por nome.
        /// </summary>
        /// <returns>Informações do privilegio encontrado.</returns>
        public NotaCollectionDTO ReadAll()
        {
            NotaCollectionDTO notaCollectionDTO = new NotaCollectionDTO();

            try
            {
                DataTable dataTable = new DataTable();
                dataTable = dataBaseAccess.Consult(CommandType.StoredProcedure, "sp_nota_todos");

                foreach (DataRow row in dataTable.Rows)
                {
                    NotaDTO notaDTO = new NotaDTO();
                    notaDTO.IdNota     = Convert.ToInt32(row["IdNota"]);
                    notaDTO.NumeroNota = row["NumeroNota"].ToString();
                    notaDTO.DataNota   = Convert.ToDateTime(row["DataNota"]);

                    notaDTO.Filial = new FilialDTO();
                    notaDTO.Filial.Pessoa.IdPessoa   = Convert.ToInt32(row["IdPessoaFilial"]);
                    notaDTO.Filial.Pessoa.NomePessoa = row["NomeFilial"].ToString();

                    notaDTO.Fornecedor = new FornecedorDTO();
                    notaDTO.Fornecedor.Pessoa.IdPessoa   = Convert.ToInt32(row["IdPessoaFornecedor"]);
                    notaDTO.Fornecedor.Pessoa.NomePessoa = row["NomeFornecedor"].ToString();
                    notaCollectionDTO.Add(notaDTO);
                }

                return(notaCollectionDTO);
            }
            catch (Exception ex)
            {
                StringBuilder message = new StringBuilder();
                message.Append("Não foi possível consultar notas fiscais:\n\n").Append(ex.Message);
                throw new Exception(message.ToString());
            }
            finally
            {
                dataBaseAccess.ClearParameters();
            }
        }