protected void btnCadastrar_Click(object sender, EventArgs e) { string descricaoProjeto = txtDescricao.Text; DateTime datainicio = Convert.ToDateTime(txtdatainicio.Text); DateTime dataimplantacao = Convert.ToDateTime(txtdataimplantacao.Text); DateTime datateste = Convert.ToDateTime(txtdatateste.Text); int qtdpessoa = Convert.ToInt32(txtQtdPessoas.Text); string telefone1 = txtTelefone1.Text; string telefone2 = txtTelefone2.Text; string observacao = txtobservacao.Text; TB_PROJETO v = new TB_PROJETO() { descricao = descricaoProjeto, dt_implantacao = dataimplantacao, dt_ini_proj = datainicio, dt_teste = datateste, observacao = observacao, contato_tel1 = telefone1, contato_tel2 = telefone2, qtd_pessoas = qtdpessoa }; TarefasDBEntities contextProjeto = new TarefasDBEntities(); string valor = Request.QueryString["idItem"]; if (String.IsNullOrEmpty(valor)) { contextProjeto.TB_PROJETO.Add(v); lblmsg.Text = "Registro Inserido!"; Clear(); } else { int id = Convert.ToInt32(valor); TB_PROJETO projeto = contextProjeto.TB_PROJETO.First(c => c.id == id); projeto.descricao = v.descricao; projeto.dt_ini_proj = v.dt_ini_proj; projeto.dt_implantacao = v.dt_implantacao; projeto.dt_teste = v.dt_teste; projeto.contato_tel1 = v.contato_tel1; projeto.contato_tel2 = v.contato_tel2; projeto.observacao = v.observacao; projeto.qtd_pessoas = v.qtd_pessoas; lblmsg.Text = "Registro Alterado!"; } contextProjeto.SaveChanges(); }
protected void GVTarefa_RowCommand(object sender, GridViewCommandEventArgs e) { int idItem = Convert.ToInt32(e.CommandArgument.ToString()); TarefasDBEntities context = new TarefasDBEntities(); TB_TAREFA tarefa = new TB_TAREFA(); tarefa = context.TB_TAREFA.First(c => c.ID == idItem); if (e.CommandName == "ALTERAR") { Response.Redirect("Tarefa.aspx?idItem=" + idItem); } else if (e.CommandName == "EXCLUIR") { context.TB_TAREFA.Remove(tarefa); context.SaveChanges(); string msg = "Tarefa excluida com sucesso!"; string titulo = "Informação"; CarregarLista(); DisplayAlert(titulo, msg, this); } }
protected void btnCadastrar_Click(object sender, EventArgs e) { string descricaoTarefa = txtDescricao.Text; DateTime dataAtividade = Convert.ToDateTime(txtdataatividade.Text); DateTime dataEentrega = Convert.ToDateTime(txtdataentrega.Text); DateTime dataLimite = Convert.ToDateTime(txtdatalimite.Text); TB_TAREFA v = new TB_TAREFA() { DESCRICAO = descricaoTarefa, DT_ATIVIDADE = dataAtividade, DT_ENTREGA = dataEentrega, DT_LIMITE_ENTREGA = dataLimite }; TarefasDBEntities contextTarefa = new TarefasDBEntities(); string valor = Request.QueryString["idItem"]; if (String.IsNullOrEmpty(valor)) { contextTarefa.TB_TAREFA.Add(v); lblmsg.Text = "Registro Inserido!"; Clear(); } else { int id = Convert.ToInt32(valor); TB_TAREFA tarefa = contextTarefa.TB_TAREFA.First(c => c.ID == id); tarefa.DESCRICAO = v.DESCRICAO; tarefa.DT_ATIVIDADE = v.DT_ATIVIDADE; tarefa.DT_ENTREGA = v.DT_ENTREGA; tarefa.DT_LIMITE_ENTREGA = v.DT_LIMITE_ENTREGA; lblmsg.Text = "Registro Alterado!"; } contextTarefa.SaveChanges(); }