Esempio n. 1
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (txtTime.Text == "")
     {
         MessageBox.Show("请输入考试时间!");
     }
     else
     {
         if (ckbSingleProblem.Checked == true)
         {
             if (txtSingleMark.Text == "" || txtSingleCount.Text == "")
             {
                 MessageBox.Show("请输入单选题详细信息!");
             }
             else
             {
                 if (Convert.ToInt32(txtSingleCount.Text) < QuestionBll.singleCount(cboCourse.SelectedValue.ToString()))
                 {
                     List <int> count = num(QuestionBll.singleCount(cboCourse.SelectedValue.ToString()), Convert.ToInt32(txtSingleCount.Text));
                     for (int i = 0; i < Convert.ToInt32(txtSingleCount.Text); i++)
                     {
                         pd.Add(new PaperDetail(PaperBll.GetPaperID(txtPaperName.Text), "singleProblem", count[i], Convert.ToInt32(txtSingleMark.Text), Convert.ToInt32(txtTime.Text)));
                     }
                 }
                 else
                 {
                     MessageBox.Show("题库题目不足!");
                 }
             }
         }
         if (ckbMultiProblem.Checked == true)
         {
             if (txtMultiCount.Text == "" || txtMultiMark.Text == "")
             {
                 MessageBox.Show("请输入多选题详细信息!");
             }
             else
             {
                 if (Convert.ToInt32(txtMultiCount.Text) < QuestionBll.multiCount(cboCourse.SelectedValue.ToString()))
                 {
                     List <int> count = num(QuestionBll.multiCount(cboCourse.SelectedValue.ToString()), Convert.ToInt32(txtMultiCount.Text));
                     for (int i = 0; i < Convert.ToInt32(txtMultiCount.Text); i++)
                     {
                         pd.Add(new PaperDetail(PaperBll.GetPaperID(txtPaperName.Text), "multiProblem", count[i], Convert.ToInt32(txtMultiMark.Text), Convert.ToInt32(txtTime.Text)));
                     }
                 }
                 else
                 {
                     MessageBox.Show("题库题目不足!");
                 }
             }
         }
         if (ckbFillBlankProblem.Checked == true)
         {
             if (txtFillBlankCount.Text == "" || txtFillBlankMark.Text == "")
             {
                 MessageBox.Show("请输入填空题详细信息!");
             }
             else
             {
                 if (Convert.ToInt32(txtFillBlankCount.Text) < QuestionBll.fillBlankCount(cboCourse.SelectedValue.ToString()))
                 {
                     List <int> count = num(QuestionBll.fillBlankCount(cboCourse.SelectedValue.ToString()), Convert.ToInt32(txtFillBlankCount.Text));
                     for (int i = 0; i < Convert.ToInt32(txtSingleCount.Text); i++)
                     {
                         pd.Add(new PaperDetail(PaperBll.GetPaperID(txtPaperName.Text), "fillBlankProblem", count[i], Convert.ToInt32(txtFillBlankMark.Text), Convert.ToInt32(txtTime.Text)));
                     }
                 }
                 else
                 {
                     MessageBox.Show("题库题目不足!");
                 }
             }
         }
         if (ckbJudgeProblem.Checked == true)
         {
             if (txtJudgeCount.Text == "" || txtJudgeMark.Text == "")
             {
                 MessageBox.Show("请输入判断题详细信息!");
             }
             else
             {
                 if (Convert.ToInt32(txtJudgeCount.Text) < QuestionBll.judgeCount(cboCourse.SelectedValue.ToString()))
                 {
                     List <int> count = num(QuestionBll.judgeCount(cboCourse.SelectedValue.ToString()), Convert.ToInt32(txtJudgeCount.Text));
                     for (int i = 0; i < Convert.ToInt32(txtJudgeCount.Text); i++)
                     {
                         pd.Add(new PaperDetail(PaperBll.GetPaperID(txtPaperName.Text), "judgeProblem", count[i], Convert.ToInt32(txtJudgeMark.Text), Convert.ToInt32(txtTime.Text)));
                     }
                 }
                 else
                 {
                     MessageBox.Show("题库题目不足!");
                 }
             }
         }
         if (ckbQuestionProblem.Checked == true)
         {
             if (txtQuestionCount.Text == "" || txtQuestionMark.Text == "")
             {
                 MessageBox.Show("请输入简答题详细信息!");
             }
             else
             {
                 if (Convert.ToInt32(txtQuestionCount.Text) < QuestionBll.questionCount(cboCourse.SelectedValue.ToString()))
                 {
                     List <int> count = num(QuestionBll.questionCount(cboCourse.SelectedValue.ToString()), Convert.ToInt32(txtQuestionCount.Text));
                     for (int i = 0; i < Convert.ToInt32(txtQuestionCount.Text); i++)
                     {
                         pd.Add(new PaperDetail(PaperBll.GetPaperID(txtPaperName.Text), "questionProblem", count[i], Convert.ToInt32(txtQuestionMark.Text), Convert.ToInt32(txtTime.Text)));
                     }
                 }
                 else
                 {
                     MessageBox.Show("题库题目不足!");
                 }
             }
         }
         if (ckbSingleProblem.Checked == false && ckbQuestionProblem.Checked == false && ckbMultiProblem.Checked == false && ckbJudgeProblem.Checked == false && ckbFillBlankProblem.Checked == false)
         {
             MessageBox.Show("请选择试题!");
         }
         dataGridView1.DataSource = PaperDetailBll.PaperDetailFillDs(pd, "questionProblem").Tables[0];
         dataGridView2.DataSource = PaperDetailBll.PaperDetailFillDs(pd, "singleProblem").Tables[0];
         dataGridView3.DataSource = PaperDetailBll.PaperDetailFillDs(pd, "multiProblem").Tables[0];
         dataGridView4.DataSource = PaperDetailBll.PaperDetailFillDs(pd, "judgeProblem").Tables[0];
         dataGridView5.DataSource = PaperDetailBll.PaperDetailFillDs(pd, "fillBlankProblem").Tables[0];
     }
 }