protected void btnRetirar_Click(object sender, EventArgs e) { TagControladora tag = new TagControladora(); foreach (ListItem i in cblSelecionadas.Items) { if (i.Selected) tagsSelecionadas.RemoveAll(x => x.Codigo == int.Parse(i.Value)); } tagsSelecionadas = tagsSelecionadas.OrderBy(x => x.Nome).ToList(); Session["tags"] = tagsSelecionadas; PreencherSelecionadas(); }
protected void btnSelecionar_Click(object sender, EventArgs e) { TagControladora tag = new TagControladora(); foreach (ListItem i in cblDisponiveis.Items) { if (i.Selected) { if (!tagsSelecionadas.Any(x=>x.Codigo == int.Parse(i.Value))) tagsSelecionadas.Add(tag.Obter(int.Parse(i.Value))); } } tagsSelecionadas = tagsSelecionadas.OrderBy(x => x.Nome).ToList(); Session["tags"] = tagsSelecionadas; PreencherSelecionadas(); }
protected void btnGravar_Click(object sender, EventArgs e) { TagControladora cTag = new TagControladora(); ItemControladora cItem = new ItemControladora(); Item item = new Item(); item.Nome = txtNome.Text; item.Descricao = txtDescricao.Text; List<Tag> tags = new List<Tag>(); foreach (ListItem i in cblSelecionadas.Items) tags.Add(cTag.Obter(int.Parse(i.Value))); item.Tags = tags; item.DataCadastro = DateTime.Now; if (cItem.Adicionar(item) > 0) lblMensagem.Text = "OK"; else lblMensagem.Text = "Erro..."; }
private void PreencherDisponiveis() { TagControladora tag = new TagControladora(); List<Tag> tagsDisponiveis = tag.ObterTags(); cblDisponiveis.DataSource = tagsDisponiveis; cblDisponiveis.DataValueField = "Codigo"; cblDisponiveis.DataTextField = "Nome"; cblDisponiveis.DataBind(); }