学生管理系统设计(数据库连接C#版)

版权声明: https://blog.csdn.net/qq_39539470/article/details/78698284

目录
一.课程设计说明 1
1.1项目概述 1
1.2设计任务和要求 1
1.3开发环境说明 1
二.需求分析阶段 1
2.1项目介绍 2
2.2数据需求分析 2
三.概念结构设计 3
3.1E-R图 4
3.2数据库设计 5
3.3数据字典 8
四.用户界面设计 11
4.1学生信息管理系统 12
4.2学生信息查询 12
4.3教师查询 12
4.4管理员查询 12
4.5专业负责人查询 13
五.程序设计 14
六.运行结果 28
七.总结

一.课程设计说明

1.1项目概述:
学生管理系统
一所大学希望建立一个数据库以便对学生进行管理。当一个学生进入学校时,他就会选择一个专业。每个学生也会指定一个指导老师。每个专业每年由一些课程组成。组成专业的课程的最小和最大数目分别是6和8。一般情况下给一个学生三次机会来通过这门课程的考试。有些特殊的课程可以在一个或多个专业中存在。大学可以有几个部门,每个部门都有一个部门负责人,每个课程都会分配一定数量的员工(称为课程合作人)来负责课程的教学
1.2设计任务与要求
建立数据库,来完成对学生进行管理的目的,要求要按照题目设定,包括学生、教师、管理员的学生管理系统的设计与开发。

1.3开发环境说明
采用SQL SERVER和Visual Studio 来进行系统开发。
二.功能需求分析阶段
2.1项目介绍
学生管理系统在学生方面,新生在校注册,注册时选择专业,从而学校分配指导教师完成在校学习的课程,学生也可通过学生管理系统查询个人信息,包括个人选修课信息,考试信息等。
在教师方面,教师可以通过学生管理系统查询任教的课程信息,以及对学生的考试成绩的录入。
在管理员方面,管理员可以通过管理员权限查询、增加、删除、修改所有信息。
2.2数据需求分析

这里写图片描述
总结如下:
这里写图片描述
2.3数据处理与任务需求
下面列出的是学生管理数据库应用应该支持的事务。

(1) 数据应该能够支持下述维护事务。
a) 创建和维护学校内学生的详细信息。
b) 创建和维护学校内教师的详细信息。
c) 创建和维护学校内课程的详细信息。
(2) 数据应该能够支持下述查询事务
a) 以报表形式列出学生的姓名,学号及其他详细信息
b) 以报表形式列出专业的名称、专业号及其他详细信息
c) 以报表形式列出课程的名称、课程号及其他详细信息
d) 列出某一给定学生的课程及成绩
e) 列出某一专业的课程信息
三、概念结构设计
3.1E-R图的分析和设计
这里写图片描述

3.2数据库逻辑设计
ER图和关系模式的转化

这里写图片描述

3.3数据字典

实体简介
学生(学号,姓名,性别,出生日期,民族,所在专业编号,指导教师编号,电话号码,家庭地址,信息备注)
课程(课程号,课程名,学分)
专业(专业号,专业名,专业负责人号)
教职工(教师号,姓名,性别,出生日期,民族,所在专业编号,职称,电话,家庭地址,信息备注)

专业课设表(专业号、课程号)
考试(课程号,学号,成绩,考试次数)
用户(用户编号,用户密码,用户类别)
(1) 学生表Student细节
这里写图片描述

(2) 4.2教师个人信息表TEACHER(教师号TNO,姓名TNAME,性别TSEX,出生日期TBIRTHDAY,名族TNATIVE,所在专业编号TDEPTNO,职称TPOSITION,电话STEL,家庭住址SADDRESS,备注信息SNOTE)
这里写图片描述

(3) 4.3专业表MAJOR(专业号MNO,专业名MNAME,专业负责人编号MTEACHER)
这里写图片描述

(4) 4.4课程表 COURSE(课程号CNO,课程名CNAME,学分CGRADE
授课教师CTEACHER)
这里写图片描述

(5) 4.5成绩表SC(学生号SNO,课程号CNO,成绩SCGRADE)
这里写图片描述

(6) 4.6专业课设表MC(专业号MNO,课程号CNO)
属性名 字段类型 长度 主键或外键 说明
这里写图片描述

(7) 4.7用户表YONGHU(用户编号YNO,用户密码YMIMA,用户类别LEIBIE)
这里写图片描述

四、用户界面设计

4.1学生信息管理系统

4.2学生信息查询

4.3教师查询

4.4管理员查询

4.5专业负责人查询

五、程序设计
源代码

FORM1//学生信息管理系统

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 学生管理系统
{
publicpartialclassForm1 : Form
    {
SqlConnection conn = newSqlConnection("Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True");

staticpublicstring sn, sub;
public Form1()
        {
            InitializeComponent();
        }
Form2 fr2 = newForm2(); Form3 fr3 = newForm3(); Form4 fr4 = newForm4(); Form5 fr5 = newForm5();


privatevoid button1_Click_1(object sender, EventArgs e)
        {
string str = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(str);
            conn.Open();
if (textBox1.Text == "" || textBox2.Text == "")
MessageBox.Show("请不要遗漏信息!");
if (radioButton1.Checked)
            {
string cstr = "select * from YONGHU where LEIBIE='管理员'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
                {
                    sn = textBox1.Text.Trim();
Form4 fm = newForm4();
                    fm.Show();
                    fr4.Show(); this.Visible = false;
                }
else
                {
MessageBox.Show("输入有误,请重新输入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
            }
if (radioButton2.Checked)
            {
string cstr = "select * from YONGHU where LEIBIE='教师'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
                { sn = textBox1.Text.Trim(); fr3.Show(); this.Visible = false; }
else
                {
MessageBox.Show("输入有误,请重新输入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
            }
if (radioButton3.Checked)
            {
string cstr = "select * from YONGHU where LEIBIE='学生'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
                { sn = textBox1.Text.Trim(); fr2.Show(); this.Visible = false; }
else
                {
MessageBox.Show("输入有误,请重新输入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
            }
if (radioButton4.Checked)
            {
string cstr = "select * from YONGHU where LEIBIE='专业负责人'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
                { sn = textBox1.Text.Trim(); fr5.Show(); this.Visible = false; }
else
                {
MessageBox.Show("输入有误,请重新输入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
            }
            conn.Close(); conn.Dispose();
        }



privatevoid button2_Click_1(object sender, EventArgs e)
        {
Application.Exit();
        }

privatevoid radioButton4_CheckedChanged(object sender, EventArgs e)
        {
string str = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(str);
            conn.Open();
string cstr = "select * from YONGHU where LEIBIE='学生'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);
SqlDataReader dr = comm.ExecuteReader();
            {
if (dr.Read())
                {
                    sn = textBox1.Text.Trim();
                    fr2.Show();
this.Visible = false;
                }
else
                {
MessageBox.Show("输入有误,请重新输入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
            }
            conn.Close(); conn.Dispose();
        } 

privatevoid radioButton3_CheckedChanged(object sender, EventArgs e)
        {    
string str = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(str);
            conn.Open(); 
string cstr = "select * from YONGHU where LEIBIE='教师'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);
SqlDataReader dr = comm.ExecuteReader();
            {
if (dr.Read())
                { sn = textBox1.Text.Trim(); 
                    fr3.Show(); 
this.Visible = false; 
                }
else
                {
MessageBox.Show("输入有误,请重新输入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
            }
            conn.Close(); conn.Dispose();
        }
privatevoid radioButton2_CheckedChanged(object sender, EventArgs e)
        {
string str = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(str);
            conn.Open(); 
string cstr = "select * from YONGHU where LEIBIE='专业负责人'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
                { sn = textBox1.Text.Trim(); fr5.Show(); this.Visible = false; }
else
                {
MessageBox.Show("输入有误,请重新输入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
                conn.Close(); 
            }

privatevoid radioButton1_CheckedChanged(object sender, EventArgs e)
        {  
string str = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(str);
            conn.Open(); 
string cstr = "select * from YONGHU where LEIBIE='管理员'and YNO='" + textBox1.Text.Trim() + "'and YMIMA='" + textBox2.Text.Trim() + "'";
SqlCommand comm = newSqlCommand(cstr, conn);

SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
                { sn = textBox1.Text.Trim(); fr4.Show(); this.Visible = false; }
else
                {
MessageBox.Show("输入有误,请重新输入!");
                    textBox1.Text = ""; textBox2.Text = "";
                }
                conn.Close(); 
        }
        }

    }

FORM2//学生信息查询

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.Data.SqlClient;

namespace 学生管理系统
{
publicpartialclassForm2 : Form
    {
public Form2()
        {
            InitializeComponent();
        }



privatevoid button4_Click(object sender, EventArgs e)
        {
SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
string ModifyString = "UPDATE  YONGHU SET YMIMA='" + textBox2.Text + "'," + "LEIBIE='" + textBox3.Text + "'where YNO='" + Form1.sn.Trim() + "'";
            cmd.CommandText = ModifyString;
            cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");
        }

privatevoid 查询成绩_Click(object sender, EventArgs e)
        {

SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open(); 
if (Form1.sn.Trim() == "001")
            {
                adapter = newSqlDataAdapter("select SC.SNO 学号,SC.CNO 课程号,SCGRADE1 成绩1,SCGRADE2 成绩2,SCGRADE3 成绩3  from SC WHERE SNO=001", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (Form1.sn.Trim() == "002")
            {
                adapter = newSqlDataAdapter("select SC.SNO 学号,SC.CNO 课程号,SCGRADE1 成绩1,SCGRADE2 成绩2,SCGRADE3 成绩3  from SC WHERE SNO=002", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (Form1.sn.Trim() == "003")
            {
                adapter = newSqlDataAdapter("select SC.SNO 学号,SC.CNO 课程号,SCGRADE1 成绩1,SCGRADE2 成绩2,SCGRADE3 成绩3  from SC WHERE SNO=003", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid 查询个人信息_Click(object sender, EventArgs e)
        {
SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (Form1.sn.Trim() == "001")
            {
                adapter = newSqlDataAdapter("select STUDENTS.SNO 学号,SNAME 姓名,SSEX 性别,SBIRTHDAY 出生年份,SNATIVE 名族,STEL 电话,SADDRESS 家庭住址,SNOTE 备注信息 from STUDENTS WHERE   SNO=001",conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (Form1.sn.Trim() == "002")
            {
                adapter = newSqlDataAdapter("select STUDENTS.SNO 学号,SNAME 姓名,SSEX 性别,SBIRTHDAY 出生年份,SNATIVE 名族,STEL 电话,SADDRESS 家庭住址,SNOTE 备注信息 from STUDENTS WHERE   SNO=002",conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (Form1.sn.Trim() == "003")
            {
                adapter = newSqlDataAdapter("select STUDENTS.SNO 学号,SNAME 姓名,SSEX 性别,SBIRTHDAY 出生年份,SNATIVE 名族,STEL 电话,SADDRESS 家庭住址,SNOTE 备注信息 from STUDENTS WHERE   SNO=003",conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid button3_Click(object sender, EventArgs e)
        {
this.Close();
Form1 f1 = newForm1();
            f1.Show();
        }
    }
}
FORM3  //教师查using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace //学生管理系统
{
publicpartialclassForm3 : Form
    {
public Form3()
        {
            InitializeComponent();
        }
privatevoid Form3_Load(object sender, EventArgs e)
        {
            学号.Text = Form1.sn + "教师,欢迎使用本管理系统!";


        }



privatevoid 学号_Click(object sender, EventArgs e)
        {

        }

privatevoid button3_Click(object sender, EventArgs e)
        {
DataTable table;
SqlDataAdapter adapter;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (textBox1.Text == "001")
            {
                adapter = newSqlDataAdapter("select SC.SNO 学号, SC.CNO 课程号,SCGRADE1 成绩1,SCGRADE2 成绩2,SCGRADE3 成绩3 from SC WHERE  SC.SNO=001 ", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (textBox1.Text == "002")
            {
                adapter = newSqlDataAdapter("select * from SC WHERE  SC.SNO=002", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (textBox1.Text == "003")
            {
                adapter = newSqlDataAdapter("select SC.SNO 学号, SC.CNO 课程号,SCGRADE1 成绩1,SCGRADE2 成绩2,SCGRADE3 成绩3 from SC WHERE  SC.SNO=003  ", conn); ;
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }

        }

privatevoid button2_Click_1(object sender, EventArgs e)
        {
Form1 f1 = newForm1();
            f1.Show();
this.Close();
        }

privatevoid button5_Click_1(object sender, EventArgs e)
        {
SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
string ModifyString = "UPDATE  YONGHU SET YMIMA='" + textBox7.Text + "'," + "LEIBIE='" + textBox8.Text + "'where YNO='" + Form1.sn.Trim() + "'";
            cmd.CommandText = ModifyString;
            cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");
        }

privatevoid button1_Click_1(object sender, EventArgs e)
        {
SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (Form1.sn.Trim() == "201")
            {
                adapter = newSqlDataAdapter("select * from TC,TEACHER WHERE TEACHER.TNO=201 ", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (Form1.sn.Trim() == "202")
            {
                adapter = newSqlDataAdapter("select * from TC,TEACHER WHERE TEACHER.TNO=202 ", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (Form1.sn.Trim() == "203")
            {
                adapter = newSqlDataAdapter("select * from TC,TEACHER WHERE TEACHER.TNO=203 ", conn); ;
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }


        }

privatevoid button4_Click_1(object sender, EventArgs e)
        {
SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
string ModifyString = "UPDATE  SC SET SNO='" + textBox1.Text + "',CNO='" + textBox2.Text + "',SCGRADE1='" + textBox3.Text + "',SCGRADE2='" + textBox4.Text + "',SCGRADE3='" + textBox5.Text + "'where SNO='" + textBox1.Text + "'and CNO='" + textBox2.Text + "'";
            cmd.CommandText = ModifyString;
            cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");


        }

privatevoid Form3_Load_1(object sender, EventArgs e)
        {

        }

privatevoid textBox6_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox7_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox8_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox1_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox2_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox3_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox4_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox5_TextChanged(object sender, EventArgs e)
        {

        }
    }
    }

M4 //管理员

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace //学生管理系统
{
publicpartialclassForm4 : Form
    {
public Form4()
        {
            InitializeComponent();
        }
privatevoid Form4_Load(object sender, EventArgs e)
        {
            label1.Text = Form1.sn + "管理员,欢迎使用本管理系统!";
        }
privatevoid label19_Click(object sender, EventArgs e)
        {
        }
privatevoid button5_Click(object sender, EventArgs e)
        {
Form1 f1 = newForm1();
            f1.Show();
this.Close();
        }
privatevoid button6_Click(object sender, EventArgs e)
        {
SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
string ModifyString = "UPDATE  YONGHU SET YNO='" + textBox21.Text + "'," + "YMIMA='" + textBox22.Text + "'," + "LEIBIE='" + textBox23.Text + "'where YNO='" + Form1.sn.Trim() + "'";
            cmd.CommandText = ModifyString;
            cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");
        }
privatevoid button3_Click_1(object sender, EventArgs e)
        {
SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
SqlCommand cmd1 = conn.CreateCommand();
string AddString = "INSERT INTO STUDENTS  VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox10.Text + "')";
string AddString1 = "INSERT INTO YONGHU  VALUES('" + textBox1.Text + "','" + textBox1.Text + "','" + "学生" + "')";
            cmd.CommandText = AddString;
            cmd1.CommandText = AddString1;
            cmd.ExecuteNonQuery();
            cmd1.ExecuteNonQuery();
MessageBox.Show("注册成功!");
            conn.Close();
        }

privatevoid label10_Click(object sender, EventArgs e)
        {

        }

privatevoid label8_Click(object sender, EventArgs e)
        {

        }

privatevoid dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

privatevoid label1_Click(object sender, EventArgs e)
        {

        }

privatevoid groupBox1_Enter(object sender, EventArgs e)
        {

        }

privatevoid button1_Click_1(object sender, EventArgs e)
        {

SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (textBox1.Text == "001")
            {
                adapter = newSqlDataAdapter("select STUDENTS.SNO 学号,SNAME 姓名,SSEX 性别,SBIRTHDAY 出生年份,SNATIVE 名族,STEL 电话,SADDRESS 家庭住址,SNOTE 备注信息 from STUDENTS WHERE   SNO=001", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (textBox1.Text == "002")
            {
                adapter = newSqlDataAdapter("select STUDENTS.SNO 学号,SNAME 姓名,SSEX 性别,SBIRTHDAY 出生年份,SNATIVE 名族,STEL 电话,SADDRESS 家庭住址,SNOTE 备注信息 from STUDENTS WHERE   SNO=002", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (textBox1.Text == "003")
            {
                adapter = newSqlDataAdapter("select STUDENTS.SNO 学号,SNAME 姓名,SSEX 性别,SBIRTHDAY 出生年份,SNATIVE 名族,STEL 电话,SADDRESS 家庭住址,SNOTE 备注信息 from STUDENTS WHERE   SNO=003", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid button2_Click_1(object sender, EventArgs e)
        {
SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();

if (textBox11.Text == "202")
            {
                adapter = newSqlDataAdapter("select TNO 教师号,TNAME 教师名,TSEX 性别,TBIRTHDAY 出生年份,TNATIVE 名族,TPOSITION 职称,TTEL 电话,TADDRESS 家庭住址,TNOTE 备注信息 from TEACHER WHERE TNO=202", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (textBox11.Text == "203")
            {
                adapter = newSqlDataAdapter("select TNO 教师号,TNAME 教师名,TSEX 性别,TBIRTHDAY 出生年份,TNATIVE 名族,TPOSITION 职称,TTEL 电话,TADDRESS 家庭住址,TNOTE 备注信息 from TEACHER WHERE  TNO=203", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid textBox1_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox2_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox3_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox4_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox5_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox6_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox7_TextChanged(object sender, EventArgs e)
        {

        }
privatevoid textBox8_TextChanged(object sender, EventArgs e)
        {

        }
privatevoid textBox9_TextChanged(object sender, EventArgs e)
        {

       }
privatevoid textBox10_TextChanged(object sender, EventArgs e)
        {

        }
privatevoid button4_Click(object sender, EventArgs e)
        {
SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
SqlCommand cmd1 = conn.CreateCommand();
string AddString = "INSERT INTO TEACHER  VALUES('" + textBox11.Text + "','" + textBox12.Text + "','" + textBox13.Text + "','" + textBox14.Text + "','" + textBox15.Text + "','" + textBox16.Text + "','" + textBox17.Text + "','" + textBox18.Text + "','" + textBox19.Text + "','" + textBox20.Text + "')";
string AddString1 = "INSERT INTO YONGHU  VALUES('" + textBox11.Text + "','" + textBox11.Text + "','" + "教师" + "')";
            cmd.CommandText = AddString;
            cmd1.CommandText = AddString1;
            cmd.ExecuteNonQuery();
            cmd1.ExecuteNonQuery();
MessageBox.Show("注册成功!");
            conn.Close();
        }

privatevoid textBox11_TextChanged(object sender, EventArgs e)
        {

        }
privatevoid textBox12_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox13_TextChanged(object sender, EventArgs e)
        {

        }
privatevoid textBox14_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox15_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox16_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox17_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox18_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox19_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox20_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid button5_Click_1(object sender, EventArgs e)
        {
this.Close();
        }

privatevoid button6_Click_1(object sender, EventArgs e)
        {
SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
string ModifyString = "UPDATE  YONGHU SET YMIMA='" + textBox22.Text + "'," + "LEIBIE='" + textBox23.Text + "'where YNO='" + Form1.sn.Trim() + "'";
            cmd.CommandText = ModifyString;
            cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");
        }

privatevoid textBox22_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox23_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

namespace 学生管理系统
{
publicpartialclassForm5 : Form
    {
public Form5()
        {
            InitializeComponent();
        }


privatevoid Form5_Load(object sender, EventArgs e)
        {
            label1.Text = Form1.sn + "专业负责人,欢迎使用本管理系统!";
        }

privatevoid button5_Click(object sender, EventArgs e)
        {

        }

privatevoid Form5_Load_1(object sender, EventArgs e)
        {

        }

privatevoid label4_Click(object sender, EventArgs e)
        {

        }

privatevoid groupBox1_Enter_1(object sender, EventArgs e)
        {

        }
privatevoid button1_Click_1(object sender, EventArgs e)
        {

SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (textBox4.Text == "401")
            {
                adapter = newSqlDataAdapter("select * from COURSE WHERE CNO=401", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid button6_Click(object sender, EventArgs e)
        {

SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
string ModifyString = "UPDATE  YONGHU SET YMIMA='" + textBox2.Text + "'," + "LEIBIE='" + textBox3.Text + "'where YNO='" + Form1.sn.Trim() + "'";
            cmd.CommandText = ModifyString;
            cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");
        }

privatevoid button4_Click_1(object sender, EventArgs e)
        {
this.Close();
Form1 f1 = newForm1();
            f1.Show();
        }

privatevoid textBox4_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid button2_Click_1(object sender, EventArgs e)
        {
SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (textBox5.Text == "001")
            {
                adapter = newSqlDataAdapter("select STUDENTS.SNO 学号,SNAME 姓名,SSEX 性别,SBIRTHDAY 出生年份,SNATIVE 名族,STEL 电话,SADDRESS 家庭住址,SNOTE 备注信息 from STUDENTS,TC,SC WHERE   STUDENTS.SNO=001 ", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid button3_Click_1(object sender, EventArgs e)
        {
SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (textBox6.Text == "401")
            {
                adapter = newSqlDataAdapter("select TEACHER.TNO 教师号, TEACHER.TNAME 姓名,TEACHER.TSEX 性别,TEACHER.TBIRTHDAY 出生日期,TEACHER.TNATIVE 民族,TEACHER.TDEPTNO 所在专业编号,TEACHER.TPOSITION 职称, TEACHER.TTEL 电话,TEACHER.TADDRESS 家庭住址,TEACHER.TNOTE 备注信息 from TEACHER,TC WHERE  TC.CNO=401 ", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }
privatevoid button1_Click(object sender, EventArgs e)
        {
SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
if (textBox4 .Text  == "401")
            {
                adapter = newSqlDataAdapter("select COURSE.CNO 课程号,COURSE.CNAME 课程名,CGRADE 学分,TC.TNO 教课教师号,TEACHER.TNAME 教课教师名  from TEACHER,TC,COURSE WHERE CNO=401", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (textBox4.Text == "402")
            {
                adapter = newSqlDataAdapter("select COURSE.CNO 课程号,COURSE.CNAME 课程名,CGRADE 学分,TC.TNO 教课教师号,TEACHER.TNAME 教课教师名  from TEACHER,MC,COURSE WHERE CNO=402", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (textBox4.Text == "403")
            {
                adapter = newSqlDataAdapter("select COURSE.CNO 课程号,COURSE.CNAME 课程名,CGRADE 学分,CTEACHER 教课教师号,TNAME 教课教师名  from TEACHER,MC,COURSE WHERE CNO=403", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid textBox1_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox2_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox3_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
FORM5//专业负责人查询

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.Data.SqlClient;

namespace 学生管理系统
{
publicpartialclassForm5 : Form
    {
public Form5()
        {
            InitializeComponent();
        }


privatevoid Form5_Load(object sender, EventArgs e)
        {
            label1.Text = Form1.sn + "专业负责人,欢迎使用本管理系统!";
        }

privatevoid button5_Click(object sender, EventArgs e)
        {

        }

privatevoid Form5_Load_1(object sender, EventArgs e)
        {

        }

privatevoid label4_Click(object sender, EventArgs e)
        {

        }

privatevoid groupBox1_Enter_1(object sender, EventArgs e)
        {

        }
privatevoid button1_Click_1(object sender, EventArgs e)
        {

SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (textBox4.Text == "401")
            {
                adapter = newSqlDataAdapter("select * from COURSE WHERE CNO=401", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid button6_Click(object sender, EventArgs e)
        {

SqlConnection conn = newSqlConnection();
            conn.ConnectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
            conn.Open();
SqlCommand cmd = conn.CreateCommand();
string ModifyString = "UPDATE  YONGHU SET YMIMA='" + textBox2.Text + "'," + "LEIBIE='" + textBox3.Text + "'where YNO='" + Form1.sn.Trim() + "'";
            cmd.CommandText = ModifyString;
            cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");
        }

privatevoid button4_Click_1(object sender, EventArgs e)
        {
this.Close();
Form1 f1 = newForm1();
            f1.Show();
        }

privatevoid textBox4_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid button2_Click_1(object sender, EventArgs e)
        {
SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (textBox5.Text == "001")
            {
                adapter = newSqlDataAdapter("select STUDENTS.SNO 学号,SNAME 姓名,SSEX 性别,SBIRTHDAY 出生年份,SNATIVE 名族,STEL 电话,SADDRESS 家庭住址,SNOTE 备注信息 from STUDENTS,TC,SC WHERE   STUDENTS.SNO=001 ", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid button3_Click_1(object sender, EventArgs e)
        {
SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
            conn.Open();
if (textBox6.Text == "401")
            {
                adapter = newSqlDataAdapter("select TEACHER.TNO 教师号, TEACHER.TNAME 姓名,TEACHER.TSEX 性别,TEACHER.TBIRTHDAY 出生日期,TEACHER.TNATIVE 民族,TEACHER.TDEPTNO 所在专业编号,TEACHER.TPOSITION 职称, TEACHER.TTEL 电话,TEACHER.TADDRESS 家庭住址,TEACHER.TNOTE 备注信息 from TEACHER,TC WHERE  TC.CNO=401 ", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }
privatevoid button1_Click(object sender, EventArgs e)
        {
SqlDataAdapter adapter;
DataTable table;
string connectionString = "Data Source=asus;Initial Catalog=xueshengguanli;Integrated Security=True";
SqlConnection conn = newSqlConnection(connectionString);
if (textBox4 .Text  == "401")
            {
                adapter = newSqlDataAdapter("select COURSE.CNO 课程号,COURSE.CNAME 课程名,CGRADE 学分,TC.TNO 教课教师号,TEACHER.TNAME 教课教师名  from TEACHER,TC,COURSE WHERE CNO=401", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (textBox4.Text == "402")
            {
                adapter = newSqlDataAdapter("select COURSE.CNO 课程号,COURSE.CNAME 课程名,CGRADE 学分,TC.TNO 教课教师号,TEACHER.TNAME 教课教师名  from TEACHER,MC,COURSE WHERE CNO=402", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
if (textBox4.Text == "403")
            {
                adapter = newSqlDataAdapter("select COURSE.CNO 课程号,COURSE.CNAME 课程名,CGRADE 学分,CTEACHER 教课教师号,TNAME 教课教师名  from TEACHER,MC,COURSE WHERE CNO=403", conn);
                table = newDataTable();
                adapter.Fill(table);
                dataGridView1.DataSource = table;
            }
        }

privatevoid textBox1_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox2_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid textBox3_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

六、运行结果
(一)学生管理管理窗口
这里写图片描述
(二)学生窗口
(1)用户名002 密码002 学生
预测结果 学生查询窗口打开
实际结果

这里写图片描述
这里写图片描述
(2)点击查询成绩
预期结果 显示学号 课程号 成绩1 成绩2 成绩3
实际结果
这里写图片描述

(3)点击查询个人成绩
预期结果 显示学号,姓名,性别,出生日期,民族,所在专业编号,指导教师编号,电话号码,家庭地址,信息备注
实际结果
这里写图片描述

(4)进行修改学生密码
最初的密码
这里写图片描述
进行更改
这里写图片描述
预期结果 修改成功
实际结果
这里写图片描述
这里写图片描述

(5)输入的用户名和密码不符

这里写图片描述
预期结果 输入有误,请重新输入
实际结果
这里写图片描述
(二)教师窗口
(1)登录教师窗口
这里写图片描述
预期结果 进入教师窗口
实际结果
这里写图片描述
(2)点击查询本人信息
预期结果 显示教师号,姓名,性别,出生日期,民族,所在专业编号,职称,电话,家庭地址,信息备注
实际结果

(3)查询信息

预期结果 显示学号 课程号 成绩1 成绩2 成绩3
实际结果
这里写图片描述

(4)修改成绩

这里写图片描述

预期结果 修改成功
实际结果
这里写图片描述
(5)修改教师密码

原密码
这里写图片描述
进行修改

预期结果 修改成功
实际结果
这里写图片描述
这里写图片描述

(6)用户名或密码不正确

(三)管理员
(1)管理员登录

预期结果 进入管理员窗口
实际结果

(2)点击查询学生信息

预期结果 显示 学号,姓名,性别,出生日期,民族,所在专业编号,指导教师编号,电话号码,家庭地址,信息备注
实际结果

(3)点击查询教师信息

预期结果 显示教师号,教师名,性别,出生日期,民族,所在专业编号,职称,电话,家庭地址,信息备注
实际结果

(4)学生注册

预期结果 注册成功
实际结果

(5)教师注册

预期结果 注册成功
实际结果

(6)修改密码

预期结果 注册成功
实际结果

(四)专业负责人
(1)专业负责人登录

预期结果 进入专业负责人窗口
实际结果

(2)点击查询本专业课程信息

预期结果 显示CNO,CNAME,CGRADE
实际结果

(3)点击查询本专业学生信息

预期结果 显示学号,姓名,性别,出生日期,民族,所在专业编号,指导教师编号,电话号码,家庭地址,信息备注
实际结果

(4)点击查询本专业教师信息

预期结果 显示教课程号CNO=401的老师的教师号,教师名,性别,出生日期,民族,所在专业编号,职称,电话,家庭地址,信息备注
实际结果

(5)修改密码

预期结果 修改成功
实际结果

七、总结
7.1系统完成的主要功能
学生信息管理系统的功能是收集学生的个人信息,以便向老师提供每个学生在校或毕业生学籍的情况,还可以让学生用自己的学号去查看自己在校期间的表现。学生信息管理系统的主要功能有:
(1)、新生入学的学籍注册;
(2)、专业与课程管理;
(3)、教职工与课程管理;
(4)、学生个人信息的查询;
学生信息管理系统主要提供学生管理:包括编辑(学号,姓名,性别,生日,名族,所属部门,指导老师,家庭住址,备注信息等),用户登录(3种权限,一种是管理员可以做任何操作,一种是教师可以查看学生信息,修改学生成绩和修改本人密码,一种是学生只能查看本人信息和修改本人密码)。

7.2遇到的问题及解决方案
关于数据库和C#的窗口程序不会连接,根据网上相关资料查询,最终解决问题,代码中时常有一些小细节上的错误,每个成员都能参与其中仔细检查一遍又一遍。从一个登陆界面键入下一个信息界面时多番修改仍不能实现,通过老师和同学的帮助共同解决,查询信息时数据库的信息不能反馈到界面中,我们借鉴其他组成功实现的代码进行反复修改得以解决。

7.3不足及展望

学生注册和教师注册不能由学生和教师自己来完成,学生选专业不够灵活,实体部门在程序中未能体现出来,界面设计简单,操作麻烦,基础知识不扎实,所做系统较为简单,望以后的学习中能注重学习基本功,多以联系所有的实验和作业内容,增强动手能力,勤于思考。

没有更多推荐了,返回首页