public void Submit() { Check(); bool flag = true; for (int i = 0; i < answer.Length; i++) { if (answer[i] == null) { flag = false; break; } } if (!flag) { DialogResult dr = MessageBoxEx.Show(this, "试卷未完成,无法交卷", "提示"); } else { DialogResult dr = MessageBoxEx.Show(this, "确认交卷?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr.ToString() == "Yes") { int sum = sumScore(); MessageBoxEx.Show(this, "交卷完毕\n得分:" + sum); history[] h = new history[answer.Length]; score s = new score(); countdao cd = new countdao(); int tpcount = cd.getTpCount(); s.tpid = tpcount; s.sc = sum; s.username = this.username; historydao hd = new historydao(); for (int i = 0; i < h.Length; i++) { h[i] = new history(); h[i].username = this.username; h[i].questionid = this.q[i].questionid; h[i].useranswer = this.answer[i]; if (answer[i] != this.q[i].answer) { h[i].rightorwrong = 0; } else { h[i].rightorwrong = 1; } h[i].tpid = tpcount; hd.insterHistory(h[i]); } scoredao sd = new scoredao(); sd.insertScore(s); this.Close(); } } }
public void setUsername(String username) { scoredao sd = new scoredao(); List <score> s = sd.getScoreList(username); int ly = 0; for (int i = 0; i < s.Count; i++) { TestPaper tp = new TestPaper(); tp.setAll(i, s[i].tpid, username, s[i].sc); tp.Location = new Point(0, ly); ly += 40; this.panel1.Controls.Add(tp); } }