예제 #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, "请输入正确编号");
     }
 }
예제 #2
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, "有空项,请检查后再提交!");
            }
        }