Example #1
0
        protected void btnCertificado_Click(object sender, EventArgs e)
        {
            // Preenche os anos disponiveis, se tiver somente 1 ano ele é selecionado e não aparece na tela
            DataTable dt = ACA_AlunoHistoricoCertificadoBO.SelecionaAnosDisponiveis(VS_alu_id);

            if (dt.Rows.Count > 0)
            {
                ddlAnoHistorico.DataSource = dt;
                ddlAnoHistorico.DataBind();
                ddlAnoHistorico.Items.Insert(0, new ListItem(GetGlobalResourceObject("UserControl", "UCInformacoesComplementares.ddlAnoHistorico.Item0").ToString(), "-1"));

                if (dt.Rows.Count == 1)
                {
                    ddlAnoHistorico.SelectedIndex = 1;
                }
                else
                {
                    ddlAnoHistorico.SelectedIndex = 0;
                }

                // Limpa campos
                txtFolha.Text           = txtGDAE.Text = txtLivro.Text = txtNumero.Text = string.Empty;
                VS_alh_id               = -1;
                ddlAnoHistorico.Enabled = true;
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "AbreCertificado", "$(document).ready(function(){ $('.divCadastroCertificado').dialog('open'); });", true);
            }
            else
            {
                lblMessage.Text = UtilBO.GetErroMessage(GetGlobalResourceObject("UserControl", "UCInformacoesComplementares.lblMessage.ErroAnoHistorico").ToString(), UtilBO.TipoMensagem.Alerta);
            }
        }
Example #2
0
        protected void btnSalvarCertificado_Click(object sender, EventArgs ev)
        {
            if (Page.IsValid)
            {
                try
                {
                    ACA_AlunoHistoricoCertificado entity = ACA_AlunoHistoricoCertificadoBO.GetEntity(new ACA_AlunoHistoricoCertificado
                    {
                        alu_id = VS_alu_id
                        ,
                        alh_id = VS_alh_id > 0 ? VS_alh_id : Convert.ToInt32(ddlAnoHistorico.SelectedValue)
                    });

                    entity.ahc_numero   = txtNumero.Text;
                    entity.ahc_livro    = txtLivro.Text;
                    entity.ahc_folha    = txtFolha.Text;
                    entity.ahc_gdae     = txtGDAE.Text;
                    entity.ahc_situacao = 1;
                    entity.IsNew        = entity.IsNew;

                    if (ACA_AlunoHistoricoCertificadoBO.Save(entity))
                    {
                        ApplicationWEB._GravaLogSistema(VS_alh_id > 0 ? LOG_SistemaTipo.Update : LOG_SistemaTipo.Insert, string.Format("alu_id: {0} alh_id: {1} ", entity.alu_id, entity.alh_id));
                        lblMessage.Text = UtilBO.GetErroMessage(GetGlobalResourceObject("UserControl", VS_alh_id > 0 ? "UCInformacoesComplementares.btnSalvarCertificado.AlteradoSucesso" : "UCInformacoesComplementares.btnSalvarCertificado.SalvoSucesso").ToString()
                                                                , UtilBO.TipoMensagem.Sucesso);

                        ScriptManager.RegisterStartupScript(Page, typeof(Page), "FechaCertificado", "$(document).ready(function() { $('.divCadastroCertificado').dialog('close'); });", true);

                        btnCertificado.Visible = __SessionWEB.__UsuarioWEB.GrupoPermissao.grp_inserir &&
                                                 ACA_AlunoHistoricoCertificadoBO.SelecionaAnosDisponiveis(VS_alu_id).Rows.Count > 0;

                        // Recarrega os certificados.
                        grvCertificado.DataBind();
                        updCertificado.Update();
                    }
                }
                catch (ValidationException e)
                {
                    lblMessage.Text = UtilBO.GetErroMessage(e.Message, UtilBO.TipoMensagem.Alerta);
                }
                catch (ArgumentException e)
                {
                    lblMessage.Text = UtilBO.GetErroMessage(e.Message, UtilBO.TipoMensagem.Alerta);
                }
                catch (Exception ex)
                {
                    ApplicationWEB._GravaErro(ex);
                    lblMessage.Text = UtilBO.GetErroMessage(GetGlobalResourceObject("UserControl", "UCInformacoesComplementares.btnSalvarCertificado.ErroSalvar").ToString(), UtilBO.TipoMensagem.Erro);
                }
            }
        }
Example #3
0
        protected void grvCertificado_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Deletar")
            {
                try
                {
                    int  index  = int.Parse(e.CommandArgument.ToString());
                    long alu_id = Convert.ToInt64(grvCertificado.DataKeys[index].Values[0]);
                    int  alh_id = Convert.ToInt32(grvCertificado.DataKeys[index].Values[1]);

                    ACA_AlunoHistoricoCertificado entity = new ACA_AlunoHistoricoCertificado
                    {
                        alu_id = alu_id,
                        alh_id = alh_id
                    };
                    ACA_AlunoHistoricoCertificadoBO.GetEntity(entity);

                    if (ACA_AlunoHistoricoCertificadoBO.Delete(entity))
                    {
                        grvCertificado.PageIndex = 0;
                        grvCertificado.DataBind();

                        btnCertificado.Visible = __SessionWEB.__UsuarioWEB.GrupoPermissao.grp_inserir &&
                                                 ACA_AlunoHistoricoCertificadoBO.SelecionaAnosDisponiveis(VS_alu_id).Rows.Count > 0;

                        ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Delete, string.Format("alu_id: {0} alh_id: {1}", alu_id, alh_id));
                        lblMessage.Text = UtilBO.GetErroMessage(GetGlobalResourceObject("UserControl", "UCInformacoesComplementares.grvCertificado.ExcluidoSucesso").ToString(), UtilBO.TipoMensagem.Sucesso);
                    }
                }
                catch (ValidationException ex)
                {
                    lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta);
                }
                catch (Exception ex)
                {
                    ApplicationWEB._GravaErro(ex);
                    lblMessage.Text = UtilBO.GetErroMessage(GetGlobalResourceObject("UserControl", "UCInformacoesComplementares.grvCertificado.ExcluidoErro").ToString(), UtilBO.TipoMensagem.Erro);
                }
            }
            else if (e.CommandName == "Alterar")
            {
                try
                {
                    int index = int.Parse(e.CommandArgument.ToString());
                    VS_alu_id = Convert.ToInt64(grvCertificado.DataKeys[index].Values[0]);
                    VS_alh_id = Convert.ToInt32(grvCertificado.DataKeys[index].Values[1]);

                    ACA_AlunoHistoricoCertificado entity = new ACA_AlunoHistoricoCertificado
                    {
                        alu_id = VS_alu_id,
                        alh_id = VS_alh_id
                    };
                    ACA_AlunoHistoricoCertificadoBO.GetEntity(entity);

                    // Limpa campos
                    txtFolha.Text  = entity.ahc_folha;
                    txtGDAE.Text   = entity.ahc_gdae;
                    txtLivro.Text  = entity.ahc_livro;
                    txtNumero.Text = entity.ahc_numero;

                    ddlAnoHistorico.DataSource = ACA_AlunoHistoricoCertificadoBO.SelecionaAnosDisponiveis(VS_alu_id);
                    ddlAnoHistorico.DataBind();
                    ddlAnoHistorico.Items.Insert(0, new ListItem(GetGlobalResourceObject("UserControl", "UCInformacoesComplementares.ddlAnoHistorico.Item0").ToString(), "-1"));
                    ddlAnoHistorico.SelectedValue = entity.alh_id.ToString();
                    ddlAnoHistorico.Enabled       = false;
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "AbreCertificadoAlteracao", "$(document).ready(function(){ $('.divCadastroCertificado').dialog('open'); });", true);
                }
                catch (ValidationException ex)
                {
                    lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta);
                }
                catch (Exception ex)
                {
                    ApplicationWEB._GravaErro(ex);
                    lblMessage.Text = UtilBO.GetErroMessage(GetGlobalResourceObject("UserControl", "UCInformacoesComplementares.grvCertificado.ErroCarregarDados").ToString(), UtilBO.TipoMensagem.Erro);
                }
            }
        }