Ejemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         int          questionid = int.Parse(textBox1.Text);
         DialogResult dr         = MessageBoxEx.Show(this, "确认删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (dr.ToString() == "Yes")
         {
             questiondao qd = new questiondao();
             if (qd.DeleteQuestion(questionid))
             {
                 MessageBoxEx.Show(this, "删除成功");
                 father.filldata();
             }
             else
             {
                 MessageBoxEx.Show(this, "删除失败");
             }
         }
     }
     catch (Exception e1)
     {
         MessageBoxEx.Show(this, "请输入正确编号");
     }
 }
Ejemplo n.º 2
0
        public void setQuestionid(int questionid)
        {
            this.questionid = questionid;
            questiondao qd = new questiondao();
            Question    q  = qd.getQuestion(questionid);

            q_name.Text = q.q_name;
            c_a.Text    = q.c_a;
            c_b.Text    = q.c_b;
            c_c.Text    = q.c_c;
            c_d.Text    = q.c_d;
            if (q.answer == "A")
            {
                A.Select();
            }
            if (q.answer == "B")
            {
                B.Select();
            }
            if (q.answer == "C")
            {
                C.Select();
            }
            if (q.answer == "D")
            {
                D.Select();
            }

            if (q.hardlevel == 1)
            {
                level1.Select();
            }
            if (q.hardlevel == 2)
            {
                level2.Select();
            }
            if (q.hardlevel == 3)
            {
                level3.Select();
            }
            if (q.hardlevel == 4)
            {
                level4.Select();
            }
            if (q.hardlevel == 5)
            {
                level5.Select();
            }

            score.Text = q.score.ToString();
        }
Ejemplo n.º 3
0
        public QuestionForm1()
        {
            InitializeComponent();
            questiondao qd = new questiondao();

            q = qd.getQuestionList();
            for (int i = 0; i < answer.Length; i++)
            {
                answer[i] = null;
                ChooseNumBox.Items.Add(i);
            }
            ABut.Checked = false;
            LoadQuestion();
        }
Ejemplo n.º 4
0
        private void History_Load(object sender, EventArgs e)
        {
            questiondao qd = new questiondao();

            q = qd.getQuestionList();
            historydao hd = new historydao();

            h = hd.getHistoryList(username, tpid);
            for (int i = 0; i < h.Count; i++)
            {
                ChooseNumBox.Items.Add(i);
            }

            q = new List <Question>();

            for (int i = 0; i < h.Count; i++)
            {
                Question qu = qd.getQuestion(h[i].questionid);
                q.Add(qu);
            }
            LoadQuestion();
        }
Ejemplo n.º 5
0
        private void submit_Click(object sender, EventArgs e)
        {
            bool flag = true;

            if (q_name.Text == "" || c_a.Text == "" || c_b.Text == "" || c_c.Text == "" || c_d.Text == "" || score.Text == "")
            {
                flag = false;
            }
            int hardlevel = -1;

            if (level1.Checked)
            {
                hardlevel = 1;
            }
            if (level2.Checked)
            {
                hardlevel = 2;
            }
            if (level3.Checked)
            {
                hardlevel = 3;
            }
            if (level4.Checked)
            {
                hardlevel = 4;
            }
            if (level5.Checked)
            {
                hardlevel = 5;
            }
            if (hardlevel == -1)
            {
                flag = false;
            }
            String s = null;

            if (A.Checked)
            {
                s = "A";
            }
            if (B.Checked)
            {
                s = "B";
            }
            if (C.Checked)
            {
                s = "C";
            }
            if (D.Checked)
            {
                s = "D";
            }
            if (s == null)
            {
                flag = false;
            }

            if (flag)
            {
                DialogResult dr = MessageBoxEx.Show(this, "确认提交?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dr.ToString() == "Yes")
                {
                    try
                    {
                        Question q = new Question();
                        q.q_name    = q_name.Text;
                        q.c_a       = c_a.Text;
                        q.c_b       = c_b.Text;
                        q.c_c       = c_c.Text;
                        q.c_d       = c_d.Text;
                        q.hardlevel = hardlevel;
                        q.score     = int.Parse(score.Text);
                        q.answer    = s;
                        questiondao qd = new questiondao();
                        if (questionid != -1)
                        {
                            q.questionid = questionid;
                            qd.UpdateQuetion(q);
                            father.filldata();
                            this.Close();
                        }
                        else
                        {
                            qd.insertQuestion(q);
                            father.filldata();
                            this.Close();
                        }
                    }
                    catch (Exception e1)
                    {
                        MessageBoxEx.Show(this, "请输如正确分数");
                    }
                }
            }
            else
            {
                MessageBoxEx.Show(this, "有空项,请检查后再提交!");
            }
        }