public static string buscarPersonaPorDNI(string dni) { for (int i = 0; i < Personas.GetPersonas().Count; i++) { if (personas[i].Dni == dni) { SoundPlayer My_JukeBox = new SoundPlayer(@"Sounds/item.wav"); try { My_JukeBox.Play(); } catch (FileNotFoundException ex) { // Write error. Console.WriteLine(ex); } return(personas[i].ToString()); } } SoundPlayer My_JukeBox2 = new SoundPlayer(@"Sounds/nope.wav"); try { My_JukeBox2.Play(); } catch (FileNotFoundException ex) { // Write error. Console.WriteLine(ex); } return("No se ha encontrado una persona con ese DNI"); }
private void Button_Click_1(object sender, RoutedEventArgs e) { for (int i = 0; i < Personas.GetPersonas().Count; i++) { texto.Text += Personas.buscarPersonaPorIndex(i); } }
public static string buscarPersonadeMasAltura() { Persona max = new Persona("", "", "", "", 0, 0); for (int i = 0; i < Personas.GetPersonas().Count; i++) { if (personas[i].Altura > max.Altura) { max = personas[i]; } } return(max.ToString()); }
public static string buscarPersonadeMenosPeso() { Persona max = new Persona("", "", "", "", 1000000, 0); for (int i = 0; i < Personas.GetPersonas().Count; i++) { if (personas[i].Peso < max.Peso) { max = personas[i]; } } return(max.ToString()); }
public void buscarPersonaPorNombre(String nombre) { SoundPlayer My_JukeBox = new SoundPlayer(@"Sounds/nope.wav"); SoundPlayer My_JukeBox2 = new SoundPlayer(@"Sounds/item.wav"); if (nombre == "") { try { My_JukeBox.Play(); } catch (FileNotFoundException ex) { Console.WriteLine(ex); } MessageBox.Show("Introduce un nombre"); } else { texto.Text = ""; for (int i = Personas.GetPersonas().Count - 1; i >= 0; i--) { if (Personas.GetPersonas()[i].Nombre == nombre) { texto.Text += Personas.buscarPersonaPorIndex(i); Personas.removePersona(Personas.GetPersonas()[i]); try { My_JukeBox2.Play(); } catch (FileNotFoundException ex) { Console.WriteLine(ex); } } } if (texto.Text == "") { texto.Text = "No se ha encontrado a nadie con ese nombre"; try { My_JukeBox.Play(); } catch (FileNotFoundException ex) { Console.WriteLine(ex); } } } }
private void Button1_Click(object sender, RoutedEventArgs e) { int opcion = Combobox1.SelectedIndex; switch (opcion) { case 0: SoundPlayer My_JukeBox = new SoundPlayer(@"Sounds/call.wav"); try { My_JukeBox.Play(); } catch (FileNotFoundException ex) { // Write error. Console.WriteLine(ex); } Window1 window = new Window1(); window.ShowDialog(); break; case 1: SoundPlayer My_JukeBox2 = new SoundPlayer(@"Sounds/alerted.wav"); try { My_JukeBox2.Play(); } catch (FileNotFoundException ex) { Console.WriteLine(ex); } texto.Text = String.Empty; for (int i = 0; i < Personas.GetPersonas().Count; i++) { texto.Text += Personas.buscarPersonaPorIndex(i); } break; case 2: SoundPlayer My_JukeBox3 = new SoundPlayer(@"Sounds/itemselect.wav"); try { My_JukeBox3.Play(); } catch (FileNotFoundException ex) { // Write error. Console.WriteLine(ex); } Window2 window2 = new Window2(); window2.ShowDialog(); break; case 3: SoundPlayer My_JukeBox4 = new SoundPlayer(@"Sounds/item2.wav"); try { My_JukeBox4.Play(); } catch (FileNotFoundException ex) { Console.WriteLine(ex); } MessageBox.Show(Personas.buscarPersonadeMenosPeso()); break; case 4: SoundPlayer My_JukeBox5 = new SoundPlayer(@"Sounds/item2.wav"); try { My_JukeBox5.Play(); } catch (FileNotFoundException ex) { Console.WriteLine(ex); } MessageBox.Show(Personas.buscarPersonadeMasAltura()); break; case 5: SoundPlayer My_JukeBox6 = new SoundPlayer(@"Sounds/item2.wav"); try { My_JukeBox6.Play(); } catch (FileNotFoundException ex) { Console.WriteLine(ex); } Window3 window3 = new Window3(); window3.ShowDialog(); break; case 6: SoundPlayer My_JukeBox7 = new SoundPlayer(@"Sounds/dead.wav"); try { My_JukeBox7.Play(); } catch (FileNotFoundException ex) { Console.WriteLine(ex); } Task.Delay(7500).Wait(); this.Close(); break; } }
private void SubmitButton_Click(object sender, RoutedEventArgs e) { string nombre, apellidos, dni, fechanac; int peso = 0, altura = 0; nombre = Textbox1.Text; apellidos = Textbox2.Text; dni = Textbox3.Text; fechanac = date.Text; if (!String.IsNullOrEmpty(Textbox5.Text)) { peso = Convert.ToInt32(Textbox5.Text); } if (!String.IsNullOrEmpty(Textbox6.Text)) { altura = Convert.ToInt32(Textbox6.Text); } Persona persona = new Persona(nombre, apellidos, dni, fechanac, peso, altura); int nope = 0; for (int i = 0; i < Personas.GetPersonas().Count; i++) { if (Personas.GetPersonas()[i].Dni == persona.Dni) { nope = 1; SoundPlayer My_JukeBox = new SoundPlayer(@"Sounds/nope.wav"); try { My_JukeBox.Play(); } catch (FileNotFoundException ex) { Console.WriteLine(ex); } MessageBox.Show("Ya hay una persona con el mismo DNI"); } } if (nope == 0) { SoundPlayer My_JukeBox2 = new SoundPlayer(@"Sounds/item.wav"); try { My_JukeBox2.Play(); } catch (FileNotFoundException ex) { // Write error. Console.WriteLine(ex); } Personas.addPersona(persona); Task.Delay(700).Wait(); this.Close(); } else { Textbox1.Clear(); Textbox2.Clear(); Textbox3.Clear(); Textbox6.Clear(); Textbox5.Clear(); date.ClearValue(DatePicker.SelectedDateProperty); } }