예제 #1
0
    protected void _dgvTipoDeficiencia_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Deletar")
        {
            try
            {
                int  index  = int.Parse(e.CommandArgument.ToString());
                Guid tde_id = new Guid(_dgvTipoDeficiencia.DataKeys[index].Value.ToString());

                PES_TipoDeficiencia EntityTipoDeficiencia = new PES_TipoDeficiencia {
                    tde_id = tde_id
                };
                PES_TipoDeficienciaBO.GetEntity(EntityTipoDeficiencia);

                if (PES_TipoDeficienciaBO.Delete(EntityTipoDeficiencia))
                {
                    _dgvTipoDeficiencia.PageIndex = 0;
                    _dgvTipoDeficiencia.DataBind();
                    ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Delete, "tde_id: " + tde_id);
                    _lblMessage.Text = UtilBO.GetErroMessage("Tipo de deficiência excluída com sucesso.", UtilBO.TipoMensagem.Sucesso);
                }
                else
                {
                    _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar excluir o tipo de deficiência.", UtilBO.TipoMensagem.Erro);
                }
            }
            catch (Exception ex)
            {
                ApplicationWEB._GravaErro(ex);
                _lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Erro);
            }
        }
    }
예제 #2
0
    protected void _Salvar()
    {
        try
        {
            PES_TipoDeficiencia TipoDeficiencia = new PES_TipoDeficiencia
            {
                tde_id = _VS_tde_id
                ,
                tde_nome = _txtTipoDeficiencia.Text
                ,
                tde_situacao = (_ckbBloqueado.Checked ? Convert.ToByte(2) : Convert.ToByte(1))
                ,
                IsNew = (_VS_tde_id != Guid.Empty) ? false : true
            };

            if (PES_TipoDeficienciaBO.Save(TipoDeficiencia))
            {
                if (_VS_tde_id != Guid.Empty)
                {
                    ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "tde_id:" + TipoDeficiencia.tde_id);
                    __SessionWEB.PostMessages = UtilBO.GetErroMessage("Tipo de deficiência alterado com sucesso.", UtilBO.TipoMensagem.Sucesso);
                }
                else
                {
                    ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Insert, "tde_id:" + TipoDeficiencia.tde_id);
                    __SessionWEB.PostMessages = UtilBO.GetErroMessage("Tipo de deficiência incluído com sucesso.", UtilBO.TipoMensagem.Sucesso);
                }

                Response.Redirect(__SessionWEB._AreaAtual._Diretorio + "TipoDeficiencia/Busca.aspx", false);
            }
            else
            {
                _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar salvar o tipo de deficiência.", UtilBO.TipoMensagem.Erro);
            }
        }
        catch (CoreLibrary.Validation.Exceptions.ValidationException e)
        {
            _lblMessage.Text = UtilBO.GetErroMessage(e.Message, UtilBO.TipoMensagem.Alerta);
        }
        catch (DuplicateNameException e)
        {
            _lblMessage.Text = UtilBO.GetErroMessage(e.Message, UtilBO.TipoMensagem.Alerta);
        }
        catch (ArgumentException e)
        {
            _lblMessage.Text = UtilBO.GetErroMessage(e.Message, UtilBO.TipoMensagem.Alerta);
        }
        catch (Exception e)
        {
            ApplicationWEB._GravaErro(e);
            _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar salvar o tipo de deficiência.", UtilBO.TipoMensagem.Erro);
        }
    }
예제 #3
0
 private void _LoadFromEntity(Guid tde_id)
 {
     try
     {
         PES_TipoDeficiencia TipoDeficiencia = new PES_TipoDeficiencia {
             tde_id = tde_id
         };
         PES_TipoDeficienciaBO.GetEntity(TipoDeficiencia);
         _VS_tde_id = TipoDeficiencia.tde_id;
         _txtTipoDeficiencia.Text = TipoDeficiencia.tde_nome;
         _ckbBloqueado.Checked    = !TipoDeficiencia.tde_situacao.Equals(1);
         _ckbBloqueado.Visible    = true;
     }
     catch (Exception e)
     {
         ApplicationWEB._GravaErro(e);
         _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar carregar o tipo de deficiência.", UtilBO.TipoMensagem.Erro);
     }
 }
예제 #4
0
        private string RetornaValorDetalhadoFiltroFixo(int valor)
        {
            string retorno = string.Empty;

            string[] vetor = { };
            if (valor > 0)
            {
                switch (valor)
                {
                case 1:
                    vetor[0] = txtDtInicial.Text;
                    vetor[1] = txtDtFinal.Text;
                    break;

                case 2:
                    vetor[0] = UCComboRacaCor._Combo.SelectedItem.Text;
                    break;

                case 3:
                    vetor[0] = txtIdadeInicial.Text;
                    vetor[1] = txtIdadeFinal.Text;
                    break;

                case 4:
                    vetor[0] = UCComboSexo._Combo.SelectedItem.Text;
                    break;

                default:
                    PES_TipoDeficiencia deficiencia = PES_TipoDeficienciaBO.GetEntity(new PES_TipoDeficiencia {
                        tde_id = ComboTipoDeficiencia.Valor
                    });
                    List <CFG_DeficienciaDetalhe> detalhes = CarregaDetalhePreenchidos();

                    vetor = detalhes.Select(x => x.dfd_nome.ToString()).ToArray();

                    break;
                }

                retorno = string.Join(",", vetor);
            }
            return(retorno);
        }
예제 #5
0
        private string RetornaValorFiltroFixo(int valor)
        {
            string        retorno = string.Empty;
            List <string> valores = new List <string>();

            if (valor > 0)
            {
                switch (valor)
                {
                case 1:
                    valores.Add(txtDtInicial.Text);
                    valores.Add(txtDtFinal.Text);
                    break;

                case 2:
                    valores.Add(UCComboRacaCor.Valor.ToString());
                    break;

                case 3:
                    valores.Add(txtIdadeInicial.Text);
                    valores.Add(txtIdadeFinal.Text);
                    break;

                case 4:
                    valores.Add(UCComboSexo.Valor.ToString());
                    break;

                default:
                    PES_TipoDeficiencia deficiencia = PES_TipoDeficienciaBO.GetEntity(new PES_TipoDeficiencia {
                        tde_id = ComboTipoDeficiencia.Valor
                    });
                    List <CFG_DeficienciaDetalhe> detalhes = CarregaDetalhePreenchidos();

                    valores = detalhes.Select(x => x.dfd_id.ToString()).ToList();

                    break;
                }

                retorno = string.Join(",", valores.ToArray());
            }
            return(retorno);
        }
예제 #6
0
        private void ValidaCamposFiltroFixo(int valor)
        {
            if (valor > 0)
            {
                switch (valor)
                {
                case 1:
                    if (String.IsNullOrEmpty(txtDtInicial.Text))
                    {
                        throw new ValidationException("Data inicial é obrigatório.");
                    }
                    if (String.IsNullOrEmpty(txtDtFinal.Text))
                    {
                        throw new ValidationException("Data final é obrigatório.");
                    }
                    DateTime dtInicial, dtFinal;
                    if (DateTime.TryParse(txtDtInicial.Text, out dtInicial) && DateTime.TryParse(txtDtFinal.Text, out dtFinal))
                    {
                        if (dtInicial >= dtFinal)
                        {
                            throw new ValidationException("Data inicial deve ser menor que a data final.");
                        }
                    }
                    else
                    {
                        throw new ValidationException("Data inválida.");
                    }
                    break;

                case 2:
                    if (UCComboRacaCor.Valor <= 0)
                    {
                        throw new ValidationException("Raça/Cor é obrigatório.");
                    }
                    break;

                case 3:
                    if (String.IsNullOrEmpty(txtIdadeInicial.Text))
                    {
                        throw new ValidationException("Idade mínima é obrigatório.");
                    }
                    if (String.IsNullOrEmpty(txtIdadeFinal.Text))
                    {
                        throw new ValidationException("Idade máxima é obrigatório.");
                    }
                    int idMin, idMax;
                    if (Int32.TryParse(txtIdadeInicial.Text, out idMin) && Int32.TryParse(txtIdadeFinal.Text, out idMax))
                    {
                        if (idMin >= idMax)
                        {
                            throw new ValidationException("Idade mínima deve ser menor que idade máxima.");
                        }
                    }
                    else
                    {
                        throw new ValidationException("Idade inválida.");
                    }
                    break;

                case 4:
                    if (UCComboSexo.Valor <= 0)
                    {
                        throw new ValidationException("Sexo é obrigatório.");
                    }
                    break;

                default:
                    if (ComboTipoDeficiencia.Valor == Guid.Empty)
                    {
                        throw new ValidationException("Tipo de deficiência é obrigatório.");
                    }
                    PES_TipoDeficiencia deficiencia = PES_TipoDeficienciaBO.GetEntity(new PES_TipoDeficiencia {
                        tde_id = ComboTipoDeficiencia.Valor
                    });
                    List <CFG_DeficienciaDetalhe> detalhes = CarregaDetalhePreenchidos();

                    if (detalhes.Select(x => x.dfd_id.ToString()).ToList().Count <= 0)
                    {
                        throw new ValidationException("É obrigatório selecionar pelo menos um detalhamento.");
                    }

                    break;
                }
            }
        }