Пример #1
0
 protected void grvParametro_DataBinding(object sender, EventArgs e)
 {
     try
     {
         GridView grv = ((GridView)sender);
         if (grv.DataSource == null)
         {
             grv.DataSource = CFG_ParametroMensagemBO.GetSelect();
         }
     }
     catch (Exception ex)
     {
         ApplicationWEB._GravaErro(ex);
         _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar carregar parâmetros de mensagem.", UtilBO.TipoMensagem.Erro);
         _updMessage.Update();
     }
 }
Пример #2
0
        protected void grvParametro_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            GridView grv = ((GridView)sender);

            try
            {
                if (!Boolean.Parse(grv.DataKeys[e.RowIndex]["IsNew"].ToString()))
                {
                    CFG_ParametroMensagem entity = new CFG_ParametroMensagem
                    {
                        pms_id = Convert.ToInt32(grv.DataKeys[e.RowIndex]["pms_id"])
                        ,
                        pms_situacao = Byte.Parse(grv.DataKeys[e.RowIndex]["pms_situacao"].ToString())
                    };

                    if (CFG_ParametroMensagemBO.Delete(entity))
                    {
                        ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Delete, "pms_id: " + entity.pms_id);
                        _lblMessage.Text = UtilBO.GetErroMessage("Parâmetro de mensagem excluído com sucesso.", UtilBO.TipoMensagem.Sucesso);

                        ApplicationWEB.RecarregarConfiguracoes();
                        grv.DataBind();
                    }
                }
            }
            catch (ValidationException ex)
            {
                _lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta);
            }
            catch (Exception ex)
            {
                ApplicationWEB._GravaErro(ex);
                _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar excluir parâmetro de mensagem.", UtilBO.TipoMensagem.Erro);
            }
            finally
            {
                _updMessage.Update();
            }
        }
Пример #3
0
        protected void _btnNovo_Click(object sender, EventArgs e)
        {
            try
            {
                List <CFG_ParametroMensagem> parametros = CFG_ParametroMensagemBO.GetSelect().ToList();
                parametros.Add(new CFG_ParametroMensagem
                {
                    IsNew = true
                    ,
                    pms_id = -1
                    ,
                    pms_chave = ""
                    ,
                    pms_descricao = ""
                    ,
                    pms_valor = ""
                    ,
                    pms_tela = (byte)CFG_ParametroMensagemTela.PlanejamentoAnual
                    ,
                    pms_situacao = (Byte)CFG_ParametroMensagemSituacao.Ativo
                });

                int index = (parametros.Count - 1);
                grvParametro.EditIndex  = index;
                grvParametro.DataSource = parametros;
                grvParametro.DataBind();

                ImageButton imgEditar = (ImageButton)grvParametro.Rows[index].FindControl("_imgEditar");
                if (imgEditar != null)
                {
                    imgEditar.Visible = false;
                }
                ImageButton imgSalvar = (ImageButton)grvParametro.Rows[index].FindControl("_imgSalvar");
                if (imgSalvar != null)
                {
                    imgSalvar.Visible = true;
                }
                ImageButton imgCancelar = (ImageButton)grvParametro.Rows[index].FindControl("_imgCancelarParametro");
                if (imgCancelar != null)
                {
                    imgCancelar.Visible = true;
                }

                ImageButton imgExcluir = (ImageButton)grvParametro.Rows[index].FindControl("_imgExcluir");
                if (imgExcluir != null)
                {
                    imgExcluir.Visible = false;
                }

                TextBox txtChave = (TextBox)grvParametro.Rows[index].FindControl("_txtChave");
                if (txtChave != null)
                {
                    txtChave.Text = "MSG_";
                }

                txtChave.Enabled  = true;
                txtChave.ReadOnly = false;

                string script = String.Format("SetConfirmDialogLoader('{0}','{1}');", String.Concat("#", imgExcluir.ClientID), "Confirma a exclusão?");
                Page.ClientScript.RegisterStartupScript(GetType(), imgExcluir.ClientID, script, true);

                grvParametro.Rows[index].Focus();
            }
            catch (Exception ex)
            {
                ApplicationWEB._GravaErro(ex);
                _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar adicionar novo parâmetro de mensagem.", UtilBO.TipoMensagem.Erro);
                _updMessage.Update();
            }
        }
Пример #4
0
        protected void grvParametro_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridView grv = ((GridView)sender);

            try
            {
                CFG_ParametroMensagem entity = new CFG_ParametroMensagem
                {
                    pms_id = Convert.ToInt32(grv.DataKeys[e.RowIndex]["pms_id"])
                };

                CFG_ParametroMensagemBO.GetEntity(entity);

                if (entity.IsNew)
                {
                    entity.pms_situacao = (Byte)CFG_ParametroMensagemSituacao.Ativo;
                    entity.pms_chave    = txtChaveText;
                }

                entity.pms_tela = 0;

                TextBox txtDescricao = (TextBox)grvParametro.Rows[e.RowIndex].FindControl("_txtDescricao");
                if (txtDescricao != null)
                {
                    entity.pms_descricao = txtDescricao.Text;
                }

                TextBox txtValor = (TextBox)grvParametro.Rows[e.RowIndex].FindControl("_txtValor");
                if (txtValor != null)
                {
                    entity.pms_valor = txtValor.Text;
                }

                if (entity.IsNew && CFG_ParametroMensagemBO.VerificaParametroExistente(entity.pms_chave))
                {
                    _lblMessage.Text = UtilBO.GetErroMessage("Já existe um parâmetro com a mesma chave cadastrado no sistema.",
                                                             UtilBO.TipoMensagem.Alerta);
                    grv.EditIndex = -1;
                    grv.DataBind();
                }
                else if (CFG_ParametroMensagemBO.Save(entity))
                {
                    CFG_ParametroMensagemBO.RecarregaParametrosAtivos();

                    if (Boolean.Parse(grv.DataKeys[e.RowIndex]["IsNew"].ToString()))
                    {
                        ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Insert, "pms_id: " + entity.pms_id);
                        _lblMessage.Text = UtilBO.GetErroMessage("Parâmetro de mensagem incluído com sucesso.", UtilBO.TipoMensagem.Sucesso);
                    }
                    else
                    {
                        ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "pms_id: " + entity.pms_id);
                        _lblMessage.Text = UtilBO.GetErroMessage("Parâmetro de mensagem alterado com sucesso.", UtilBO.TipoMensagem.Sucesso);
                    }
                    ApplicationWEB.RecarregarConfiguracoes();
                    grv.EditIndex = -1;
                    grv.DataBind();
                }
            }
            catch (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 parâmetro.", UtilBO.TipoMensagem.Erro);
            }
            finally
            {
                _updMessage.Update();
            }
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                ScriptManager sm = ScriptManager.GetCurrent(this);
                if (sm != null)
                {
                    sm.Scripts.Add(new ScriptReference(ArquivoJS.MsgConfirmBtn));
                }

                string mensagemFlash = CFG_ParametroMensagemBO.RetornaValor(CFG_ParametroMensagemChave.CAPTURA_REQUERFLASH);
                lblMessageFlash.Text    = UtilBO.GetErroMessage(mensagemFlash, UtilBO.TipoMensagem.Informacao);
                lblMessageFlash.Visible = !String.IsNullOrEmpty(mensagemFlash);
                if (Session["alu_id"] != null)
                {
                    if (Session["PaginaRetorno_CapturaFoto"] != null)
                    {
                        VS_PaginaRetorno = Session["PaginaRetorno_CapturaFoto"].ToString();
                        Session.Remove("PaginaRetorno_CapturaFoto");
                        VS_DadosPaginaRetorno = Session["DadosPaginaRetorno"];
                        Session.Remove("DadosPaginaRetorno");

                        VS_DadosPaginaRetorno_MinhasTurmas = Session["VS_DadosTurmas"];
                        Session.Remove("VS_DadosTurmas");
                    }

                    VS_alu_id = Convert.ToInt64(Session["alu_id"].ToString());
                    Session.Remove("alu_id");
                    busca = false;
                }

                if (((PreviousPage != null) && (PreviousPage.EditItem > 0)) || VS_alu_id != -1)
                {
                    if (VS_alu_id == -1)
                    {
                        VS_alu_id = PreviousPage.EditItem;
                    }

                    InfoComplementarAluno1.InformacaoComplementarAluno(VS_alu_id);

                    ACA_Aluno alu = new ACA_Aluno
                    {
                        alu_id = VS_alu_id
                    };
                    ACA_AlunoBO.GetEntity(alu);

                    PES_Pessoa pes = new PES_Pessoa
                    {
                        pes_id = alu.pes_id
                    };
                    PES_PessoaBO.GetEntity(pes);

                    CFG_Arquivo entFoto;
                    string      src = CriaFotoAluno(pes, out entFoto);

                    imgAntiga.Visible   = !string.IsNullOrEmpty(src) && string.IsNullOrEmpty(hdnArqExcluir.Value);
                    lblDataFoto.Visible = imgAntiga.Visible;

                    if (imgAntiga.Visible)
                    {
                        const string script = "var existeImagem = true;";
                        Page.ClientScript.RegisterStartupScript(typeof(Page), "confirm", script, true);

                        imgAntiga.Src = src;
                        imgAntiga.Style.Remove("display");
                        lblDataFoto.Text = @"<br />Última alteração da foto: " + entFoto.arq_dataAlteracao.ToString("dd/MM/yyyy");
                    }
                    else
                    {
                        imgAntiga.Src = "";
                        imgAntiga.Style.Add("display", "none");
                    }
                }
                else
                {
                    Redireciona();
                }
            }
            catch (Exception ex)
            {
                ApplicationWEB._GravaErro(ex);
                lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar carregar o sistema.", UtilBO.TipoMensagem.Erro);
            }
        }