public void IncluirEmprestimo(Emprestimo emprestimo)
        {
            try
            {
                DAL.LeitorDAL dalLe = new DAL.LeitorDAL();
                DAL.LivroDAL  dalLi = new DAL.LivroDAL();
                dal = new DAL.EmprestimoDAL();

                if (dal.SelectEmprestimoByIdLivro(emprestimo.IdLivro) != null)
                {
                    throw new Exception("Livro emprestado, emprestimo cancelado");
                }

                if (dal.SelectEmprestimosByIdLeitor(emprestimo.IdLeitor).Count >= 5)
                {
                    throw new Exception("Leitor ja atingiu o limite de livros, emprestimo cancelado");
                }

                dal.InsertEmprestimo(emprestimo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void AlterarEmprestimo(Emprestimo emprestimo)
 {
     try
     {
         dal = new DAL.EmprestimoDAL();
         dal.UpdateEmprestimo(emprestimo);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public Emprestimo SelecionarEmprestimoPorIdLivro(int idLivro)
 {
     try
     {
         dal = new DAL.EmprestimoDAL();
         return(dal.SelecionarPorIdLivro(idLivro));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public List <Emprestimo> ListarEmprestimos()
 {
     try
     {
         dal = new DAL.EmprestimoDAL();
         return(dal.SelectListEmprestimos());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void ExcluirEmprestimo(Emprestimo emprestimo)
 {
     try
     {
         dal = new DAL.EmprestimoDAL();
         dal.DeleteEmprestimo(emprestimo);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public List <Emprestimo> SelecionarEmprestimoPorIdLeitor(int idLeitor)
 {
     try
     {
         dal = new DAL.EmprestimoDAL();
         return(dal.SelectEmprestimosByIdLeitor(idLeitor));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public Emprestimo SelecionarEmprestimoPorId(int id)
 {
     try
     {
         dal = new DAL.EmprestimoDAL();
         return(dal.SelectEmprestimoByID(id));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public DataTable SelecionarEmprestimos()
        {
            DataTable dt = new DataTable();

            try
            {
                dal = new DAL.EmprestimoDAL();
                dt  = dal.SelecionarEmprestimos();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(dt);
        }
 public void IncluirEmprestimo(Emprestimo emprestimo)
 {
     try
     {
         dal = new DAL.EmprestimoDAL();
         if (dal.LeitorCheio(emprestimo.IdLeitor)) // se o leitor já tem 5 livros
         {
             throw new Exception("Leitor já tem número máximo de livros!");
         }
         dal.InsertEmprestimo(emprestimo);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 10
0
 public void ExcluirLivro(Livro livro)
 {
     try
     {
         dal = new DAL.LivroDAL();
         DAL.EmprestimoDAL empDal = new DAL.EmprestimoDAL();
         if (empDal.LivroEmprestado(livro.IdLivro)) // se o livro estiver emprestado
         {
             throw new Exception("O livro está emprestado!");
         }
         dal.DeleteLivro(livro);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void ExcluirEmprestimo(Emprestimo emprestimo)
        {
            try
            {
                dal = new DAL.EmprestimoDAL();

                if (emprestimo.DataDevolucaoReal.CompareTo(DateTime.Now) > 0)
                {
                    throw new Exception("Impossivel excluir emprestimo, livro nao devolvido!");
                }

                dal.DeleteEmprestimo(emprestimo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 12
0
        public void ExcluirLeitor(int id)
        {
            try
            {
                dal = new DAL.LeitorDAL();

                DAL.EmprestimoDAL dalEmp = new DAL.EmprestimoDAL();

                if (dalEmp.LeitorTemLivro(id)) // se o leitor não tem livros emprestados
                {
                    throw new Exception("Leitor tem livros emprestados!");
                }
                dal.DeleteLeitor(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 13
0
        public void ExcluirLeitor(Leitor leitor)
        {
            try
            {
                DAL.EmprestimoDAL dalEm = new DAL.EmprestimoDAL();

                if (dalEm.SelectEmprestimosByIdLeitor(leitor.IdLeitor).Count > 0)
                {
                    throw new Exception("Leitor possui pendencias, Impossivel Exclui-lo");
                }

                dal = new DAL.LeitorDAL();
                dal.DeleteLeitor(leitor);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 14
0
        public void ExcluirLivro(Livro livro)
        {
            try
            {
                DAL.EmprestimoDAL dalEm = new DAL.EmprestimoDAL();

                if (dalEm.SelectEmprestimoByIdLivro(livro.IdLivro) != null)
                {
                    throw new Exception("O livro esta emprestado, nao e possivel excluir");
                }

                dal = new DAL.LivroDAL();
                dal.DeleteLivro(livro);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }