Пример #1
0
    protected void _dgvUsuario_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        byte situacao = Convert.ToByte(DataBinder.Eval(e.Row.DataItem, "usu_situacao"));

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            try
            {
                Repeater rpt = (Repeater)e.Row.FindControl("_rptEntidadeUA");
                if (rpt != null)
                {
                    rpt.DataSource = SYS_UsuarioGrupoUABO.GetSelect(new Guid(_dgvUsuario.DataKeys[e.Row.RowIndex].Values[0].ToString()), _VS_gru_id);
                    rpt.DataBind();
                }
            }
            catch (Exception)
            {
                throw;
            }

            LinkButton btnAlterar = (LinkButton)e.Row.FindControl("_btnAlterar");
            if (btnAlterar != null)
            {
                btnAlterar.CommandArgument = e.Row.RowIndex.ToString();
                btnAlterar.Visible         = situacao != 4 && __SessionWEB.__UsuarioWEB.GrupoPermissao.grp_alterar;
            }

            Label lblAlterar = (Label)e.Row.FindControl("_lblAlterar");
            if (lblAlterar != null)
            {
                lblAlterar.Visible = situacao == 4 || !__SessionWEB.__UsuarioWEB.GrupoPermissao.grp_alterar;
            }

            ImageButton btnExcluir = (ImageButton)e.Row.FindControl("_btnExcluir");
            if (btnExcluir != null)
            {
                btnExcluir.CommandArgument = e.Row.RowIndex.ToString();
                btnExcluir.Visible         = situacao != 4 && __SessionWEB.__UsuarioWEB.GrupoPermissao.grp_excluir;
            }
        }
    }
Пример #2
0
        public HttpResponseMessage SelectEntityByLogin([FromUri] UsuarioEntradaDTO data)
        {
            try
            {
                if (data == null || data.usu_login == null)
                {
                    throw new ValidationException("É necessário informar o(s) parâmetro(s).");
                }

                List <SYS_UsuarioGrupoUA> listaUsuarios = SYS_UsuarioGrupoUABO.SelecionaPorLogin(data.usu_login);

                var usuarios = (from usu in listaUsuarios
                                group usu by usu.ent_id into grupo
                                select new
                {
                    pes_id = grupo.First().pes_id
                    ,
                    ent_razaoSocial = grupo.First().ent_razaoSocial
                    ,
                    ent_id = grupo.Key
                    ,
                    list_uad_id = grupo.GroupBy(p => p.uad_id).Where(p => p.Key != Guid.Empty).Select(p => new { uad_id = p.Key }).ToList()
                }).ToList();

                return(Request.CreateResponse(HttpStatusCode.OK, usuarios));
            }
            catch (ValidationException ex)
            {
                Util.GravarErro(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                Util.GravarErro(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }