private void button3_Click(object sender, EventArgs e)
 {
     Textbox5.Clear();
     Textbox6.Clear();
     Textbox7.Clear();
 }
        private void button1_Click(object sender, EventArgs e)
        {
            String connection = "Provider=OraOLEDB.Oracle;Data Source=localhost;Workspace=Malcolm;User Id=MALCOLM;Password=madeira;OLEDB.NET=True";

            OleDbConnection obj1 = new OleDbConnection(connection);
            string          S3   = ComboBox1.SelectedItem.ToString(); //sex
            string          S1   = ComboBox2.SelectedItem.ToString();
            string          S2   = Textbox5.Text + 8;                 //For ID

            if (ComboBox2.SelectedItem.ToString() == "Employee")
            {
                if (Textbox6.Text == Textbox7.Text)
                {
                    String q2 = "insert into Login values ('" + Textbox5.Text + "','" + Textbox6.Text + "','" + S1 + "')";
                    obj1.Open();

                    try
                    {
                        OleDbCommand cm2 = new OleDbCommand(q2, obj1);
                        cm2.ExecuteNonQuery();
                    }
                    catch (Exception ee)
                    {
                        MessageBox.Show(ee.Message);
                    }
                }
                else
                {
                    MessageBox.Show("**********Password Don't Match\nPlease Re-ENTER*********");
                }
                //Employee details

                String q3 = "insert into EMPLOYEE values ('" + S2 + "','" + Textbox5.Text + "','" + Textbox2.Text + "','" + Textbox1.Text + "','" + Textbox3.Text + "','" + S3 + "')";


                try
                {
                    OleDbCommand cm2 = new OleDbCommand(q3, obj1);
                    cm2.ExecuteNonQuery();
                    MessageBox.Show("************Record Insert Successfully*********");
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
            }

            if (ComboBox2.SelectedItem.ToString() == "Customer")
            {
                if (Textbox6.Text == Textbox7.Text)
                {
                    String q4 = "insert into Login values ('" + Textbox5.Text + "','" + Textbox6.Text + "','" + ComboBox2.SelectedItem.ToString() + "')";
                    obj1.Open();

                    try
                    {
                        OleDbCommand cm2 = new OleDbCommand(q4, obj1);
                        cm2.ExecuteNonQuery();
                    }
                    catch (Exception ee)
                    {
                        MessageBox.Show(ee.Message);
                    }
                }
                else
                {
                    MessageBox.Show("**********Password Don't Match\nPlease Re-ENTER*********");
                }
                //Customer details

                String q3 = "insert into CUSTOMER values ('" + Textbox5.Text + "','" + S2 + "','" + Textbox2.Text + "','" + Textbox1.Text + "','" + Textbox3.Text + "','" + S3 + "')";


                try
                {
                    OleDbCommand cm2 = new OleDbCommand(q3, obj1);
                    cm2.ExecuteNonQuery();
                    MessageBox.Show("************Record Insert Successfully*********");
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
            }

            Textbox5.Clear();
            Textbox6.Clear();
            Textbox7.Clear();
            Textbox1.Clear();
            Textbox2.Clear();
            Textbox3.Clear();
        }
Пример #3
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);
            }
        }