C# Windows窗体应用程序设计综合实例--------学生成绩管理系统

C# Windows窗体应用程序设计综合实例(二)--------学生成绩管理系统

今天给大家更新一个综合实例,学生成绩管理系统。从需求分析、窗体应用程序的编写、运行结果来阐述整个过程
(文末和评论区有源代码文件,需要自取,建议先看内容再看源代码,代码描述部分可忽略,比较长,影响观看时间。)

需求分析

首先先要进行需求分析,需求分析就是想清楚你写的窗体应用具体要实现哪些功能。最好把它用表格的形式列出来。本次实例的需求如下表格。

窗体功能描述
主窗体对整个系统的功能进行汇总和导航
添加对输入系统内的学生成绩进行添加输入数据
保存至TXT将系统内的成绩导出系统
从TXT导入从系统外导入成绩信息
查找根据特定信息查找学生的成绩信息
排序按照特定要求进行降序或者升序排序
删除对特定学生的成绩信息进行删除
修改找到学生信息再修改相应的值

接下来我们了解了需求后,就开始在大脑里面构思具体的一个情景。

整体构思

假定这个系统完成了,你在使用的时候首先出现的应该是导航的页面,也就是主窗体,上面有各个功能的按钮。然后接着是每个功能对应的窗体的情景。最后退出结束。这一步的目的是为了在写的时候有一个大致的布局和编写习惯的预定判定。就像是一个工程师在心里画好了图纸,到时候就不用考虑布局和习惯的问题,只需要关注代码之间的逻辑和语法问题
在这里插入图片描述
下面就是整个最煎熬的步骤了,也就是按照前面说讲的窗体应用程序设计的步骤来完成。

窗体应用程序设计的编写

选取学生信息的存储结构

本次由于是做成绩管理系统,就要想好具体在程序里面的存储结构。这里我们用典型的单链表作为存储结构来存储学生的各项信息。
那么可能有一部分不太了解数据结构的小伙伴就比较疑惑了,接下来简单介绍一下单链表。
单链表的结构如下:
在这里插入图片描述
每个节点由数据域和指针域构成,在开头的的节点有一个头指针。该存储结构的优点是在进行某些操作的时候便于修改。具体的内容自行查找知识点,这里不做过多解释。(文末和评论区有源代码,需要自取)

设置布局

接下来我们就开始设置窗体的布局,如下图所示:
1.主界面
在这里插入图片描述
2.修改在这里插入图片描述
3.添加在这里插入图片描述
4.删除在这里插入图片描述
5.排序
在这里插入图片描述
6.查找
在这里插入图片描述
在这里说明一下,在写的过程中,最好是完成一个界面就运行检查一次,不要等到写完了再去查错,工作量比较大容易混乱。

控件布局及属性设置

在了解了布局后,我们接下来根据具体的要求进行属性的设置,属性设置如下:
注意:控件较多的情况下,name属性会自动命名为控件名+加入的顺序,例如加入两个label,第一个自动命名为label1,第二个就为label2。因此后面添加控件按照表格的顺序来一个一个搞好再添加,不然容易混乱与代码对不上。
在这里插入图片描述
在这里再强调一下,最好是完成一个界面就运行检查一次,不要等到写完了再去查错,工作量比较大容易混乱!
最好是完成一个界面就运行检查一次,不要等到写完了再去查错,工作量比较大容易混乱!
最好是完成一个界面就运行检查一次,不要等到写完了再去查错,工作量比较大容易混乱! 重要的事情说三遍。
2.排序在这里插入图片描述
3.查找
在这里插入图片描述
4.删除
在这里插入图片描述
5.修改
在这里插入图片描述
在这里插入图片描述
6.添加
在这里插入图片描述
在这里插入图片描述
严格注意区分name属性里面的大小写,具体事项见备注。

添加代码

添加代码的方法就是双击你的控件,对应的添加。具体的可以看主页之前写的匹配游戏设计和数学测验器。

***************************************
前方高能,非战斗人员请撤离
请爱护好自己的眼睛
***************************************
1.Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
    namespace C_sharp学生成绩管理系统
    {
        public class Node
        {
            //数据域,当前结点数据

            //信息
            public int id;
            public string name;
            public string classnum;
        internal object tiyu;
        internal object yingyu;
        internal object shuxue;
        //分数
        public int c_sharp { set; get; }
            public int ds { set; get; }
            public int maogai { set; get; }
            public int ps { set; get; }   
            public int sports { set; get; }

            public double total { set; get; }
            public double average { set; get; }
            //指针   
            public Node Next { set; get; }    //位置域,下一个结点地址
            //构造函数
            public Node(int id, string name, string classnum, int c_sharp, int ds, int maogai, int ps,int sports)
            {
                this.id = id;
                this.name = name;
                this.classnum = classnum;
                this.c_sharp = c_sharp;
                this.ds = ds;
                this.maogai = maogai;
                this.ps = ps;
                this.sports = sports;

                this.total = this.c_sharp + this.ds + this.maogai + this.ps  + this.sports;
                this.average = this.total / 6;

                this.Next = null;
            }
        }
        public class LinkList
        {
            public Node Head { set; get; } //单链表头
            public int total { set; get; } //总人数

            //构造
            public LinkList()
            {
                Head = null;
                total = 0;
            }

            //增加新元素到单链表末尾
            public static void Append(int id, string name, string classnum, int c_sharp, int ds, int maogai, int ps,  int sports)
            {
                Node foot = new Node(id, name, classnum, c_sharp, ds,maogai, ps,  sports);
                Node A = new Node(id, name, classnum, c_sharp, ds, maogai, ps, sports);

                if (PublicValue.Head == null)
                {
                    PublicValue.Head = foot;
                    return;
                }
                A = PublicValue.Head;
                while (A.Next != null)
                {
                    A = A.Next;
                }
                A.Next = foot;
            }
        }

        //全局变量
        public class PublicValue
        {
            public static Node Head; //单链表头
            public static Node Tail; //单链表尾
            public static int total; //学生总数
        }
        /// 应用程序的主入口点
        static class Program
        {
            /// <summary>
            /// 应用程序的主入口点
            /// </summary>
            [STAThread]
            static void Main()
            {
                LinkList link = new LinkList();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
        }
    }

2.主界面:

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;//Stream流类

namespace C_sharp学生成绩管理系统
{
    public partial class MainForm : Form
    {

        public MainForm()
        {
            InitializeComponent();
        }

       

        private void SaveTXT_Click_1(object sender, EventArgs e)
        {
            //清空txt
            System.IO.File.WriteAllText(@"data.txt", string.Empty);

            //写入
            StreamWriter sw = new StreamWriter("data.txt", true, Encoding.Default);
            Node B = new Node(0, "0", "0", 0, 0, 0, 0, 0);
            B = PublicValue.Head;

            sw.Write(PublicValue.total + "\r\n");
            while (B != null)
            {
                sw.Write(B.id + "\r\n" + B.classnum + "\r\n" + B.name + "\r\n" + B.c_sharp + "\r\n" + B.ds + "\r\n" + B.maogai + "\r\n" + B.ps + "\r\n" + +B.sports + "\r\n");
                B = B.Next;
            }

            //清空缓冲区
            sw.Flush();

            //关闭流
            sw.Close();

            MessageBox.Show("保存成功");
        }

        private void AppendTxt_Click(object sender, EventArgs e)
        {
            int i;

            FileStream fs = new FileStream("data.txt", FileMode.Open);
            StreamReader sr = new StreamReader(fs, Encoding.Default);

            //临时接收
            int id;
            string name;
            string classnum;
            int c_sharp;
            int ds;
            int maogai;
            int ps;
            int sports;

            PublicValue.total = int.Parse(sr.ReadLine());

            for (i = 0; i < PublicValue.total; i++)
            {
                id = int.Parse(sr.ReadLine());
                name = sr.ReadLine();
                classnum = sr.ReadLine();

                c_sharp = int.Parse(sr.ReadLine());
                ds = int.Parse(sr.ReadLine());
                maogai = int.Parse(sr.ReadLine());
                ps = int.Parse(sr.ReadLine());
                sports = int.Parse(sr.ReadLine());

                LinkList.Append(id, classnum, name, c_sharp, ds, maogai, ps, sports);

            }
            sr.Close();
            MessageBox.Show("导入成功");
            List_Click_1(null, null);
        }

        private void List_Click_1(object sender, EventArgs e)
        {
            Node B = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
            B = PublicValue.Head;

            Change.Text = "";//先清空
            Change.Text += "  学号 \t\t 班级 \t\t姓名\t语文\t体育\t数学\t英语\t物理\t总分\t平均分\r\n";
            while (B != null)
            {
                Change.Text += B.id + " \t" + B.classnum + "\t" + B.name + "\t" + B.c_sharp + "\t" + B.ds + "\t" + "\t" + B.maogai + "\t" + B.ps + "\t" +  + B.sports + "\t" + B.total + "\t" + B.average.ToString("f2") + "\r\n";
                B = B.Next;
            }
        }

        private void ch_Click(object sender, EventArgs e)
        {
            ChangeStuForm f3 = new ChangeStuForm();
            f3.ShowDialog();
            List_Click_1(null, null);
        }

        private void Delete_Click_1(object sender, EventArgs e)
        {
            DelStuForm f4 = new DelStuForm();
            f4.ShowDialog();
            List_Click_1(null, null);
        }

        private void Find_Click_1(object sender, EventArgs e)
        {

            FindForm f6 = new FindForm();
            f6.ShowDialog();
        }

        private void Sort_Click_1(object sender, EventArgs e)
        {
            SortForm f5 = new SortForm();
            f5.ShowDialog();
            List_Click_1(null, null);
        }

        private void Exit_Click_1(object sender, EventArgs e)
        {
            System.Environment.Exit(0);
        }

        private void Add_Click(object sender, EventArgs e)
        {
            AddStuForm f2 = new AddStuForm();
            f2.ShowDialog();
            List_Click_1(null, null);
        }

        private void MainForm_Load(object sender, EventArgs e)
        {

        }
    }
}

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;

namespace C_sharp学生成绩管理系统
{
    public partial class ChangeStuForm : Form
    {
        private Button button1;
        private Button button2;
        private TextBox textBox1;
        private TextBox textBox2;
        private TextBox textBox3;
        private TextBox textBox4;
        private TextBox textBox5;
        private TextBox textBox6;
        private TextBox textBox7;
        private TextBox textBox8;
        private Label label1;
        private Label label2;
        private Label label3;
        private Label label4;
        private Label label5;
        private Label label6;
        private Label label7;
        private Label label8;
        private TextBox textBox9;
        private Label label9;
        private Button button3;

        public ChangeStuForm()
        {
            InitializeComponent();
        }
        
        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.textBox3 = new System.Windows.Forms.TextBox();
            this.textBox4 = new System.Windows.Forms.TextBox();
            this.textBox5 = new System.Windows.Forms.TextBox();
            this.textBox6 = new System.Windows.Forms.TextBox();
            this.textBox7 = new System.Windows.Forms.TextBox();
            this.textBox8 = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.label6 = new System.Windows.Forms.Label();
            this.label7 = new System.Windows.Forms.Label();
            this.label8 = new System.Windows.Forms.Label();
            this.textBox9 = new System.Windows.Forms.TextBox();
            this.label9 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.BackColor = System.Drawing.SystemColors.Info;
            this.button1.Location = new System.Drawing.Point(75, 372);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(128, 41);
            this.button1.TabIndex = 0;
            this.button1.Text = "确定";
            this.button1.UseVisualStyleBackColor = false;
            this.button1.Click += new System.EventHandler(this.button1_Click_1);
            // 
            // button2
            // 
            this.button2.BackColor = System.Drawing.SystemColors.Info;
            this.button2.Location = new System.Drawing.Point(264, 371);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(140, 41);
            this.button2.TabIndex = 1;
            this.button2.Text = "修改";
            this.button2.UseVisualStyleBackColor = false;
            this.button2.Click += new System.EventHandler(this.button2_Click_1);
            // 
            // button3
            // 
            this.button3.BackColor = System.Drawing.SystemColors.Info;
            this.button3.Location = new System.Drawing.Point(479, 372);
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(136, 40);
            this.button3.TabIndex = 2;
            this.button3.Text = "退出";
            this.button3.UseVisualStyleBackColor = false;
            this.button3.Click += new System.EventHandler(this.button3_Click_1);
            // 
            // textBox1
            // 
            this.textBox1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox1.Location = new System.Drawing.Point(94, 46);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(155, 25);
            this.textBox1.TabIndex = 3;
            // 
            // textBox2
            // 
            this.textBox2.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox2.Location = new System.Drawing.Point(94, 96);
            this.textBox2.Name = "textBox2";
            this.textBox2.Size = new System.Drawing.Size(155, 25);
            this.textBox2.TabIndex = 4;
            // 
            // textBox3
            // 
            this.textBox3.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox3.Location = new System.Drawing.Point(436, 46);
            this.textBox3.Name = "textBox3";
            this.textBox3.Size = new System.Drawing.Size(130, 25);
            this.textBox3.TabIndex = 5;
            // 
            // textBox4
            // 
            this.textBox4.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox4.Location = new System.Drawing.Point(94, 209);
            this.textBox4.Name = "textBox4";
            this.textBox4.Size = new System.Drawing.Size(100, 25);
            this.textBox4.TabIndex = 6;
            // 
            // textBox5
            // 
            this.textBox5.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox5.Location = new System.Drawing.Point(304, 209);
            this.textBox5.Name = "textBox5";
            this.textBox5.Size = new System.Drawing.Size(100, 25);
            this.textBox5.TabIndex = 7;
            // 
            // textBox6
            // 
            this.textBox6.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox6.Location = new System.Drawing.Point(500, 276);
            this.textBox6.Name = "textBox6";
            this.textBox6.Size = new System.Drawing.Size(100, 25);
            this.textBox6.TabIndex = 8;
            // 
            // textBox7
            // 
            this.textBox7.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox7.Location = new System.Drawing.Point(500, 209);
            this.textBox7.Name = "textBox7";
            this.textBox7.Size = new System.Drawing.Size(100, 25);
            this.textBox7.TabIndex = 9;
            // 
            // textBox8
            // 
            this.textBox8.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox8.Location = new System.Drawing.Point(94, 276);
            this.textBox8.Name = "textBox8";
            this.textBox8.Size = new System.Drawing.Size(100, 25);
            this.textBox8.TabIndex = 10;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(51, 99);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(37, 15);
            this.label1.TabIndex = 11;
            this.label1.Text = "班级";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.ForeColor = System.Drawing.Color.Blue;
            this.label2.Location = new System.Drawing.Point(393, 49);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(37, 15);
            this.label2.TabIndex = 12;
            this.label2.Text = "姓名";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(51, 219);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(37, 15);
            this.label3.TabIndex = 13;
            this.label3.Text = "语文";
            this.label3.Click += new System.EventHandler(this.label3_Click);
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(261, 212);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(37, 15);
            this.label4.TabIndex = 14;
            this.label4.Text = "数学";
            this.label4.Click += new System.EventHandler(this.label4_Click);
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(457, 278);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(37, 15);
            this.label5.TabIndex = 15;
            this.label5.Text = "体育";
            this.label5.Click += new System.EventHandler(this.label5_Click);
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(457, 212);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(37, 15);
            this.label6.TabIndex = 16;
            this.label6.Text = "英语";
            this.label6.Click += new System.EventHandler(this.label6_Click);
            // 
            // label7
            // 
            this.label7.AutoSize = true;
            this.label7.Location = new System.Drawing.Point(51, 278);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(37, 15);
            this.label7.TabIndex = 17;
            this.label7.Text = "物理";
            this.label7.Click += new System.EventHandler(this.label7_Click);
            // 
            // label8
            // 
            this.label8.AutoSize = true;
            this.label8.Location = new System.Drawing.Point(51, 46);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(37, 15);
            this.label8.TabIndex = 18;
            this.label8.Text = "学号";
            // 
            // textBox9
            // 
            this.textBox9.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox9.Location = new System.Drawing.Point(304, 278);
            this.textBox9.Name = "textBox9";
            this.textBox9.Size = new System.Drawing.Size(100, 25);
            this.textBox9.TabIndex = 19;
            // 
            // label9
            // 
            this.label9.AutoSize = true;
            this.label9.Location = new System.Drawing.Point(261, 279);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(37, 15);
            this.label9.TabIndex = 20;
            this.label9.Text = "政治";
            // 
            // ChangeStuForm
            // 
            this.BackColor = System.Drawing.SystemColors.InactiveCaption;
            this.ClientSize = new System.Drawing.Size(719, 478);
            this.Controls.Add(this.label9);
            this.Controls.Add(this.textBox9);
            this.Controls.Add(this.label8);
            this.Controls.Add(this.label7);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.textBox8);
            this.Controls.Add(this.textBox7);
            this.Controls.Add(this.textBox6);
            this.Controls.Add(this.textBox5);
            this.Controls.Add(this.textBox4);
            this.Controls.Add(this.textBox3);
            this.Controls.Add(this.textBox2);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.button3);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.ForeColor = System.Drawing.Color.Blue;
            this.Name = "ChangeStuForm";
            this.Text = "修改";
            this.Load += new System.EventHandler(this.ChangeStuForm_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            //遍历查找
            Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
            cur = PublicValue.Head;//从头开始查找
            int findId = int.Parse(textBox1.Text);
            while (cur != null)
            {
                if (cur.id == findId)
                {
                    textBox2.Text = cur.classnum;
                    textBox3.Text = cur.name;
                    textBox4.Text = Convert.ToString(cur.c_sharp);
                    textBox5.Text = Convert.ToString(cur.ds);
                    textBox6.Text = Convert.ToString(cur.maogai);
                    textBox7.Text = Convert.ToString(cur.ps);
                    textBox8.Text = Convert.ToString(cur.sports);
                    break;
                }
                cur = cur.Next;
            }
            if (cur == null)
            {
                MessageBox.Show("你输入的学号不存在!");
            }
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            //再次遍历查找
            Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
            cur = PublicValue.Head;//从头开始查找
            int findId = int.Parse(textBox1.Text);
            while (cur != null)
            {
                if (cur.id == findId)
                {
                    cur.classnum = textBox2.Text;
                    cur.name = textBox3.Text;
                    cur.c_sharp = int.Parse(textBox4.Text);
                    cur.ds = int.Parse(textBox5.Text);
                    cur.maogai = int.Parse(textBox6.Text);
                    cur.ps = int.Parse(textBox7.Text);
                    cur.sports = int.Parse(textBox8.Text);
                    cur.total = cur.c_sharp + cur.ds + cur.maogai + cur.ps + cur.sports;
                    cur.average = cur.total / 5;

                    MessageBox.Show("修改成功");
                    break;
                }
                cur = cur.Next;
            }
            if (cur == null)
            {
                MessageBox.Show("修改失败,你输入的学号不存在!请不要改变刚才输入的学号");
            }
        }

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

        private void label7_Click(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void ChangeStuForm_Load(object sender, EventArgs e)
        {

        }
    }
}

*******************************
看到这里休息一下吧
***************
4.添加

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;

namespace C_sharp学生成绩管理系统
{
    public partial class AddStuForm : Form
    {
        private Button button1;
        private Button button2;
        private Button button3;
        private TextBox textBox1;
        private TextBox textBox2;
        private TextBox textBox3;
        private TextBox textBox4;
        private TextBox textBox5;
        private TextBox textBox6;
        private TextBox textBox7;
        private TextBox textBox8;
        private Label label1;
        private Label label2;
        private Label label3;
        private Label label4;
        private Label label5;
        private Label label6;
        private Label label7;
        private TextBox textBox9;
        private Label label9;
        private Label label8;

        public AddStuForm()
        {
            InitializeComponent();
        }

        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.textBox3 = new System.Windows.Forms.TextBox();
            this.textBox4 = new System.Windows.Forms.TextBox();
            this.textBox5 = new System.Windows.Forms.TextBox();
            this.textBox6 = new System.Windows.Forms.TextBox();
            this.textBox7 = new System.Windows.Forms.TextBox();
            this.textBox8 = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.label6 = new System.Windows.Forms.Label();
            this.label7 = new System.Windows.Forms.Label();
            this.label8 = new System.Windows.Forms.Label();
            this.textBox9 = new System.Windows.Forms.TextBox();
            this.label9 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.BackColor = System.Drawing.SystemColors.Info;
            this.button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.button1.Location = new System.Drawing.Point(34, 369);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(131, 43);
            this.button1.TabIndex = 0;
            this.button1.Text = "添加";
            this.button1.UseVisualStyleBackColor = false;
            this.button1.Click += new System.EventHandler(this.button1_Click_1);
            // 
            // button2
            // 
            this.button2.BackColor = System.Drawing.SystemColors.Info;
            this.button2.Location = new System.Drawing.Point(235, 369);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(122, 43);
            this.button2.TabIndex = 1;
            this.button2.Text = "自动添加";
            this.button2.UseVisualStyleBackColor = false;
            this.button2.Click += new System.EventHandler(this.button2_Click_1);
            // 
            // button3
            // 
            this.button3.BackColor = System.Drawing.SystemColors.Info;
            this.button3.Location = new System.Drawing.Point(445, 369);
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(136, 43);
            this.button3.TabIndex = 2;
            this.button3.Text = "退出";
            this.button3.UseVisualStyleBackColor = false;
            this.button3.Click += new System.EventHandler(this.button3_Click_1);
            // 
            // textBox1
            // 
            this.textBox1.BackColor = System.Drawing.SystemColors.ControlLightLight;
            this.textBox1.Location = new System.Drawing.Point(101, 63);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(166, 25);
            this.textBox1.TabIndex = 3;
            // 
            // textBox2
            // 
            this.textBox2.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox2.Location = new System.Drawing.Point(376, 66);
            this.textBox2.Name = "textBox2";
            this.textBox2.Size = new System.Drawing.Size(144, 25);
            this.textBox2.TabIndex = 4;
            this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
            // 
            // textBox3
            // 
            this.textBox3.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox3.Location = new System.Drawing.Point(101, 119);
            this.textBox3.Name = "textBox3";
            this.textBox3.Size = new System.Drawing.Size(166, 25);
            this.textBox3.TabIndex = 5;
            // 
            // textBox4
            // 
            this.textBox4.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox4.Location = new System.Drawing.Point(70, 217);
            this.textBox4.Name = "textBox4";
            this.textBox4.Size = new System.Drawing.Size(100, 25);
            this.textBox4.TabIndex = 6;
            // 
            // textBox5
            // 
            this.textBox5.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox5.Location = new System.Drawing.Point(282, 279);
            this.textBox5.Name = "textBox5";
            this.textBox5.Size = new System.Drawing.Size(100, 25);
            this.textBox5.TabIndex = 7;
            // 
            // textBox6
            // 
            this.textBox6.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox6.Location = new System.Drawing.Point(282, 217);
            this.textBox6.Name = "textBox6";
            this.textBox6.Size = new System.Drawing.Size(100, 25);
            this.textBox6.TabIndex = 8;
            // 
            // textBox7
            // 
            this.textBox7.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox7.Location = new System.Drawing.Point(497, 217);
            this.textBox7.Name = "textBox7";
            this.textBox7.Size = new System.Drawing.Size(100, 25);
            this.textBox7.TabIndex = 9;
            // 
            // textBox8
            // 
            this.textBox8.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox8.Location = new System.Drawing.Point(74, 279);
            this.textBox8.Name = "textBox8";
            this.textBox8.Size = new System.Drawing.Size(100, 25);
            this.textBox8.TabIndex = 10;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(49, 63);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(37, 15);
            this.label1.TabIndex = 11;
            this.label1.Text = "学号";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(313, 69);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(37, 15);
            this.label2.TabIndex = 12;
            this.label2.Text = "姓名";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(49, 129);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(37, 15);
            this.label3.TabIndex = 13;
            this.label3.Text = "班级";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(31, 220);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(37, 15);
            this.label4.TabIndex = 14;
            this.label4.Text = "语文";
            this.label4.Click += new System.EventHandler(this.label4_Click);
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(442, 289);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(37, 15);
            this.label5.TabIndex = 15;
            this.label5.Text = "体育";
            this.label5.Click += new System.EventHandler(this.label5_Click);
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(232, 217);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(37, 15);
            this.label6.TabIndex = 16;
            this.label6.Text = "数学";
            this.label6.Click += new System.EventHandler(this.label6_Click);
            // 
            // label7
            // 
            this.label7.AutoSize = true;
            this.label7.Location = new System.Drawing.Point(442, 220);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(37, 15);
            this.label7.TabIndex = 17;
            this.label7.Text = "英语";
            this.label7.Click += new System.EventHandler(this.label7_Click);
            // 
            // label8
            // 
            this.label8.AutoSize = true;
            this.label8.Location = new System.Drawing.Point(31, 289);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(37, 15);
            this.label8.TabIndex = 18;
            this.label8.Text = "物理";
            this.label8.Click += new System.EventHandler(this.label8_Click);
            // 
            // textBox9
            // 
            this.textBox9.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.textBox9.Location = new System.Drawing.Point(497, 286);
            this.textBox9.Name = "textBox9";
            this.textBox9.Size = new System.Drawing.Size(100, 25);
            this.textBox9.TabIndex = 19;
            // 
            // label9
            // 
            this.label9.AutoSize = true;
            this.label9.Location = new System.Drawing.Point(232, 279);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(37, 15);
            this.label9.TabIndex = 20;
            this.label9.Text = "政治";
            // 
            // AddStuForm
            // 
            this.BackColor = System.Drawing.SystemColors.InactiveCaption;
            this.ClientSize = new System.Drawing.Size(655, 484);
            this.Controls.Add(this.label9);
            this.Controls.Add(this.textBox9);
            this.Controls.Add(this.label8);
            this.Controls.Add(this.label7);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.textBox8);
            this.Controls.Add(this.textBox7);
            this.Controls.Add(this.textBox6);
            this.Controls.Add(this.textBox5);
            this.Controls.Add(this.textBox4);
            this.Controls.Add(this.textBox3);
            this.Controls.Add(this.textBox2);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.button3);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.ForeColor = System.Drawing.Color.Blue;
            this.Name = "AddStuForm";
            this.Text = "添加";
            this.Load += new System.EventHandler(this.AddStuForm_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            //临时接收
            int id;
            string name;
            string classnum;

            //分数
            int c_sharp;
            int ds;
            int maogai;
            int ps;
            int sports;

            id = int.Parse(textBox1.Text);
            name = textBox2.Text;
            classnum = textBox3.Text;
            c_sharp = int.Parse(textBox4.Text);
            ds = int.Parse(textBox5.Text);
            maogai = int.Parse(textBox6.Text);
            ps = int.Parse(textBox7.Text);
            sports = int.Parse(textBox8.Text);

            LinkList.Append(id, name, classnum, c_sharp, ds, maogai, ps, sports);
            PublicValue.total++;
            MessageBox.Show("添加成功");
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            Random rd = new Random();

            if (Convert.ToString(textBox1.Text) == "")
            {
                textBox1.Text = Convert.ToString(1);
            }
            else
            {
                textBox1.Text = Convert.ToString(1 + int.Parse(textBox1.Text));//学号自动顺延
            }

            textBox2.Text = "张三";
            textBox3.Text = "计算机科学与技术1班";

            textBox4.Text = Convert.ToString(rd.Next(50, 100));
            textBox5.Text = Convert.ToString(rd.Next(50, 100));
            textBox6.Text = Convert.ToString(rd.Next(50, 100));
            textBox7.Text = Convert.ToString(rd.Next(50, 100));
            textBox8.Text = Convert.ToString(rd.Next(50, 100));
        }

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

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void label7_Click(object sender, EventArgs e)
        {

        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void label8_Click(object sender, EventArgs e)
        {

        }

        private void AddStuForm_Load(object sender, EventArgs e)
        {

        }
    }
}

5.删除

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;

namespace C_sharp学生成绩管理系统
{
    public partial class DelStuForm : Form
    {
        private Button button1;
        private Button button2;
        private Label label1;
        private Label label2;
        private TextBox textBox1;
        private TextBox textBox2;
        private Button button3;

        public DelStuForm()
        {
            InitializeComponent();
        }

        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.BackColor = System.Drawing.SystemColors.Info;
            this.button1.Location = new System.Drawing.Point(393, 58);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(103, 39);
            this.button1.TabIndex = 0;
            this.button1.Text = "查找";
            this.button1.UseVisualStyleBackColor = false;
            this.button1.Click += new System.EventHandler(this.button1_Click_1);
            // 
            // button2
            // 
            this.button2.BackColor = System.Drawing.SystemColors.Info;
            this.button2.Location = new System.Drawing.Point(410, 425);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(121, 46);
            this.button2.TabIndex = 1;
            this.button2.Text = "删除";
            this.button2.UseVisualStyleBackColor = false;
            this.button2.Click += new System.EventHandler(this.button2_Click_1);
            // 
            // button3
            // 
            this.button3.BackColor = System.Drawing.SystemColors.Info;
            this.button3.Location = new System.Drawing.Point(594, 425);
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(93, 46);
            this.button3.TabIndex = 2;
            this.button3.Text = "退出";
            this.button3.UseVisualStyleBackColor = false;
            this.button3.Click += new System.EventHandler(this.button3_Click_1);
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(44, 58);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(37, 15);
            this.label1.TabIndex = 3;
            this.label1.Text = "学号";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(44, 127);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(37, 15);
            this.label2.TabIndex = 4;
            this.label2.Text = "信息";
            // 
            // textBox1
            // 
            this.textBox1.BackColor = System.Drawing.Color.Snow;
            this.textBox1.Location = new System.Drawing.Point(96, 58);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(206, 25);
            this.textBox1.TabIndex = 5;
            // 
            // textBox2
            // 
            this.textBox2.BackColor = System.Drawing.Color.SeaShell;
            this.textBox2.Location = new System.Drawing.Point(96, 124);
            this.textBox2.Multiline = true;
            this.textBox2.Name = "textBox2";
            this.textBox2.Size = new System.Drawing.Size(591, 281);
            this.textBox2.TabIndex = 6;
            // 
            // DelStuForm
            // 
            this.BackColor = System.Drawing.SystemColors.InactiveCaption;
            this.ClientSize = new System.Drawing.Size(783, 483);
            this.Controls.Add(this.textBox2);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.button3);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.ForeColor = System.Drawing.Color.Blue;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
            this.Name = "DelStuForm";
            this.Text = "删除";
            this.Load += new System.EventHandler(this.DelStuForm_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
            cur = PublicValue.Head;

            textBox2.Text = "";//先清空
            textBox2.Text += "学号 \t\t 班级 \t\t姓名\t语文\t体育\t数学\t英语\t物理\r\n";

            int findId = int.Parse(textBox1.Text);
            while (cur != null)
            {
                if (cur.id == findId)
                {
                    textBox2.Text += cur.id + "\t";
                    textBox2.Text += cur.classnum + "\t";
                    textBox2.Text += cur.name + "\t";
                    textBox2.Text += cur.c_sharp + "\t";
                    textBox2.Text += cur.ds + "\t"+"\t";
                    textBox2.Text += cur.maogai + "\t";
                    textBox2.Text += cur.ps + "\t";
                    textBox2.Text += cur.sports;
                    break;
                }
                cur = cur.Next;
            }
            if (cur == null)
            {
                MessageBox.Show("你输入的学号不存在!");
            }
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//大哥
            Node last = new Node(0, "0", "0", 0, 0, 0, 0, 0);//小弟

            cur = PublicValue.Head;
            last = cur;

            int findId = int.Parse(textBox1.Text);

            //查找
            while (cur != null)
            {
                if (cur.id == findId)//如果找到了
                {
                    PublicValue.total--;

                    if (cur == PublicValue.Head)//如果删除的是头节点
                    {
                        PublicValue.Head = PublicValue.Head.Next;
                        MessageBox.Show("删除成功");
                        return;
                    }
                    else
                    {
                        last.Next = cur.Next;//垃圾回收机制,不需要自己清理内存
                        MessageBox.Show("删除成功");
                        return;
                    }
                }
                last = cur;//小弟踩大哥脚印
                cur = cur.Next;//大哥先走一步
            }

            if (cur == null)
            {
                MessageBox.Show("你删除的学号不存在!");
            }

        }

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

        private void DelStuForm_Load(object sender, EventArgs e)
        {

        }
    }
}

6.排序

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;

namespace C_sharp学生成绩管理系统
{
    public partial class SortForm : Form
    {
        private Button button1;
        private Button button2;
        private Button button3;
        private Button button4;
        private Button button5;
        private TextBox textBox1;
        private Label label1;
        private ComboBox comboBox1;

        public SortForm()
        {
            InitializeComponent();
        }


        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.button4 = new System.Windows.Forms.Button();
            this.button5 = new System.Windows.Forms.Button();
            this.comboBox1 = new System.Windows.Forms.ComboBox();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.BackColor = System.Drawing.SystemColors.Info;
            this.button1.Location = new System.Drawing.Point(614, 12);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(112, 44);
            this.button1.TabIndex = 0;
            this.button1.Text = "按课程排序";
            this.button1.UseVisualStyleBackColor = false;
            this.button1.Click += new System.EventHandler(this.button1_Click_1);
            // 
            // button2
            // 
            this.button2.BackColor = System.Drawing.SystemColors.Info;
            this.button2.Location = new System.Drawing.Point(39, 12);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(108, 44);
            this.button2.TabIndex = 1;
            this.button2.Text = "按班级排序";
            this.button2.UseVisualStyleBackColor = false;
            this.button2.Click += new System.EventHandler(this.button2_Click_1);
            // 
            // button3
            // 
            this.button3.BackColor = System.Drawing.SystemColors.Info;
            this.button3.Location = new System.Drawing.Point(424, 12);
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(93, 44);
            this.button3.TabIndex = 2;
            this.button3.Text = "按总分排序";
            this.button3.UseVisualStyleBackColor = false;
            this.button3.Click += new System.EventHandler(this.button3_Click_1);
            // 
            // button4
            // 
            this.button4.BackColor = System.Drawing.SystemColors.Info;
            this.button4.Location = new System.Drawing.Point(662, 358);
            this.button4.Name = "button4";
            this.button4.Size = new System.Drawing.Size(119, 44);
            this.button4.TabIndex = 3;
            this.button4.Text = "退出";
            this.button4.UseVisualStyleBackColor = false;
            this.button4.Click += new System.EventHandler(this.button4_Click_1);
            // 
            // button5
            // 
            this.button5.BackColor = System.Drawing.SystemColors.Info;
            this.button5.Location = new System.Drawing.Point(221, 12);
            this.button5.Name = "button5";
            this.button5.Size = new System.Drawing.Size(95, 44);
            this.button5.TabIndex = 4;
            this.button5.Text = "按学号排序";
            this.button5.UseVisualStyleBackColor = false;
            this.button5.Click += new System.EventHandler(this.button5_Click_1);
            // 
            // comboBox1
            // 
            this.comboBox1.BackColor = System.Drawing.Color.WhiteSmoke;
            this.comboBox1.ForeColor = System.Drawing.Color.MediumPurple;
            this.comboBox1.FormattingEnabled = true;
            this.comboBox1.Items.AddRange(new object[] {
            "语文",
            "数学",
            "英语",
            "物理",
            "政治",
            "体育"});
            this.comboBox1.Location = new System.Drawing.Point(614, 62);
            this.comboBox1.Name = "comboBox1";
            this.comboBox1.Size = new System.Drawing.Size(121, 20);
            this.comboBox1.TabIndex = 5;
            // 
            // textBox1
            // 
            this.textBox1.BackColor = System.Drawing.Color.White;
            this.textBox1.Location = new System.Drawing.Point(87, 117);
            this.textBox1.Multiline = true;
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(519, 224);
            this.textBox1.TabIndex = 6;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(36, 117);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(29, 12);
            this.label1.TabIndex = 7;
            this.label1.Text = "信息";
            // 
            // SortForm
            // 
            this.BackColor = System.Drawing.SystemColors.InactiveCaption;
            this.ClientSize = new System.Drawing.Size(848, 533);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.comboBox1);
            this.Controls.Add(this.button5);
            this.Controls.Add(this.button4);
            this.Controls.Add(this.button3);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.ForeColor = System.Drawing.Color.Blue;
            this.Name = "SortForm";
            this.Text = "排序";
            this.Load += new System.EventHandler(this.SortForm_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            Node temp = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
            Node left = new Node(0, "0", "0", 0, 0, 0, 0, 0);
            Node right = new Node(0, "0", "0", 0, 0, 0, 0, 0);
            Node rightmin = new Node(0, "0", "0", 0, 0, 0, 0, 0);

            left = PublicValue.Head;
            right = PublicValue.Head;

            if (left == null)
            {
                MessageBox.Show("无法排序,请先存入数据");
            }
            else
            {
                for (; left != null; left = left.Next)//最大的数放在左边
                {
                    right = left;
                    for (rightmin = right; right != null; right = right.Next)//从右边找出最小的数,用prightmax记录其位置
                    {
                        if (right.id < rightmin.id)
                        {
                            rightmin = right;
                        }
                    }

                    temp.id = rightmin.id;
                    temp.name = rightmin.name;
                    temp.classnum = rightmin.classnum;
                    temp.c_sharp = rightmin.c_sharp;
                    temp.ds = rightmin.ds;
                    temp.maogai = rightmin.maogai;
                    temp.ps = rightmin.ps;
                    temp.sports = rightmin.sports;
                    temp.total = rightmin.total;//补充
                    temp.average = rightmin.average;//补充

                    rightmin.id = left.id;
                    rightmin.name = left.name;
                    rightmin.classnum = left.classnum;
                    rightmin.c_sharp = left.c_sharp;
                    rightmin.ds = left.ds;
                    rightmin.maogai = left.maogai;
                    rightmin.ps = left.ps;
                    rightmin.sports = left.sports;
                    rightmin.total = left.total;//补充
                    rightmin.average = left.average;//补充


                    left.id = temp.id;
                    left.name = temp.name;
                    left.classnum = temp.classnum;
                    left.c_sharp = temp.c_sharp;
                    left.ds = temp.ds;
                    left.maogai = temp.maogai;
                    left.ps = temp.ps;
                    left.sports = temp.sports;
                    left.total = temp.total;//补充
                    left.average = temp.average;//补充
                }

                //输出
                MessageBox.Show("排序成功");
                Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值

                textBox1.Text = "";//先清空
                textBox1.Text += "学号 \t\t 班级 \t\t姓名\t语文\t体育\t数学\t英语\t物理\t总分\t平均分\r\n";

                cur = PublicValue.Head;

                while (cur != null)
                {
                    textBox1.Text += cur.id + "\t" + cur.classnum + "\t" + cur.name + "\t" + cur.c_sharp + "\t" + cur.ds + "\t" + "\t" + cur.maogai + "\t" + cur.ps + "\t" + "\t" + cur.sports + "\t" + cur.total + "\t" + cur.average.ToString("f2") + "\r\n";
                    cur = cur.Next;
                }
            }
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            Node temp = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
            Node left = new Node(0, "0", "0", 0, 0, 0, 0, 0);
            Node right = new Node(0, "0", "0", 0, 0, 0, 0, 0);
            Node rightmin = new Node(0, "0", "0", 0, 0, 0, 0, 0);

            left = PublicValue.Head;
            right = PublicValue.Head;

            if (left == null)
            {
                MessageBox.Show("无法排序,请先存入数据");
            }
            else
            {
                for (; left != null; left = left.Next)//最大的数放在左边
                {
                    right = left;
                    for (rightmin = right; right != null; right = right.Next)//从右边找出最小的数,用prightmax记录其位置
                    {
                        if (right.classnum.CompareTo(rightmin.classnum) < 0)
                        {
                            rightmin = right;
                        }
                    }

                    temp.id = rightmin.id;
                    temp.name = rightmin.name;
                    temp.classnum = rightmin.classnum;
                    temp.c_sharp = rightmin.c_sharp;
                    temp.ds = rightmin.ds;
                    temp.maogai = rightmin.maogai;
                    temp.ps = rightmin.ps;
                    temp.sports = rightmin.sports;
                    temp.total = rightmin.total;//补充
                    temp.average = rightmin.average;//补充

                    rightmin.id = left.id;
                    rightmin.name = left.name;
                    rightmin.classnum = left.classnum;
                    rightmin.c_sharp = left.c_sharp;
                    rightmin.ds = left.ds;
                    rightmin.maogai = left.maogai;
                    rightmin.ps = left.ps;
                    rightmin.sports = left.sports;
                    rightmin.total = left.total;//补充
                    rightmin.average = left.average;//补充


                    left.id = temp.id;
                    left.name = temp.name;
                    left.classnum = temp.classnum;
                    left.c_sharp = temp.c_sharp;
                    left.ds = temp.ds;
                    left.maogai = temp.maogai;
                    left.ps = temp.ps;
                    left.sports = temp.sports;
                    left.total = temp.total;//补充
                    left.average = temp.average;//补充
                }

                //输出
                MessageBox.Show("排序成功");
                Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值

                textBox1.Text = "";//先清空
                textBox1.Text += "学号 \t\t 班级 \t\t姓名\t语文\t体育\t数学\t英语\t物理\t总分\t平均分\r\n";

                cur = PublicValue.Head;

                while (cur != null)
                {
                    textBox1.Text += cur.id + "\t" + cur.classnum + "\t" + cur.name + "\t" + cur.c_sharp + "\t" + cur.ds + "\t" + "\t" + cur.maogai + "\t" + cur.ps + "\t" + "\t" + cur.sports + "\t" + cur.total + "\t" + cur.average.ToString("f2") + "\r\n";
                    cur = cur.Next;
                }
            }
        }

        private void button3_Click_1(object sender, EventArgs e)
        {
            Node temp = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
            Node left = new Node(0, "0", "0", 0, 0, 0, 0, 0);
            Node right = new Node(0, "0", "0", 0, 0, 0, 0, 0);
            Node rightmin = new Node(0, "0", "0", 0, 0, 0, 0, 0);

            left = PublicValue.Head;
            right = PublicValue.Head;

            if (left == null)
            {
                MessageBox.Show("无法排序,请先存入数据");
            }
            else
            {
                for (; left != null; left = left.Next)//最大的数放在左边
                {
                    right = left;
                    for (rightmin = right; right != null; right = right.Next)//从右边找出最小的数,用prightmax记录其位置
                    {
                        if (right.total > rightmin.total)//从大到小 其他排序方式只改这一行即可
                        {
                            rightmin = right;
                        }
                    }

                    temp.id = rightmin.id;
                    temp.name = rightmin.name;
                    temp.classnum = rightmin.classnum;
                    temp.c_sharp = rightmin.c_sharp;
                    temp.ds = rightmin.ds;
                    temp.maogai = rightmin.maogai;
                    temp.ps = rightmin.ps;
                    temp.sports = rightmin.sports;
                    temp.total = rightmin.total;//补充
                    temp.average = rightmin.average;//补充

                    rightmin.id = left.id;
                    rightmin.name = left.name;
                    rightmin.classnum = left.classnum;
                    rightmin.c_sharp = left.c_sharp;
                    rightmin.ds = left.ds;
                    rightmin.maogai = left.maogai;
                    rightmin.ps = left.ps;
                    rightmin.sports = left.sports;
                    rightmin.total = left.total;//补充
                    rightmin.average = left.average;//补充


                    left.id = temp.id;
                    left.name = temp.name;
                    left.classnum = temp.classnum;
                    left.c_sharp = temp.c_sharp;
                    left.ds = temp.ds;
                    left.maogai = temp.maogai;
                    left.ps = temp.ps;
                    left.sports = temp.sports;
                    left.total = temp.total;//补充
                    left.average = temp.average;//补充
                }

                //输出
                MessageBox.Show("排序成功");
                Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值

                textBox1.Text = "";//先清空
                textBox1.Text += "学号 \t\t 班级 \t\t姓名\t语文\t体育\t数学\t英语\t物理\t总分\t平均分\r\n";

                cur = PublicValue.Head;

                while (cur != null)
                {
                    textBox1.Text += cur.id + "\t" + cur.classnum + "\t" + cur.name + "\t" + cur.c_sharp + "\t" + cur.ds + "\t" + "\t" + cur.maogai + "\t" + cur.ps + "\t" + "\t" + cur.sports + "\t" + cur.total + "\t" + cur.average.ToString("f2") + "\r\n";
                    cur = cur.Next;
                }
            }
        }

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

        private void button5_Click_1(object sender, EventArgs e)
        {

            int choose = -1;//

            if (comboBox1.Text == "语文") choose = 0;
            else if (comboBox1.Text == "体育") choose = 1;
            else if (comboBox1.Text == "数学") choose = 2;
            else if (comboBox1.Text == "英语") choose = 3;
            else if (comboBox1.Text == "物理") choose = 4;

            //排序
            Node temp = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
            Node left = new Node(0, "0", "0", 0, 0, 0, 0, 0);
            Node right = new Node(0, "0", "0", 0, 0, 0, 0, 0);
            Node rightmin = new Node(0, "0", "0", 0, 0, 0, 0, 0);

            left = PublicValue.Head;
            right = PublicValue.Head;

            if (left == null)
            {
                MessageBox.Show("无法排序,请先存入数据");
            }
            else
            {
                for (; left != null; left = left.Next)//最大的数放在左边
                {
                    right = left;
                    for (rightmin = right; right != null; right = right.Next)//从右边找出最小的数,用prightmax记录其位置
                    {
                        switch (choose)
                        {
                            case -1:
                                MessageBox.Show("出错了!choose=-1 没有选择");
                                break;
                            case 0:
                                if (right.c_sharp > rightmin.c_sharp)//从大到小
                                {
                                    rightmin = right;
                                }
                                break;
                            case 1:
                                if (right.ds > rightmin.ds)//从大到小
                                {
                                    rightmin = right;
                                }
                                break;
                            case 2:
                                if (right.maogai > rightmin.maogai)//从大到小
                                {
                                    rightmin = right;
                                }
                                break;
                            case 3:
                                if (right.ps > rightmin.ps)//从大到小
                                {
                                    rightmin = right;
                                }
                                break;
                            case 4:
                                if (right.sports > rightmin.sports)//从大到小
                                {
                                    rightmin = right;
                                }
                                break;
                        }

                    }


                    temp.id = rightmin.id;
                    temp.name = rightmin.name;
                    temp.classnum = rightmin.classnum;
                    temp.c_sharp = rightmin.c_sharp;
                    temp.ds = rightmin.ds;
                    temp.maogai = rightmin.maogai;
                    temp.ps = rightmin.ps;
                    temp.sports = rightmin.sports;
                    temp.total = rightmin.total;//补充
                    temp.average = rightmin.average;//补充

                    rightmin.id = left.id;
                    rightmin.name = left.name;
                    rightmin.classnum = left.classnum;
                    rightmin.c_sharp = left.c_sharp;
                    rightmin.ds = left.ds;
                    rightmin.maogai = left.maogai;
                    rightmin.ps = left.ps;
                    rightmin.sports = left.sports;
                    rightmin.total = left.total;//补充
                    rightmin.average = left.average;//补充


                    left.id = temp.id;
                    left.name = temp.name;
                    left.classnum = temp.classnum;
                    left.c_sharp = temp.c_sharp;
                    left.ds = temp.ds;
                    left.maogai = temp.maogai;
                    left.ps = temp.ps;
                    left.sports = temp.sports;
                    left.total = temp.total;//补充
                    left.average = temp.average;//补充
                }

                //输出
                MessageBox.Show("排序成功");
                Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值

                textBox1.Text = "";//先清空
                textBox1.Text += "学号 \t\t 班级 \t\t姓名\t语文\t体育\t数学\t英语\t物理\t总分\t平均分\r\n";

                cur = PublicValue.Head;

                while (cur != null)
                {
                    textBox1.Text += cur.id + "\t" + cur.classnum + "\t" + cur.name + "\t" + cur.c_sharp + "\t" + cur.ds + "\t" + "\t" + cur.maogai + "\t" + cur.ps + "\t" + "\t" + cur.sports + "\t" + cur.total + "\t" + cur.average.ToString("f2") + "\r\n";
                    cur = cur.Next;
                }
            }

        }

        private void SortForm_Load(object sender, EventArgs e)
        {

        }
    }
}

7.查找

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;

namespace C_sharp学生成绩管理系统
{
    public partial class FindForm : Form
    {
        private Button button1;
        private TextBox textBox1;
        private TextBox textBox2;
        private Label label1;
        private Label label2;
        private Button button2;
        
        public FindForm()
        {
            InitializeComponent();
        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            this.Close();
        }
       
        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.BackColor = System.Drawing.SystemColors.Info;
            this.button1.Location = new System.Drawing.Point(561, 386);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(98, 51);
            this.button1.TabIndex = 0;
            this.button1.Text = "退出";
            this.button1.UseVisualStyleBackColor = false;
            this.button1.Click += new System.EventHandler(this.button1_Click_1);
            // 
            // button2
            // 
            this.button2.BackColor = System.Drawing.SystemColors.Info;
            this.button2.Location = new System.Drawing.Point(309, 31);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(115, 40);
            this.button2.TabIndex = 1;
            this.button2.Text = "查找";
            this.button2.UseVisualStyleBackColor = false;
            this.button2.Click += new System.EventHandler(this.button2_Click_1);
            // 
            // textBox2
            // 
            this.textBox2.BackColor = System.Drawing.Color.Snow;
            this.textBox2.Location = new System.Drawing.Point(103, 99);
            this.textBox2.Multiline = true;
            this.textBox2.Name = "textBox2";
            this.textBox2.Size = new System.Drawing.Size(556, 261);
            this.textBox2.TabIndex = 2;
            // 
            // textBox1
            // 
            this.textBox1.BackColor = System.Drawing.Color.Snow;
            this.textBox1.Location = new System.Drawing.Point(103, 38);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(168, 25);
            this.textBox1.TabIndex = 3;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(39, 38);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(37, 15);
            this.label1.TabIndex = 4;
            this.label1.Text = "学号";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(39, 102);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(37, 15);
            this.label2.TabIndex = 5;
            this.label2.Text = "信息";
            // 
            // FindForm
            // 
            this.BackColor = System.Drawing.SystemColors.InactiveCaption;
            this.ClientSize = new System.Drawing.Size(739, 449);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.textBox2);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.ForeColor = System.Drawing.Color.Blue;
            this.Name = "FindForm";
            this.Text = "查找";
            this.Load += new System.EventHandler(this.FindForm_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            Node cur = new Node(0, "0", "0", 0, 0, 0, 0, 0);//毫无意义的赋值
            cur = PublicValue.Head;
            int findId = int.Parse(textBox1.Text);
            textBox2.Text = "";//先清空
            textBox2.Text += "学号 \t\t 班级 \t\t姓名\t语文\t体育\t数学\t英语\t物理\t总分\t平均分\r\n";

         

            while (cur != null)
            {
                if (cur.id == findId)
                {
                    textBox2.Text += cur.id + "\t";
                    textBox2.Text += cur.classnum + "\t";
                    textBox2.Text += cur.name + "\t";
                    textBox2.Text += cur.c_sharp + "\t";
                    textBox2.Text += cur.ds + "\t" + "\t";
                    textBox2.Text += cur.maogai + "\t";
                    textBox2.Text += cur.ps + "\t";
                    textBox2.Text += cur.sports + "\t";
                    textBox2.Text += cur.total + "\t";
                    textBox2.Text += cur.average.ToString("f2");
                    break;
                }
                cur = cur.Next;
            }
            if (cur == null)
            {
                MessageBox.Show("你输入的学号不存在!");
            }
        }

        private void FindForm_Load(object sender, EventArgs e)
        {

        }
    }
}

==那么先恭喜看到这里的亲,你已经快要胜利了,666. 长时间地做和用眼对身体不好,请缓解一下自己的疲劳。==看着以下图片缓解一下吧。

在这里插入图片描述
没办法,码农的生活就是这么枯燥且乏味,为了自己的目标和学习、工作努力有什么不值得呢。
为了方便大家做出来,我提供了每一块的代码和控件属性表给大家,链接如下:
链接:https://pan.baidu.com/s/1T8VV4jX0G9wxV3QIJgOCkA
提取码:zuyc

运行结果

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里说明一下,可能运行出来的信息界面不太规则排列,大家可以去自行更改。

行百里者半九十,坚持练习,就会有长足的进步。加油!
博主整理不易,还请大家多多指正,转载请注明出处。如果对你的学习有帮助的话请留下你那个大大的赞,你的支持与关注就是博主最大的更新动力。

本期博文如果反响比较好的话,我会在评论区发放源代码链接,也请大家在评论区多多留言,谢谢大家的支持与鼓励

C# 下期预告:
1.简易计算器的实现
2.C#核心语法
3.俄罗斯方块的设计与编写
本期源代码文件链接:
链接:https://pan.baidu.com/s/16CJzZ_2GsmjO-fypOpgNHA
提取码:y72z

  • 102
    点赞
  • 535
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 9
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

思维矩阵K

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值