Ejemplo n.º 1
0
        private void handle_Finalizadas()
        {
            BindingSource bind = new BindingSource();

            bind.DataSource             = TarefaController.Listar_Finalizadas().ToList();
            data_Finalizadas.DataSource = bind;
            data_Finalizadas.Refresh();
        }
Ejemplo n.º 2
0
        private void handle_Pendentes()
        {
            BindingSource bind = new BindingSource();

            bind.DataSource           = TarefaController.Listar_Pendentes().ToList();
            data_Pendentes.DataSource = bind;
            data_Pendentes.Refresh();
        }
Ejemplo n.º 3
0
 private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (data_Finalizadas.Columns[e.ColumnIndex].Name == "CheckFin")
     {
         int id_tarefa = int.Parse(data_Finalizadas.CurrentRow.Cells[0].Value.ToString());
         TarefaController.Desfazer_Finalizar(id_tarefa);
         handle_Pendentes();
         handle_Finalizadas();
     }
 }
Ejemplo n.º 4
0
    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);
    }
Ejemplo n.º 5
0
        protected void CadastrarTarefa_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();


            var NovaTarefa = new Tarefa();

            var tarefaController = new TarefaController();

            bool cadastrado = tarefaController.Cadastrar(NovaTarefa);
        }
Ejemplo n.º 6
0
    private bool DeletarRegistro(string idTarefa)
    {
        int codigo = Convert.ToInt32(hdnCodigo.Value);
        var tarefa = TarefaController.Lista().FirstOrDefault(p => p.IdTarefa == codigo);

        if (tarefa == null)
        {
            return(false);
        }
        TarefaController.Remover(tarefa);
        return(true);
    }
Ejemplo n.º 7
0
        private void CarregarTarefas()
        {
            SLTarefas.Children.Clear();
            List <Tarefa> lista = new TarefaController().ListarTarefas();
            int           i     = 0;

            foreach (Tarefa tarefa in lista)
            {
                ListaStackLayout(tarefa, i);
                i++;
            }
        }
Ejemplo n.º 8
0
        private void btn_ExcluirPendente_Click(object sender, EventArgs e)
        {
            DialogResult resultado = MessageBox.Show("Você tem certeza que deseja excluir?", "Confirmar", MessageBoxButtons.YesNo);

            if (resultado == DialogResult.Yes && data_Pendentes.Rows.Count > 0)
            {
                int id_tarefa = int.Parse(data_Pendentes.CurrentRow.Cells[0].Value.ToString());
                if (id_tarefa > 0)
                {
                    TarefaController.Remover_Tarefa(id_tarefa);
                }
                handle_Pendentes();
            }
        }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            controller = new TarefaController();

            lista = controller.ListarTudo();

            if (!this.IsPostBack)
            {
                AlertarTarefasAtrasadas();
            }

            TabelaTarefa.DataSource = lista;

            TabelaTarefa.DataBind();
        }
Ejemplo n.º 10
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            btn_ExcluirPendente.Visible = true;

            if (data_Pendentes.Columns[e.ColumnIndex].Name == "Check")
            {
                int id_tarefa = int.Parse(data_Pendentes.CurrentRow.Cells[0].Value.ToString());
                if (id_tarefa > 0)
                {
                    TarefaController.Finalizar_Tarefa(id_tarefa);
                }
                handle_Pendentes();
                handle_Finalizadas();
            }
        }
Ejemplo n.º 11
0
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                var _tarefa     = new Tarefa();
                var _controller = new TarefaController();

                _tarefa.Id = tarefa.Id;
                if (!String.IsNullOrEmpty(dtDataEntrega.Text))
                {
                    _tarefa.DataEntrega = DateTime.ParseExact(dtDataEntrega.Text, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
                }
                if (!String.IsNullOrEmpty(txtDescricao.Text))
                {
                    _tarefa.Descricao = txtDescricao.Text;
                }
                _tarefa.Entregue = chkEntregue.Checked;
                if (!String.IsNullOrEmpty(txtNota.Text))
                {
                    _tarefa.Nota = Convert.ToByte(txtNota.Text);
                }
                if (!String.IsNullOrEmpty(txtTipo.Text))
                {
                    _tarefa.Tipo = txtTipo.Text;
                }
                if (!String.IsNullOrEmpty(txtTitulo.Text))
                {
                    _tarefa.Titulo = txtTitulo.Text;
                }

                bool response = _controller.Alterar(_tarefa);

                if (response)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Sucesso", "alert('Tarefa Atualizada com sucesso');", true);
                    Response.Redirect("~/");
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Erro", "alert('Não foi possível Atualizar.');", true);
                }
            }
            catch (Exception err)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Erro", $"alert('erro ao tentar executar: {err.Message}');", true);
            }
        }
Ejemplo n.º 12
0
    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);
        }
    }
Ejemplo n.º 13
0
    protected void Salvar_Click(object sender, EventArgs e)
    {
        int        dsTipoTarefa  = Convert.ToInt32(tipoTarefa.SelectedValue);
        TipoTarefa auxTipoTarefa = (TipoTarefa)dsTipoTarefa;

        if (string.IsNullOrWhiteSpace(txtCodigo.Text))
        {
            var listaParticipantes = new List <Pessoa>();
            foreach (var nomePessoa in txtParticipantes.Text.Split(',').ToList <string>())
            {
                Pessoa pessoa = PessoaController.Lista().FirstOrDefault(p => p.Nome.Equals(nomePessoa));
                if (pessoa == null || !(pessoa.IdPessoa >= 1))
                {
                    pessoa = PessoaController.Inseir(new Pessoa()
                    {
                        Nome  = nomePessoa,
                        Papel = Papel.Outros
                    });
                }
                listaParticipantes.Add(pessoa);
            }

            var listaMaterias = new List <Materia>();
            foreach (var nomeMateria in txtParticipantes.Text.Split(',').ToList <string>())
            {
                Materia materia = MateriaController.Lista().FirstOrDefault(p => p.Nome.Equals(nomeMateria));
                if (materia == null || !(materia.IdMateria >= 1))
                {
                    materia = MateriaController.Inseir(new Materia()
                    {
                        Nome = nomeMateria
                    });
                }
                listaMaterias.Add(materia);
            }

            TarefaController.Inseir(new Tarefa()
            {
                DataCadastro      = DateTime.Now,
                DataLimite        = Convert.ToDateTime(txtDataLimite.Text),
                DescricaoResumida = txtDescResumida.Text,
                DescricaoCompleta = txtDescCompleta.Text,
                TipoTarefa        = auxTipoTarefa,
                Participantes     = listaParticipantes,
                Materias          = listaMaterias
            });

            msgRegistro.CssClass = "text-success";
            msgRegistro.Text     = "Registo salvo com sucesso.";
            msgRegistro.Visible  = true;
        }
        else
        {
            int codigo = Convert.ToInt32(hdnCodigo.Value);
            var tarefa = TarefaController.Lista().FirstOrDefault(p => p.IdTarefa == codigo);
            if (tarefa == null)
            {
                msgRegistro.CssClass = "text-danger";
                msgRegistro.Text     = "Não foi possível identificar o registro.";
                msgRegistro.Visible  = true;
                return;
            }

            tarefa.DataLimite        = Convert.ToDateTime(txtDataLimite.Text);
            tarefa.DescricaoResumida = txtDescResumida.Text;
            tarefa.DescricaoCompleta = txtDescCompleta.Text;
            tarefa.TipoTarefa        = auxTipoTarefa;

            TarefaController.Editar(tarefa);

            msgRegistro.CssClass = "text-success";
            msgRegistro.Text     = "Registo atualizado com sucesso.";
            msgRegistro.Visible  = true;
        }
    }
Ejemplo n.º 14
0
 private void materialFlatButton1_Click(object sender, EventArgs e)
 {
     TarefaController.Criar_Tarefa(txt_Fazer.Text);
     handle_Pendentes();
 }