Ejemplo n.º 1
0
        private void btnDevolver_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtId.Text.Trim() == "")
                {
                    throw new Exception("id vazio");
                }

                EmprestimoBLL bll = new EmprestimoBLL();
                Emprestimo    emp = bll.SelecionarEmprestimoPorId(int.Parse(txtId.Text)); // selecionamos o emprestimo escolhido

                if (emp.DataDevolucaoReal != Convert.ToDateTime("01/01/1900"))            // se o emprestimo ja foi devolvido
                {
                    throw new Exception("Livro já devolvido!");
                }


                emp.DataDevolucaoReal = DateTime.Now; // atribuimos ao emprestimo a data atual
                bll.AlterarEmprestimo(emp);           // alteramos o emprestimo com a nova data, ficando assim 'devolvido'

                if (emp.DataDevolucaoReal > emp.DataDevolucaoPrevista)
                {
                    MessageBox.Show("Livro devolvido com atraso!");
                }
                else
                {
                    MessageBox.Show("Livro devolvido no prazo");
                }
            }
            catch (Exception ex) {
                MessageBox.Show("Erro: " + ex.Message.ToString());
            }
        }
Ejemplo n.º 2
0
        private void btnProcurarDev_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtId.Text.Trim() == "") // se o text box do id esta vazio
                {
                    throw new Exception("Id vazio");
                }

                EmprestimoBLL bll = new EmprestimoBLL();
                Emprestimo    emp = bll.SelecionarEmprestimoPorId(int.Parse(txtId.Text)); // selecionamos o emprestimo escolhido

                txtIdLivroDev.Text  = emp.IdLivro.ToString();                             // exibimos suas informacoes
                txtIdLeitorDev.Text = emp.IdLeitor.ToString();
                txtDataDevPrev.Text = emp.DataDevolucaoPrevista.ToString();
                txtDataEmpDev.Text  = emp.DataEmprestimo.ToString();

                if (emp.DataDevolucaoReal != Convert.ToDateTime("01/01/1900"))
                {
                    chkDevolvido.Checked = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.Message.ToString());
            }
        }
 public FrmConsultarEmprestimo()
 {
     InitializeComponent();
     emprestimo    = new Emprestimo();
     emprestimoBLL = new EmprestimoBLL();
     AtualizarGrid();
     btnCancelar.Enabled  = false;
     btnDevolucao.Enabled = false;
 }
 public FrmCadastrarEmprestimo()
 {
     InitializeComponent();
     emprestimo        = new Emprestimo();
     emprestimoBLL     = new EmprestimoBLL();
     leitorBLL         = new LeitorBLL();
     livroBLL          = new LivroBLL();
     txtRetirada.Text  = DateTime.Now.ToShortDateString();
     txtDevolucao.Text = DateTime.Now.AddDays(7).ToShortDateString();
 }
Ejemplo n.º 5
0
 private void tabControl1_Click(object sender, EventArgs e)
 {
     try
     {
         EmprestimoBLL bll = new EmprestimoBLL();
         dgvDados.DataSource = bll.SelecionarEmprestimos();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Erro: " + ex.Message.ToString());
     }
 }
Ejemplo n.º 6
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            Emprestimo emp = null;

            try
            {
                EmprestimoBLL empBll = new EmprestimoBLL();
                emp = empBll.SelecionarEmprestimoPorId(int.Parse(txtIdEmp.Text)); // atribuimos ao objeto 'emp' o emprestimo escolhido
                btnProcurar.PerformClick();                                       // exibimos as informações do emprestimo
                empBll.ExcluirEmprestimo(emp);                                    // excluimos
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.Message.ToString());
            }
        }
Ejemplo n.º 7
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            Emprestimo empAlterado = new Emprestimo(int.Parse(txtIdLeitor.Text),
                                                    int.Parse(txtIdLeitor.Text),
                                                    Convert.ToDateTime(mtxtDataEmp.Text),
                                                    Convert.ToDateTime(mtxtDataDev.Text));

            try
            {
                EmprestimoBLL empBLL = new EmprestimoBLL();
                empBLL.AlterarEmprestimo(empAlterado);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.Message.ToString());
            }
        }
Ejemplo n.º 8
0
        private void btnNovo_Click(object sender, EventArgs e)
        {
            Emprestimo novoEmp = new Emprestimo(int.Parse(txtIdLivro.Text), // instancia um novo obj emprestimo
                                                int.Parse(txtIdLeitor.Text),
                                                DateTime.Parse(mtxtDataEmp.Text),
                                                DateTime.Parse(mtxtDataDev.Text));

            try
            {
                EmprestimoBLL empBLL = new EmprestimoBLL();
                empBLL.IncluirEmprestimo(novoEmp);                  // inclui o emprestimo
                MessageBox.Show("Empréstimo incluído com sucesso"); // se deu certo, avisamos ao usuario
                limparTela();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.Message.ToString());
            }
        }
Ejemplo n.º 9
0
        private void btnProcurar_Click(object sender, EventArgs e)
        {
            Emprestimo emp = null;

            try
            {
                EmprestimoBLL bll = new EmprestimoBLL();
                emp = bll.SelecionarEmprestimoPorId(int.Parse(txtIdEmp.Text)); // selecionamos o emprestimo escolhido

                txtIdLeitor.Text = emp.IdLeitor.ToString();                    // exibimos suas informacoes
                txtIdLivro.Text  = emp.IdLivro.ToString();
                mtxtDataEmp.Text = emp.DataEmprestimo.ToString();
                mtxtDataDev.Text = emp.DataDevolucaoPrevista.ToString();

                if (emp.DataDevolucaoReal != Convert.ToDateTime("01/01/1900")) // se a data de devoluvcao real for diferente da padrão
                {
                    chkDev.Checked = true;                                     // quer dizer que ja foi devolvido
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.Message.ToString());
            }
        }
Ejemplo n.º 10
0
 public FrmDevolucao()
 {
     InitializeComponent();
     emprestimo    = new Emprestimo();
     emprestimoBLL = new EmprestimoBLL();
 }