• 大小: 3.38MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-11
  • 语言: C#
  • 标签: 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  考试管理系统\WindowsFormsApplication1\MySchool.sln
     文件      158720  2014-01-06 23:41  考试管理系统\WindowsFormsApplication1\MySchool.suo
     目录           0  2013-12-22 14:26  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\
     文件       24528  2009-11-07 13:37  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AddQuestion.Designer.cs
     文件        8831  2013-11-29 23:03  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AddQuestion.cs
     文件       17946  2009-11-07 13:37  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AddQuestion.resx
     文件       18466  2013-12-05 20:52  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AddStudentForm.Designer.cs
     文件       11327  2013-12-17 22:54  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AddStudentForm.cs
     文件       17946  2013-12-05 20:52  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AddStudentForm.resx
     文件       13718  2013-12-05 22:25  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AddTeacherForm.Designer.cs
     文件        4323  2013-12-17 23:00  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AddTeacherForm.cs
     文件        5817  2013-12-05 22:25  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AddTeacherForm.resx
     文件       30121  2009-11-07 14:22  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AnswerCard.Designer.cs
     文件        2958  2013-11-30 11:36  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AnswerCard.cs
     文件       18145  2009-11-07 14:22  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AnswerCard.resx
     文件        9339  2009-11-07 13:44  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AnswerQuestionForm.Designer.cs
     文件        5955  2013-11-30 11:36  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AnswerQuestionForm.cs
     文件       18145  2009-11-07 13:44  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\AnswerQuestionForm.resx
     文件           1  2009-10-12 19:55  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\ClassDiagram1.cd
     文件           1  2009-10-26 19:14  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\ClassDiagram2.cd
     文件         429  2009-10-30 17:52  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\ClassDiagram3.cd
     文件       24592  2009-11-07 13:45  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\DetailsQuestions.Designer.cs
     文件       10220  2013-11-29 23:07  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\DetailsQuestions.cs
     文件       17946  2009-11-07 13:45  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\DetailsQuestions.resx
     文件       13256  2013-12-17 22:55  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\EditStudentForm.cs
     文件       31396  2013-12-05 22:00  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\EditStudentForm.designer.cs
     文件        5814  2013-12-05 22:00  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\EditStudentForm.resx
     文件        6097  2013-12-05 22:26  考试管理系统\WindowsFormsApplication1\WindowsFormsApplication1\EditTeacherForm.cs
............此处省略212个文件信息

评论

共有 条评论