コード例 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            string   text       = tbText.Text;
            Subject  subj       = cbSubjects.SelectedItem as Subject;
            int      complexity = rbVeryEz.Checked ? 1 : rbEz.Checked ? 2 : rbMiddle.Checked ? 3 : rbHard.Checked ? 4 : rbHardcore.Checked ? 5 : 0;
            Question q;

            if (lbOptions.Items.Count > 0)
            {
                List <string> strings = new List <string>();
                foreach (var t in lbOptions.Items)
                {
                    strings.Add(t.ToString());
                }
                q = new TestQuestion(strings, text, complexity, subj);
            }
            else
            {
                q = new SimpleQuestion(text, complexity, subj);
            }
            if (updateMode == false)
            {
                controller.AddQuestion(q);
            }
            else
            {
                q.ID = this.q.ID;
                controller.UpdateQuestion(q);
            }

            Close();
        }