在线考试系统C#


用C# ADO。NET编写的在线考试系统
资源截图
代码片段和文件信息
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 MySchool
{
    /// 
    /// 增加试题窗体
    /// 

    public partial class AddQuestion : Form
    {
        int difficulty = 0;     //难度
        int subjectId = 0;      //科目编号
        string answer = ““;     //答案

        public AddQuestion()
        {
            InitializeComponent();
        }

        //提示用户选择的答案
        public void rdoAnswer_Click(object sender EventArgs e)
        {
            //将sender转换为单选按钮,并获取选中的单选按钮的值
            string answer = ((RadioButton)sender).Text;
            MessageBox.Show(“你选择了答案“ + answer “提示“ MessageBoxButtons.OK MessageBoxIcon.Information);
        }

        //提示用户选择的难度
        public void rdoDifficulty_Click(object sender EventArgs e)
        {
            string answer = ((RadioButton)sender).Text;
            MessageBox.Show(“你选择了难度“ + answer “提示“ MessageBoxButtons.OK MessageBoxIcon.Information);
        }

        private void AddQuestionExit_Click(object sender EventArgs e)
        {
            this.Close();
        }

        //窗体加载时将科目载入科目组合框中
        public void 增加试题_Load(object sender EventArgs e)
        {
            //查询科目的SQL语句
            string sql = “SELECT SubjectName FROM Subject“;
            SqlConnection conn = new SqlConnection();
            SqlConnectionStringBuilder connbuilder = new SqlConnectionStringBuilder();
            connbuilder.DataSource = @“.SQLEXPRESS“;
            connbuilder.InitialCatalog = “MySchool“;
            connbuilder.IntegratedSecurity = true;
            conn.ConnectionString = connbuilder.ConnectionString;
            try
            {
                SqlCommand command = new SqlCommand(sqlconn);
                conn.Open();

                SqlDataReader dataReader = command.ExecuteReader();

                while (dataReader.Read())
                {
                    cboSubject.Items.Add(dataReader[“SubjectName“].ToString());
                }
                dataReader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                conn.Close();
            }
        }

        //输入验证
        public bool ValidateInput()
        {
            if (txtQuestion.Text == ““)
            {
                MessageBox.Show(“请输入问题!“);
                txtQuestion.Focus();
                return false;
            }
            else if (txtOptionA.Text == ““)
            {
                MessageBox.Show(“请输入答案A“);
                txtOptionA.Focus();
                return false;
            }
            else if (txtOptionB.Text == ““)
            {
                MessageBox.Show(“请输入答案B“);
         

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-12-22 14:26  考试管理系统
     文件      200178  2013-12-17 23:19  考试管理系统MySchool.sql
     目录           0  2013-12-22 14:26  考试管理系统WindowsFormsApplication1
     文件         930  2009-10-26 18:57  考试管理系统WindowsFormsApplication1MySchool.sln
     文件      158720  2014-01-06 23:41  考试管理系统WindowsFormsApplication1MySchool.suo
     目录           0  2013-12-22 14:26  考试管理系统WindowsFormsApplication1WindowsFormsApplication1
     文件       24528  2009-11-07 13:37  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AddQuestion.Designer.cs
     文件        8831  2013-11-29 23:03  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AddQuestion.cs
     文件       17946  2009-11-07 13:37  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AddQuestion.resx
     文件       18466  2013-12-05 20:52  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AddStudentForm.Designer.cs
     文件       11327  2013-12-17 22:54  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AddStudentForm.cs
     文件       17946  2013-12-05 20:52  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AddStudentForm.resx
     文件       13718  2013-12-05 22:25  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AddTeacherForm.Designer.cs
     文件        4323  2013-12-17 23:00  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AddTeacherForm.cs
     文件        5817  2013-12-05 22:25  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AddTeacherForm.resx
     文件       30121  2009-11-07 14:22  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AnswerCard.Designer.cs
     文件        2958  2013-11-30 11:36  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AnswerCard.cs
     文件       18145  2009-11-07 14:22  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AnswerCard.resx
     文件        9339  2009-11-07 13:44  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AnswerQuestionForm.Designer.cs
     文件        5955  2013-11-30 11:36  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AnswerQuestionForm.cs
     文件       18145  2009-11-07 13:44  考试管理系统WindowsFormsApplication1WindowsFormsApplication1AnswerQuestionForm.resx
     文件           1  2009-10-12 19:55  考试管理系统WindowsFormsApplication1WindowsFormsApplication1ClassDiagram1.cd
     文件           1  2009-10-26 19:14  考试管理系统WindowsFormsApplication1WindowsFormsApplication1ClassDiagram2.cd
     文件         429  2009-10-30 17:52  考试管理系统WindowsFormsApplication1WindowsFormsApplication1ClassDiagram3.cd
     文件       24592  2009-11-07 13:45  考试管理系统WindowsFormsApplication1WindowsFormsApplication1DetailsQuestions.Designer.cs
     文件       10220  2013-11-29 23:07  考试管理系统WindowsFormsApplication1WindowsFormsApplication1DetailsQuestions.cs
     文件       17946  2009-11-07 13:45  考试管理系统WindowsFormsApplication1WindowsFormsApplication1DetailsQuestions.resx
     文件       13256  2013-12-17 22:55  考试管理系统WindowsFormsApplication1WindowsFormsApplication1EditStudentForm.cs
     文件       31396  2013-12-05 22:00  考试管理系统WindowsFormsApplication1WindowsFormsApplication1EditStudentForm.designer.cs
     文件        5814  2013-12-05 22:00  考试管理系统WindowsFormsApplication1WindowsFormsApplication1EditStudentForm.resx
     文件        6097  2013-12-05 22:26  考试管理系统WindowsFormsApplication1WindowsFormsApplication1EditTeacherForm.cs
............此处省略212个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)