Created
February 19, 2014 20:23
-
-
Save kidchenko/9100728 to your computer and use it in GitHub Desktop.
HtmlHelper para o tipo do produto segundo as tabelas utilizadas no SPED
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq.Expressions; | |
using System.Web.Mvc; | |
using System.Web.Mvc.Html; | |
namespace HtmlHelpers | |
{ | |
public static class HtmlHelperExtensions | |
{ | |
public static MvcHtmlString TipoProdutoDropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes) | |
{ | |
var metadata = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData); | |
var valor = metadata.Model; | |
var itens = new List<SelectListItem> | |
{ | |
new SelectListItem {Selected = string.Equals(valor, "00"), Value = "00", Text = "Mercadoria para Revenda"}, | |
new SelectListItem {Selected = string.Equals(valor, "01"), Value = "01", Text = "Matéria Pima"}, | |
new SelectListItem {Selected = string.Equals(valor, "02"), Value = "02", Text = "Embalagem"}, | |
new SelectListItem {Selected = string.Equals(valor, "03"), Value = "03", Text = "Produto em Processo"}, | |
new SelectListItem {Selected = string.Equals(valor, "04"), Value = "04", Text = "Produto Acabado"}, | |
new SelectListItem {Selected = string.Equals(valor, "05"), Value = "05", Text = "Subproduto"}, | |
new SelectListItem {Selected = string.Equals(valor, "06"), Value = "06", Text = "Produto Intermediário"}, | |
new SelectListItem {Selected = string.Equals(valor, "07"), Value = "07", Text = "Material de Uso/Consumo"}, | |
new SelectListItem {Selected = string.Equals(valor, "08"), Value = "08", Text = "Ativo Imobilizado"}, | |
new SelectListItem {Selected = string.Equals(valor, "09"), Value = "09", Text = "Serviços"}, | |
new SelectListItem {Selected = string.Equals(valor, "10"), Value = "10", Text = "Outros Insumos"}, | |
new SelectListItem {Selected = string.Equals(valor, "99"), Value = "99", Text = "Outros"} | |
}; | |
return htmlHelper.DropDownListFor(expression, itens, htmlAttributes); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment