private (Semestre semestre, Semestre semestre2) SalvaSemestres() { var semestre = new Semestre() { Id = 1, Ano = 2020, SegundoSemestre = false, Start = new DateTime(2020, 01, 01), End = new DateTime(2020, 05, 31) }; var semestre2 = new Semestre() { Id = 2, Ano = 2020, SegundoSemestre = true, Start = new DateTime(2020, 01, 01), End = new DateTime(2020, 05, 31) }; _f7DbContext.Add(semestre); _f7DbContext.Add(semestre2); return(semestre, semestre2); }
/// <summary> /// Méthode permettant de modifier une UE (nom ou coeff) /// Listener sur le double click sur un élément de la listBox des UE /// </summary> /// <param name="sender">L'UE sélectionnée</param> /// <param name="e">Double click</param> private void EditerPtésUE(object sender, MouseButtonEventArgs e) { Semestre semestreSelected = this.lbSemestres.SelectedItem as Semestre; // on récupère l'ue sélectionnée UE ueSelected = this.lbUE.SelectedItem as UE; if (semestreSelected != null) { if (ueSelected != null) { // nouvelle fenêtre d'édition EditionWindowUE fenetre = new EditionWindowUE(ueSelected); // remplissage des champs fenetre.tbNom.Text = ueSelected.Nom; fenetre.tbCoeff.Text = ueSelected.Coefficient.ToString().Replace(",", "."); if (fenetre.ShowDialog() == true) { // on actualise l'affichage this.lbUE.Items.Clear(); foreach (UE ue in semestreSelected.ListerUE()) { this.lbUE.Items.Add(ue); } } } } }
public List <Grupo> seleccionarGrupos(Semestre s) { // Creamos lista vacía en caso de Excepcion List <Grupo> listaGrupos = new List <Grupo>(); // Intentamos realizar la operación. Si hubo algún error, // el controlador visual mostrará el mensaje correspondiente. try { if (s.idSemestre == 0) { listaGrupos = daoGrupos.seleccionarGrupos(); } else if (s.idSemestre > 0) { listaGrupos = daoGrupos.seleccionarGruposPorSemestre(s); } } catch (MySqlException e) { ControladorVisual.mostrarMensaje(ControladorExcepciones.crearResultadoOperacionMySqlException(e)); } catch (Exception e) { ControladorVisual.mostrarMensaje(ControladorExcepciones.crearResultadoOperacionException(e)); } // Devolvemos resultado return(listaGrupos); }
public Form5(Form1 main) { InitializeComponent(); this.main = main; semestres = new Semestre[10]; try { StreamReader reader = new StreamReader("..\\..\\Semestres.txt"); String line; int a = 0; while ((line = reader.ReadLine()) != null) { String[] datos = line.Split(','); String nombre = datos[0]; String bolsas = datos[1]; int no_bolsas = Convert.ToInt32(bolsas); Semestre semestre = new Semestre(nombre, no_bolsas); semestres[a] = semestre; a++; } reader.Close(); } catch { } }
public bool EliminarSemestre(int id) { bool resultado = false; using (ExperisDBEntities experisDBEntities = new ExperisDBEntities()) { using (var transacion = experisDBEntities.Database.BeginTransaction()) { try { Semestre semestre = experisDBEntities.Semestre.Find(id); experisDBEntities.Semestre.Remove(semestre); experisDBEntities.SaveChanges(); transacion.Commit(); resultado = true; } catch (Exception e) { transacion.Rollback(); throw new Exception(e.Message); } } } return(resultado); }
/// <summary> /// Méthode permettant d'ajouter une UE /// Listener sur le bouton "Ajouter une nouvelle UE" (click) /// </summary> /// <param name="sender">Le bouton "Ajouter une nouvelle UE"</param> /// <param name="e">Evenement click</param> private void AjouterUE(object sender, RoutedEventArgs e) { Semestre semestreSelected = this.lbSemestres.SelectedItem as Semestre; if (semestreSelected != null) { // on récupère le numéro du semestre sélectionné int numero = semestreSelected.NumeroSemestre; // on crée une UE pour la passer en paramètre puis récupérer ses informations grâce au binding UE ue = new UE("Saisir le nom de l'UE", 0.01F); EditionWindowUE fenetre = new EditionWindowUE(ue); // appel du constructeur de la fenêtre if (fenetre.ShowDialog() == true) { // on ajoute l'UE au semestre correspondant ListeSemestres.Instance.ListerSemestres().ElementAt(numero).AjouterUE(ue); ue.Semestre = ListeSemestres.Instance.ListerSemestres().ElementAt(numero); // on ajoute l'UE à la liste this.liste.AjouterUE(ue); this.lbUE.Items.Clear(); foreach (UE ueToAdd in semestreSelected.ListerUE()) { this.lbUE.Items.Add(ueToAdd); } } } }
public void TestSemestre() { Semestre s = new Semestre(0); Assert.AreEqual(s.NumeroSemestre, 0); Assert.AreEqual(s.ToString(), "Semestre 1"); }
public bool RegistrarActualizarSemestre(ISemestreDTO semestreDTO) { bool resultado = false; using (ExperisDBEntities experisDBEntities = new ExperisDBEntities()) { using (var transacion = experisDBEntities.Database.BeginTransaction()) { try { Semestre semestre = new Semestre(); if (semestreDTO.IdSemestre > 0) { semestre = experisDBEntities.Semestre.Find(semestreDTO.IdSemestre); semestre = semestreDTO.MapearSemestre <Semestre>(semestre); } else { semestre = semestreDTO.MapearSemestre <Semestre>(); experisDBEntities.Semestre.Add(semestre); } experisDBEntities.SaveChanges(); transacion.Commit(); resultado = true; } catch (Exception e) { transacion.Rollback(); throw new Exception(e.Message); } } } return(resultado); }
public async Task <IActionResult> PutSemestre([FromRoute] int id, [FromForm] Semestre semestre) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != semestre.Id) { return(BadRequest()); } _context.Entry(semestre).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SemestreExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// Método que se encarga de verificar la existencia de un periodo lectivo en el sistema /// </summary> /// <param name="nombre">Nombre del periodo lectivo a verificar</param> /// <returns>Retorna una lista de tipo semestre, con los semestres encontrados. Null si falla</returns> public List <Semestre> verificarNombreSemestres(string nombre) { List <Semestre> resultado = new List <Semestre>(); Semestre semestre; SqlCommand buscar = new SqlCommand("SP_SIS_VerificarNombreSemestre", _conexion); buscar.CommandType = CommandType.StoredProcedure; SqlParameter[] parametros = new SqlParameter[1]; parametros[0] = new SqlParameter("@nombre", SqlDbType.VarChar); parametros[0].Value = nombre; buscar.Parameters.AddRange(parametros); try { if (_conexion.State == ConnectionState.Closed) { _conexion.Open(); } SqlDataReader reader = buscar.ExecuteReader(); while (reader.Read()) { semestre = new Semestre(); semestre.IdSemestre = reader.GetInt32(0); // Obtener el PK del semestre resultado.Add(semestre); } _conexion.Close(); return(resultado); } catch (Exception) { return(null); } }
public async Task <IActionResult> BorrarTodo() { var solicitudes = await _context.Solicitud.ToListAsync(); foreach (var item in solicitudes) { _context.Solicitud.Remove(item); } await _context.SaveChangesAsync(); var pdfs = await _context.PDF.ToListAsync(); foreach (var item in pdfs) { _context.PDF.Remove(item); } await _context.SaveChangesAsync(); var semestres = await _context.Semestre.ToListAsync(); foreach (var item in semestres) { _context.Semestre.Remove(item); } await _context.SaveChangesAsync(); Semestre semestreNuevo = new Semestre(); semestreNuevo.Numero = 1; _context.Add(semestreNuevo); await _context.SaveChangesAsync(); return(RedirectToAction("ConfirmacionAño")); }
public async Task <IActionResult> Edit(int id, [Bind("SemestreId,FechaInicio,FechaFin,Nombre")] Semestre semestre) { if (id != semestre.SemestreId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(semestre); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SemestreExists(semestre.SemestreId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(semestre)); }
private void FrmEstadisticas_Load(object sender, EventArgs e) { Semestre semestre = ObtenerSemestre(); lblSemestre.Text = semestre.ToString(); this.dtpFecha.Value = FechaHelper.Ahora(); try { IResultado <IList <Estadistica> > resultadoObtenerNombres = _domain.ObtenerTodos(); if (!resultadoObtenerNombres.Correcto) { throw new ResultadoIncorrectoException <IList <Estadistica> >(resultadoObtenerNombres); } IList <Estadistica> vistas = resultadoObtenerNombres.Retorno; cbVista.DataSource = vistas; cbVista.DisplayMember = "NombreEstadistica"; cbVista.ValueMember = "IdEstadistica"; } catch (Exception ex) { MensajePorPantalla.MensajeError(this, ex.Message); } }
public ActionResult DeleteConfirmed(int id) { Semestre semestre = db.Semestres.Find(id); db.Semestres.Remove(semestre); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Método que se encarga de crear un periodo lectivo en el sistema /// </summary> /// <param name="datosSemestre">Lista que contiene los datos del periodo lectivo a crear de la forma: /// List(NombreSemestre:String, FechaInicio:String, FechaFinal:String)</param> /// <returns>Un valor int, 1 en caso de éxito, 0 en caso contrario</returns> public int crearSemestre(List<string> datosSemestre) { Semestre semestre = new Semestre(); semestre.NombreSemestre = datosSemestre.ElementAt(0); semestre.FechaInicio = Convert.ToDateTime(datosSemestre.ElementAt(1)); semestre.FechaFinal = Convert.ToDateTime(datosSemestre.ElementAt(2)); return _sistemaBD.crearSemestre(semestre); }
public ActionResult GuardarSem(DateTime FechaIni, DateTime FechaFin, string NombreSemestre, string DiasFeriados, string AnioAcad) { Semestre modeloSemestre = new Semestre(); modeloSemestre = new GuardarSemestre().GuardarElSemestre(FechaIni, FechaFin, NombreSemestre, DiasFeriados, AnioAcad); return(View("1AdCreacionSemestre")); }
// DELETES public int eliminarSemestre(Semestre s) { string query = "DELETE FROM semestres " + "WHERE idSemestre = " + s.idSemestre; return(dataSource.ejecutarActualizacion(query)); }
/// <summary> /// Método que se encarga de crear un periodo lectivo en el sistema /// </summary> /// <param name="datosSemestre">Lista que contiene los datos del periodo lectivo a crear de la forma: /// List(NombreSemestre:String, FechaInicio:String, FechaFinal:String)</param> /// <returns>Un valor int, 1 en caso de éxito, 0 en caso contrario</returns> public int crearSemestre(List <string> datosSemestre) { Semestre semestre = new Semestre(); semestre.NombreSemestre = datosSemestre.ElementAt(0); semestre.FechaInicio = Convert.ToDateTime(datosSemestre.ElementAt(1)); semestre.FechaFinal = Convert.ToDateTime(datosSemestre.ElementAt(2)); return(_sistemaBD.crearSemestre(semestre)); }
public ActionResult Edit([Bind(Include = "SemestreID,NomeSemestre")] Semestre semestre) { if (ModelState.IsValid) { db.Entry(semestre).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(semestre)); }
public ActionResult Edit([Bind(Include = "id_semestre,inicio,fin,folio")] Semestre semestre) { if (ModelState.IsValid) { db.Entry(semestre).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(semestre)); }
// INSERTS public int insertarSemestre(Semestre s) { string query = "INSERT INTO semestres " + "(nombre, nombrecorto, nombrecorto2, nombrecorto3) " + "VALUES " + "('" + s.nombre + "', '" + s.nombreCorto + "', '" + s.nombreCorto2 + "', '" + s.nombreCorto3 + "');"; return(dataSource.ejecutarActualizacion(query)); }
public void SupprimerSemestre(Semestre s) { foreach (Semestre se in this.lesSemestres) { if (s.Equals(se)) { this.lesSemestres.Remove(se); } } }
public void AjouterUETest() { Semestre c = new Semestre(); UE monUE = new UE("Info"); c.AjouterUE(monUE); UE[] tabUE = c.ListeDesUE(); Assert.AreEqual(tabUE[0].Nom, "Info"); // Assert.Fail(); }
public void GetUETest() { UE monUE1 = new UE("Info"); Semestre c = new Semestre(); c.AjouterUE(monUE1); Assert.AreEqual(c.GetUE("Info").Nom, "Info"); //Assert.Fail(); }
public ActionResult Create([Bind(Include = "id_semestre,inicio,fin,folio")] Semestre semestre) { if (ModelState.IsValid) { db.Semestre.Add(semestre); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(semestre)); }
public void TestAjouterUEListerUE() { Semestre s = new Semestre(1); UE ue = new UE("INFO", 12); s.AjouterUE(ue); Assert.AreEqual(s.ListerUE()[0].Nom, ue.Nom); Assert.AreEqual(s.ListerUE()[0].Coefficient, ue.Coefficient); Assert.AreEqual(s.ListerUE()[0], ue); }
public List <Grupo> seleccionarGruposPorSemestre(Semestre s) { string query = "SELECT *, C.nombre AS carrera_nombre FROM grupos G, semestres S, carreras C " + "WHERE G.idSemestre = " + s.idSemestre + " AND " + "G.idSemestre = S.idSemestre AND G.idCarrera = C.idCarrera " + "ORDER BY semestre, turno, especialidad, letra;"; MySqlDataReader dr = dataSource.ejecutarConsulta(query); return(crearListaGruposMySqlDataReader(dr)); }
public async Task <IActionResult> Create([Bind("SemestreId,FechaInicio,FechaFin,Nombre")] Semestre semestre) { if (ModelState.IsValid) { _context.Add(semestre); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(semestre)); }
public static int SemestreParaNumero(Semestre sem) { if (sem == Semestre.Primeiro) { return(1); } else { return(2); } }
public ActionResult Create([Bind(Include = "SemestreID,NomeSemestre")] Semestre semestre) { if (ModelState.IsValid) { db.Semestres.Add(semestre); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(semestre)); }
//Action Guardar public ActionResult Guardar(Semestre objSemestre) { if (ModelState.IsValid) { objSemestre.Guardar(); return(Redirect("~/Semestre")); } else { return(View("~/Views/Semestre/AgregarEditar")); } }
/// <summary> /// Método que se encarga de modificar un periodo lectivo del sistema /// </summary> /// <param name="datosSemestre">Lista que contiene los datos del periodo lectivo a modificar de la forma: /// List(NombreSemestre:String, FechaInicio:String, FechaFinal:String)</param> /// <returns>Retorna un int, 1 si fue exitoso, 0 si hubo algun error</returns> public int modificarSemestre(List<string> datosSemestre) { Semestre semestre = new Semestre(); semestre.IdSemestre = Convert.ToInt16(datosSemestre.ElementAt(0)); semestre.NombreSemestre = datosSemestre.ElementAt(1); semestre.FechaInicio = Convert.ToDateTime(datosSemestre.ElementAt(2)); semestre.FechaFinal = Convert.ToDateTime(datosSemestre.ElementAt(3)); semestre.Activo = Convert.ToInt16(datosSemestre.ElementAt(4)); if (_sistemaBD.modificarSemestre(semestre)) return 1; else return 0; }
/// <summary> /// Método que se encarga de obtener todos los semestres registrados /// </summary> /// <returns>Retorna una lista de tipo semestre, con todos los semestres encontrados. Null si falla</returns> public List<Semestre> consultarSemestres() { List<Semestre> resultado = new List<Semestre>(); Semestre semestre; SqlCommand buscar = new SqlCommand("SP_COM_ConsultarSemestres", _conexion); buscar.CommandType = CommandType.StoredProcedure; try { if (_conexion.State == ConnectionState.Closed) _conexion.Open(); SqlDataReader reader = buscar.ExecuteReader(); while (reader.Read()) { semestre = new Semestre(); semestre.IdSemestre = reader.GetInt32(0); // Obtener el PK del semestre semestre.NombreSemestre = reader.GetString(1); // Obtener nombre del semestre semestre.FechaInicio = reader.GetDateTime(2); // Obtener fecha de inicio del semestre semestre.FechaFinal = reader.GetDateTime(3); // Obtener fecha de fin del semestre semestre.Activo = reader.GetInt32(4); // Obtener el estadod el semestre resultado.Add(semestre); } _conexion.Close(); return resultado; } catch (Exception ex) { if (_conexion.State == ConnectionState.Open) _conexion.Close(); insertarBitacoraError(ex.ToString(), ""); return null; } }
private void BotaoConfirmar_Click(object sender, RoutedEventArgs e) { try { //Verifica o modo atual da tela switch (modo) { case ModoDeTela.Novo: using (var context = new Proxy.SistemaHorariosServiceClient()) { var item = new Semestre() { Numero = Convert.ToInt16(TextBoxNome.Text) }; context.AddSemestre(item); } break; case ModoDeTela.Editar: using (var context = new Proxy.SistemaHorariosServiceClient()) { var item = new Semestre() { Codigo = Convert.ToInt16(TextBoxCodigo.Text), Numero = Convert.ToInt16(TextBoxNome.Text) }; context.UpdateSemestre(item); } break; default: MessageBox.Show("Modo de tela inválido!"); break; } MessageBox.Show("Registro atualizado/cadastrado com sucesso! =)"); AtualizarLista(); //Seta o modo da tela para o modo standard mudarModo(ModoDeTela.Cancelar); } catch (Exception) { MessageBox.Show("Erro ao criar/atualizar registro"); } }
private void BotaoExcluir_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Tem certeza que deseja excluir este registro?", "Aviso", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { try { //Tenta deletar o registro using (var context = new Proxy.SistemaHorariosServiceClient()) { var item = new Semestre() { Codigo = Convert.ToInt16(TextBoxCodigo.Text), Numero = Convert.ToInt16(TextBoxNome.Text) }; context.DeleteSemestre(item); } MessageBox.Show("Registro deletado com sucesso! =)"); AtualizarLista(); //Seta o modo da tela para o modo standard mudarModo(ModoDeTela.Cancelar); } catch (Exception) { MessageBox.Show("Erro ao deletar o registro"); } } }