private void QueryButton_Click(object sender, RoutedEventArgs e)
        {
            // Event handler for when the user clicks the Query button
            // Retrieves questions from the database

            this.RemoveButton.IsEnabled = true;
            DataTable data = DatabaseConnectionQuery.getTableForDataGrid(this.QuestionTypeToQuery.Text, this.CatagoryToQuery.Text);

            this.QueryDataGrid.ItemsSource = data.DefaultView;
            this.QueryDataGrid.IsReadOnly  = true;
            this.EditButton.IsEnabled      = true;
        }
Пример #2
0
        public GameWindow()
        {
            InitializeComponent();
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            // this.category = category;
            InitializeQuestionElements();
            InitializeExitPath();
            InitializeGameRooms();
            InitializeLocks();

            questions = DatabaseConnectionQuery.fillQuestionList();

            StartGame();
        }
        //doesn't do anything yet!
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            // Event handler for when the user clicks the Edit button
            // Modifies a question in the database

            QuestionEntryWindow editor = new QuestionEntryWindow();
            Boolean             isInt  = false;
            int    edit = 0;
            String type = "";

            try
            {
                edit  = Convert.ToInt32(NumberToRemove.Text);
                isInt = true;
            }
            catch (Exception convertError)
            {
                MessageBox.Show("Can't Edit at value!");
            }
            if (isInt)
            {
                if (this.QuestionTypeToQuery.SelectedIndex == 0)
                {
                    type = "trueFalse";
                    DataRow toEdit = DatabaseConnectionQuery.getItemToEdit(edit, type);
                    editor = new QuestionEntryWindow(edit, (String)toEdit.ItemArray[1], "True", "False", null, null, type, this.CatagoryToQuery.SelectedIndex);
                }
                else if (this.QuestionTypeToQuery.SelectedIndex == 1)
                {
                    type = "multipleChoice";
                    DataRow toEdit = DatabaseConnectionQuery.getItemToEdit(edit, type);
                    editor = new QuestionEntryWindow(edit, (String)toEdit.ItemArray[1], (String)toEdit.ItemArray[2], (String)toEdit.ItemArray[3], (String)toEdit.ItemArray[4], (String)toEdit.ItemArray[5], type, this.CatagoryToQuery.SelectedIndex);
                }
                else if (this.QuestionTypeToQuery.SelectedIndex == 2)
                {
                    type = "shortAnswer";
                    DataRow toEdit = DatabaseConnectionQuery.getItemToEdit(edit, type);
                    editor = new QuestionEntryWindow(edit, (String)toEdit.ItemArray[1], (String)toEdit.ItemArray[2], (String)toEdit.ItemArray[3], (String)toEdit.ItemArray[4], (String)toEdit.ItemArray[5], type, this.CatagoryToQuery.SelectedIndex);
                }



                editor.Show();
            }
        }
        private void RemoveButton_Click(object sender, RoutedEventArgs e)
        {
            // Event handler for when the user clicks the Remove button
            // Removes a question from the database

            Boolean isInt  = false;
            int     remove = 0;
            String  type   = "";

            try
            {
                remove = Convert.ToInt32(NumberToRemove.Text);
                isInt  = true;
            }
            catch (Exception convertError)
            {
                MessageBox.Show("Can't remove at value!");
            }
            if (isInt)
            {
                if (this.QuestionTypeToQuery.SelectedIndex == 0)
                {
                    type = "trueFalse";
                }
                else if (this.QuestionTypeToQuery.SelectedIndex == 1)
                {
                    type = "multipleChoice";
                }
                else if (this.QuestionTypeToQuery.SelectedIndex == 2)
                {
                    type = "shortAnswer";
                }
                DatabaseConnectionQuery.removeItem(remove, type);

                QueryButton_Click(null, null);
                MessageBox.Show("Question removed!");
            }
        }
Пример #5
0
 public MainWindow()
 {
     InitializeComponent();
     DatabaseConnectionQuery.InitializeDatabase();
     WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
 }
Пример #6
0
        private void UpdateQuestionToDatebase_Click(object sender, RoutedEventArgs e)
        {
            // Event handler for when the user clicks Update

            if (isTrueFalse)
            {
                if (IsACorrect.IsChecked == true)
                {
                    DatabaseConnectionQuery.updateTFQuestion(QuestionEntry.Text, "true", CatagoryToAddTo.Text, id);
                    MessageBox.Show("Success! Question Updated!");
                    this.Close();
                }
                else if (IsBCorrect.IsChecked == true)
                {
                    DatabaseConnectionQuery.updateTFQuestion(QuestionEntry.Text, "false", CatagoryToAddTo.Text, id);
                    MessageBox.Show("Success! Question Updated!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Answer must be true or false, please select a value and try again!");
                }
            }
            else if (isMultipleChoice)
            {
                if (OptionAEntry.Text.Equals("") || OptionBEntry.Text.Equals("") || OptionCEntry.Text.Equals("") || OptionDEntry.Text.Equals(""))
                {
                    MessageBox.Show("One or more of your options are blank! Please input an answer and try again!");
                }
                else if (IsACorrect.IsChecked == false && IsBCorrect.IsChecked == false && IsCCorrect.IsChecked == false && IsDCorrect.IsChecked == false)
                {
                    MessageBox.Show("You must select an answer! Please pick the button that represents the correct answer and submit again!");
                }
                else if (IsACorrect.IsChecked == true)
                {
                    DatabaseConnectionQuery.updateMCQuestion(QuestionEntry.Text, OptionAEntry.Text, OptionBEntry.Text, OptionCEntry.Text, OptionDEntry.Text, "A", CatagoryToAddTo.Text, id);
                    MessageBox.Show("Success! Question Updated!");
                    this.Close();
                }
                else if (IsBCorrect.IsChecked == true)
                {
                    DatabaseConnectionQuery.updateMCQuestion(QuestionEntry.Text, OptionAEntry.Text, OptionBEntry.Text, OptionCEntry.Text, OptionDEntry.Text, "B", CatagoryToAddTo.Text, id);
                    MessageBox.Show("Success! Question Updated!");
                    this.Close();
                }
                else if (IsCCorrect.IsChecked == true)
                {
                    DatabaseConnectionQuery.updateMCQuestion(QuestionEntry.Text, OptionAEntry.Text, OptionBEntry.Text, OptionCEntry.Text, OptionDEntry.Text, "C", CatagoryToAddTo.Text, id);
                    MessageBox.Show("Success! Question Updated!");
                    this.Close();
                }
                else if (IsDCorrect.IsChecked == true)
                {
                    DatabaseConnectionQuery.updateMCQuestion(QuestionEntry.Text, OptionAEntry.Text, OptionBEntry.Text, OptionCEntry.Text, OptionDEntry.Text, "D", CatagoryToAddTo.Text, id);
                    MessageBox.Show("Success! Question Updated!");
                    this.Close();
                }
            }
            else if (isShortAnswer)
            {
                if (OptionAEntry.Text.Equals("") || OptionBEntry.Text.Equals("") || OptionCEntry.Text.Equals("") || OptionDEntry.Text.Equals(""))
                {
                    MessageBox.Show("One or more of your options are blank! Short Answer questions must have 4 possible correct answers! Please input an answer and try again!");
                }
                else
                {
                    DatabaseConnectionQuery.updateShortQuestion(QuestionEntry.Text, OptionAEntry.Text, OptionBEntry.Text, OptionCEntry.Text, OptionDEntry.Text, CatagoryToAddTo.Text, id);
                    MessageBox.Show("Success! Question Updated!");
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Something went terribly wrong!");
            }
        }