protected void grvConfig_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridView grv = ((GridView)sender); try { CFG_Configuracao entityConfiguracao = new CFG_Configuracao() { IsNew = Boolean.Parse(grv.DataKeys[e.RowIndex]["IsNew"].ToString()) , cfg_id = new Guid(grv.DataKeys[e.RowIndex]["cfg_id"].ToString()) , cfg_situacao = Byte.Parse(grv.DataKeys[e.RowIndex]["cfg_situacao"].ToString()) }; TextBox txtValor = (TextBox)grvConfig.Rows[e.RowIndex].FindControl("txtValor"); if (txtValor != null) { entityConfiguracao.cfg_valor = txtValor.Text; } TextBox txtDescricao = (TextBox)grvConfig.Rows[e.RowIndex].FindControl("txtDescricao"); if (txtDescricao != null) { entityConfiguracao.cfg_descricao = txtDescricao.Text; } TextBox txtChave = (TextBox)grvConfig.Rows[e.RowIndex].FindControl("txtChave"); if (txtChave != null) { entityConfiguracao.cfg_chave = txtChave.Text; } if (CFG_ConfiguracaoBO.Salvar(entityConfiguracao)) { if (Boolean.Parse(grv.DataKeys[e.RowIndex]["IsNew"].ToString())) { ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Insert, "cfg_id: " + entityConfiguracao.cfg_id); lblMessage.Text = UtilBO.GetErroMessage("Configuração incluída com sucesso.", UtilBO.TipoMensagem.Sucesso); } else { ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "cfg_id: " + entityConfiguracao.cfg_id); lblMessage.Text = UtilBO.GetErroMessage("Configuração alterada com sucesso.", UtilBO.TipoMensagem.Sucesso); } ApplicationWEB.RecarregarConfiguracoes(); grv.EditIndex = -1; grv.DataBind(); } } catch (CoreLibrary.Validation.Exceptions.ValidationException ex) { lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta); } catch (DuplicateNameException ex) { lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta); } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar salvar configuração.", UtilBO.TipoMensagem.Erro); } finally { updMessage.Update(); } }