private void LlenaCampo(Semestres semestre) { IdNumericUpDown.Value = semestre.SemestreId; FechaInicioDateTimePicker.Value = semestre.FechaInicio; FechaFinalDateTimePicker.Value = semestre.FechaFin; ActivoCheckBox.Checked = semestre.Activo; }
public async Task <ActionResult <Semestres> > PostSemestres(Semestres semestres) { _context.Semestres.Add(semestres); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSemestres", new { id = semestres.idsemestre }, semestres)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { FechaTextBox.Text = DateTime.Today.ToString("yyyy-MM-dd"); VenceTextBox.Text = DateTime.Today.AddDays(1).ToString("yyyy-MM-dd"); AsignaturaDropDownList.DataSource = Asignaturas.Listar(" IdAsignatura, Nombre ", " 1=1 "); AsignaturaDropDownList.DataValueField = "IdAsignatura"; AsignaturaDropDownList.DataTextField = "Nombre"; AsignaturaDropDownList.DataBind(); SemestreDropDownList.DataSource = Semestres.Listar(" Codigo, IdSemestre", " 1=1 "); SemestreDropDownList.DataTextField = "Codigo"; SemestreDropDownList.DataValueField = "IdSemestre"; SemestreDropDownList.DataBind(); if (Request.QueryString["IdTarea"] != null) { tarea.IdTarea = int.Parse(Request.QueryString["IdTarea"].ToString()); if (tarea.Buscar(tarea.IdTarea)) { CodigoTareaTextBox.Text = tarea.CodigoTarea; FechaTextBox.Text = tarea.Fecha.ToString("yyyy-MM-dd"); VenceTextBox.Text = tarea.Vence.ToString("yyyy-MM-dd"); AsignaturaDropDownList.SelectedIndex = AsignaturaDropDownList.Items.IndexOf(AsignaturaDropDownList.Items.FindByValue(tarea.IdAsignatura.ToString())); SemestreDropDownList.SelectedIndex = SemestreDropDownList.Items.IndexOf(SemestreDropDownList.Items.FindByValue(tarea.IdSemestre.ToString())); DescripcionTextBox.Text = tarea.Descripcion; ResultadoEsperadoTextBox.Text = tarea.ResultadoEsperado; EliminarButton.Visible = true; } EliminarButton.Visible = true; } } }
protected void Page_Load(object sender, EventArgs e) { Semestres semestre = new Semestres(); Asignaturas asignatura = new Asignaturas(); if (!IsPostBack) { Tareas tarea = new Tareas(); if (Request.QueryString["IdTarea"] != null) { tarea.IdTarea = Util.ObtenerEntero(Request.QueryString["IdTarea"]); if (tarea.Buscar()) { this.LLenarCampos(tarea); } } } this.IdsemestreDropDownList.DataSource = semestre.Listar("IdSemestre,Codigo", "1=1"); this.IdsemestreDropDownList.DataValueField = "IdSemestre"; this.IdsemestreDropDownList.DataTextField = "Codigo"; this.IdsemestreDropDownList.DataBind(); this.IdasignaturaDropDownList.DataSource = Asignaturas.Lista("IdAsignatura,Nombre", "1=1"); this.IdasignaturaDropDownList.DataValueField = "IdAsignatura"; this.IdasignaturaDropDownList.DataTextField = "Nombre"; this.IdasignaturaDropDownList.DataBind(); }
public int SaveChanges() { Semestres entity = new Semestres { estado = estado, user_crea = user_crea, fecha_crea = fecha_crea, fecha_modif = fecha_modif, idsemestre = idsemestre, semestre = semestre, user_modif = user_modif }; int salida = 0; switch (states) { case EntityStates.Add: salida = repositorioDataModel.Add(entity); break; case EntityStates.Delete: salida = repositorioDataModel.Delete(entity); break; case EntityStates.Update: salida = repositorioDataModel.Edit(entity); break; default: break; } return(salida); }
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> PutSemestres(int id, Semestres semestres) { if (id != semestres.idsemestre) { return(BadRequest()); } _context.Entry(semestres).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SemestresExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private bool ExisteEnLaBaseDeDatos() { SemestreRepositorio repositorio = new SemestreRepositorio(); Semestres semestre = repositorio.Buscar((int)IdNumericUpDown.Value); return(semestre != null); }
private void llenaClase(Semestres sem) { sem.Codigo = CodigoTextBox.Text; sem.FechaInicio = DateTime.Parse(FechaInicioTextBox.Text); sem.FechaFin = DateTime.Parse(FechaFinTextBox.Text); sem.FechaParcial1 = DateTime.Parse(FechaParcial1TextBox.Text); sem.FechaParcial2 = DateTime.Parse(FechaParcial2TextBox.Text); sem.FechaFinal = DateTime.Parse(FechaFinalTextBox.Text); sem.esActivo = esActivoCheckBox.Checked; }
private Semestres LlenaClase() { Semestres semestre = new Semestres(); semestre.SemestreId = Convert.ToInt32(IdNumericUpDown.Value); semestre.FechaInicio = FechaInicioDateTimePicker.Value; semestre.FechaFin = FechaFinalDateTimePicker.Value; semestre.UsuarioId = UsuarioId; semestre.Usuario = UsuarioTextBox.Text; return(semestre); }
private void BorrarButton_Click(object sender, EventArgs e) { RepositorioBase <Inscripciones> repositorioInscripciones = new RepositorioBase <Inscripciones>(); bool interruptor = false; RepositorioBase <Usuarios> repositorioUsuario = new RepositorioBase <Usuarios>(); Usuarios usuario = repositorioUsuario.Buscar(UsuarioId); if (usuario.Tipo.CompareTo("Administrador") == 0) { SemestreRepositorio repositorio = new SemestreRepositorio(); int id; int.TryParse(Convert.ToString(IdNumericUpDown.Value), out id); Semestres semestre = repositorio.Buscar(id); //Si existen inscripciones relacionadas no se puede eliminar. foreach (var item in repositorioInscripciones.GetList(a => true)) { if (item.SemestreId == id) { interruptor = true; break; } } if (interruptor) { MessageBox.Show("No puede eliminar este semestre debido \na que existen inscripciones relacionadas con este.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Limpiar(); if (semestre != null) { repositorio.Eliminar(id); MessageBox.Show("Eliminado!"); } else { MyErrorProvider.SetError(IdNumericUpDown, "No se puede eliminar un semestre que no existe"); } } else { MessageBox.Show("Esta registrado como usuario estandar, no puedes eliminar semestres", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void ModificarTest() { SemestreRepositorio repositorio = new SemestreRepositorio(); Semestres semestres = new Semestres(); semestres.FechaInicio = DateTime.Now; semestres.FechaFin = DateTime.Now; semestres.SemestreId = 2; semestres.Usuario = "Jose"; semestres.UsuarioId = 1; Assert.IsTrue(repositorio.Guardar(semestres)); }
protected void DeleteButton_Click(object sender, EventArgs e) { Semestres semestre = new Semestres(); if (semestre.Eliminar(IdSemestreTextBox.Text) == true) { Response.Write("Semestre Eliminado"); LimpiarCampos(); } else { Response.Write("Selecione el semestre que decea eliminar"); } }
protected void SaveButton_Click(object sender, EventArgs e) { Semestres sem = new Semestres(); llenaClase(sem); if (sem.Insertar()) { Response.Redirect("~/Consultas/cSemestres.aspx"); } else { Response.Write("Error!!!"); } }
public int Edit(Semestres entity) { try { using (var db = new BitacorasContexto()) { db.Entry(entity).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges()); } } catch (Exception e) { log.Error(DateTime.Now + " " + e); return(0); } }
public int Delete(Semestres entity) { try { using (var db = new BitacorasContexto()) { db.Semestres.Remove(entity); return(db.SaveChanges()); } } catch (Exception e) { log.Error(DateTime.Now + " " + e); return(0); } }
private void SemestreIdNumericUpDown_ValueChanged(object sender, EventArgs e) { if ((SemestreIdNumericUpDown.Value == 0)) { return; } SemestreRepositorio repositorio = new SemestreRepositorio(); Semestres semestre = repositorio.Buscar((int)SemestreIdNumericUpDown.Value); if (!ValidarSemestre(semestre)) { return; } }
public int Add(Semestres entity) { //throw new NotImplementedException(); try { using (var db = new BitacorasContexto()) { db.Semestres.Add(entity); return(db.SaveChanges()); } } catch (Exception e) { log.Error(DateTime.Now + " " + e); return(0); } }
private void LlenaCampo(Semestres semestre) { IdSemestreTextBox.Text = Convert.ToString(IdSemestreTextBox.Text); CodigoTextBox.Text = semestre.Codigo; FechaInicio.Text = semestre.FechaInicio.ToString("yyyy-MM-dd"); FechaFin0.Text = semestre.FechaFin.ToString("yyyy-MM-dd"); FechaParcial1.Text = semestre.FechaInicio.ToString("yyyy-MM-dd"); FechaParcial2.Text = semestre.FechaParcial1.ToString("yyyy-MM-dd"); FechaFinal.Text = semestre.FechaFinal.ToString("yyyy-MM-dd"); esActivoCheckBox.Checked = semestre.esActivo; //if (semestre.Codigo != null) //{ // Session["Modificando"] = true; //} //else //{ // Session["Modificando"] = false; //} }
private bool ValidarSemestre(Semestres semestre) { MyErrorProvider.Clear(); bool paso = true; if (semestre == null) { MyErrorProvider.SetError(SemestreIdNumericUpDown, "Debe de insertar un id de un semestre valido"); SemestreIdNumericUpDown.Focus(); return(false); } if (!semestre.Activo) { MyErrorProvider.SetError(SemestreIdNumericUpDown, "Debe de insertar un id de un semestre activo"); SemestreIdNumericUpDown.Focus(); paso = false; } return(paso); }
private void BuscarButton_Click(object sender, EventArgs e) { SemestreRepositorio repositorio = new SemestreRepositorio(); int id; int.TryParse(Convert.ToString(IdNumericUpDown.Value), out id); Semestres semestre = repositorio.Buscar(id); Limpiar(); if (semestre != null) { LlenaCampo(semestre); } else { MessageBox.Show("Semestre no encontrado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private bool Validar() { MyErrorProvider.Clear(); bool paso = true; if (string.IsNullOrWhiteSpace(AsignaturasComboBox.Text)) { MyErrorProvider.SetError(AsignaturasComboBox, "Debe de seleccionar una asignatura"); AsignaturasComboBox.Focus(); paso = false; } if (this.Detalle.Count == 0) { MyErrorProvider.SetError(EstudiantesDataGridView, "Debe agregar algun estudiante"); EstudiantesDataGridView.Focus(); paso = false; } SemestreRepositorio repositorio = new SemestreRepositorio(); Semestres semestre = repositorio.Buscar((int)SemestreIdNumericUpDown.Value); if (semestre == null) { MyErrorProvider.SetError(SemestreIdNumericUpDown, "Debe de insertar un id de un semestre valido"); SemestreIdNumericUpDown.Focus(); return(false); } if (!semestre.Activo) { MyErrorProvider.SetError(SemestreIdNumericUpDown, "Debe de insertar un id de un semestre activo"); SemestreIdNumericUpDown.Focus(); paso = false; } return(paso); }
private void GuardarButton_Click(object sender, EventArgs e) { SemestreRepositorio repositorio = new SemestreRepositorio(); bool paso = false; if (!Validar()) { return; } Semestres semestre = LlenaClase(); if (IdNumericUpDown.Value == 0) { paso = repositorio.Guardar(semestre); } else { if (!ExisteEnLaBaseDeDatos()) { MessageBox.Show("No se encuentra en la base de datos el semestre buscado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } paso = repositorio.Modificar(semestre); } if (paso) { Limpiar(); MessageBox.Show("Guardado exitosamente", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No se pudo guardar el semestre", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected void SaveButton_Click(object sender, EventArgs e) { Semestres semestre = new Semestres(); LlenaClase(); //if (Convert.ToBoolean(Session["Modificando"]) == false) //{ if (Request.QueryString["IdSemestre"] != null) { semestre.IdSemestre = int.Parse(Request.QueryString["IdSemestre"]); if (semestre.Modificar()) { Response.Redirect("cSemestres.aspx"); } else { Response.Write("No se pudo modificar"); } } else if (semestre.Insertar()) { LimpiarCampos(); Response.Write("Registro realizado con exito"); } else { Response.Write("Error de registro"); } //} }