// Method to add options public void addOption(Questionoption option) { questionoptions.Add(option); }
private void Save_Click(object sender, EventArgs e) { if (isTextboxEmpty()) { MessageBox.Show("Vul eerst de lege velden in voordat u opslaat"); } else { foreach (Panel p in questionFlowPanel.Controls) { Question question = new Question(); string panelName = splitString(p.Name, true); if (panelName == "multipleChoicePanel") { int questionType = 2; switch (p.Controls.Count) { case 11: questionType = 2; break; case 14: questionType = 3; break; case 17: questionType = 4; break; case 20: questionType = 5; break; case 23: questionType = 6; break; } foreach (Control c in p.Controls) { string controlName = splitString(c.Name, true); int controlNumber = Int32.Parse(splitString(c.Name, false)); if (controlName == "QuestionTextbox") { question = new Question(controlNumber, c.Text, questionType, questionlist); } if (controlName == "Answer1Textbox") { Control radioButton = null; Boolean radioButtonValue = false; foreach (Control cont in p.Controls) { string contName = splitString(cont.Name, true); if (contName == "Answer1Radiobutton") { radioButton = cont; } } radioButtonValue = (radioButton as RadioButton).Checked; Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, radioButtonValue); question.addOption(questionOption); } if (controlName == "Answer2Textbox") { Control radioButton = null; Boolean radioButtonValue = false; foreach (Control cont in p.Controls) { string contName = splitString(cont.Name, true); if (contName == "Answer2Radiobutton") { radioButton = cont; } } radioButtonValue = (radioButton as RadioButton).Checked; Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, radioButtonValue); question.addOption(questionOption); } if (controlName == "Answer3Textbox") { Control radioButton = null; Boolean radioButtonValue = false; foreach (Control cont in p.Controls) { string contName = splitString(cont.Name, true); if (contName == "Answer3Radiobutton") { radioButton = cont; } } radioButtonValue = (radioButton as RadioButton).Checked; Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, radioButtonValue); question.addOption(questionOption); } if (controlName == "Answer4Textbox") { Control radioButton = null; Boolean radioButtonValue = false; foreach (Control cont in p.Controls) { string contName = splitString(cont.Name, true); if (contName == "Answer4Radiobutton") { radioButton = cont; } } radioButtonValue = (radioButton as RadioButton).Checked; Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, radioButtonValue); question.addOption(questionOption); } if (controlName == "Answer5Textbox") { Control radioButton = null; Boolean radioButtonValue = false; foreach (Control cont in p.Controls) { string contName = splitString(cont.Name, true); if (contName == "Answer5Radiobutton") { radioButton = cont; } } radioButtonValue = (radioButton as RadioButton).Checked; Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, radioButtonValue); question.addOption(questionOption); } if (controlName == "Answer6Textbox") { Control radioButton = null; Boolean radioButtonValue = false; foreach (Control cont in p.Controls) { string contName = splitString(cont.Name, true); if (contName == "Answer6Radiobutton") { radioButton = cont; } } radioButtonValue = (radioButton as RadioButton).Checked; Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, radioButtonValue); question.addOption(questionOption); } } } if (panelName == "openQuestionPanel") { foreach (Control c in p.Controls) { string controlName = splitString(c.Name, true); int controlNumber = Int32.Parse(splitString(c.Name, false)); if (controlName == "QuestionTextbox") { question = new Question(controlNumber, c.Text, 0, questionlist); } if (controlName == "AnswerTextbox") { Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, true); question.addOption(questionOption); } } } if (panelName == "thesisPanel") { foreach (Control c in p.Controls) { string controlName = splitString(c.Name, true); int controlNumber = Int32.Parse(splitString(c.Name, false)); if (controlName == "QuestionTextbox") { question = new Question(controlNumber, c.Text, 1, questionlist); } if (controlName == "Answer1Textbox") { Questionoption questionOption = new Questionoption(1, c.Text, controlNumber, false); question.addOption(questionOption); } if (controlName == "Answer2Textbox") { Questionoption questionOption = new Questionoption(2, c.Text, controlNumber, false); question.addOption(questionOption); } } } bc.qc.create(question); } MessageBox.Show("Uw vragenlijst is toegevoegt"); bc.cc.setOverviewPanel(); } }
//save button public void SaveAll_Click(object sender, EventArgs e) { int AmountOfQuestions = bc.qc.getQuestions(index).Count(); if (combobox.SelectedIndex == 0) { if (string.IsNullOrWhiteSpace(QuestionName.Text)) { MessageBox.Show("Vul eerst een vraag in"); } else if (string.IsNullOrWhiteSpace(AnswerOpenQuestionTextbox.Text)) { MessageBox.Show("Vul eerst een antwoord in"); } else { question = new Question(AmountOfQuestions + 1, QuestionName.Text, 0, index); Questionoption questionOption = new Questionoption(1, AnswerOpenQuestionTextbox.Text, AmountOfQuestions + 1, true); question.addOption(questionOption); bc.qc.create(question); MessageBox.Show("De vraag is toegevoegd"); bc.qc.editListPanel(index); } } else if (combobox.SelectedIndex == 1) { if (string.IsNullOrWhiteSpace(QuestionName.Text)) { MessageBox.Show("Vul eerst een vraag in"); } else if (string.IsNullOrWhiteSpace(Answer1TextboxThesis.Text) || string.IsNullOrWhiteSpace(Answer2TextboxThesis.Text)) { MessageBox.Show("Vul eerst een antwoord in"); } else { AmountOfQuestions += 1; question = new Question(AmountOfQuestions + 1, QuestionName.Text, 1, index); Questionoption questionOption = new Questionoption(1, Answer1TextboxThesis.Text, AmountOfQuestions, false); question.addOption(questionOption); Questionoption questionOption1 = new Questionoption(1, Answer2TextboxThesis.Text, AmountOfQuestions, false); question.addOption(questionOption1); bc.qc.create(question); MessageBox.Show("De stelling is toegevoegd"); bc.qc.editListPanel(index); } } else if (combobox.SelectedIndex == 2) { if (string.IsNullOrWhiteSpace(QuestionName.Text)) { MessageBox.Show("Vul eerst een vraag in"); } else if (string.IsNullOrWhiteSpace(Answer1Textbox.Text) || string.IsNullOrWhiteSpace(Answer2Textbox.Text)) { MessageBox.Show("Vul eerst alle antwoorden in"); } else { if (Answer1Radiobuttons.Checked || Answer2Radiobuttons.Checked) { AmountOfQuestions += 1; question = new Question(AmountOfQuestions + 1, QuestionName.Text, 2, index); Questionoption questionOption1 = new Questionoption(1, Answer1Textbox.Text, AmountOfQuestions, Answer1Radiobuttons.Checked); question.addOption(questionOption1); Questionoption questionOption2 = new Questionoption(2, Answer2Textbox.Text, AmountOfQuestions, Answer2Radiobuttons.Checked); question.addOption(questionOption2); bc.qc.create(question); MessageBox.Show("De vraag is toegevoegd"); bc.qc.editListPanel(index); } else { MessageBox.Show("Selecteer eerst een juist antwoord"); } } } else if (combobox.SelectedIndex == 3) { if (string.IsNullOrWhiteSpace(QuestionName.Text)) { MessageBox.Show("Vul eerst een vraag in"); } else if (string.IsNullOrWhiteSpace(Answer1Textbox.Text) || string.IsNullOrWhiteSpace(Answer2Textbox.Text) || string.IsNullOrWhiteSpace(Answer3Textbox.Text)) { MessageBox.Show("Vul eerst alle antwoorden in"); } else { if (Answer1Radiobuttons.Checked || Answer2Radiobuttons.Checked || Answer3Radiobuttons.Checked) { AmountOfQuestions += 1; question = new Question(AmountOfQuestions + 1, QuestionName.Text, 3, index); Questionoption questionOption1 = new Questionoption(1, Answer1Textbox.Text, AmountOfQuestions, Answer1Radiobuttons.Checked); question.addOption(questionOption1); Questionoption questionOption2 = new Questionoption(1, Answer2Textbox.Text, AmountOfQuestions, Answer2Radiobuttons.Checked); question.addOption(questionOption2); Questionoption questionOption3 = new Questionoption(1, Answer3Textbox.Text, AmountOfQuestions, Answer3Radiobuttons.Checked); question.addOption(questionOption3); bc.qc.create(question); MessageBox.Show("De vraag is toegevoegd"); bc.qc.editListPanel(index); } else { MessageBox.Show("Selecteer eerst een juist antwoord"); } } } else if (combobox.SelectedIndex == 4) { if (string.IsNullOrWhiteSpace(QuestionName.Text)) { MessageBox.Show("Vul eerst een vraag in"); } else if (string.IsNullOrWhiteSpace(Answer1Textbox.Text) || string.IsNullOrWhiteSpace(Answer2Textbox.Text) || string.IsNullOrWhiteSpace(Answer3Textbox.Text) || string.IsNullOrWhiteSpace(Answer4Textbox.Text)) { MessageBox.Show("Vul eerst alle antwoorden in"); } else { if (Answer1Radiobuttons.Checked || Answer2Radiobuttons.Checked || Answer3Radiobuttons.Checked || Answer4Radiobuttons.Checked) { AmountOfQuestions += 1; question = new Question(AmountOfQuestions + 1, QuestionName.Text, 4, index); Questionoption questionOption1 = new Questionoption(1, Answer1Textbox.Text, AmountOfQuestions, Answer1Radiobuttons.Checked); question.addOption(questionOption1); Questionoption questionOption2 = new Questionoption(1, Answer2Textbox.Text, AmountOfQuestions, Answer2Radiobuttons.Checked); question.addOption(questionOption2); Questionoption questionOption3 = new Questionoption(1, Answer3Textbox.Text, AmountOfQuestions, Answer3Radiobuttons.Checked); question.addOption(questionOption3); Questionoption questionOption4 = new Questionoption(1, Answer4Textbox.Text, AmountOfQuestions, Answer4Radiobuttons.Checked); question.addOption(questionOption4); bc.qc.create(question); MessageBox.Show("De vraag is toegevoegd"); bc.qc.editListPanel(index); } else { MessageBox.Show("Selecteer eerst een juist antwoord"); } } } else if (combobox.SelectedIndex == 5) { if (string.IsNullOrWhiteSpace(QuestionName.Text)) { MessageBox.Show("Vul eerst een vraag in"); } else if (string.IsNullOrWhiteSpace(Answer1Textbox.Text) || string.IsNullOrWhiteSpace(Answer2Textbox.Text) || string.IsNullOrWhiteSpace(Answer3Textbox.Text) || string.IsNullOrWhiteSpace(Answer4Textbox.Text) || string.IsNullOrWhiteSpace(Answer5Textbox.Text)) { MessageBox.Show("Vul eerst alle antwoorden in"); } else { if (Answer1Radiobuttons.Checked || Answer2Radiobuttons.Checked || Answer3Radiobuttons.Checked || Answer4Radiobuttons.Checked || Answer5Radiobuttons.Checked) { AmountOfQuestions += 1; question = new Question(AmountOfQuestions + 1, QuestionName.Text, 5, index); Questionoption questionOption1 = new Questionoption(1, Answer1Textbox.Text, AmountOfQuestions, Answer1Radiobuttons.Checked); question.addOption(questionOption1); Questionoption questionOption2 = new Questionoption(1, Answer2Textbox.Text, AmountOfQuestions, Answer2Radiobuttons.Checked); question.addOption(questionOption2); Questionoption questionOption3 = new Questionoption(1, Answer3Textbox.Text, AmountOfQuestions, Answer3Radiobuttons.Checked); question.addOption(questionOption3); Questionoption questionOption4 = new Questionoption(1, Answer4Textbox.Text, AmountOfQuestions, Answer4Radiobuttons.Checked); question.addOption(questionOption4); Questionoption questionOption5 = new Questionoption(1, Answer5Textbox.Text, AmountOfQuestions, Answer5Radiobuttons.Checked); question.addOption(questionOption5); bc.qc.create(question); MessageBox.Show("De vraag is toegevoegd"); bc.qc.editListPanel(index); } else { MessageBox.Show("Selecteer eerst een juist antwoord"); } } } else if (combobox.SelectedIndex == 6) { if (string.IsNullOrWhiteSpace(QuestionName.Text)) { MessageBox.Show("Vul eerst een vraag in"); } else if (string.IsNullOrWhiteSpace(Answer1Textbox.Text) || string.IsNullOrWhiteSpace(Answer2Textbox.Text) || string.IsNullOrWhiteSpace(Answer3Textbox.Text) || string.IsNullOrWhiteSpace(Answer4Textbox.Text) || string.IsNullOrWhiteSpace(Answer5Textbox.Text) || string.IsNullOrWhiteSpace(Answer6Textbox.Text)) { MessageBox.Show("Vul eerst alle antwoorden in"); } else { if (Answer1Radiobuttons.Checked || Answer2Radiobuttons.Checked || Answer3Radiobuttons.Checked || Answer4Radiobuttons.Checked || Answer5Radiobuttons.Checked || Answer6Radiobuttons.Checked) { AmountOfQuestions += 1; question = new Question(AmountOfQuestions + 1, QuestionName.Text, 6, index); Questionoption questionOption1 = new Questionoption(1, Answer1Textbox.Text, AmountOfQuestions, Answer1Radiobuttons.Checked); question.addOption(questionOption1); Questionoption questionOption2 = new Questionoption(1, Answer2Textbox.Text, AmountOfQuestions, Answer2Radiobuttons.Checked); question.addOption(questionOption2); Questionoption questionOption3 = new Questionoption(1, Answer3Textbox.Text, AmountOfQuestions, Answer3Radiobuttons.Checked); question.addOption(questionOption3); Questionoption questionOption4 = new Questionoption(1, Answer4Textbox.Text, AmountOfQuestions, Answer4Radiobuttons.Checked); question.addOption(questionOption4); Questionoption questionOption5 = new Questionoption(1, Answer5Textbox.Text, AmountOfQuestions, Answer5Radiobuttons.Checked); question.addOption(questionOption5); Questionoption questionOption6 = new Questionoption(1, Answer6Textbox.Text, AmountOfQuestions, Answer6Radiobuttons.Checked); question.addOption(questionOption6); bc.qc.create(question); MessageBox.Show("De vraag is toegevoegd"); bc.qc.editListPanel(index); } else { MessageBox.Show("Selecteer eerst een juist antwoord"); } } } }