Esempio n. 1
0
        protected void FinalizarEmprestimo(object sender, EventArgs e)
        {
            Entity.Emprestimo loEmprestimoFinalizar = new Entity.Emprestimo(0, 0, string.Empty, string.Empty, DateTime.Today);
            string            lsMensagemOperacao    = string.Empty;

            if (HttpContext.Current.Session["selecao_emprestimo"] != null)
            {
                loEmprestimoFinalizar.EMP_id = Convert.ToInt32(HttpContext.Current.Session["selecao_emprestimo"].ToString());

                if (new Business.Emprestimo().RealizaDevolucao(loEmprestimoFinalizar, out lsMensagemOperacao))
                {
                    this.alert_topo_emprestimo.Visible  = true;
                    this.lbl_alert_topo_emprestimo.Text = "Este empréstimo foi finalizado! Agora o livro já está disponível para ser emprestado novamente!";
                    this.PreencheGridEmprestimosUsuario();
                    this.PreencheGridLivrosUsuario();
                }
                else
                {
                    this.alert_topo_erro_emprestimo.Visible  = true;
                    this.lbl_alert_topo_erro_emprestimo.Text = "Ocorreu um erro no servidor. Tente novamente mais tarde!";
                }
            }
            else
            {
                this.alert_topo_erro_emprestimo.Visible  = true;
                this.lbl_alert_topo_erro_emprestimo.Text = "Não foi possível finalizar o empréstimo. Tente novamente!";
            }
        }
Esempio n. 2
0
        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!";
            }
        }
Esempio n. 3
0
        protected void AlterarPrazo(object sender, EventArgs e)
        {
            string lsMensagemOperacao = string.Empty;

            Entity.Emprestimo loEmprestimoAlterar = new Entity.Emprestimo(0, 0, string.Empty, string.Empty, DateTime.ParseExact(this.txt_nova_data_prazo.Value.ToString(), "dd/MM/yyyy", null));
            if (HttpContext.Current.Session["selecao_emprestimo"] != null)
            {
                loEmprestimoAlterar.EMP_id = Convert.ToInt32(HttpContext.Current.Session["selecao_emprestimo"].ToString());

                if (new Business.Emprestimo().AlterarPrazo(loEmprestimoAlterar, out lsMensagemOperacao))
                {
                    this.alert_topo_emprestimo.Visible  = true;
                    this.lbl_alert_topo_emprestimo.Text = "O prazo de devolução do seu empréstimo foi alterado com sucesso!";
                    this.PreencheGridEmprestimosUsuario();
                }
                else
                {
                    this.alert_alterar_prazo.Visible  = true;
                    this.lbl_alert_alterar_prazo.Text = lsMensagemOperacao;
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "abrir_popup", "<script> $('#modal_alterar_prazo').modal('show'); </script>", false);
                }
            }
            else
            {
                this.alert_topo_erro_emprestimo.Visible  = true;
                this.lbl_alert_topo_erro_emprestimo.Text = "Não foi possível alterar o prazo. Tente novamente!";
            }
        }