private void dgvScoreInfo_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { int state = Convert.ToInt32(dgvScoreInfo.Rows[e.RowIndex].Cells[6].Value); if (e.ColumnIndex == 0 && state == 0) { //成绩id int scoreId = Convert.ToInt32(dgvScoreInfo.Rows[e.RowIndex].Cells[1].Value); //学员id int stuId = Convert.ToInt32(dgvScoreInfo.Rows[e.RowIndex].Cells[2].Value); dialog = new PaperDialog(); dialog.scoreId = scoreId; dialog.stuId = stuId; this.MdiParent.Hide(); if (dialog.ShowDialog() == DialogResult.OK) { showAllScores(paperId); } this.MdiParent.Show(); } } }
private void layoutAllQuestions(List <Question> slist, List <Question> blist, List <Question> jlist, List <Question> salist) { lblPaperName.Text = PaperDialog.getPaperNameById(paperId); lblTimer.Location = new Point(this.Width - lblTimer.Width - SPACE, 9); lblPaperName.Location = new Point((this.Width - lblPaperName.Width) / 2, 9); mark = lblPaperName.Location.Y + lblPaperName.Height; //大题题号标示 int j = 1; //小题题号标示 int i; if (slist.Count != 0) { //选择题 i = 0; Label slbl = new Label(); slbl.Text = "一、选择题"; j++; slbl.AutoSize = true; this.Controls.Add(slbl); slbl.Location = new Point(SPACE, mark + 2 * SPACE); int hit = slbl.Location.Y + 2 * SPACE; foreach (Question question in slist) { Label lbl = new Label(); lbl.Text = (i + 1) + "." + question.question + "(" + question.mark + "分)"; i++; lbl.Width = 50 * SPACE; //得到lbl所占行数,从而确定lbl的高度 lbl.Height = getLineNum(lbl.Text) * SPACE; this.Controls.Add(lbl); lbl.Location = new Point(SPACE, hit); hit += (lbl.Height + 2 * SPACE); Panel pnl = new Panel(); pnl.AutoSize = true; pnl.Height = 2 * SPACE; //pnl.BackColor = Color.Green; this.Controls.Add(pnl); pnl.Location = new Point(SPACE, lbl.Location.Y + lbl.Height); mark = pnl.Location.Y + pnl.Height; String[] str = { "A", "B", "C", "D" }; int len = 0; //获得当前问题索引 int index = slist.IndexOf(question); foreach (string s in str) { RadioButton rdo = new RadioButton(); rdo.Tag = index + "." + s; rdo.Click += new EventHandler(rdo_Click); switch (s) { case "A": rdo.Text = s + "." + question.optionA; break; case "B": rdo.Text = s + "." + question.optionB; break; case "C": rdo.Text = s + "." + question.optionC; break; case "D": rdo.Text = s + "." + question.optionD; break; default: break; } //rdo.BackColor = Color.Gray; rdo.AutoSize = true; pnl.Controls.Add(rdo); rdo.Location = new Point(len, (2 * SPACE - rdo.Height) / 2); len += (rdo.Width + SPACE); } } } if (blist.Count != 0) { //填空题 i = 0; Label blbl = new Label(); if (j == 1) { blbl.Text = "一、填空题"; } else { blbl.Text = "二、填空题"; } j++; blbl.AutoSize = true; this.Controls.Add(blbl); blbl.Location = new Point(SPACE, mark + 2 * SPACE); int hit = blbl.Location.Y + 2 * SPACE; foreach (Question question in blist) { Label lbl = new Label(); lbl.Text = (i + 1) + "." + question.question + "(" + question.mark + "分)"; i++; lbl.Width = 50 * SPACE; lbl.Height = getLineNum(lbl.Text) * SPACE; this.Controls.Add(lbl); lbl.Location = new Point(SPACE, hit); hit += (lbl.Height + 2 * SPACE); TextBox txt = new TextBox(); txt.Tag = question.question_paper_id; txt.Width = 10 * SPACE; this.Controls.Add(txt); txt.Location = new Point(SPACE, lbl.Location.Y + lbl.Height + 2); mark = txt.Location.Y + txt.Height; } } if (jlist.Count != 0) { //判断题 i = 0; Label jlbl = new Label(); if (j == 1) { jlbl.Text = "一、判断题"; } else if (j == 2) { jlbl.Text = "二、判断题"; } else { jlbl.Text = "三、判断题"; } j++; jlbl.AutoSize = true; this.Controls.Add(jlbl); jlbl.Location = new Point(SPACE, mark + 2 * SPACE); int hit = jlbl.Location.Y + 2 * SPACE; foreach (Question question in jlist) { Label lbl = new Label(); lbl.Text = (i + 1) + "." + question.question + "(" + question.mark + "分)"; i++; lbl.Width = 50 * SPACE; lbl.Height = getLineNum(lbl.Text) * SPACE; this.Controls.Add(lbl); lbl.Location = new Point(SPACE, hit); hit += (lbl.Height + SPACE); //获得当前问题索引 int index = jlist.IndexOf(question); CheckBox chk = new CheckBox(); chk.Tag = index; chk.CheckedChanged += new EventHandler(chk_CheckedChanged); chk.AutoSize = true; this.Controls.Add(chk); chk.Location = new Point(55 * SPACE, lbl.Location.Y); if (getLineNum(lbl.Text) == 1) { mark = chk.Location.Y + chk.Height; } else { mark = lbl.Location.Y + lbl.Height; } } } if (salist.Count != 0) { //简答题 i = 0; Label salbl = new Label(); if (j == 1) { salbl.Text = "一、简答题"; } else if (j == 2) { salbl.Text = "二、简答题"; } else if (j == 3) { salbl.Text = "三、简答题"; } else { salbl.Text = "四、简答题"; } j++; salbl.AutoSize = true; this.Controls.Add(salbl); salbl.Location = new Point(SPACE, mark + 2 * SPACE); int hit = salbl.Location.Y + 2 * SPACE; foreach (Question question in salist) { Label lbl = new Label(); lbl.Text = (i + 1) + "." + question.question + "(" + question.mark + "分)"; i++; lbl.Width = 50 * SPACE; lbl.Height = getLineNum(lbl.Text) * SPACE; this.Controls.Add(lbl); lbl.Location = new Point(SPACE, hit); hit += (lbl.Height + 6 * SPACE); TextBox txt = new TextBox(); txt.Tag = question.question_paper_id; txt.Multiline = true; txt.Width = 50 * SPACE; txt.Height = 5 * SPACE; this.Controls.Add(txt); txt.Location = new Point(SPACE, lbl.Location.Y + lbl.Height + 2); mark = txt.Location.Y + txt.Height; } } Button btn = new Button(); btn.Click += new EventHandler(btn_Click); btn.Text = "交卷"; btn.Width = 6 * SPACE; btn.Height = 2 * SPACE; this.Controls.Add(btn); btn.Location = new Point((this.Width - btn.Width) / 2, mark + 3 * SPACE); }