Exemplo n.º 1
0
 private void continueLabel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     ViewManager form = new ViewManager();
     this.Close();
     form.Show();
 }
Exemplo n.º 2
0
        private void exitButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            ViewManager form = new ViewManager();

            this.Close();
            form.Show();
        }
        private void createButton_Click(object sender, RoutedEventArgs e)
        {
            reset_identity(); // clears DB

            bool validated = false;                                                      //Stores the value for whether textboxes are correct
            int happiness = 0;                                                           //Stores the value for happiness
            int intelligence = 0;                                                        //Stores the value for intelligence
            int appearance = 0;                                                          //Stores the value for appearance
            int musical = 0;                                                             //Stores the value for musical
            int artistic = 0;                                                            //Stores the value for artistic
            int athletic = 0;                                                            //Stores the value for athletic
            int strength = 0;                                                            //Stores the value for strength
            int endurance = 0;                                                           //Stores teh value for endurance

            string firstName, lastName;                                                  //Store first and second name of the user
            bool personGender = false;                                                   //Used for person gender

            firstName = firstNameTextBox.Text;                                           //Gets the input from the user for first name
            lastName = lastNameTextBox.Text;                                             //Gets the input from the user for second name

            if ((!maleRadioButton.IsChecked == true) && (!femaleRadioButton.IsChecked == true))              //If no gender selected
                MessageBox.Show("Select a gender.");                                     //Prompt again
            else if (maleRadioButton.IsChecked == true)                                            //If user selected male as gender
                personGender = true;                                                     //set the bool to true ( make him male )
            else                                                                         //If user selected female as gender
                personGender = false;                                                    //set the bool to false ( make her female )

            //Validates the user input
            //*******************************************************************
            validated = validateUserAttributes(ref happiness, ref intelligence,
                                      ref appearance, ref musical, ref artistic,
                                      ref athletic, ref strength, ref endurance);
            if (validated)
            {
                //*******************************************************************

                //Puts the attributes data into the correct table
                //*******************************************************************
                saveAttributes(ref happiness, ref intelligence,
                                        ref appearance, ref musical, ref artistic,
                                        ref athletic, ref strength, ref endurance);
                //*******************************************************************
                create_households("!generateName!", "!generateName!", 30, 3);
                create_households(firstName, lastName, 1, 1);

                /*
                //Establishes connection to database in order to store the user's input\
                //***********************************************************************************************************
                cn.Open();          //Opens connection
                //Tells which table to connect to and where to insert the data and in what order
                cmd = new SqlCommand("Insert into peopleTb (name,gender) values(@name,@gender)", cn);
                cmd.Parameters.AddWithValue("@name", firstName);                //Insert the first name at the proper place
                cmd.Parameters.AddWithValue("@gender", personGender);           //Insert the gender in the proper place
                //cmd.Parameters.AddWithValue("household_id",
                cmd.ExecuteNonQuery();
                cn.Close();         //Closes connection
                //***********************************************************************************************************
                */

                save("autoSave", getLastIdInTable("peopleTb", "person_id")); // Creates save and sends person_id

                ViewManager form = new ViewManager();
                this.Close();
                form.Show();

            }
        }