Exemple #1
0
        private void addAnswerBtn_Click(object sender, EventArgs e)
        {
            if (answerTextBox.Text == "") {
                MessageBox.Show("Please enter answer name");
                return;
            }

            foreach (Answer answer in answerListBox.Items) {
                if (String.Equals(answer.Name, answerTextBox.Text, StringComparison.OrdinalIgnoreCase)) {
                    MessageBox.Show("Name already exist. Please enter another name");
                    return;
                }
            }

            Answer newAnswer = new Answer(answerTextBox.Text, Convert.ToDecimal(costTextBox.Text), this.question);
            answerListBox.Items.Add(newAnswer);
        }
Exemple #2
0
 public void ToggleModification(Answer modification)
 {
     if (modifications.Contains(modification)) modifications.Remove(modification);
     else {
         if (modification.Owner.Type == Question.QuestionType.SingleAnswer) {
             Answer modificationToRemove = null;
             foreach (Answer otherModification in modifications) {
                 if (otherModification.Owner == modification.Owner) {
                     modificationToRemove = otherModification;
                     break;
                 }
             }
             if (modificationToRemove != null) modifications.Remove(modificationToRemove);
         }
         modifications.Add(modification);
     }
 }