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 AlterarLeitor(Leitor leitor) { try { dal = new DAL.LeitorDAL(); dal.UpdateLeitor(leitor); } catch (Exception ex) { throw ex; } }
public void IncluirLeitor(Leitor leitor) { try { dal = new DAL.LeitorDAL(); dal.InsertLeitor(leitor); } catch (Exception ex) { throw ex; } }
public Leitor SelecionarLeitorPorNome(string nome) { try { dal = new DAL.LeitorDAL(); return(dal.SelectLeitorByNome(nome)); } catch (Exception ex) { throw ex; } }
public Leitor SelecionarLeitorPorId(int id) { try { dal = new DAL.LeitorDAL(); return(dal.SelectByID(id)); } catch (Exception ex) { throw ex; } }
public List <Leitor> ListarLeitores() { try { dal = new DAL.LeitorDAL(); return(dal.SelectListLeitores()); } catch (Exception ex) { throw ex; } }
public DataTable SelecionarLeitor() { DataTable dt = new DataTable(); try { dal = new DAL.LeitorDAL(); dt = dal.SelectLeitores(); } catch (Exception ex) { throw ex; } return(dt); }
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; } }
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; } }