protected void AtualizarLivro(object sender, EventArgs e) { Entity.Usuario loUsuarioAlterarLivro = new Entity.Usuario(string.Empty, string.Empty, string.Empty, string.Empty); loUsuarioAlterarLivro.USR_id = (int)Session["ID_Usuario"]; Entity.Livro loAlterarLivro = new Entity.Livro(this.txt_editar_livro_nome.Value.ToString(), loUsuarioAlterarLivro.USR_id); if (HttpContext.Current.Session["selecao_livro"] != null) { loAlterarLivro.LVR_id = Convert.ToInt32(HttpContext.Current.Session["selecao_livro"].ToString()); string lsMensagemOperacao = string.Empty; if (!new Business.Livro().AlterarLivro(loAlterarLivro, out lsMensagemOperacao)) { this.div_msg_alterar_livro.Visible = true; this.lbl_msg_alterar_livro.Text = lsMensagemOperacao; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "abrir_popup", "<script> $('#edit').modal('show'); </script>", false); } else { this.alert_topo_livro.Visible = true; this.lbl_alert_topo_livro.Text = "Seu livro foi alterado com sucesso!"; this.PreencheGridLivrosUsuario(); } } else { this.alert_erro_topo_livro.Visible = true; this.lbl_alert_erro_topo_livro.Text = "Não foi possível atualizar o livro. Tente novamente!"; } }
protected void EmprestarLivro(object sender, EventArgs e) { Entity.Usuario loUsuarioEmprestimo = new Entity.Usuario(string.Empty, string.Empty, string.Empty, string.Empty); loUsuarioEmprestimo.USR_id = (int)Session["ID_Usuario"]; string lsMensagemOperacao = string.Empty; Entity.Livro loLivroEmprestimo = new Entity.Livro(string.Empty, loUsuarioEmprestimo.USR_id); if (HttpContext.Current.Session["selecao_livro"] != null) { loLivroEmprestimo.LVR_id = Convert.ToInt32(HttpContext.Current.Session["selecao_livro"].ToString()); Entity.Emprestimo loNovoEmprestimo = new Entity.Emprestimo(loLivroEmprestimo.LVR_id, loUsuarioEmprestimo.USR_id, this.txt_email_emprestante.Value.ToString(), this.txt_nome_emprestante.Value.ToString(), Convert.ToDateTime(this.txt_nova_data.Value.ToString())); if (new Business.Emprestimo().InserirNovoEmprestimo(loLivroEmprestimo, loNovoEmprestimo, out lsMensagemOperacao)) { this.alert_topo_livro.Visible = true; this.lbl_alert_topo_livro.Text = "Seu livro foi emprestado com sucesso. Você pode conferir na aba de Empréstimos!"; this.PreencheGridLivrosUsuario(); this.PreencheGridEmprestimosUsuario(); } else { this.div_msg_emprestimo.Visible = true; this.lbl_emprestimo.Text = lsMensagemOperacao; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "abrir_popup", "<script> $('#modal_novo_emprestimo').modal('show'); </script>", false); } } else { this.alert_erro_topo_livro.Visible = true; this.lbl_alert_erro_topo_livro.Text = "Não foi possível emprestar o livro. Tente novamente!"; } }
protected void ExcluirLivro(object sender, EventArgs e) { string lsMensagem = string.Empty; Entity.Livro loExcluirLivro = new Entity.Livro(string.Empty, 0); if (HttpContext.Current.Session["selecao_livro"] != null) { loExcluirLivro.LVR_id = Convert.ToInt32(HttpContext.Current.Session["selecao_livro"].ToString()); if (new Business.Livro().RemoverLivro(loExcluirLivro, out lsMensagem)) { this.alert_topo_livro.Visible = true; this.lbl_alert_topo_livro.Text = "Seu livro foi excluido com sucesso!"; } else { this.alert_erro_topo_livro.Visible = true; this.lbl_alert_erro_topo_livro.Text = "Ocorreu um erro no servidor. Tente novamente mais tarde!"; } this.PreencheGridLivrosUsuario(); } else { this.alert_erro_topo_livro.Visible = true; this.lbl_alert_erro_topo_livro.Text = "Não foi possível excluir o livro. Tente novamente!"; } }
protected void CadastrarLivro(object sender, EventArgs e) { Entity.Usuario loUsuarioLivro = new Entity.Usuario(string.Empty, string.Empty, string.Empty, string.Empty); loUsuarioLivro.USR_id = (int)Session["ID_Usuario"]; Entity.Livro loNovoLivro = new Entity.Livro(this.txt_nome_livro.Text.ToString(), loUsuarioLivro.USR_id); loNovoLivro.LVR_emprestado = false; string lsMensagemOperacao = string.Empty; if (!new Business.Livro().InserirNovoLivro(loNovoLivro, loUsuarioLivro, out lsMensagemOperacao)) { this.div_mensagem_livro.Visible = true; this.lbl_mensagem_livro.Text = lsMensagemOperacao; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "abrir_popup", "<script> $('#modal_novo_livro').modal('show'); </script>", false); } else { this.alert_topo_livro.Visible = true; this.lbl_alert_topo_livro.Text = "Seu livro foi cadastrado com sucesso!"; this.PreencheGridLivrosUsuario(); } }