免费预览已结束,剩余21页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
开始窗体/using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace Exam public partial class ExamForm : Form public ExamForm() InitializeComponent(); / / ExamForm / / / private void ExamForm_Load(object sender, EventArgs e) CenterToScreen(); Text = 模拟考试系统; this.Width = 360; this.Height = 230; gressBar1.Width = 360; gressBar1.Height = 10; gressBar1.Left = 0; gressBar1.Top = 220; this.timer1.Start(); int i = 8; private void timer1_Tick(object sender, EventArgs e) gressBar1.PerformStep(); i-; if (i=0) this.timer1.Stop(); FormExam f = new FormExam(); f.Show(); this.Hide(); 数据库辅助类/using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using System.Data.SqlClient;namespace Exam public class DataBase public string connString = Data Source=XUTAO;Initial Catalog=Exam;Integrated Security=True; private SqlConnection conn; / / SqlConnection / public SqlConnection Conn get if (conn = null) conn = new SqlConnection(connString); return conn; / / 打开数据库 / public void openData() if (Conn.State = ConnectionState.Closed) Conn.Open(); else if (Conn.State = ConnectionState.Broken) Conn.Close(); Conn.Open(); / / 关闭数据库 / public void closeData() if (Conn.State = ConnectionState.Open | Conn.State = ConnectionState.Broken) Conn.Close(); 主窗体/using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace Exam public partial class FormExam : Form public FormExam() InitializeComponent(); / / 调用数据库 / DataBase db = new DataBase(); / / ExamForm / / / private void FormExam_Load(object sender, EventArgs e) CenterToScreen(); this.Cursor = Cursors.Hand; this.Text = 模拟考试系统; this.tscmbExamType.SelectedIndex = 0; this.timerDate.Start(); this.Width = 1000; this.Height = 600; this.MaximizeBox = false; this.Top = 50; this.groupBox1.Top = 40; 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.groupBox2.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.groupBox3.Text = 试题选项; 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; this.groupBox4.Text = 操作区域; this.groupBox4.ForeColor = Color.White; this.groupBox4.BackColor = Color.Transparent; this.groupBox4.Width = 200; this.groupBox4.Height = 250; this.groupBox4.Top = 295; this.groupBox4.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 = 上一试题; 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.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; 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; this.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.radioButton2.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; 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.radioButton4.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 = ; 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; 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.button3.Enabled = false; this.button4.Enabled = false; this.button5.Enabled = false; this.toolStripButton1.Enabled = false; / / 时间 / / / private void timerDate_Tick(object sender, EventArgs e) this.toolStripLabel2.Text = DateTime.Now.ToString(); int j = 600; / / 计时器 / / / private void timerP_Tick(object sender, EventArgs e) j-; this.toolStripLabel4.Text = j.ToString(); if (j 60) this.toolStripLabel4.ForeColor = Color.GreenYellow; else this.toolStripLabel4.ForeColor = Color.Red; if (j = 0) this.timerP.Stop(); this.radioButton1.Enabled = false; this.radioButton2.Enabled = false; this.radioButton3.Enabled = false; this.radioButton4.Enabled = false; this.label1.Enabled = false; this.label2.Enabled = false; this.label3.Enabled = false; this.label4.Enabled = false; 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.Show(时间到,请提交试题!); return; / / 开始答题 / / / private void button1_Click(object sender, EventArgs e) 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; this.label3.Enabled = true; this.label4.Enabled = true; this.listExam.Enabled = true; this.listExam.Focus();/第一行默认选中 this.listExam.Items0.Selected = true; this.button1.Enabled = false; this.button2.Enabled = true; this.button3.Enabled = true; this.button4.Enabled = true; this.button5.Enabled = true; / / 停止答题 / / / private 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; 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; this.button3.Enabled = false; this.button4.Enabled = false; this.button5.Enabled = false; / / 显示试题表数据 / public void ListShow() Random random = new Random(); int rand = random.Next(0, 190); string sql = string.Format(select top 10 ExamPaper.SubjectNo, ExamPaper.SubjectName, ExamResult.A,ExamResult.B, ExamResult.C,ExamResult.D, ExamPaper.TypeID from ExamPaper inner join ExamResult on ExamPaper.TypeID=ExamResult.TypeID and ExamPaper.SubjectNo=ExamResult.SubjectNo where ExamPaper.SubjectNo not in (select top 0 ExamPaper.SubjectNo from ExamPaper) and ExamResult.TypeID= (select TypeID from ExamPaperType where ExamPaperType.TypeName like %1%), rand, this.tscmbExamType.Text.Substring(0, 3); try db.openData(); SqlCommand comm = new SqlCommand(sql, db.Conn); SqlDataReader reader = comm.ExecuteReader(); if (!reader.HasRows) return; else while (reader.Read() string SubjectNo = readerSubjectNo.ToString();/题号 string SubjectName = readerSubjectName.ToString();/题干 string TypeID = readerTypeID.ToString(); string A = readerA.ToString(); string B = readerB.ToString(); string C = readerC.ToString(); string D = readerD.ToString(); ListViewItem items = new ListViewItem(SubjectNo); items.SubItems.Add(SubjectName); items.SubItems.Add(TypeID); items.SubItems.Add(A); items.SubItems.Add(B); items.SubItems.Add(C); items.SubItems.Add(D); this.listExam.Items.Add(items); reader.Close(); catch (Exception ex) MessageBox.Show(ex.Message); finally db.closeData(); / / listShow / / / private void tscmbExamType_SelectedIndexChanged(object sender, EventArgs e) if (this.listExam.Items.Count != 0) this.listExam.Items.Clear(); this.timerP.Stop(); j = 600; this.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 = 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.label4.Text = ; this.label5.Text = ; this.label6.Text = ; this.button1.Enabled = true; this.button2.Enabled = false; this.button3.Enabled = false; this.button4.Enabled = false; this.button5.Enabled = false; this.ListShow(); string TypeID = ;/类型号 / / 显示题干和选项 / public void ShowExam() if (this.listExam.SelectedItems.Count != 0) this.label5.Text = this.listExam.SelectedItems0.SubItems0.Text; this.rtbExam.Text = this.listExam.SelectedItems0.SubItems1.Text; TypeID = this.listExam.SelectedItems0.SubItems2.Text; this.label1.Text = this.listExam.SelectedItems0.SubItems3.Text; this.label2.Text = this.listExam.SelectedItems0.SubItems4.Text; this.label3.Text = this.listExam.SelectedItems0.SubItems5.Text; this.label4.Text = this.listExam.SelectedItems0.S
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年重庆工信职业学院单招职业适应性测试模拟测试卷附答案
- 2026年淮南联合大学单招综合素质考试题库及参考答案详解一套
- 2026年濮阳石油化工职业技术学院单招职业技能测试模拟测试卷附答案
- 2026年邵阳职业技术学院单招(计算机)测试模拟题库附答案
- 2026年绍兴文理学院单招职业倾向性考试模拟测试卷附答案
- 2025年衢江区第二期机关、事业单位公开选调工作人员14人考试参考题库附答案解析
- 2026年贵州文化旅游职业学院单招(计算机)考试备考题库必考题
- 2026年重庆三峡学院单招职业适应性测试题库附答案
- 电子商务团队沟通与协作技巧
- 2026年甘肃林业职业技术学院单招职业倾向性测试题库带答案详解
- 《中小学校校长办公会议(校务会议)议事规则(参考文本)》
- 物业客服管家试题及答案
- 个人房屋装修合同模板
- 纽恩泰空气能知识培训课件
- 智能陪伴机器人改善老年人孤独感的可行性研究报告
- 2025能源管理体系要求及实施指南(整合版-2025)
- 国际贸易基础复习资料
- 牧场生物安全培训方案课件
- 2025年高考真题分类汇编选择性必修二 《法律与生活》(全国)(解析版)
- 2025年儿科副主任年度考核个人总结
- 部编版《道德与法治》一年级上册上册第9课《作息有规律》精美课件
评论
0/150
提交评论