C# 学生成绩管理系统 完整版
生活随笔
收集整理的這篇文章主要介紹了
C# 学生成绩管理系统 完整版
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
知識點
一種類似指針的數據結構?
文件的讀取和寫入 避免亂碼 ansi
字符串讀取后分割的bug 可能是因為編碼問題導致的 為了解決這個bug 寫入的時候直接用\r\n分割了 但是解決亂碼問題之后可能就沒有這個bug了 以后可以用\t或者space分割試試
完全面向對象用起來不是很習慣,定義全局變量都要放在一個單獨的類里
窗體之間的交互也不是很會 尤其是排序那部分 每一種排序方式都是復制粘貼的 除了那個下拉菜單以外(用的switch)有沒有可能定義一個全局函數?
效果
其他窗體的圖懶得帖了,等完善總分平均分那部分之后一起吧
代碼
program.cs
/* 學生成績管理系統* 待添加功能:* * 按照姓名查找學生* 添加時學號重復性檢查* 一鍵生成學生、分數,學號重復性檢查,自動添加* 排序方式下拉菜單* 注冊賬戶,登錄密碼(有點雞肋)*/using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms;namespace C_sharp學生管理系統 {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, int classnum, int chinese, int math, int english, int physics, int politics, int sports){Node foot = new Node(id, name, classnum, chinese, math, english, physics, politics, sports);Node A = new Node(id, name, classnum, chinese, math, english, physics, politics, 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{//應用程序的主入口點[STAThread]static void Main(){LinkList link = new LinkList();Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(new MainForm());}} }mainform.cs
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; using System.Text;namespace C_sharp學生管理系統 {public partial class MainForm : Form{public MainForm(){InitializeComponent();}//顯示學生名單:從head到null遍歷private void button1_Click(object sender, EventArgs e){Node B = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);//毫無意義的賦值B = PublicValue.Head;textBox1.Text = "";//先清空textBox1.Text += "學號\t姓名\t班級\t語文\t數學\t英語\t物理\t政治\t體育\t總分\t平均分\r\n";while (B != null){textBox1.Text += B.id + "\t" + B.name + "\t" + B.classnum + "\t" + B.chinese + "\t" + B.math + "\t" + B.english + "\t" + B.physics + "\t" + B.politics + "\t" + B.sports + "\t" + B.total+ "\t" + B.average.ToString("f2") + "\r\n";B = B.Next;}}//添加學生private void add_Click(object sender, EventArgs e){AddStuForm f2 = new AddStuForm();f2.ShowDialog();button1_Click(null, null);}//修改學生private void change_Click(object sender, EventArgs e){ChangeStuForm f3 = new ChangeStuForm();f3.ShowDialog();button1_Click(null, null);}//刪除學生private void delete_Click(object sender, EventArgs e){DelStuForm f4 = new DelStuForm();f4.ShowDialog();button1_Click(null, null);}private void button4_Click(object sender, EventArgs e){System.Environment.Exit(0);}private void button1_Click_1(object sender, EventArgs e){SortForm f5 = new SortForm();f5.ShowDialog();button1_Click(null, null);}private void textBox1_TextChanged(object sender, EventArgs e){}private void button2_Click(object sender, EventArgs e){FindForm f6 = new FindForm();f6.ShowDialog();}private void button6_Click(object sender, EventArgs e){//清空txtSystem.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, 0);B = PublicValue.Head;sw.Write(PublicValue.total + "\r\n");while (B != null){sw.Write(B.id + "\r\n" + B.name + "\r\n" + B.classnum + "\r\n" + B.chinese + "\r\n" + B.math + "\r\n" + B.english + "\r\n" + B.physics + "\r\n" + B.politics + "\r\n" + B.sports + "\r\n");B = B.Next;}//清空緩沖區sw.Flush();//關閉流sw.Close();MessageBox.Show("保存成功");}private void button5_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;int classnum;int chinese;int math;int english;int physics;int politics;int sports;PublicValue.total = int.Parse(sr.ReadLine());for (i = 0; i < PublicValue.total; i++){id = int.Parse(sr.ReadLine());name = sr.ReadLine();classnum = int.Parse(sr.ReadLine());chinese = int.Parse(sr.ReadLine());math = int.Parse(sr.ReadLine());english = int.Parse(sr.ReadLine());physics = int.Parse(sr.ReadLine());politics = int.Parse(sr.ReadLine());sports = int.Parse(sr.ReadLine());LinkList.Append(id, name, classnum, chinese, math, english, physics, politics, sports);}sr.Close();MessageBox.Show("導入成功");button1_Click(null, null);}private void button3_Click(object sender, EventArgs e){textBox1.Text = "";//先清空textBox1.Text += " 學生成績管理系統\r\n\r\n";textBox1.Text += " by 寒泉hq\r\n\r\n";textBox1.Text += " 歡迎關注我的CSDN博客\r\n\r\n";textBox1.Text += " https://blog.csdn.net/sinat_42483341\r\n\r\n";textBox1.Text += " 僅供學習使用 保留所有權利\r\n\r\n";textBox1.Text += " 2019.03.10\r\n\r\n";}private void button7_Click(object sender, EventArgs e){button6_Click(null, null);System.Environment.Exit(0);}private void MainForm_Load(object sender, EventArgs e){}}//一個節點public class Node{//數據域,當前結點數據//信息public int id;public string name;public int classnum;//分數public int chinese { set; get; }public int math { set; get; }public int english { set; get; }public int physics { set; get; }public int politics { 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, int classnum, int chinese, int math, int english, int physics, int politics, int sports){this.id = id;this.name = name;this.classnum = classnum;this.chinese = chinese;this.math = math;this.english = english;this.physics = physics;this.politics = politics;this.sports = sports;this.total = this.chinese + this.math + this.english + this.physics + this.politics + this.sports;this.average = this.total / 6;this.Next = null;}} }sortform.cs
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{public SortForm(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){Node temp = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);//毫無意義的賦值Node left = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);Node right = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);Node rightmin = new Node(0, "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;}}//復制粘貼好幾遍,有類似于#define的使用方式嗎?temp.id = rightmin.id;temp.name = rightmin.name;temp.classnum = rightmin.classnum;temp.chinese = rightmin.chinese;temp.math = rightmin.math;temp.english = rightmin.english;temp.physics = rightmin.physics;temp.politics = rightmin.politics;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.chinese = left.chinese;rightmin.math = left.math;rightmin.english = left.english;rightmin.physics = left.physics;rightmin.politics = left.politics;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.chinese = temp.chinese;left.math = temp.math;left.english = temp.english;left.physics = temp.physics;left.politics = temp.politics;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, 0);//毫無意義的賦值textBox1.Text = "";//先清空textBox1.Text += "學號\t姓名\t班級\t語文\t數學\t英語\t物理\t政治\t體育\t總分\t平均分\r\n";cur = PublicValue.Head;while (cur != null){textBox1.Text += cur.id + "\t" + cur.name + "\t" + cur.classnum + "\t" + cur.chinese + "\t" + cur.math + "\t" + cur.english + "\t" + cur.physics + "\t" + cur.politics + "\t" + cur.sports+ "\t"+cur.total + "\t" + cur.average.ToString("f2") + "\r\n";cur = cur.Next;}}}//按班級排序private void button2_Click(object sender, EventArgs e){Node temp = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);//毫無意義的賦值Node left = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);Node right = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);Node rightmin = new Node(0, "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 < rightmin.classnum){rightmin = right;}}//復制粘貼好幾遍,有類似于#define的使用方式嗎?temp.id = rightmin.id;temp.name = rightmin.name;temp.classnum = rightmin.classnum;temp.chinese = rightmin.chinese;temp.math = rightmin.math;temp.english = rightmin.english;temp.physics = rightmin.physics;temp.politics = rightmin.politics;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.chinese = left.chinese;rightmin.math = left.math;rightmin.english = left.english;rightmin.physics = left.physics;rightmin.politics = left.politics;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.chinese = temp.chinese;left.math = temp.math;left.english = temp.english;left.physics = temp.physics;left.politics = temp.politics;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, 0);//毫無意義的賦值textBox1.Text = "";//先清空textBox1.Text += "學號\t姓名\t班級\t語文\t數學\t英語\t物理\t政治\t體育\t總分\t平均分\r\n";cur = PublicValue.Head;while (cur != null){textBox1.Text += cur.id + "\t" + cur.name + "\t" + cur.classnum + "\t" + cur.chinese + "\t" + cur.math + "\t" + cur.english + "\t" + cur.physics + "\t" + cur.politics + "\t" + cur.sports + "\t" + cur.total + "\t" + cur.average.ToString("f2") + "\r\n";cur = cur.Next;}}}private void button4_Click(object sender, EventArgs e){this.Close();}//按總分排序private void button3_Click(object sender, EventArgs e){Node temp = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);//毫無意義的賦值Node left = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);Node right = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);Node rightmin = new Node(0, "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;}}//復制粘貼好幾遍,有類似于#define的使用方式嗎?temp.id = rightmin.id;temp.name = rightmin.name;temp.classnum = rightmin.classnum;temp.chinese = rightmin.chinese;temp.math = rightmin.math;temp.english = rightmin.english;temp.physics = rightmin.physics;temp.politics = rightmin.politics;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.chinese = left.chinese;rightmin.math = left.math;rightmin.english = left.english;rightmin.physics = left.physics;rightmin.politics = left.politics;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.chinese = temp.chinese;left.math = temp.math;left.english = temp.english;left.physics = temp.physics;left.politics = temp.politics;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, 0);//毫無意義的賦值textBox1.Text = "";//先清空textBox1.Text += "學號\t姓名\t班級\t語文\t數學\t英語\t物理\t政治\t體育\t總分\t平均分\r\n";cur = PublicValue.Head;while (cur != null){textBox1.Text += cur.id + "\t" + cur.name + "\t" + cur.classnum + "\t" + cur.chinese + "\t" + cur.math + "\t" + cur.english + "\t" + cur.physics + "\t" + cur.politics + "\t" + cur.sports + "\t" + cur.total + "\t" + cur.average.ToString("f2") + "\r\n";cur = cur.Next;}}}private void button5_Click(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;else if (comboBox1.Text == "體育") choose = 5;//排序Node temp = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);//毫無意義的賦值Node left = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);Node right = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);Node rightmin = new Node(0, "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.chinese > rightmin.chinese)//從大到小{rightmin = right;}break;case 1:if (right.math > rightmin.math)//從大到小{rightmin = right;}break;case 2:if (right.english > rightmin.english)//從大到小{rightmin = right;}break;case 3:if (right.physics > rightmin.physics)//從大到小{rightmin = right;}break;case 4:if (right.politics > rightmin.politics)//從大到小{rightmin = right;}break;case 5:if (right.sports > rightmin.sports)//從大到小{rightmin = right;}break;}}//復制粘貼好幾遍,有類似于#define的使用方式嗎?temp.id = rightmin.id;temp.name = rightmin.name;temp.classnum = rightmin.classnum;temp.chinese = rightmin.chinese;temp.math = rightmin.math;temp.english = rightmin.english;temp.physics = rightmin.physics;temp.politics = rightmin.politics;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.chinese = left.chinese;rightmin.math = left.math;rightmin.english = left.english;rightmin.physics = left.physics;rightmin.politics = left.politics;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.chinese = temp.chinese;left.math = temp.math;left.english = temp.english;left.physics = temp.physics;left.politics = temp.politics;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, 0);//毫無意義的賦值textBox1.Text = "";//先清空textBox1.Text += "學號\t姓名\t班級\t語文\t數學\t英語\t物理\t政治\t體育\t總分\t平均分\r\n";cur = PublicValue.Head;while (cur != null){textBox1.Text += cur.id + "\t" + cur.name + "\t" + cur.classnum + "\t" + cur.chinese + "\t" + cur.math + "\t" + cur.english + "\t" + cur.physics + "\t" + cur.politics + "\t" + cur.sports + "\t" + cur.total + "\t" + cur.average.ToString("f2") + "\r\n";cur = cur.Next;}}}} }findform.cs
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{public FindForm(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){this.Close();}//查找學生private void button2_Click(object sender, EventArgs e){Node cur = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);//毫無意義的賦值cur = PublicValue.Head;textBox2.Text = "";//先清空textBox2.Text += "學號\t姓名\t班級\t語文\t數學\t英語\t物理\t政治\t體育\t總分\t平均分\r\n\r\n";int findId = int.Parse(textBox1.Text);while (cur != null){if (cur.id == findId){textBox2.Text += cur.id + "\t";textBox2.Text += cur.name + "\t";textBox2.Text += cur.classnum + "\t";textBox2.Text += cur.chinese + "\t";textBox2.Text += cur.math + "\t";textBox2.Text += cur.english + "\t";textBox2.Text += cur.physics + "\t";textBox2.Text += cur.politics + "\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("你輸入的學號不存在!");}}} }delstuform.cs
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{public DelStuForm(){InitializeComponent();}private void Form4_Load(object sender, EventArgs e){}//刪除 點擊查找信息private void button1_Click(object sender, EventArgs e){Node cur = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);//毫無意義的賦值cur = PublicValue.Head;textBox2.Text = "";//先清空textBox2.Text += "學號\t姓名\t班級\t語文\t數學\t英語\t物理\t政治\t體育\r\n\r\n";int findId = int.Parse(textBox1.Text);while (cur != null){if (cur.id == findId){textBox2.Text += cur.id + "\t";textBox2.Text += cur.name + "\t";textBox2.Text += cur.classnum + "\t";textBox2.Text += cur.chinese + "\t";textBox2.Text += cur.math + "\t";textBox2.Text += cur.english + "\t";textBox2.Text += cur.physics + "\t";textBox2.Text += cur.politics + "\t";textBox2.Text += cur.sports;break;}cur = cur.Next;}if (cur == null){MessageBox.Show("你輸入的學號不存在!");}}//刪除學生private void button2_Click(object sender, EventArgs e){Node cur = new Node(0, "0", 0, 0, 0, 0, 0, 0, 0);//大哥Node last = new Node(0, "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(object sender, EventArgs e){this.Close();}} }changestuform.cs
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{public ChangeStuForm(){InitializeComponent();}private void Form3_Load(object sender, EventArgs e){}//輸入學號,點擊確定private void button1_Click(object sender, EventArgs e){//遍歷查找Node cur = new Node(0, "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.name;textBox3.Text = Convert.ToString(cur.classnum);textBox4.Text = Convert.ToString(cur.chinese);textBox5.Text = Convert.ToString(cur.math);textBox6.Text = Convert.ToString(cur.english);textBox7.Text = Convert.ToString(cur.physics);textBox8.Text = Convert.ToString(cur.politics);textBox9.Text = Convert.ToString(cur.sports);break;}cur = cur.Next;}if (cur == null){MessageBox.Show("你輸入的學號不存在!");}}//修改后點擊確定private void button2_Click(object sender, EventArgs e){//迷之再次遍歷查找Node cur = new Node(0, "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.name = textBox2.Text;cur.classnum = int.Parse(textBox3.Text);cur.chinese = int.Parse(textBox4.Text);cur.math = int.Parse(textBox5.Text);cur.english = int.Parse(textBox6.Text);cur.physics = int.Parse(textBox7.Text);cur.politics = int.Parse(textBox8.Text);cur.sports = int.Parse(textBox9.Text);cur.total = cur.chinese + cur.math + cur.english + cur.physics + cur.politics + cur.sports;cur.average = cur.total / 6;MessageBox.Show("修改成功");break;}cur = cur.Next;}if (cur == null){MessageBox.Show("修改失敗,你輸入的學號不存在!請不要改變剛才輸入的學號");}}private void button3_Click(object sender, EventArgs e){this.Close();}} }addstuform.cs
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{public AddStuForm(){InitializeComponent();}/// <summary>/// 點擊"添加"按鈕/// 增加新元素到單鏈表末尾/// </summary>public void button1_Click(object sender, EventArgs e){//臨時接收int id;string name;int classnum;//分數int chinese;int math;int english;int physics;int politics;int sports;id = int.Parse(idnum.Text);name = textBox2.Text;classnum = int.Parse(textBox3.Text);chinese = int.Parse(textBox4.Text);math = int.Parse(textBox5.Text);english = int.Parse(textBox6.Text);physics = int.Parse(textBox7.Text);politics = int.Parse(textBox8.Text);sports = int.Parse(textBox8.Text);LinkList.Append(id, name, classnum, chinese, math, english, physics, politics, sports);PublicValue.total++;MessageBox.Show("添加成功");}//自動填充表單private void button2_Click(object sender, EventArgs e){Random rd = new Random();if (Convert.ToString(idnum.Text) == ""){idnum.Text = Convert.ToString(1);}else{idnum.Text = Convert.ToString(1 + int.Parse(idnum.Text));//學號自動順延}textBox2.Text = "自動";textBox3.Text = Convert.ToString(rd.Next(1, 10));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));textBox9.Text = Convert.ToString(rd.Next(50, 100));}private void button3_Click(object sender, EventArgs e){this.Close();}} }總結
以上是生活随笔為你收集整理的C# 学生成绩管理系统 完整版的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C# int.Parse()与int.T
- 下一篇: 算法设计与分析(第四周)同时选最大和最小