示例#1
0
        protected void grvObservacao_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Deletar")
            {
                try
                {
                    int  index  = int.Parse(e.CommandArgument.ToString());
                    long alu_id = Convert.ToInt64(grvObservacao.DataKeys[index].Values[0]);
                    int  aho_id = Convert.ToInt32(grvObservacao.DataKeys[index].Values[1]);

                    ACA_AlunoHistoricoObservacao entity = new ACA_AlunoHistoricoObservacao
                    {
                        alu_id = alu_id,
                        aho_id = aho_id
                    };
                    ACA_AlunoHistoricoObservacaoBO.GetEntity(entity);

                    if (ACA_AlunoHistoricoObservacaoBO.Delete(entity))
                    {
                        grvObservacao.PageIndex = 0;
                        grvObservacao.DataBind();
                        ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Delete, string.Format("alu_id: {0} aho_id: {1}", alu_id, aho_id));
                        lblMessage.Text = UtilBO.GetErroMessage(GetGlobalResourceObject("UserControl", "UCInformacoesComplementares.grvObservacao.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.grvObservacao.ExcluidoErro").ToString(), UtilBO.TipoMensagem.Erro);
                }
            }
            else if (e.CommandName == "Alterar")
            {
                try
                {
                    int index = int.Parse(e.CommandArgument.ToString());
                    VS_alu_id = Convert.ToInt64(grvObservacao.DataKeys[index].Values[0]);
                    VS_aho_id = Convert.ToInt32(grvObservacao.DataKeys[index].Values[1]);

                    ACA_AlunoHistoricoObservacao entity = new ACA_AlunoHistoricoObservacao
                    {
                        alu_id = VS_alu_id,
                        aho_id = VS_aho_id
                    };
                    ACA_AlunoHistoricoObservacaoBO.GetEntity(entity);

                    txtObservacaoHtml.Text = entity.aho_observacao;

                    DataTable dtObsPadrao = ACA_HistoricoObservacaoPadraoBO.SelecionaPorTipo(Convert.ToInt32(ACA_HistoricoObservacaoPadraoTipo.Observacao));

                    rptObservacoesPadroes.DataSource = dtObsPadrao;
                    rptObservacoesPadroes.DataBind();

                    divObsPadrao.Visible = dtObsPadrao.Rows.Count > 0;

                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "AbreObservacaoAlteracao", "$(document).ready(function(){ $('.divCadastroObservacao').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.grvObservacao.ErroCarregarDados").ToString(), UtilBO.TipoMensagem.Erro);
                }
            }
        }