private void btnProcurar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtIdLeitor.Text == "")
                {
                    throw new Exception("Digite o id antes de procurá-lo");
                }

                Leitor leitor = new Leitor(int.Parse(txtIdLeitor.Text), "", "", "", "");

                LeitorBLL leitorBLL = new LeitorBLL();
                leitor = leitorBLL.SelecionarLeitorPorId(leitor.IdLeitor);

                txtIdLeitor.Text       = leitor.IdLeitor.ToString();
                txtNomeLeitor.Text     = leitor.NomeLeitor;
                txtTelefoneLeitor.Text = leitor.TelefoneLeitor;
                txtEmailLeitor.Text    = leitor.EmailLeitor;
                txtEnderecoLeitor.Text = leitor.EnderecoLeitor;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.Message.ToString());
            }
        }
Exemple #2
0
        private void btnProcurarLeitor_Click(object sender, EventArgs e)
        {
            limparTela();
            int    id     = int.Parse(txtIdLeitor.Text);
            Leitor leitor = new Leitor("", "", "", "");

            try
            {
                LeitorBLL leitorBLL = new LeitorBLL();
                leitor                 = leitorBLL.SelecionarLeitorPorId(id);
                txtNomeLeitor.Text     = leitor.NomeLeitor;
                txtTelLeitor.Text      = leitor.TelefoneLeitor;
                txtEmailLeitor.Text    = leitor.EmailLeitor;
                txtEnderecoLeitor.Text = leitor.EnderecoLeitor;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.Message.ToString());
            }
        }
        private void FrmRelatorio_Load(object sender, EventArgs e)
        {
            try
            {
                List <Emprestimo> listaEmprestimo = emprestimoBLL.ListarEmprestimos();
                Livro             livroAtual      = null;
                Leitor            leitorAtual     = null;

                dgvRelatorio.RowCount = listaEmprestimo.Count;

                for (short i = 0; i < listaEmprestimo.Count; i++)
                {
                    livroAtual  = livroBLL.SelecionarLivroPorId(listaEmprestimo[i].IdLivro);
                    leitorAtual = leitorBLL.SelecionarLeitorPorId(listaEmprestimo[i].IdLeitor);

                    dgvRelatorio[0, i].Value = livroAtual.IdLivro;
                    dgvRelatorio[1, i].Value = livroAtual.TituloLivro;
                    dgvRelatorio[2, i].Value = leitorAtual.IdLeitor;
                    dgvRelatorio[3, i].Value = leitorAtual.NomeLeitor;

                    if (listaEmprestimo[i].DataDevolucaoPrevista.CompareTo(DateTime.Now) < 0)
                    {
                        dgvRelatorio[4, i].Value = "Sim";
                    }

                    if (listaEmprestimo[i].DataDevolucaoPrevista.CompareTo(DateTime.Now) > 0)
                    {
                        dgvRelatorio[4, i].Value = "Não";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.Message.ToString());
            }
        }