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