成绩查询程序

该成绩查询软件安装包

链接: http://pan.baidu.com/s/1mg9xsEk 密码: f839

实现功能:

1 检查用户是否存在:若不存在,则输出用户不存在;若存在,则检查学号是否正确:若正确,则输出成绩,若不正确,则输出学号不正确;

2 实现从文本读取用户名、学号、成绩。

3 一个按钮实现查询,一个实现重新输入,一个实现退出程序

本程序的三个文本:

这里写图片描述

这里写图片描述

这里写图片描述

效果图:

1 用户不存在

这里写图片描述

2 学号不正确

这里写图片描述

3查询成功

这里写图片描述

代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace chaxun
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            l4.Text = "";//初始化提示标签l4
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

            String name1 = System.IO.Directory.GetCurrentDirectory() + "//name.txt";//读取文本,本程序文本路径E:\C++程序\chaxun\chaxun\bin\Debug,下同!
            String num1= System.IO.Directory.GetCurrentDirectory() + "//num.txt";
            String grade1 = System.IO.Directory.GetCurrentDirectory() + "//grade.txt";
            String[] na =File.ReadAllLines(name1, Encoding.Default);
            String[] nu = File.ReadAllLines(num1, Encoding.Default);
            String[] gr = File.ReadAllLines(grade1, Encoding.Default);
            int i = 0,k=0;//k=0初始化用户不存在!
            do
            {
                if (t1.Text == na[i])
                {
                    if (t2.Text == nu[i])//用户存在
                    {
                        t3.Text = gr[i];
                        l4.Text = "查询成功!";
                        k = 1;
                    }
                    else//学号不正确
                    {
                        k = 2;
                        l4.Text = "";
                    }

                }
                i++;
            } while (i<=na.Length-1);
            if(k!=1)
            switch (k)
            {
                case 0: l4.Text = "用户不存在!"; break;//判断出用户不存在!
                case 2:l4.Text = "学号不正确!";break ;//判断出学号不正确!
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();//退出按钮
        }

        private void button3_Click(object sender, EventArgs e)//重新输入按钮
        {
            t1.Text = "";
            t2.Text = "";
            t3.Text = "";
            l4.Text = "";
            t1.Focus();
        }

    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值