protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { IdProfesorDropDownList.DataSource = Profesores.Listar("1=1"); IdProfesorDropDownList.DataValueField = "IdProfesor"; IdProfesorDropDownList.DataTextField = "Nombres"; IdProfesorDropDownList.DataBind(); IdSemestreDropDownList.DataSource = Semestres.Listar("IdSemestre, Codigo", "1=1"); IdSemestreDropDownList.DataValueField = "IdSemestre"; IdSemestreDropDownList.DataTextField = "Codigo"; IdSemestreDropDownList.DataBind(); IdAsignaturaDropDownList.DataSource = Asignaturas.Listar("IdAsignatura, Nombre", "1=1"); IdAsignaturaDropDownList.DataValueField = "IdAsignatura"; IdAsignaturaDropDownList.DataTextField = "Nombre"; IdAsignaturaDropDownList.DataBind(); IdSeccionDropDownList.DataSource = Secciones.Listar("1=1"); IdSeccionDropDownList.DataValueField = "IdSeccion"; IdSeccionDropDownList.DataTextField = "Numero"; IdSeccionDropDownList.DataBind(); } }
public async Task <IActionResult> PutCursos(int id, Cursos cursos) { Profesores profesor = await ComprobacionSesion.ComprobarInicioSesion(HttpContext.Request.Headers, _context); if (profesor == null) { return(BadRequest()); } if (id != cursos.Id) { return(BadRequest()); } _context.Entry(cursos).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CursosExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> DeleteCursosGrupos(List <CursosGrupos> cursosGrupos) { Profesores profesor = await ComprobacionSesion.ComprobarInicioSesion(HttpContext.Request.Headers, _context); if (profesor == null) { return(BadRequest()); } CursosGrupos borrarGC; foreach (CursosGrupos cg in cursosGrupos) { borrarGC = _context.CursosGrupos.FirstOrDefault(cgt => cgt.Id == cg.Id); _context.CursosGrupos.Remove(borrarGC); } //_context.CursosGrupos.RemoveRange(cursosGrupos); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(NoContent()); }
public async Task <Boolean> DeleteAllAsignaciones() { Profesores profesor = await ComprobacionSesion.ComprobarInicioSesion(HttpContext.Request.Headers, _context); if (profesor == null) { return(false); } try { var evaluaciones = await _context.Evaluaciones.Where(eva => eva.Profesor == profesor.Id).ToListAsync(); _context.Evaluaciones.RemoveRange(evaluaciones); await _context.SaveChangesAsync(); var listaAsignaciones = await _context.Asignaciones.Include(x => x.NotificacionesCorreo) .Where(x => x.Profesor == profesor.Id).ToListAsync(); _context.Asignaciones.RemoveRange(listaAsignaciones); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(false); } return(true); }
public async Task <ActionResult <Cursos> > DeleteCursos(int id) { Profesores profesor = await ComprobacionSesion.ComprobarInicioSesion(HttpContext.Request.Headers, _context); if (profesor == null) { return(BadRequest()); } var listaAsignaciones = _context.Asignaciones.Include(z => z.NotificacionesCorreo).Where(x => x.Curso == id).ToList(); foreach (Asignaciones asignacion in listaAsignaciones) { await DeleteAsignacionesC(asignacion); } _context.Asignaciones.RemoveRange(listaAsignaciones); await _context.SaveChangesAsync(); var cursos = await _context.Cursos.Include(curso => curso.CursosGrupos) .ThenInclude(cursoGrupo => cursoGrupo.IdGrupoNavigation) .Where(curso => curso.Id == id).FirstOrDefaultAsync(); if (cursos == null) { return(NotFound()); } _context.Cursos.Remove(cursos); await _context.SaveChangesAsync(); return(cursos); }
public ActionResult AgregarProfesor(Profesores p) { try { if (!ModelState.IsValid) { return(View()); } using (var db = new ManageITLAContext()) { p.FechaRegistro = DateTime.Now; DetalleProfesorAsignatura dpa = new DetalleProfesorAsignatura(); dpa.IDProfesor = p.IDProfesor; dpa.IDAsignatura = p.IDAsignatura; dpa.Cuatrimestre = p.Cuatrimestre; dpa.FechaAsignacion = DateTime.Now; db.DetalleProfesorAsignatura.Add(dpa); db.Profesores.Add(p); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (Exception) { throw; } }
[Route("PutProfesor")]//Actualiza el perfil public async Task <IActionResult> PutProfesor(Profesores profesores) { Profesores profesor = await ComprobacionSesion.ComprobarInicioSesion(HttpContext.Request.Headers, _context); if (profesor == null && profesor.Id != profesores.Id) { return(BadRequest()); } // Se realiza de esta manera, ya que habría conflicto con la entidad entrante (son iguales), // por lo que se modifica la ultima retornada por el ef profesor.Nombre = profesores.Nombre; profesor.PrimerApellido = profesores.PrimerApellido; profesor.SegundoApellido = profesores.SegundoApellido; profesor.Correo = profesores.Correo; profesor.Contrasenia = profesores.Contrasenia; _context.Entry(profesor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(NoContent()); }
public async Task <Boolean> PutProfesores(Profesores profesor) { _context.Entry(profesor).State = EntityState.Modified; await _context.SaveChangesAsync(); return(await Task.FromResult(true)); }
/* * Metodo para actualizar una Materia */ public async Task <bool> ProfesorUpdate(Profesores profesor) { using (var conn = new SqlConnection(_configuration.Value)) { var parameters = new DynamicParameters(); parameters.Add("nombreProfesor", profesor.nombreProfesor, DbType.String); parameters.Add("apellidoProfesor", profesor.apellidoProfesor, DbType.Int32); parameters.Add("direccionProfesor", profesor.direccionProfesor, DbType.String); parameters.Add("telefonoProfesor", profesor.telefonoProfesor, DbType.Int32); parameters.Add("correoProfesor", profesor.correoProfesor, DbType.String); const string query = @"UPDATE profesores SET nombreProfesor = @nombreProfesor, apellidoProfesor = @apellidoProfesor, direccionProfesor = @direccionProfesor, telefonoProfesor = @telefonoProfesor, correoProfesor = @correoProfesor WHERE idProfesor = @idProfesor"; await conn.ExecuteAsync(query, new { profesor.nombreProfesor, profesor.apellidoProfesor, profesor.direccionProfesor, profesor.telefonoProfesor, profesor.correoProfesor }, commandType : CommandType.Text); } return(true); }
public async Task <ActionResult <Asignaciones> > DeleteAsignaciones(int id) { Profesores profesor = await ComprobacionSesion.ComprobarInicioSesion(HttpContext.Request.Headers, _context); if (profesor == null) { return(BadRequest()); } var evaluaciones = await _context.Evaluaciones.Where(eva => eva.Asignacion == id).ToListAsync(); _context.Evaluaciones.RemoveRange(evaluaciones); await _context.SaveChangesAsync(); var asignacion = await _context.Asignaciones.Where(asig => asig.Id == id).FirstOrDefaultAsync(); if (asignacion == null) { return(NotFound()); } _context.Asignaciones.Remove(asignacion); await _context.SaveChangesAsync(); return(asignacion); }
public async Task <IActionResult> Edit(int id, [Bind("ProfesoresID,Nombre,Apellido")] Profesores profesores) { if (id != profesores.ProfesoresID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(profesores); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfesoresExists(profesores.ProfesoresID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(profesores)); }
public async Task <Profesores> PostProfesores(Profesores profesor) { _context.Profesores.Add(profesor); await _context.SaveChangesAsync(); return(await Task.FromResult(profesor)); }
protected void ButtGuardar_Click(object sender, EventArgs e) { int id = 0; if (IsValid) { profesor = LlenarCampos(); if (id != profesor.IdProfesores) { if (BLLProfesor.Mofidicar(profesor)) { Utilidades.ShowToastr(this, "Se modifico Satisfactoriamente", "Correcto", "success"); } else { Utilidades.ShowToastr(this, "No se pudo modificar", "Error", "Error"); } } else { if (BLLProfesor.Guardar(profesor)) { Utilidades.ShowToastr(this, " Agregado", "Correcto", "success"); } else { Utilidades.ShowToastr(this, "No se agrego", "Error", "error"); } } } Limpiar(); }
public async Task <IActionResult> Edit(int id, [Bind("Idprofesor,Identificacion,Nombres,Apellidos,Nacimiento,Ingreso,Trabaja,Idtipodeprofesor,Idcondicion")] Profesores profesores) { if (id != profesores.Idprofesor) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(profesores); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfesoresExists(profesores.Idprofesor)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Idcondicion"] = new SelectList(_context.Condiciones, "Idcondicion", "Condicion", profesores.Idcondicion); ViewData["Idtipodeprofesor"] = new SelectList(_context.ProfesoresTipos, "Idtipodeprofesor", "Tipodeprofesor", profesores.Idtipodeprofesor); return(View(profesores)); }
private bool ExisteEnLaBaseDeDatos() { RepositorioBase <Profesores> repositorio = new RepositorioBase <Profesores>(); Profesores profesor = repositorio.Buscar(Convert.ToInt32(ProfesorIdNumericUpDown.Value)); return(profesor != null); }
public ActionResult DeleteConfirmed(int id) { Profesores profesores = db.Profesores.Find(id); db.Profesores.Remove(profesores); db.SaveChanges(); return(RedirectToAction("Index")); }
static async Task <Profesores> ComprobarInicioSesion(Usuario usuario, BDSAEEContext _context) { Profesores profesor = await _context.Profesores. Where(P => P.Cedula.Equals(usuario.Profesor.Cedula) && P.Contrasenia.Equals(usuario.Profesor.Contrasenia)). FirstOrDefaultAsync(); return(profesor); }
public ModificarMaterias() { InitializeComponent(); cmb_esp.DataSource = Llenar.ObtenerEspecialidad(); cmb_esp.ValueMember = "IdEspecialidad"; cmb_esp.DisplayMember = "EspecialidadString"; Profesores.ListadoProf(dgv); dgv.Columns["idProfesor"].Visible = false; }
public async Task <ActionResult> DeleteConfirmed(int id) { Profesores profesores = await db.Profesores.FindAsync(id); db.Profesores.Remove(profesores); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <Boolean> DeleteProfesores(Profesores profesor) { var profesorborrar = await GetProfesorCompleteData(profesor.Id); _context.Remove(profesorborrar); await _context.SaveChangesAsync(); return(await Task.FromResult(true)); }
public void AgregarProfesor(Profesor profesor) { if (Profesores.Any(entidad => entidad.Cedula == profesor.Cedula)) { throw new FenixExceptionConflict("Ya existe este profesor"); } Profesores.Add(profesor); }
public ActionResult Edit([Bind(Include = "id,Nombre,Apellido")] Profesores profesores) { if (ModelState.IsValid) { db.Entry(profesores).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(profesores)); }
public async Task <ActionResult <Profesores> > GetProfesor() { Profesores profesor = await ComprobacionSesion.ComprobarInicioSesion(HttpContext.Request.Headers, _context); if (profesor == null) { return(BadRequest()); } return(profesor); }
public IActionResult Visualizar(string rut) { Profesores nueva = BuscarProfe(rut); if (nueva != null) { return(View("Ficha", nueva)); } return(View("Listado", Listar)); }
public ActionResult Edit([Bind(Include = "Id,Nombre,Apellido,Honorarios,Edad,Telefono,Salario_periodo,Fecha_contratacion")] Profesores profesores) { if (ModelState.IsValid) { db.Entry(profesores).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(profesores)); }
public async Task <ActionResult <IEnumerable <Grupos> > > GetGrupos() { Profesores profesor = await ComprobacionSesion.ComprobarInicioSesion(HttpContext.Request.Headers, _context); if (profesor == null) { return(BadRequest()); } return(await _context.Grupos.Where(grupo => grupo.IdProfesor == profesor.Id).Include(grupo => grupo.EstudiantesXgrupos).ToListAsync()); }
public List <Profesor> ObtenerProfesores() { return(Profesores .Include(entidad => entidad.Grupos) .ThenInclude(entidad => entidad.Materia) .Include(entidad => entidad.Grupos) .ThenInclude(entidad => entidad.MateriasEstudiantes) .ThenInclude(entidad => entidad.Estudiante) .OrderBy(entidad => entidad.Nombre).ToList()); }
private void LlenarCamposInstancia() { int id = 0; if (IDTextBox.Text != "") { id = Utilidades.TOINT(IDTextBox.Text); } profesores = new Profesores(id, NombreTextBox.Text, apellidoTextBox.Text, TandaTextBox.Text); }
private void btnCrear_Click(object sender, EventArgs e) { Profesores profe = new Profesores(); //Nota: como voy hacer con los IDs Profesor y cursos? Una coleccion? // creando un objeto de tipo list de estas dos entidades para relacionarlos //con el estudiante? profe.Cedula = txtCedula.Text; profe.Nombres = txtNombres.Text; profe.Apellidos = txtApellidos.Text; profe.Celular = txtCelular.Text; profe.Telefono = txtTelefono.Text; profe.Direccion = txtDireccion.Text; profe.Comentario = txtComentario.Text; //Esta parte del codigo esta de la manera tradicional; preguntar a Francis como es // mejor? si es valido usar las sentencias de SQL como SELECT, INSERT o por el ADD // del objeto instanciado de las clases? try { string sql = ""; SqlConnection con = new SqlConnection(strcon); sql = "INSERT INTO tblProfesores (Cedula, Nombres, Apellidos, Sexo, Telefono, Celular, Direccion, Comentario ) " + "VALUES (@Cedula, @Nombres, @Apellidos, @Sexo, @Telefono, @Celular, @Direccion, @Comentario )"; SqlCommand cmd = new SqlCommand(sql, con); cmd.CommandType = CommandType.Text; // cmd.Parameters.AddWithValue("@Id", es.IdEstudiante); cmd.Parameters.AddWithValue("@Cedula", profe.Cedula); cmd.Parameters.AddWithValue("@Nombres", profe.Nombres); cmd.Parameters.AddWithValue("@Apellidos", profe.Apellidos); cmd.Parameters.AddWithValue("@Sexo", profe.Sexo); cmd.Parameters.AddWithValue("@Telefono", profe.Telefono); cmd.Parameters.AddWithValue("@Celular", profe.Celular); //cmd.Parameters.AddWithValue("@FechaIngreso", dtpFechaIngreso.Value); //cmd.Parameters.AddWithValue("@FechaNacimiento", dtpFechaNacimiento.Value); cmd.Parameters.AddWithValue("@Direccion", profe.Direccion); cmd.Parameters.AddWithValue("@Comentario", profe.Comentario); con.Open(); int i = cmd.ExecuteNonQuery(); if (i > 0) { MessageBox.Show("Registro ingresado!!!"); } } catch (Exception ex) { MessageBox.Show("Error ingresando profesor" + ex); } cargarDataGrid(); }
public ActionResult Create([Bind(Include = "id,Nombre,Apellido")] Profesores profesores) { if (ModelState.IsValid) { db.Profesores.Add(profesores); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(profesores)); }