Example #1
0
 private void bwUpdateNumQuestionsPerCategory_DoWork(object sender, DoWorkEventArgs e)
 {
     if (!DB_Update.UpdateGameNumQuestionsPerCategory(game.NumQuestionsPerCategory, game.Id)) //updating db happens here
     {
         MessageBox.Show("Failed to update NumQuestionsPerCategory");
     }
 }
Example #2
0
 private void bwUpdateGameName_DoWork(object sender, DoWorkEventArgs e)
 {
     if (!DB_Update.UpdateGameName(game.GameName, game.Id)) //updating the database happens here
     {
         MessageBox.Show("Error updating Game name", "Error");
     }
 }
Example #3
0
 private void bwUpdateNumCategories_DoWork(object sender, DoWorkEventArgs e)
 {
     if (!DB_Update.UpdateGameNumCategories(game.NumCategories, game.Id))
     {
         MessageBox.Show("Failed to update NumCategories");
     }
 }
Example #4
0
        //MARK: Button Event Handlers
        private void btnOK_Click(object sender, EventArgs e)
        {
            string subtitle = txtSubtitle.Text;

            // allows user to enter in a blank subtitle
            if (subtitle == "" || subtitle == null)
            {
                subtitle = " ";
            }

            if (Validation.ValidateCategoryTitle(txtTitle.Text) && Validation.ValidateCategorySubtitle(subtitle))
            {
                category.Title    = txtTitle.Text;
                category.Subtitle = txtSubtitle.Text;

                if (!DB_Update.UpdateCategory(category))
                {
                    MessageBox.Show("Updating Category Failed");
                }
                else
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
Example #5
0
 private void bwUpdateTimeLimit_DoWork(object sender, DoWorkEventArgs e) //also update in db for future games
 {
     //Updates the database whenever the user changes the question time limit
     if (!DB_Update.UpdateGameQuestionTimeLimit(game.QuestionTimeLimit, game.Id))
     {
         MessageBox.Show("Error updating Game name");
     }
 }
Example #6
0
        //MARK: Button Event Handlers
        private void btnOK_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = DialogResult.OK;

            //error / warning checking
            if (txtQuestionText.Text.Length > 1 && txtAnswer.Text.Trim() == "")
            {
                dialogResult = MessageBox.Show("You have not given this question an answer yet.\n\nThis question will appear Red until you give it an answer.", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            }
            else if (rdoMultipleChoice.Checked && (txtChoiceA.Text.Trim() == "" || txtChoiceB.Text.Trim() == "" || txtChoiceC.Text.Trim() == "" || txtChoiceD.Text.Trim() == ""))
            {
                dialogResult = MessageBox.Show("You have not given this multiple choice question all 4 Choices yet.\n\nThis question will appear Orange until you give it 4 choices.", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            }

            if (dialogResult == DialogResult.OK)
            {
                if (rdoFillInTheBlank.Checked)
                {
                    question.Type = "fb";
                }
                else if (rdoMultipleChoice.Checked)
                {
                    question.Type = "mc";

                    question.Choices[0].Text = txtChoiceA.Text;
                    question.Choices[1].Text = txtChoiceB.Text;
                    question.Choices[2].Text = txtChoiceC.Text;
                    question.Choices[3].Text = txtChoiceD.Text;

                    for (int i = 0; i < 4; i++)
                    {
                        DB_Update.UpdateChoiceText(question.Choices[i].Text, question.Choices[i].Id);
                    }
                }
                else if (rdoTrueFalse.Checked)
                {
                    question.Type = "tf";
                }

                question.QuestionText = txtQuestionText.Text;
                question.Answer       = txtAnswer.Text;

                if (!DB_Update.UpdateQuestion(question))
                {
                    MessageBox.Show("Updating Question failed");
                }
                else
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
Example #7
0
        private void bwUpdateCategory_DoWork(object sender, DoWorkEventArgs e) //also updates questions
        {
            int i = (int)e.Argument;                                           // i is category index

            DB_Update.UpdateCategory(currentCategory);

            for (int j = 0; j < game.NumQuestionsPerCategory; j++) // j is question index
            {
                game.Categories[i].Questions[j].ResetQuestionToDefaults();
                DB_Update.UpdateQuestion(game.Categories[i].Questions[j]);
            }
        }
Example #8
0
        private void bwImportCategory_DoWork(object sender, DoWorkEventArgs e)
        {
            if (importCategoryForm.SelectedCategory.Questions.Count > 0) //only import questions if there are any
            {
                //only imports questions to the max size of the grid and the max size of the other game grid
                for (int i = 0; i < category.Questions.Count && i < importCategoryForm.SelectedCategory.Questions.Count; i++)
                {
                    //if going from multiple choice to another type, delete the choices
                    if (category.Questions[i].Type == "mc" && importCategoryForm.SelectedCategory.Questions[i].Type != "mc")
                    {
                        for (int j = 0; j < 4 && j < category.Questions[i].Choices.Count; j++)
                        {
                            DB_Delete.DeleteChoice(category.Questions[i].Choices[j].Id);
                        }
                    }
                    // going from other type of question to multiple choice, make the choices
                    else if (category.Questions[i].Type != "mc" && importCategoryForm.SelectedCategory.Questions[i].Type == "mc")
                    {
                        category.Questions[i].Choices = new List <Choice>(new Choice[4]);
                        for (int j = 0; j < 4 && j < category.Questions[i].Choices.Count; j++)
                        {
                            category.Questions[i].Choices[j]            = new Choice();
                            category.Questions[i].Choices[j].QuestionId = (int)category.Questions[i].Id;
                            category.Questions[i].Choices[j].Index      = j;
                            category.Questions[i].Choices[j].Text       = importCategoryForm.SelectedCategory.Questions[i].Choices[j].Text;
                            category.Questions[i].Choices[j].Id         = DB_Insert.InsertChoice(category.Questions[i].Choices[j]);
                        }
                    }
                    //if both are multiple choice, just do a simple update
                    else if (category.Questions[i].Type == "mc" && importCategoryForm.SelectedCategory.Questions[i].Type == "mc")
                    {
                        for (int j = 0; j < 4; j++)
                        {
                            category.Questions[i].Choices[j].Text = importCategoryForm.SelectedCategory.Questions[i].Choices[j].Text;
                            DB_Update.UpdateChoice(category.Questions[i].Choices[j]);
                        }
                    }

                    //set the other new properties of the importing questions. This needs to go after the previous code
                    category.Questions[i].Type         = importCategoryForm.SelectedCategory.Questions[i].Type;
                    category.Questions[i].QuestionText = importCategoryForm.SelectedCategory.Questions[i].QuestionText;
                    category.Questions[i].Answer       = importCategoryForm.SelectedCategory.Questions[i].Answer;

                    //update the question (import the question)
                    DB_Update.UpdateQuestion(category.Questions[i]);
                }
            }
        }
Example #9
0
        private void moveUpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DisableAllControls();

            ToolStripItem menuItem = sender as ToolStripItem;

            if (menuItem != null)
            {
                ContextMenuStrip owner = menuItem.Owner as ContextMenuStrip;
                if (owner != null)
                {
                    //detect position in button grid
                    int x = -1;
                    int y = -1;
                    for (int i = 0; i < game.NumCategories && x < 0; ++i)
                    {
                        for (int j = 0; j < game.NumQuestionsPerCategory; ++j)
                        {
                            if (questionButtons[i, j] == (Button)owner.SourceControl)
                            {
                                x = i;
                                y = j;
                                break;
                            }
                        }
                    }
                    if (x >= 0 && y >= 0)
                    {
                        DB_Update.UpdateQuestionWeight(game.Categories[x].Questions[y].Weight     -= 100, game.Categories[x].Questions[y].Id);
                        DB_Update.UpdateQuestionWeight(game.Categories[x].Questions[y - 1].Weight += 100, game.Categories[x].Questions[y - 1].Id);
                        bwLoadGame.RunWorkerAsync();
                    }
                    else
                    {
                        EnableAllControls();
                    }
                }
                else
                {
                    EnableAllControls();
                }
            }
            else
            {
                EnableAllControls();
            }
        }
Example #10
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            frmImportQuestion importQuestionForm = new frmImportQuestion();
            DialogResult      dialogResult       = importQuestionForm.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                //if going from multiple choice to another type, delete the choices
                if (question.Type == "mc" && importQuestionForm.selectedQuestion.Type != "mc")
                {
                    for (int j = 0; j < 4 && j < question.Choices.Count; j++)
                    {
                        DB_Delete.DeleteChoice(question.Choices[j].Id);
                    }
                }
                // going from other type of question to multiple choice, make the choices
                else if (question.Type != "mc" && importQuestionForm.selectedQuestion.Type == "mc")
                {
                    question.Choices = new List <Choice>(new Choice[4]);
                    for (int j = 0; j < 4 && j < question.Choices.Count; j++)
                    {
                        question.Choices[j]            = new Choice();
                        question.Choices[j].QuestionId = (int)question.Id;
                        question.Choices[j].Index      = j;
                        question.Choices[j].Text       = importQuestionForm.selectedQuestion.Choices[j].Text;
                        question.Choices[j].Id         = DB_Insert.InsertChoice(question.Choices[j]);
                    }
                }
                //if both are multiple choice, just do a simple update
                else if (question.Type == "mc" && importQuestionForm.selectedQuestion.Type == "mc")
                {
                    for (int j = 0; j < 4; j++)
                    {
                        question.Choices[j].Text = importQuestionForm.selectedQuestion.Choices[j].Text;
                        DB_Update.UpdateChoice(question.Choices[j]);
                    }
                }

                //get info from the selected question (not a complete clone because the IDs have to be different)
                question.Type         = importQuestionForm.selectedQuestion.Type;
                question.QuestionText = importQuestionForm.selectedQuestion.QuestionText;
                question.Answer       = importQuestionForm.selectedQuestion.Answer;

                frmEditQuestion_Load(sender, e); //reload this form with the info
            }
        }
Example #11
0
        private void moveRightToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DisableAllControls();
            ToolStripItem menuItem = sender as ToolStripItem;

            if (menuItem != null)
            {
                ContextMenuStrip owner = menuItem.Owner as ContextMenuStrip;
                if (owner != null)
                {
                    //detect position in button grid
                    int x = -1;
                    for (int i = 0; i < game.NumCategories && x < 0; ++i)
                    {
                        if (categoryButtons[i] == (Button)owner.SourceControl)
                        {
                            x = i;
                            break;
                        }
                    }
                    if (x >= 0)
                    {
                        DB_Update.UpdateCategoryIndex(++game.Categories[x].Index, game.Categories[x].Id);
                        DB_Update.UpdateCategoryIndex(--game.Categories[x + 1].Index, game.Categories[x + 1].Id);
                        bwLoadGame.RunWorkerAsync();
                    }
                    else
                    {
                        EnableAllControls();
                    }
                }
                else
                {
                    EnableAllControls();
                }
            }
            else
            {
                EnableAllControls();
            }
        }
Example #12
0
 private void bwUpdateTimeLimit_DoWork(object sender, DoWorkEventArgs e)
 {
     DB_Update.UpdateGameQuestionTimeLimit(game.QuestionTimeLimit, game.Id);
 }
Example #13
0
 private void bwUpdateQuestion_DoWork(object sender, DoWorkEventArgs e)
 {
     DB_Update.UpdateQuestion(currentQuestion);
 }