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(); } } }
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(); }