protected void btnGravar_Click(object sender, EventArgs e) { DateTime dti = Convert.ToDateTime(tbDtInicio.Text), dtf = Convert.ToDateTime(tbDtFinal.Text); Session.Add("dti", dti); Session.Add("dtf", dtf); if (dti < dtf) { int codigo = 0; if (hfCodOferta.Value != "") { codigo = Convert.ToInt32(hfCodOferta.Value); } OfertaCurso oc = new OfertaCurso(codigo, Convert.ToDateTime(tbDtInicio.Text), Convert.ToDateTime(tbDtFinal.Text), Convert.ToInt32(hfCodUe.Value), Convert.ToInt32(hfCodCurso.Value), tbDescOC.Text); if (codigo == 0) { oc.GravarOfertaCurso(); hfCodOferta.Value = oc.CodOferta.ToString(); Response.Redirect("CadOfertaCursoModulo.aspx?oferta=" + hfCodOferta.Value + "&cur=" + hfCodCurso.Value); } else { oc.AlterarOC(); LimpaTela(); } } else { Utils u = new Utils(); u.MsgBox(this, "Data Inicial tem que ser menor que a Data Final"); } }
protected void CarregaAlteracao(int cod) { OfertaCurso oc = new OfertaCurso(); if (oc.RecuperarOfertaCurso(cod)) { tbDescOC.Text = oc.Desc; tbDtInicio.Text = oc.DtInicio.ToString(); tbDtFinal.Text = oc.DtFinal.ToString(); hfCodCurso.Value = oc.Curso.ToString(); hfCodOferta.Value = oc.CodOferta.ToString(); hfCodUe.Value = oc.UnidadeEnsino.ToString(); Curso cur = new Curso(); if (cur.RecuperarCurso(Convert.ToInt32(oc.Curso))) { tbNome.Text = cur.DescCurso; } UnidadeEnsino ue = new UnidadeEnsino(); if (ue.RecuperarUnidadeEnsino(Convert.ToInt32(oc.UnidadeEnsino))) { tbNomeUE.Text = ue.Nome; } btnPesqCurso.Enabled = false; btnPesqUE.Enabled = false; btnExcluir.Enabled = true; btnAdd.Enabled = true; } }
public IActionResult DeleteConfirmed(Guid id) { OfertaCurso ofertaCurso = _context.OfertasCurso.Single(m => m.Id == id); _context.OfertasCurso.Remove(ofertaCurso); _context.SaveChanges(); return(RedirectToAction("Index")); }
protected void lbtnSelecionar_Command(object sender, CommandEventArgs e) { OfertaCurso oc = new OfertaCurso(); gvOfertaCurso.DataSource = oc.PesqOfertaCurso(Convert.ToInt32(e.CommandArgument)); gvOfertaCurso.DataBind(); pOferta.Visible = true; pUE.Visible = false; }
public IActionResult Edit(OfertaCurso ofertaCurso) { if (ModelState.IsValid) { _context.Update(ofertaCurso); _context.SaveChanges(); return(RedirectToAction("Index")); } ViewData["CursoId"] = new SelectList(_context.Cursos, "Id", "Curso", ofertaCurso.CursoId); return(View(ofertaCurso)); }
public IActionResult Create(OfertaCurso ofertaCurso) { if (ModelState.IsValid) { ofertaCurso.Id = Guid.NewGuid(); _context.OfertasCurso.Add(ofertaCurso); _context.SaveChanges(); return(RedirectToAction("Index")); } ViewData["CursoId"] = new SelectList(_context.Cursos, "Id", "Curso", ofertaCurso.CursoId); return(View(ofertaCurso)); }
public IActionResult Create(OfertaCurso ofertaCurso) { if (ModelState.IsValid) { ofertaCurso.Id = Guid.NewGuid(); _context.OfertasCurso.Add(ofertaCurso); _context.SaveChanges(); return RedirectToAction("Index"); } ViewData["CursoId"] = new SelectList(_context.Cursos, "Id", "Curso", ofertaCurso.CursoId); return View(ofertaCurso); }
protected void btnExcluir_Click(object sender, EventArgs e) { OfertaCurso oc = new OfertaCurso(); if (oc.ExcluirOfertaCurso(Convert.ToInt32(hfCodOferta.Value))) { LimpaTela(); } else { Utils u = new Utils(); u.MsgBox(this, "Não foi possivel excluir, Oferta Curso sendo utilizada."); } }
// GET: OfertaCurso/Edit/5 public IActionResult Edit(Guid?id) { if (id == null) { return(HttpNotFound()); } OfertaCurso ofertaCurso = _context.OfertasCurso.Single(m => m.Id == id); if (ofertaCurso == null) { return(HttpNotFound()); } ViewData["CursoId"] = new SelectList(_context.Cursos, "Id", "Curso", ofertaCurso.CursoId); return(View(ofertaCurso)); }
public IActionResult Delete(Guid?id) { if (id == null) { return(HttpNotFound()); } OfertaCurso ofertaCurso = _context.OfertasCurso.Single(m => m.Id == id); if (ofertaCurso == null) { return(HttpNotFound()); } return(View(ofertaCurso)); }
protected void btnGerar_Click(object sender, EventArgs e) { if (File.Exists(Server.MapPath(@"~\_csv\") + @"exporta_SAAET.csv")) { File.Delete(Server.MapPath(@"~\_csv\") + @"exporta_SAAET.csv"); } StreamWriter stream = new StreamWriter(Server.MapPath(@"~\_csv\") + @"exporta_SAAET.csv", false); OfertaCurso oc = new OfertaCurso(); List <OfertaCurso> lista = oc.GerarCertificado(Convert.ToInt32(hfOferta.Value)); string header = "RA;CPF;Nome;DtInicio;DtFinal"; stream.WriteLine(header); for (int i = 0; i < lista.Count; i++) { string linha = lista[i].Aluno.Ra.ToString() + ";" + lista[i].Aluno.Cpf.ToString() + ";" + lista[i].Aluno.Nome.ToString() + ";" + lista[i].DtInicio.ToString("dd/MM/yyyy") + ";" + lista[i].DtFinal.ToString("dd/MM/yyyy"); stream.WriteLine(linha); } stream.Close(); Response.Clear(); byte[] vet = File.ReadAllBytes(Server.MapPath(@"~\_csv\") + @"exporta_SAAET.csv"); Response.AddHeader("content-disposition", "attachment; filename=exporta_SAAET.csv"); Response.ContentType = "text/plain"; Response.BinaryWrite(vet); Response.End(); }
public IActionResult Edit(OfertaCurso ofertaCurso) { if (ModelState.IsValid) { _context.Update(ofertaCurso); _context.SaveChanges(); return RedirectToAction("Index"); } ViewData["CursoId"] = new SelectList(_context.Cursos, "Id", "Curso", ofertaCurso.CursoId); return View(ofertaCurso); }