模擬考試系統(tǒng)C源碼

上傳人:仙*** 文檔編號(hào):35084694 上傳時(shí)間:2021-10-25 格式:DOC 頁(yè)數(shù):26 大?。?23.50KB
收藏 版權(quán)申訴 舉報(bào) 下載
模擬考試系統(tǒng)C源碼_第1頁(yè)
第1頁(yè) / 共26頁(yè)
模擬考試系統(tǒng)C源碼_第2頁(yè)
第2頁(yè) / 共26頁(yè)
模擬考試系統(tǒng)C源碼_第3頁(yè)
第3頁(yè) / 共26頁(yè)

下載文檔到電腦,查找使用更方便

0 積分

下載資源

還剩頁(yè)未讀,繼續(xù)閱讀

資源描述:

《模擬考試系統(tǒng)C源碼》由會(huì)員分享,可在線閱讀,更多相關(guān)《模擬考試系統(tǒng)C源碼(26頁(yè)珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。

1、開始窗體 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using S

2、ystem.Text; using System.Windows.Forms; namespace Exam { public partial class ExamForm : Form { public ExamForm() { InitializeComponent(); } ///

/// ExamForm /// /// <

3、/param> /// private void ExamForm_Load(object sender, EventArgs e) { CenterToScreen(); Text = "模擬考試系統(tǒng)"; this.Width = 360; this.Height = 230; this.progressBar1.Width = 360;

4、 this.progressBar1.Height = 10; this.progressBar1.Left = 0; this.progressBar1.Top = 220; this.timer1.Start(); } int i = 8; private void timer1_Tick(object sender, EventArgs e) { this.progressBar1.Pe

5、rformStep(); i--; if (i==0) { this.timer1.Stop(); FormExam f = new FormExam(); f.Show(); this.Hide(); } } } } 數(shù)據(jù)庫(kù)輔助類 ////////////////////////////////////////////

6、////////////////////////////////////////////////////////////////////////////////////////////////// using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; namespace Exam { public class DataBase {

7、 public string connString = @"Data Source=XUTAO;Initial Catalog=Exam;Integrated Security=True"; private SqlConnection conn; ///

/// SqlConnection /// public SqlConnection Conn { get

8、{ if (conn == null) { conn = new SqlConnection(connString); } return conn; } } ///

/// 打開數(shù)據(jù)庫(kù) /// public void openData() {

9、 if (Conn.State == ConnectionState.Closed) { Conn.Open(); } else if (Conn.State == ConnectionState.Broken) { Conn.Close(); Conn.Open(); } } ///

10、 /// 關(guān)閉數(shù)據(jù)庫(kù) ///

public void closeData() { if (Conn.State == ConnectionState.Open || Conn.State == ConnectionState.Broken) { Conn.Close(); } } } } 主窗體 ///////////////

11、/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using Sy

12、stem.Windows.Forms; using System.Data.SqlClient; namespace Exam { public partial class FormExam : Form { public FormExam() { InitializeComponent(); } ///

/// 調(diào)用數(shù)據(jù)庫(kù) /// DataBase db = new

13、DataBase(); ///

/// ExamForm /// /// /// private void FormExam_Load(object sender, EventArgs e) { CenterToScreen(); this.Cursor = Curso

14、rs.Hand; this.Text = "模擬考試系統(tǒng)"; this.tscmbExamType.SelectedIndex = 0; this.timerDate.Start(); this.Width = 1000; this.Height = 600; this.MaximizeBox = false; this.Top = 50; this.groupBox1.Top = 4

15、0; this.groupBox1.Left = 10; this.groupBox1.Height = 250; this.groupBox1.Width = 200; this.listExam.GridLines = true; this.listExam.FullRowSelect = true; this.groupBox2.BackColor = Color.Transparent; this.gr

16、oupBox2.Text = "試題題干"; this.groupBox2.Height = 250; this.groupBox2.Width = 755; this.groupBox2.Left = 215; this.groupBox2.Top = 40; this.groupBox2.ForeColor = Color.White; this.rtbExam.ReadOnly = true; this.

17、groupBox3.Text = "試題選項(xiàng)"; this.groupBox3.ForeColor = Color.White; this.groupBox3.BackColor = Color.Transparent; this.groupBox3.Left = 215; this.groupBox3.Width = 755; this.groupBox3.Height = 250; this.groupBox3.Top = 295;

18、 this.groupBox4.Text = "操作區(qū)域"; this.groupBox4.ForeColor = Color.White; this.groupBox4.BackColor = Color.Transparent; this.groupBox4.Width = 200; this.groupBox4.Height = 250; this.groupBox4.Top = 295; this.grou

19、pBox4.Left = 10; this.button1.Text = "開始答題"; this.button1.Top = 40; this.button1.Left = 50; this.button1.Width = 90; this.button1.Height = 25; this.button1.ForeColor = Color.Blue; this.button2.Text = "上一試題

20、"; this.button2.Top = 80; this.button2.Left = 50; this.button2.Width = 90; this.button2.Height = 25; this.button2.ForeColor = Color.Blue; this.button3.Text = "下一試題"; this.button3.Top = 120; this

21、.button3.Left = 50; this.button3.Width = 90; this.button3.Height = 25; this.button3.ForeColor = Color.Blue; this.button4.Text = "停止答題"; this.button4.Top = 160; this.button4.Left = 50; this.button4.Width = 90

22、; this.button4.Height = 25; this.button4.ForeColor = Color.Blue; this.button5.Text = "提交試題"; this.button5.Top = 200; this.button5.Left = 50; this.button5.Width = 90; this.button5.Height = 25; th

23、is.button5.ForeColor = Color.Blue; this.radioButton1.Text = "A"; this.radioButton1.Left = 5; this.radioButton1.Top = 50; this.radioButton1.ForeColor = Color.GreenYellow; this.radioButton1.Enabled = false; this.radioBut

24、ton2.Text = "B"; this.radioButton2.Left = 5; this.radioButton2.Top = 100; this.radioButton2.ForeColor = Color.GreenYellow; this.radioButton2.Enabled = false; this.radioButton3.Text = "C"; this.radioButton3.Left = 5;

25、 this.radioButton3.Top = 150; this.radioButton3.ForeColor = Color.GreenYellow; this.radioButton3.Enabled = false; this.radioButton4.Text = "D"; this.radioButton4.Left = 5; this.radioButton4.Top = 200; this.radioB

26、utton4.ForeColor = Color.GreenYellow; this.radioButton4.Enabled = false; this.label1.Left = 40; this.label1.Top = 52; this.label1.Text = ""; this.label2.Left = 40; this.label2.Top = 102; this.label2.Text =

27、 ""; this.label3.Left = 40; this.label3.Top = 152; this.label3.Text = ""; this.label4.Left = 40; this.label4.Top = 202; this.label4.Text = ""; this.label5.Left = 5; this.label5.Top = 20;

28、 this.label5.Text = ""; this.label5.ForeColor = Color.Red; this.label6.Left = 35; this.label6.Top = 20; this.label6.Text = ""; this.listExam.Enabled = false; this.button2.Enabled = false; this.b

29、utton3.Enabled = false; this.button4.Enabled = false; this.button5.Enabled = false; this.toolStripButton1.Enabled = false; } ///

/// 時(shí)間 /// /// ///

30、 name="e"> private void timerDate_Tick(object sender, EventArgs e) { this.toolStripLabel2.Text = DateTime.Now.ToString(); } int j = 600; ///

/// 計(jì)時(shí)器 /// ///

31、 /// private void timerP_Tick(object sender, EventArgs e) { j--; this.toolStripLabel4.Text = j.ToString(); if (j > 60) { this.toolStripLabel4.ForeColor = Color.GreenYellow;

32、 } else { this.toolStripLabel4.ForeColor = Color.Red; } if (j == 0) { this.timerP.Stop(); this.radioButton1.Enabled = false; this.radioButton2.Enabled = false;

33、 this.radioButton3.Enabled = false; this.radioButton4.Enabled = false; this.label1.Enabled = false; this.label2.Enabled = false; this.label3.Enabled = false; this.label4.Enabled = false;

34、 this.listExam.Enabled = false; this.button1.Enabled = false; this.button2.Enabled = false; this.button3.Enabled = false; this.button4.Enabled = false; this.button5.Enabled = true; MessageBox.S

35、how("時(shí)間到,請(qǐng)?zhí)峤辉囶}!"); return; } } ///

/// 開始答題 /// /// /// private void button1_Click(object sender, EventArgs e) {

36、 this.timerP.Start(); this.radioButton1.Enabled = true; this.radioButton2.Enabled = true; this.radioButton3.Enabled = true; this.radioButton4.Enabled = true; this.label1.Enabled = true; this.label2.Enabled = true;

37、 this.label3.Enabled = true; this.label4.Enabled = true; this.listExam.Enabled = true; this.listExam.Focus();//第一行默認(rèn)選中 this.listExam.Items[0].Selected = true; this.button1.Enabled = false; this.button2.Enabled = tru

38、e; this.button3.Enabled = true; this.button4.Enabled = true; this.button5.Enabled = true; } ///

/// 停止答題 /// /// /// pri

39、vate void button4_Click(object sender, EventArgs e) { this.timerP.Stop(); this.radioButton1.Enabled = false; this.radioButton2.Enabled = false; this.radioButton3.Enabled = false; this.radioButton4.Enabled = false;

40、 this.label1.Enabled = false; this.label2.Enabled = false; this.label3.Enabled = false; this.label4.Enabled = false; this.listExam.Enabled = false; this.button1.Enabled = true; this.button2.Enabled = false; th

41、is.button3.Enabled = false; this.button4.Enabled = false; this.button5.Enabled = false; } ///

/// 顯示試題表數(shù)據(jù) /// public void ListShow() { Random random = new Random(); int rand

42、 = random.Next(0, 190); string sql = string.Format(@"select top 10 ExamPaper.SubjectNo, ExamPaper.SubjectName, ExamResult.A,ExamResult.B,

43、 ExamResult.C,ExamResult.D, ExamPaper.TypeID from ExamPaper inner join

44、 ExamResult on ExamPaper.TypeID=ExamResult.TypeID and ExamPaper.SubjectNo=ExamResult.SubjectNo

45、 where ExamPaper.SubjectNo not in (select top {0} ExamPaper.SubjectNo from ExamPaper) and ExamResult.TypeID=

46、 (select TypeID from ExamPaperType where ExamPaperType.TypeName like %{1}%)", r

47、and, this.tscmbExamType.Text.Substring(0, 3)); try { db.openData(); SqlCommand comm = new SqlCommand(sql, db.Conn); SqlDataReader reader = comm.ExecuteReader(); if (!reader.HasRows) {

48、 return; } else { while (reader.Read()) { string SubjectNo = reader["SubjectNo"].ToString();//題號(hào) string SubjectName = reader["SubjectName"].

49、ToString();//題干 string TypeID = reader["TypeID"].ToString(); string A = reader["A"].ToString(); string B = reader["B"].ToString(); string C = reader["C"].ToString(); string D

50、= reader["D"].ToString(); ListViewItem items = new ListViewItem(SubjectNo); items.SubItems.Add(SubjectName); items.SubItems.Add(TypeID); items.SubItems.Add(A); items.SubItems.

51、Add(B); items.SubItems.Add(C); items.SubItems.Add(D); this.listExam.Items.Add(items); } } reader.Close(); } catch (Exception ex)

52、{ MessageBox.Show(ex.Message); } finally { db.closeData(); } } ///

/// listShow /// /// ///

53、> private void tscmbExamType_SelectedIndexChanged(object sender, EventArgs e) { if (this.listExam.Items.Count != 0) { this.listExam.Items.Clear(); } this.timerP.Stop(); j = 600; t

54、his.toolStripLabel4.Text = "00"; this.radioButton1.Enabled = false; this.radioButton2.Enabled = false; this.radioButton3.Enabled = false; this.radioButton4.Enabled = false; this.label1.Enabled = false; this.label2.Enabled

55、= false; this.label3.Enabled = false; this.label4.Enabled = false; this.listExam.Enabled = false; this.rtbExam.Text = ""; this.label1.Text = ""; this.label2.Text = ""; this.label3.Text = ""; this.

56、label4.Text = ""; this.label5.Text = ""; this.label6.Text = ""; this.button1.Enabled = true; this.button2.Enabled = false; this.button3.Enabled = false; this.button4.Enabled = false; th

57、is.button5.Enabled = false; this.ListShow(); } string TypeID = "";//類型號(hào) ///

/// 顯示題干和選項(xiàng) /// public void ShowExam() { if (this.listExam.SelectedItems.Count != 0) {

58、 this.label5.Text = this.listExam.SelectedItems[0].SubItems[0].Text; this.rtbExam.Text = this.listExam.SelectedItems[0].SubItems[1].Text; TypeID = this.listExam.SelectedItems[0].SubItems[2].Text; this.label1.Text = this.listExam.SelectedItems[0].S

59、ubItems[3].Text; this.label2.Text = this.listExam.SelectedItems[0].SubItems[4].Text; this.label3.Text = this.listExam.SelectedItems[0].SubItems[5].Text; this.label4.Text = this.listExam.SelectedItems[0].SubItems[6].Text; }

60、else { return; } } ///

/// 選項(xiàng) /// /// /// private void listExam_SelectedIndexChanged(object sender, EventArgs e)

61、 { this.ShowExam(); } private void button3_Click(object sender, EventArgs e) { this.radioButton1.Checked = false; this.radioButton2.Checked = false; this.radioButton3.Checked = false; this.radioButton4

62、.Checked = false; this.label6.Text = ""; for (int i = 0; i < listExam.Items.Count - 1; i++) { if (listExam.Items[i].Selected) // 得到當(dāng)前選中項(xiàng),因?yàn)檫@個(gè)控件支持多選,所以只能通過(guò)遍歷得到 { if (i != 0 || i == 0)

63、 { listExam.Items[i + 1].Selected = true; listExam.Select(); break; } } } } ///

/// 上一題 /// ///

64、e="sender"> /// private void button2_Click(object sender, EventArgs e) { this.radioButton1.Checked = false; this.radioButton2.Checked = false; this.radioButton3.Checked = false; this.radio

65、Button4.Checked = false; this.label6.Text = ""; for (int i = 0; i < listExam.Items.Count; i++) { if (listExam.Items[i].Selected) // 得到當(dāng)前選中項(xiàng),因?yàn)檫@個(gè)控件支持多選,所以只能通過(guò)遍歷得到 { if (i != 0) {

66、 listExam.Items[i - 1].Selected = true; listExam.Select(); break; } } } } ///

/// 所選答案 /// public int InsertData() { string rightname = ""; if (this.radioButton1.Checked == true) { rightname = radioButton1.Text; } else if

展開閱讀全文
溫馨提示:
1: 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

相關(guān)資源

更多
正為您匹配相似的精品文檔
關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號(hào):ICP2024067431號(hào)-1 川公網(wǎng)安備51140202000466號(hào)


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺(tái),本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請(qǐng)立即通知裝配圖網(wǎng),我們立即給予刪除!