Beispiel #1
0
        protected void btnAtualizarCliente(object sender, EventArgs e)
        {
            try
            {
                Tarefa t = new Tarefa();
                t.Codigo      = Convert.ToInt32(txtCodigo.Text);
                t.Nome        = Convert.ToString(txtNome.Text);
                t.Tipo        = ddltipo.SelectedItem.Text;
                t.Responsavel = Convert.ToString(txtResponsavel.Text);
                t.DataEntrega = Convert.ToString(txtDataEntrega.Text);

                TarefaDAO d = new TarefaDAO();
                d.Atualizar(t);
                lblMensagem.Text = "Tarefa atualizado com sucesso.";

                txtNome.Text          = string.Empty;
                ddltipo.SelectedIndex = 0;
                txtResponsavel.Text   = string.Empty;
                txtDataEntrega.Text   = string.Empty;
            }
            catch (Exception ex)
            {
                lblMensagem.Text = ex.Message;
            }
        }
Beispiel #2
0
        private void dgvAgenda_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            TarefaDAO tarefaDao = new TarefaDAO();

            if (e.ColumnIndex == 4 && e.RowIndex != -1)
            {
                bool statusB = false;

                if (dgvAgenda.CurrentRow.Cells[4].Value.Equals("Pendente"))
                {
                    statusB = true;
                }

                Tarefa tarefa = new Tarefa
                {
                    id        = (int)dgvAgenda.CurrentRow.Cells[0].Value,
                    titulo    = dgvAgenda.CurrentRow.Cells[1].Value.ToString(),
                    descricao = dgvAgenda.CurrentRow.Cells[2].Value.ToString(),
                    tempo     = (int)dgvAgenda.CurrentRow.Cells[3].Value,
                    status    = statusB
                };

                tarefaDao.Atualizar(tarefa);
                CarregarGrid();
            }
        }
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            TarefaDAO tarefaDao = new TarefaDAO();

            if (this.tarefa == null)
            {
                Tarefa tarefa = new Tarefa
                {
                    titulo    = txbTitulo.Text,
                    descricao = txbDescricao.Text,
                    tempo     = Convert.ToInt32(txbTempo.Text),
                    status    = ckbStatus.Checked
                };

                tarefaDao.Inserir(tarefa);
            }
            else
            {
                this.tarefa.titulo    = txbTitulo.Text;
                this.tarefa.descricao = txbDescricao.Text;
                this.tarefa.tempo     = Convert.ToInt32(txbTempo.Text);
                this.tarefa.status    = ckbStatus.Checked;

                tarefaDao.Atualizar(this.tarefa);
            }

            this.Close();
        }