欢迎来到代码驿站!

.NET代码

当前位置:首页 > 软件编程 > .NET代码

基于C#制作考试答题系统

时间:2023-01-24 10:49:21|栏目:.NET代码|点击:

效果展示:

1. 进入页面:

2. 答题界面:

3. 时间截止界面:

4. 提交界面:

起始页代码

public partial class Start : Form
    {
        public Start()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Test t = new Test();
            t.Show();
            this.Hide();            
        }
    }

考试页面代码

public partial class Test : Form
    {
        public int currentTime = 0;
        public int num = 0;
        public Test()
        {
            InitializeComponent();
            button2.Visible = false;
        }

        private void 视图ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Start s = new Start();
            this.Hide();
            s.Show();
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void Test_Load(object sender, EventArgs e)
        {
            this.timer1.Enabled = true;
            this.timer1.Interval = 1000;
            this.timer1.Start();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            currentTime = Convert.ToInt32(label2.Text);
            currentTime -= 1;
            label2.Text = Convert.ToString(currentTime);
            if(currentTime == 0)
            {
                timer1.Stop();
                System.Media.SystemSounds.Asterisk.Play();
                MessageBox.Show("时间到!", "提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
            }
        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void label7_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Check(groupBox1, "?");
            Check(groupBox2, "?");
            Check(groupBox3, "?");
            Check(groupBox4, "?");
            Check(groupBox5, "?");
            a.Enabled = false;
            b.Enabled = false;
            radioButton3.Enabled = false;
            radioButton4.Enabled = false;
            radioButton5.Enabled = false;
            radioButton6.Enabled = false;
            radioButton7.Enabled = false;
            radioButton8.Enabled = false;
            radioButton9.Enabled = false;
            radioButton10.Enabled = false;
            label6.Text = Convert.ToString(num);
            label7.Text = Convert.ToString(num * 20);
            this.timer1.Stop();
            button2.Visible = true;
        }
        public void Check(GroupBox s, String db)
        {
            foreach(Control D in s.Controls)
            {
                if (((RadioButton)D).Checked == true && ((RadioButton)D).Text.Substring(0, 1) == db)
                {
                    num++;
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            label2.Text = "20";
            label6.Text = "0";
            label7.Text = "0";
            this.timer1.Start();
            this.timer1.Interval = 1000;
            Clean(groupBox1);
            Clean(groupBox2);
            Clean(groupBox3);
            Clean(groupBox4);
            Clean(groupBox5);
            a.Enabled = true;
            b.Enabled = true;
            radioButton3.Enabled = true;
            radioButton4.Enabled = true;
            radioButton5.Enabled = true;
            radioButton6.Enabled = true;
            radioButton7.Enabled = true;
            radioButton8.Enabled = true;
            radioButton9.Enabled = true;
            radioButton10.Enabled = true;
            button2.Visible = false;
            num = 0;
        }
        public void Clean(GroupBox s)
        {
            foreach(Control D in s.Controls)
            {
                if(((RadioButton)D).Checked == true)
                {
                    ((RadioButton)D).Checked = false;
                }
            }
        }
    }

有图标的应用程序

上一篇:LINQ(语言集成查询)使用案例

栏    目:.NET代码

下一篇:编译 dotnet和aspnetcore 源代码详情

本文标题:基于C#制作考试答题系统

本文地址:http://www.codeinn.net/misctech/224345.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有