private void 成绩查询ToolStripMenuItem_Click(object sender, EventArgs e) { chaxunchachengji mainfrom = new chaxunchachengji(); mainfrom.Show(); this.Show(); }
private void button3_Click(object sender, EventArgs e) { String myanswer = null; if (radioButton1.Checked == true) { myanswer = "A"; } if (radioButton2.Checked == true) { myanswer = "B"; } if (radioButton3.Checked == true) { myanswer = "C"; } if (radioButton4.Checked == true) { myanswer = "D"; } myanswers[a] = myanswer; if (Array.IndexOf(myanswers, null) == -1) { if (MessageBox.Show("是否提交试卷?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { this.Visible = false; int i, myscore; myscore = 0; for (i = 0; i < canshu.suma; i++) { if (myanswers[i] == myds.Tables["table"].Rows[i][5].ToString()) { myscore++; } } double result = Math.Round((double)myscore / canshu.suma, 2); conn.Open(); SqlCommand updatecmd = new SqlCommand("UPDATE Student SET " + username.kaoshi + " = " + Convert.ToString(result * 100) + " WHERE SID = '" + username.usrname + "'", conn); if (updatecmd.ExecuteNonQuery() == 1) { MessageBox.Show("你的成绩为" + result * 100 + "", "提示"); } conn.Close(); this.Close(); chaxunchachengji Mainfrom = new chaxunchachengji(); Mainfrom.ShowDialog(); this.Show(); } } else { MessageBox.Show("第" + Convert.ToString(Array.IndexOf(myanswers, null) + 1) + "题还未完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }