Ejemplo n.º 1
0
        public static MvcHtmlString SelectFPgto(this HtmlHelper html, int idFPgto = 0, bool todas = false)
        {
            var fpgtos = new FPgtoService().Listar()
                         .Where(x => x.Ativo == true)
                         .OrderBy(x => x.Descricao)
                         .ToList();

            TagBuilder tag = new TagBuilder("select");

            tag.MergeAttribute("id", "IdFPgto");
            tag.MergeAttribute("name", "IdFPgto");
            tag.MergeAttribute("class", "form-control");

            if (todas == true)
            {
                TagBuilder itemTag = new TagBuilder("option");
                itemTag.MergeAttribute("value", "0");
                itemTag.SetInnerText("");
                tag.InnerHtml += itemTag.ToString();
            }

            foreach (var item in fpgtos)
            {
                TagBuilder itemTag = new TagBuilder("option");
                itemTag.MergeAttribute("value", item.Id.ToString());
                if (item.Id == idFPgto)
                {
                    itemTag.MergeAttribute("selected", "selected");
                }
                itemTag.SetInnerText(item.Descricao);
                tag.InnerHtml += itemTag.ToString();
            }

            return(new MvcHtmlString(tag.ToString()));
        }
Ejemplo n.º 2
0
        public static MvcHtmlString SelectFPgto(this HtmlHelper html, int idFPgto = 0, bool todas = false)
        {
            var fpgtos = new FPgtoService().Listar()
                .Where(x => x.Ativo == true)
                .OrderBy(x => x.Descricao)
                .ToList();

            TagBuilder tag = new TagBuilder("select");
            tag.MergeAttribute("id", "IdFPgto");
            tag.MergeAttribute("name", "IdFPgto");
            tag.MergeAttribute("class", "form-control");

            if (todas == true)
            {
                TagBuilder itemTag = new TagBuilder("option");
                itemTag.MergeAttribute("value", "0");
                itemTag.SetInnerText("");
                tag.InnerHtml += itemTag.ToString();
            }

            foreach (var item in fpgtos)
            {
                TagBuilder itemTag = new TagBuilder("option");
                itemTag.MergeAttribute("value", item.Id.ToString());
                if (item.Id == idFPgto)
                {
                    itemTag.MergeAttribute("selected", "selected");
                }
                itemTag.SetInnerText(item.Descricao);
                tag.InnerHtml += itemTag.ToString();
            }

            return new MvcHtmlString(tag.ToString());
        }
Ejemplo n.º 3
0
        public static MvcHtmlString SelectFPgto(this HtmlHelper html, int idFpgto = 0, bool selecione = false)
        {
            var idEmpresa = new UsuarioService().GetUsuario(System.Web.HttpContext.Current.User.Identity.Name).IdEmpresa;

            var fpgtos = new FPgtoService().Listar()
                         .Where(x => x.Ativo == true && x.IdEmpresa == idEmpresa)
                         .OrderBy(x => x.Descricao)
                         .ToList();

            TagBuilder tag = new TagBuilder("select");

            tag.MergeAttribute("id", "IdFPgto");
            tag.MergeAttribute("name", "IdFPgto");
            tag.MergeAttribute("class", "form-control");

            if (selecione == true)
            {
                TagBuilder itemSel = new TagBuilder("option");
                itemSel.MergeAttribute("value", "0");
                itemSel.SetInnerText("");
                tag.InnerHtml += itemSel.ToString();
            }

            foreach (var item in fpgtos)
            {
                TagBuilder itemTag = new TagBuilder("option");
                itemTag.MergeAttribute("value", item.Id.ToString());
                if (item.Id == idFpgto)
                {
                    itemTag.MergeAttribute("selected", "selected");
                }
                itemTag.SetInnerText(item.Descricao);
                tag.InnerHtml += itemTag.ToString();
            }
            return(new MvcHtmlString(tag.ToString()));
        }