Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        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);
            }
        }