private void eliminar_Click(object sender, EventArgs e) { StreamReader Lector; bool encontrar; encontrar = false; String[] longitud = new String[99]; String Cadenas; StreamWriter escribir; escribir = File.CreateText("copia.txt"); try { Lector = File.OpenText("Estudiantes.txt"); string id = textBox1.Text; Cadenas = Lector.ReadLine(); while (Cadenas != null) { longitud = Cadenas.Split(','); if (longitud[0].Trim().Equals(id)) { Console.WriteLine("Nombre: " + longitud[0].Trim()); encontrar = true; } else { escribir.WriteLine(Cadenas); } Cadenas = Lector.ReadLine(); } if (encontrar == false) { MessageBox.Show("La ID no es correcta o no existe", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("La Eliminacion se completo exitosamente!", "Message", MessageBoxButtons.OK); } Lector.Close(); escribir.Close(); File.Delete("Estudiantes.txt"); File.Move("copia.txt", "Estudiantes.txt"); } catch { MessageBox.Show("Error masivo en el sistema favor intentar nuevamente", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); } this.Close(); }
private void Ventana_Buscador_Archivos_Duplicados_FormClosing(object sender, FormClosingEventArgs e) { try { Temporizador_Principal.Stop(); if (Lector_Texto != null) { Lector_Texto.Flush(); Lector_Texto.Close(); Lector_Texto.Dispose(); Lector_Texto = null; } if (Lector != null) { Lector.Close(); Lector.Dispose(); Lector = null; } } catch (Exception Excepción) { Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null); Variable_Excepción_Total++; Variable_Excepción = true; } }
private async void InicializarReproduccion() { IReproductor.Bloquear(); if (Lector != null) { Lector.Close(); } Reproductor.Stop(); Servicios.ServiciosDeDescarga serviciosDeDescarga = new Servicios.ServiciosDeDescarga(); serviciosDeDescarga.EliminarArchivosTemporales(); if (CancionesEnCola.Count > CancionActual) { if (CancionActual >= 0) { CancionesEnCola[CancionActual].CargarDireccionDeCancion(); bool resultado; if (!CancionesEnCola[CancionActual].CancionEstaDescargada()) { if (ModoConectado) { resultado = await serviciosDeDescarga.DescargarAudioTemporalDeCancion(CancionesEnCola[CancionActual].Id, Token); } else { IReproductor.Desbloquear(); Siguiente(); } } Lector = new Mp3FileReader(CancionesEnCola[CancionActual].DireccionDeCancion); Reproductor.DeviceNumber = 0; Reproductor.Init(Lector); Reproductor.Play(); Reproductor.Volume = Volumen; IReproductor.CargarDatosDeCancionActual(); } } IReproductor.Desbloquear(); }
public void MetodoActualizarFicha(string IdFicha) { try { ConnectionBD Puente; SqlCommand Comando; SqlDataReader Lector; Puente = new ConnectionBD(); Comando = new SqlCommand("select * from Ficha where IdFicha='" + IdFicha + "'", Puente.RetornarConnexion()); Lector = Comando.ExecuteReader(); while (Lector.Read()) { DocumentoInstructor = Lector.GetString(1); IdPrograma = Lector.GetString(2); Jornada = Lector.GetString(3); FechaInicio = Lector.GetDateTime(4); FechaFin = Lector.GetDateTime(5); Estado = Lector.GetString(6); } a = IdPrograma.ToString(); if (a == "") { existe = 1; } Lector.Close(); Comando.Dispose(); Puente.CerrarConnexion(); } catch (Exception ex) { MessageBox.Show("la ficha no existe"); } }
// public string DocumentoInstructor,Nombre1,Apellido1,Direccion1,Telefono1,Celular1,Profesion1,Estado1; public void MetodoInstructor(string DocumentoInstructor) { try { ConnectionBD Puente; SqlCommand Comando; SqlDataReader Lector; Puente = new ConnectionBD(); Comando = new SqlCommand("select * from Instructor where DocumentoInstructor='" + DocumentoInstructor + "'", Puente.RetornarConnexion()); Lector = Comando.ExecuteReader(); while (Lector.Read()) { Nombre = Lector.GetString(1); Apellido = Lector.GetString(2); Direccion = Lector.GetString(3); Telefono = Lector.GetString(4); Celular = Lector.GetString(5); Profesion = Lector.GetString(6); Estado = Lector.GetString(7); } Nombre.ToString(); Apellido.ToString(); Direccion.ToString(); Telefono.ToString(); Celular.ToString(); Profesion.ToString(); Estado.ToString(); Lector.Close(); Comando.Dispose(); Puente.CerrarConnexion(); } catch (Exception ex) { MessageBox.Show("El Instructor no existe"); } }
private void button1_Click(object sender, EventArgs e) { StreamReader Lector; bool encontrar; encontrar = false; String[] longitud = new String[99]; String Cadenas; StreamWriter escribir; escribir = File.CreateText("copia.txt"); try { Lector = File.OpenText("Calificaciones.txt"); string Nota = textBox1.Text; string IDE = textBox2.Text; string IDP = textBox3.Text; string Clave = textBox4.Text; Cadenas = Lector.ReadLine(); while (Cadenas != null) { longitud = Cadenas.Split(','); if (longitud[0].Trim().Equals(IDE)) { if (longitud[1].Trim().Equals(IDP)) { if (longitud[2].Trim().Equals(Clave)) { if (longitud[3].Trim().Equals(Nota)) { encontrar = true; } else { escribir.WriteLine(Cadenas); } } } } Cadenas = Lector.ReadLine(); } if (encontrar == false) { MessageBox.Show("La calificacion no es correcta o no existe", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("La Eliminacion se completo exitosamente!", "Message", MessageBoxButtons.OK); Lector.Close(); escribir.Close(); File.Delete("Calificaciones.txt"); File.Move("copia.txt", "Calificaciones.txt"); } } catch { MessageBox.Show("Error masivo en el sistema favor intentar nuevamente", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); } this.Close(); }