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;
            }
        }
예제 #2
0
 public void AlterarLivro(Livro livro)
 {
     try
     {
         dal = new DAL.LivroDAL();
         dal.UpdateLivro(livro);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #3
0
 public void IncluirLivro(Livro livro)
 {
     try
     {
         dal = new DAL.LivroDAL();
         dal.InsertLivro(livro);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #4
0
 public Livro SelecionarLivroPorCodigo(string codigo)
 {
     try
     {
         dal = new DAL.LivroDAL();
         return(dal.SelectLivroByCodigo(codigo));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #5
0
 public Livro SelecionarLivroPorId(int id)
 {
     try
     {
         dal = new DAL.LivroDAL();
         return(dal.SelectByID(id));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #6
0
 public List <Livro> ListarLivros()
 {
     try
     {
         dal = new DAL.LivroDAL();
         return(dal.SelectListLivros());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #7
0
        public DataTable SelecionarLivros()
        {
            DataTable dt = new DataTable();

            try {
                dal = new DAL.LivroDAL();
                dt  = dal.SelectLivros();
            }

            catch (Exception ex)
            {
                throw ex;
            }
            return(dt);
        }
예제 #8
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;
     }
 }
예제 #9
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;
            }
        }