private void BuscarPessoas(string pesquisa = null) { var lista = PessoaController.Lista(); if (!string.IsNullOrWhiteSpace(pesquisa)) { pesquisa = pesquisa.ToLower(); lista = lista.Where(p => p.Nome.ToLower().Contains(pesquisa) || p.IdPessoa.ToString().ToLower().Equals(pesquisa) || Formatacao.GetDescriptionFromEnum(p.Papel).ToLower().Contains(pesquisa) ).ToList(); } foreach (var reg in lista) { TableRow row = new TableRow(); row.CssClass = "table-light"; TableCell acao = new TableCell(); HyperLink linkEditar = new HyperLink(); linkEditar.Text = "Editar"; linkEditar.NavigateUrl = $"~/Views/pessoa.aspx?Id={reg.IdPessoa}&Acao=Editar"; acao.Controls.Add(linkEditar); HyperLink linkExcluir = new HyperLink(); linkExcluir.Text = "Excluir"; linkExcluir.CssClass = "ml-2"; linkExcluir.NavigateUrl = $"~/Views/pessoa.aspx?Id={reg.IdPessoa}&Acao=Excluir"; acao.Controls.Add(linkExcluir); row.Cells.AddAt(0, acao); TableCell cod = new TableCell(); cod.Text = reg.IdPessoa.ToString("0"); row.Cells.AddAt(1, cod); TableCell nome = new TableCell(); nome.Text = reg.Nome; row.Cells.AddAt(2, nome); TableCell papel = new TableCell(); papel.Text = Formatacao.GetDescriptionFromEnum(reg.Papel); row.Cells.AddAt(3, papel); listaPessoa.Rows.Add(row); } }
protected void Page_Load(object sender, EventArgs e) { try { var lista = PessoaController.Lista(); foreach (var reg in lista) { TableRow row = new TableRow(); row.CssClass = "table-light"; TableCell acao = new TableCell(); HyperLink linkEditar = new HyperLink(); linkEditar.Text = "Editar"; linkEditar.NavigateUrl = $"~/index.aspx?Id={reg.IdPessoa}&Acao=Editar"; acao.Controls.Add(linkEditar); HyperLink linkExcluir = new HyperLink(); linkExcluir.Text = "Excluir"; linkExcluir.CssClass = "ml-2"; linkExcluir.NavigateUrl = $"~/index.aspx?Id={reg.IdPessoa}&Acao=Excluir"; acao.Controls.Add(linkExcluir); row.Cells.AddAt(0, acao); TableCell cod = new TableCell(); cod.Text = reg.IdPessoa.ToString("0"); row.Cells.AddAt(1, cod); TableCell nome = new TableCell(); nome.Text = reg.Nome; row.Cells.AddAt(2, nome); TableCell papel = new TableCell(); papel.Text = Formatacao.GetDescriptionFromEnum(reg.Papel); row.Cells.AddAt(3, papel); listaTarefa.Rows.Add(row); } } catch (Exception ex) { throw ex; } }
private void BuscarTarefas(string pesquisa = null) { var lista = TarefaController.Lista(); if (!string.IsNullOrWhiteSpace(pesquisa)) { pesquisa = pesquisa.ToLower(); lista = lista.Where(p => p.IdTarefa.ToString().Equals(pesquisa) || p.DescricaoResumida.ToLower().Contains(pesquisa) || p.DescricaoCompleta.ToLower().Contains(pesquisa) || Formatacao.GetDescriptionFromEnum(p.TipoTarefa).ToLower().Contains(pesquisa) ).ToList(); } foreach (var reg in lista) { TableRow row = new TableRow(); row.CssClass = "table-light"; TableCell acao = new TableCell(); HyperLink linkEditar = new HyperLink(); linkEditar.Text = "Editar"; linkEditar.NavigateUrl = $"~/Views/tarefa.aspx?Id={reg.IdTarefa}&Acao=Editar"; acao.Controls.Add(linkEditar); HyperLink linkExcluir = new HyperLink(); linkExcluir.Text = "Excluir"; linkExcluir.CssClass = "ml-2"; linkExcluir.NavigateUrl = $"~/Views/tarefa.aspx?Id={reg.IdTarefa}&Acao=Excluir"; acao.Controls.Add(linkExcluir); row.Cells.AddAt(0, acao); TableCell cod = new TableCell(); cod.Text = reg.IdTarefa.ToString("0"); row.Cells.AddAt(1, cod); TableCell papel = new TableCell(); papel.Text = Formatacao.GetDescriptionFromEnum(reg.TipoTarefa); row.Cells.AddAt(2, papel); TableCell descResumida = new TableCell(); if (reg.DescricaoResumida.Length < 25) { descResumida.Text = reg.DescricaoResumida; } else { descResumida.Text = $"{reg.DescricaoResumida.Substring(0, 23)}..."; } row.Cells.AddAt(3, descResumida); TableCell participantes = new TableCell(); participantes.Text = string.Join(",", reg.ParticipantesRemoto); row.Cells.AddAt(4, participantes); TableCell materias = new TableCell(); materias.Text = string.Join(",", reg.MateriasRemoto); row.Cells.AddAt(5, materias); TableCell dataLimit = new TableCell(); dataLimit.Text = reg.DataLimite.ToString("dd/MM/yyyy"); row.Cells.AddAt(6, dataLimit); listaTarefa.Rows.Add(row); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } string dsId = Request.QueryString["Id"]; string dsAcao = Request.QueryString["Acao"]; if (!string.IsNullOrWhiteSpace(dsId) && !string.IsNullOrWhiteSpace(dsAcao)) { int id = 0; int.TryParse(dsId, out id); if (id >= 1) { if (dsAcao.Equals("Editar")) { var tarefa = TarefaController.Lista().FirstOrDefault(p => p.IdTarefa == id); if (tarefa != null) { hdnCodigo.Value = dsId; txtCodigo.Text = dsId; txtDescResumida.Text = tarefa.DescricaoResumida; txtDescCompleta.Text = tarefa.DescricaoCompleta; tipoTarefa.SelectedIndex = tipoTarefa.Items.IndexOf(tipoTarefa.Items.FindByText(Formatacao.GetDescriptionFromEnum(tarefa.TipoTarefa))); txtDataCadastro.Text = tarefa.DataCadastro.ToString("dd/MM/yyyy HH:mm"); txtDataLimite.Text = tarefa.DataLimite.ToString("dd/MM/yyyy HH:mm"); txtParticipantes.Text = string.Join(",", tarefa.ParticipantesRemoto.Select(p => p.Nome)); txtMaterias.Text = string.Join(",", tarefa.MateriasRemoto.Select(p => p.Nome)); panelRegistro.Visible = true; panelLista.Visible = false; Deletar.Visible = true; return; } } if (dsAcao.Equals("Excluir")) { btnBuscar_Click(null, null); if (!DeletarRegistro(dsId)) { msgRegistro.CssClass = "text-danger"; msgRegistro.Text = "Não foi possível remover o registro."; msgRegistro.Visible = true; return; } //Response.Redirect("index.aspx", false); } } } btnBuscar_Click(null, null); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } string dsId = Request.QueryString["Id"]; string dsAcao = Request.QueryString["Acao"]; if (!string.IsNullOrWhiteSpace(dsId) && !string.IsNullOrWhiteSpace(dsAcao)) { int id = 0; int.TryParse(dsId, out id); if (id >= 1) { if (dsAcao.Equals("Editar")) { var pessoa = PessoaController.Lista().FirstOrDefault(p => p.IdPessoa == id); if (pessoa != null) { hdnCodigo.Value = dsId; txtCodigo.Text = dsId; txtNome.Text = pessoa.Nome; tipoPapel.SelectedIndex = tipoPapel.Items.IndexOf(tipoPapel.Items.FindByText(Formatacao.GetDescriptionFromEnum(pessoa.Papel))); panelRegistro.Visible = true; panelLista.Visible = false; Deletar.Visible = true; return; } } if (dsAcao.Equals("Excluir")) { btnBuscar_Click(null, null); if (!DeletarRegistro(dsId)) { msgRegistro.CssClass = "text-danger"; msgRegistro.Text = "Não foi possível remover o registro."; msgRegistro.Visible = true; return; } //Response.Redirect("index.aspx", false); } } } btnBuscar_Click(null, null); }