【2019-2020春学期】数据库实验大作业

实验目的:

使用SQL Server 和Visual Studio实现一个学生信息管理系统。

实验内容:

设计并实现“学生信息管理系统”,该系统的主要任务为管理学生的信息。用户为学生和系统管理员。
在进入页面之前需要进行登录,在学生在学号和密码正确的情况下进入系统,管理员在工号和密码对应的情况下进入系统。
管理员可以增加、删除、修改、查询管理员的个人信息,增加、删除、修改、查询学生的个人信息,添加、查询课程,以及对学生的成绩进行录入、统计、修改和查询,还可以修改个人的密码。
学生可以查询学习成绩,修改个人的密码,还可以查询、选择课程。
在这里插入图片描述

代码:

数据准备:

DROP DATABASE IF EXISTS student_information_management_system;  

CREATE DATABASE student_information_management_system;  

USE student_information_management_system;

DROP TABLE IF EXISTS Student
DROP TABLE IF EXISTS Manage
DROP TABLE IF EXISTS Course
DROP TABLE IF EXISTS SC

CREATE TABLE Student          
 (	
 学号 NCHAR(10) PRIMARY KEY NOT NULL,        /* 列级完整性约束条件,学号是主码*/                  
 姓名 NCHAR(10) NOT NULL,          
 性别 NCHAR(2) CHECK(性别 IN ('男','女')) NOT NULL,
 出生日期 CHAR(10),
 民族 NCHAR(10),
 专业 NCHAR(20) NOT NULL,
 年级 NCHAR(4) NOT NULL,
 籍贯 NCHAR(25),
 手机号码 CHAR(11)NOT NULL,
 密码 NCHAR(35) NOT NULL,
 ); 

 CREATE TABLE Manage          
 (	
 工号 NCHAR(10) PRIMARY KEY NOT NULL,        /* 列级完整性约束条件,学号是主码*/                  
 姓名 NCHAR(10) NOT NULL,          
 性别 NCHAR(2) CHECK(性别 IN ('男','女'))NOT NULL,
 出生日期 NCHAR(10),
 籍贯 NCHAR(25),
 手机号码 CHAR(11)NOT NULL,
 民族 NCHAR(10),
 密码 NCHAR(35) NOT NULL,
 ); 

 CREATE TABLE  Course
 (	
 课程号 NCHAR(10) PRIMARY KEY NOT NULL,
 课程名 NCHAR(10) NOT NULL,            
 学分 SMALLINT NOT NULL,               	                      
 上课地点 NCHAR(20) NOT NULL,
 上课时间 NCHAR(20)NOT NULL 
 ); 

 CREATE TABLE  SC
 (
 学号 NCHAR(10) NOT NULL, 
 姓名 NCHAR(10),
 课程号 NCHAR(10)NOT NULL,
 课程名 NCHAR(10),
 成绩 SMALLINT CHECK(成绩>=0 AND 成绩<=100),
 学分 SMALLINT ,
 PRIMARY KEY (学号,课程号),                     /* 主码由两个属性构成,必须作为表级完整性进行定义*/
 FOREIGN KEY (学号) REFERENCES Student(学号),  /* 表级完整性约束条件,学号是外码,被参照表是Student */
 FOREIGN KEY (课程号)REFERENCES Course(课程号),     /* 表级完整性约束条件, 工号是外码,被参照表是Course*/
 ); 

INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215121','李勇','男','2000-11-03','汉族','数学信息专业','18','北京市','123123213','41b2e380f4ee72d92e4e1b61672d07ed');
INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215122','刘晨','男','2000-01-03','汉族','网络安全专业','18','上海市','1231232222','4fe3a5afd4d66bc2768870421bef6d80');
INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215123','佟露露','女','1998-02-13','汉族','生命科学专业','16','福建省','1231239873','aed333517421ba701dcfeaf3ee0da619');
INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215124','王敏','女','1999-07-30','汉族','通信专业','17','河北省','1231239803','5c15d3390d851205843a7e2c3a3a3d12');
INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215125','张丽','女','2001-04-21','汉族','航空航天专业','19','江西省','1231234563','f5579fdd1b92e1cecbe534a5e74cecfd');
INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215126','张扉','男','2000-06-30','汉族','计算机科学与技术专业','18','北京市','1232342213','9f83c11348a0a3a6259963823be1870f');
INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215127','顾依凉','男','2000-08-20','汉族','生命科学专业','18','贵州省','1231276513','b98a4565eb67c24a9481eb96d202d0e5');
INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215128','白雪','女','2001-03-23','汉族','通信专业','19','黑龙江省','1311232213','206111b43716ab18328809c64bef1fff');
INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215129','赵岑','男','2001-04-19','汉族','计算机科学与技术专业','19','吉林省','1345232213','cfb159592100391fce3640ce840dcd3d');
INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215120','林琳','女','2000-03-09','汉族','生命科学专业','18','四川省','1239802213','4c81c88cd7709d8b28d558c8f8af22d2');
INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215130','宋言','男','2002-07-03','汉族','航空航天专业','19','安徽','1234562213','415dfeb3e03aa46004ba95342897e702');
INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215131','卫琬','女','2000-11-03','汉族','通信专业','18','江西省','1231098713','039552cd56eb9fb800416d384052a0b0');
INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215132','韩晓梦','女','2000-12-09','汉族','数学信息专业','18','黑龙江省','1231342313','a2f5e908f5e96a9e44fea614fc3c0837');
INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215133','李祁','男','2000-08-17','汉族','计算机科学与技术专业','18','北京市','1239872213','40325844eaa57b823e4cc8f524ac43e7');
INSERT  INTO  Student(学号,姓名,性别,出生日期,民族,专业,年级,籍贯,手机号码,密码) VALUES ('201215134','郑颂雨','男','2002-06-12','汉族','生命科学专业','18','四川省','1231000213','6a9a16592c30de3aed9cb898886b2a6c');

SELECT * FROM Student

INSERT  INTO  Manage(工号,姓名,性别,出生日期,籍贯,手机号码,民族,密码) VALUES ('201203','张珊','女','1982-01-01','四川省','13812345678','汉族','9365f8127adaa91c6ed8433cd9f32c24');
INSERT  INTO  Manage(工号,姓名,性别,出生日期,籍贯,手机号码,民族,密码) VALUES ('201204','李姒','女','1993-11-01','江西省','13898762312','汉族','d01bb7551d54d9c0806d79233b6fe10b');
INSERT  INTO  Manage(工号,姓名,性别,出生日期,籍贯,手机号码,民族,密码) VALUES ('201205','王武','男','1989-02-01','黑龙江省','13154342378','汉族','205ded2984e1daf6e3b9373767e8bf6e');
INSERT  INTO  Manage(工号,姓名,性别,出生日期,籍贯,手机号码,民族,密码) VALUES ('201206','钱珥','女','1982-01-01','安徽','13819334328','汉族','2d0cac1b87699da50b07937dcee15a05');
INSERT  INTO  Manage(工号,姓名,性别,出生日期,籍贯,手机号码,民族,密码) VALUES ('201207','赵依','女','1993-11-01','江西省','13898762312','汉族','28689f39401b4eaa9fc79efde978ca11');
INSERT  INTO  Manage(工号,姓名,性别,出生日期,籍贯,手机号码,民族,密码) VALUES ('201208','孙柳','男','1987-05-16','上海市','13159877348','汉族','bef90937301f701a5c39280d255e9e86');
SELECT * FROM Manage

INSERT  INTO Course(课程号,课程名,学分,上课地点,上课时间)VALUES ('1','数据库',4,'一教101','周二7-9节');
INSERT  INTO Course(课程号,课程名,学分,上课地点,上课时间)VALUES ('2','高等数学',2,'三教212','周一1-4节');
INSERT  INTO Course(课程号,课程名,学分,上课地点,上课时间)VALUES ('3','信息系统',2,'二教103','周三7-9节');
INSERT  INTO Course(课程号,课程名,学分,上课地点,上课时间)VALUES ('4','操作系统',1,'一教601','周二1-2节');
INSERT  INTO Course(课程号,课程名,学分,上课地点,上课时间)VALUES ('5','数据结构',3,'三教101','周五5-6节');
INSERT  INTO Course(课程号,课程名,学分,上课地点,上课时间)VALUES ('6','数据处理',2,'二教211','周四2-4节');
INSERT  INTO Course(课程号,课程名,学分,上课地点,上课时间)VALUES ('7','Pascal语言',4,'一教101','周三3-4节');
SELECT * FROM Course


INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215122 ','刘晨','1','数据库',80,4);
INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215123 ','佟露露','1','数据库',60,4);
INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215126 ','张扉','1','数据库',70,4);
INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215129 ','赵岑','1','数据库',97,4);
INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215131 ','卫琬','1','数据库',84,4);
INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215134 ','郑颂雨','2','高等数学',88,2);
INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215121 ','李勇','2','高等数学',56,0);
INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215125 ','张丽','2','高等数学',70,2);
INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215127 ','顾依凉','2','高等数学',77,2);
INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215133 ','李祁','2','高等数学',84,2);
INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215124 ','王敏','3','信息系统',88,2);
INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215128 ','白雪','4','操作系统',56,0);
INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215120 ','林琳','5','数据结构',70,3);
INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215130 ','宋言','6','数据处理',77,2);
INSERT  INTO SC(学号,姓名,课程号,课程名,成绩,学分) VALUES ('201215132 ','韩晓梦','7','Pascal语言',84,4);
UPDATE SC SET 学分=0 WHERE 成绩<60
SELECT * FROM SC

触发器

--在SC表中如果修改学号会对应修改姓名
IF(OBJECT_ID('show_Sname') is not null)        -- 判断名为 show_Sname 的触发器是否存在
DROP TRIGGER show_Sname        -- 删除触发器
GO

CREATE TRIGGER show_Sname
ON SC  	         
FOR UPDATE
AS 
	declare @NEWSno NCHAR(10),
			@Sname NCHAR(10);
IF(UPDATE(学号))
	BEGIN
	SELECT @NEWSno =学号 FROM INSERTED
	SELECT @Sname =姓名 FROM Student WHERE 学号=@NEWSno
	UPDATE SC SET 姓名=@Sname WHERE 学号=@NEWSno

END;

--在SC表中如果修改课程号会对应修改课程名
IF(OBJECT_ID('show_Cname') is not null)        -- 判断名为 show_Cname 的触发器是否存在
DROP TRIGGER show_Cname        -- 删除触发器
GO

CREATE TRIGGER show_Cname
ON SC  	         
FOR UPDATE
AS 
	declare @NEWCno NCHAR(10),
			@Cname NCHAR(10),
			@credit SMALLINT;
IF(UPDATE(课程号))
	BEGIN
	SELECT @NEWCno =课程号 FROM INSERTED
	SELECT @Cname =课程名 FROM Course WHERE 课程号=@NEWCno
	SELECT @credit = 学分 FROM Course WHERE 课程号=@NEWCno
	UPDATE SC SET 课程名=@Cname WHERE 课程号=@NEWCno
	UPDATE SC SET 学分=@credit WHERE 课程号=@NEWCno AND 成绩>=60
	UPDATE SC SET 学分=0 WHERE 课程号=@NEWCno AND 成绩<60

END;

--在SC表中如果修改成绩,成绩大于60时,学分获得,否则为0
IF(OBJECT_ID('show_credit') is not null)        -- 判断名为 show_credit 的触发器是否存在
DROP TRIGGER show_credit        -- 删除触发器
GO

CREATE TRIGGER show_credit
ON SC  	         
FOR UPDATE
AS 
	declare @NEWgrade SMALLINT,
			@Sno NCHAR(10),
			@Cno NCHAR(10),
			@credit SMALLINT;
IF(UPDATE(成绩))
	BEGIN
	SELECT @NEWgrade = 成绩 FROM INSERTED
	SELECT @Sno = 学号 FROM DELETED
	SELECT @Cno = 课程号 FROM DELETED 
	SELECT @credit  =学分 FROM Course WHERE 课程号=@Cno
	UPDATE SC SET 学分=0 WHERE 课程号=@Cno AND 成绩<60
	UPDATE SC SET 学分=@credit WHERE 课程号=@Cno AND 成绩>=60

END;

--在Course表中如果修改学分,SC表中的对应学分也要修改
IF(OBJECT_ID('change_credit') is not null)        -- 判断名为 change_credit 的触发器是否存在
DROP TRIGGER change_credit        -- 删除触发器
GO
CREATE TRIGGER change_credit
ON Course  	         
FOR UPDATE
AS 
	declare @Cno NCHAR(10),
			@credit SMALLINT;
IF(UPDATE(学分))
	BEGIN
	SELECT @Cno = 课程号 FROM DELETED 
	SELECT @credit  =学分 FROM INSERTED
	UPDATE SC SET 学分=0 WHERE 课程号=@Cno AND 成绩<60
	UPDATE SC SET 学分=@credit WHERE 课程号=@Cno AND 成绩>=60

END;

Class1.cs文件:
目的:定义全局变量,保存输入的账号,以此显示对应的信息。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 学生信息管理系统
{
    public class Class1
    {
        public static string UserID;
    }
}

登录界面:
在这里插入图片描述

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 学生信息管理系统
{
    public partial class Form1 : Form
    {
        
        public Form1()
        {
            InitializeComponent();
        }
        public string code;
        private void Login_Load_1(object sender, EventArgs e)
        {
            //随机实例化 
            Random ran = new Random();
            int number;
            char code1;
            //取五个数 
            for (int i = 0; i < 5; i++)
            {
                number = ran.Next();
                if (number % 2 == 0)
                    code1 = (char)('0' + (char)(number % 10));
                else
                    code1 = (char)('A' + (char)(number % 26)); //转化为字符 

                this.code += code1.ToString();
            }

            label5.Text = code;
        }
        public static string EncryptWithMD5(string source)
        {
            byte[] sor = Encoding.UTF8.GetBytes(source);
            MD5 md5 = MD5.Create();
            byte[] result = md5.ComputeHash(sor);
            StringBuilder strbul = new StringBuilder(40);
            for (int i = 0; i < result.Length; i++)
            {
                strbul.Append(result[i].ToString("x2"));//加密结果"x2"结果为32位,"x3"结果为48位,"x4"结果为64位
            }
            return strbul.ToString();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            //随机实例化 
            Random ran = new Random();
            int number;
            char code1;
            //取五个数 
            for (int i = 0; i < 5; i++)
            {
                number = ran.Next();
                if (number % 2 == 0)
                    code1 = (char)('0' + (char)(number % 10));
                else
                    code1 = (char)('A' + (char)(number % 26)); //转化为字符 

                this.code += code1.ToString();
            }

            label5.Text = code;
        }
        private void textBox1_TextChanged(object sender,EventArgs e)
        {

        }

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

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string username = textBox1.Text.Trim();  //取出账号
            string password = EncryptWithMD5(textBox2.Text.Trim());  //取出密码并加密

            // if (username == "admin")
            //   password = "123";//测试用例,便于初始化时候的 admin 密码 123可以顺利登陆。程序完成后可注释掉这行代码。

            //string connstr = ConfigurationManager.ConnectionStrings["connectionString"].ToString(); //读取连接字符串
            string myConnString = "Data Source=.;Initial Catalog=student_information_management_system;Persist Security Info=True;User ID=sa;Password=***********";

            SqlConnection sqlConnection = new SqlConnection(myConnString);  //实例化连接对象
            sqlConnection.Open();

            string sql1 = "select 学号,密码 from Student where 学号 = '" + username + "' and 密码 = '" + password + "'";                                            //编写SQL命令
            SqlCommand sqlCommand1 = new SqlCommand(sql1, sqlConnection);
            
            SqlDataReader sqlDataReader1 = sqlCommand1.ExecuteReader();
            if (sqlDataReader1.HasRows && textBox3.Text == code)
            {
                Class1.UserID = username;
                student_manage form2 = new student_manage();
                form2.Show();
                this.Hide();
            }
            sqlDataReader1.Close();


            string sql2 = "select 工号,密码 from Manage where 工号 = '" + username + "' and 密码 = '" + password + "'";
            SqlCommand sqlCommand2 = new SqlCommand(sql2, sqlConnection);
            SqlDataReader sqlDataReader2 = sqlCommand2.ExecuteReader();
            if (sqlDataReader2.HasRows && textBox3.Text == code)
            {
                Class1.UserID = username;
                manager_manage form3 = new manager_manage();
                form3.Show();
                this.Hide();
            }
            else
            {
                label6.Text = "登录失败,输入密码或验证码错误";
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
                return;
            }

            sqlDataReader2.Close();
            sqlConnection.Close();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            retrieve_password form3 = new retrieve_password();
            form3.Show();
            this.Hide();
        }
    }
}

找回密码界面:
在这里插入图片描述

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 学生信息管理系统
{
    public partial class retrieve_password : Form
    {
        public retrieve_password()
        {
            InitializeComponent();
        }
        public string code;
        public static string EncryptWithMD5(string source)
        {
            byte[] sor = Encoding.UTF8.GetBytes(source);
            MD5 md5 = MD5.Create();
            byte[] result = md5.ComputeHash(sor);
            StringBuilder strbul = new StringBuilder(40);
            for (int i = 0; i < result.Length; i++)
            {
                strbul.Append(result[i].ToString("x2"));//加密结果"x2"结果为32位,"x3"结果为48位,"x4"结果为64位
            }
            return strbul.ToString();
        }
        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string username = textBox1.Text.Trim();  //取出账号
            string cellphone = textBox2.Text.Trim();  //取出手机号码
            int flag1 = 0;
            int flag2 = 0;

            string myConnString = "Data Source=.;Initial Catalog=student_information_management_system;Persist Security Info=True;User ID=sa;Password=**********";

            SqlConnection sqlConnection = new SqlConnection(myConnString);  //实例化连接对象
            sqlConnection.Open();

            string sql1 = "select 学号,手机号码 from Student where 学号 = '" + username + "' and 手机号码 = '" + cellphone + "'";                                            //编写SQL命令
            SqlCommand sqlCommand1 = new SqlCommand(sql1, sqlConnection);

            SqlDataReader sqlDataReader1 = sqlCommand1.ExecuteReader();
            if (sqlDataReader1.HasRows )
            {
                if (textBox3.Text.Trim() != "")
                {
                    //使用regex(正则表达式)进行格式设置 至少有数字、大写字母、小写字母各一个。最少3个字符、最长20个字符。
                    Regex regex = new Regex(@"(?=.*[0-9]).{3,15}");

                    if (regex.IsMatch(textBox3.Text))//判断格式是否符合要求
                    {
                        flag1 = 1;
                    }
                 
                }
            }
            sqlDataReader1.Close();
            if (flag1 == 1)
            {
                string password = EncryptWithMD5(textBox3.Text.Trim());
                string sql3 = "update Student set 密码='" + password + "' where 学号='"+username+"'";
                SqlCommand sqlCommand3 = new SqlCommand(sql3, sqlConnection);
                SqlDataReader sqlDataReader3 = sqlCommand3.ExecuteReader();
                MessageBox.Show("修改成功");
                sqlDataReader3.Close();
                Form1 form1 = new Form1();
                form1.Show();
                this.Hide();
            }
            


            string sql2 = "select 工号,手机号码 from Manage where 工号 = '" + username + "' and 手机号码 = '" + cellphone + "'";
            SqlCommand sqlCommand2 = new SqlCommand(sql2, sqlConnection);
            SqlDataReader sqlDataReader2 = sqlCommand2.ExecuteReader();
            if (sqlDataReader2.HasRows)
            {
                if (textBox3.Text.Trim() != "")
                {
                    //使用regex(正则表达式)进行格式设置 至少有数字、大写字母、小写字母各一个。最少3个字符、最长20个字符。
                    Regex regex = new Regex(@"(?=.*[0-9]).{3,15}");

                    if (regex.IsMatch(textBox3.Text))//判断格式是否符合要求
                    {
                        flag2 = 1;
                    }

                }
                sqlDataReader2.Close();
                if (flag2 == 1)
                {
                    string password = EncryptWithMD5(textBox3.Text.Trim());
                    string sql4 = "update Manage set 密码='" + password + "' where 工号='" + username + "'";
                    SqlCommand sqlCommand4 = new SqlCommand(sql4, sqlConnection);
                    SqlDataReader sqlDataReader4 = sqlCommand4.ExecuteReader();
                    MessageBox.Show("修改成功");
                    sqlDataReader4.Close();
                    Form1 form1 = new Form1();
                    form1.Show();
                    this.Hide();
                }
            }
            else
            {
                label5.Text = "输入密码错误或手机号码错误,请重新输入";
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
                return;
            }
            sqlConnection.Close();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            Form1 form1 = new Form1();
            form1.Show();
            this.Hide();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
        }
    }
}

管理员功能界面:
在这里插入图片描述

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

namespace 学生信息管理系统
{
    public partial class manager_manage : Form
    {
        public string MyID;

        public manager_manage()
        {
            InitializeComponent();
        }

        private void manager_manage_Load(object sender, EventArgs e)
        {
            label1.Text = Class1.UserID+" 你好,欢迎进入系统";
            

            

        }

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

        private void button5_Click(object sender, EventArgs e)
        {
            Form1 form1 = new Form1();
            form1.Show();
            this.Hide();
        }

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

        private void button2_Click(object sender, EventArgs e)
        {
            manage_student_information manage_student_information1 = new manage_student_information();
            manage_student_information1.Show();
            this.Hide();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            manage_course manage_course1 = new manage_course();
            manage_course1.Show();
            this.Hide();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            manage_SCcs manage_SCcs1 = new manage_SCcs();
            manage_SCcs1.Show();
            this.Hide();
        }
    }
}

管理员管理管理员信息界面:
在这里插入图片描述

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 学生信息管理系统
{
    public partial class manage_manager_information : Form
    {
        SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=***********");
        public manage_manager_information()
        {
            InitializeComponent();
        }

        private void manage_manager_information_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“student_information_management_systemDataSet2.Manage”中。您可以根据需要移动或删除它。
            this.manageTableAdapter.Fill(this.student_information_management_systemDataSet2.Manage);

        }
        public static string EncryptWithMD5(string source)
        {
            byte[] sor = Encoding.UTF8.GetBytes(source);
            MD5 md5 = MD5.Create();
            byte[] result = md5.ComputeHash(sor);
            StringBuilder strbul = new StringBuilder(40);
            for (int i = 0; i < result.Length; i++)
            {
                strbul.Append(result[i].ToString("x2"));//加密结果"x2"结果为32位,"x3"结果为48位,"x4"结果为64位
            }
            return strbul.ToString();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void Close_Click_1(object sender, EventArgs e)
        {
            manager_manage manager_manage1 = new manager_manage();
            manager_manage1.Show();
            this.Hide();
        }

        private void Insert_Click_1(object sender, EventArgs e)
        {
            String Mno = textBox1.Text.Trim();
            String Mname = textBox2.Text.Trim();
            String Msex = textBox3.Text.Trim();
            String Mbirth = textBox4.Text.Trim();
            String Mnative = textBox5.Text.Trim();//籍贯
            String Mcelllphone = textBox6.Text.Trim();
            String Mnation = textBox7.Text.Trim();//民族
            String Mpassword = EncryptWithMD5(Mno);//密码
            try
            {
                con.Open();
                string insertStr = "INSERT INTO Manage(工号,姓名,性别,出生日期,籍贯,手机号码,民族,密码) " +
                    "VALUES('" + Mno + "','" + Mname + "','" + Msex + "','" + Mbirth + "','" + Mnative +"','"+Mcelllphone + "','"+Mnation+"','"+ Mpassword + "')";
                SqlCommand cmd = new SqlCommand(insertStr, con);
                cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("输入数据违反要求");
            }
            finally
            {
                con.Dispose();
            }
            this.manageTableAdapter.Fill(this.student_information_management_systemDataSet2.Manage);
        }

        private void Delete_Click(object sender, EventArgs e)
        {
            try
            {
                con.Open();
                string select_id = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();//选择的当前行第一列的值,也就是ID
                string delete_by_id = "delete from Manage where 工号=" + select_id;//sql删除语句
                SqlCommand cmd = new SqlCommand(delete_by_id, con);
                cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("请正确选择行!");
            }
            finally
            {
                con.Dispose();
            }
            this.manageTableAdapter.Fill(this.student_information_management_systemDataSet2.Manage);
        }

        private void Update_Click(object sender, EventArgs e)
        {
            String Mno = textBox1.Text.Trim();
            String Mname = textBox2.Text.Trim();
            String Msex = textBox3.Text.Trim();
            String Mbirth = textBox4.Text.Trim();
            String Mnative = textBox5.Text.Trim();//籍贯
            String Mcelllphone = textBox6.Text.Trim();
            String Mnation = textBox7.Text.Trim();//民族
            try
            {
                con.Open();
                if (Mname != "")
                {
                    string insertStr = "UPDATE Manage SET 姓名 = '" + Mname + "' WHERE   工号='" + Mno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Msex != "")
                {
                    string insertStr = "UPDATE Manage SET 性别 = '" + Msex + "' WHERE   工号='" + Mno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Mbirth != "")
                {
                    string insertStr = "UPDATE Manage SET 出生日期 = '" + Mbirth + "' WHERE   工号='" + Mno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Mnative != "")
                {
                    string insertStr = "UPDATE Manage SET 籍贯 = '" + Mnative + "' WHERE   工号='" + Mno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Mcelllphone != "")
                {
                    string insertStr = "UPDATE Manage SET 手机号码 = '" + Mcelllphone + "' WHERE   工号='" + Mno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Mnation != "")
                {
                    string insertStr = "UPDATE Manage SET 民族 = '" + Mnation + "' WHERE   工号='" + Mno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
            }
            catch
            {
                MessageBox.Show("输入数据违反要求!");
            }
            finally
            {
                con.Dispose();
            }
            this.manageTableAdapter.Fill(this.student_information_management_systemDataSet2.Manage);
        }

        private void Select_Click(object sender, EventArgs e)
        {
            String Mno = textBox1.Text.Trim();
            String Mname = textBox2.Text.Trim();
            String Msex = textBox3.Text.Trim();
            String Mbirth = textBox4.Text.Trim();
            String Mnative = textBox5.Text.Trim();//籍贯
            String Mcelllphone = textBox6.Text.Trim();
            String Mnation = textBox7.Text.Trim();//民族
            
            String conn = "Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=********";
            SqlConnection sqlConnection = new SqlConnection(conn);
            try
            {
                if (Mno != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Manage where 工号='" + Mno + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Mname != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Manage where 姓名 Like'" + Mname + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Msex != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Manage where 性别='" + Msex + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Mbirth != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Manage where 出生日期 Like'" + Mbirth + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Mnative != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Manage where 籍贯 Like'" + Mnative + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Mcelllphone != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Manage where 手机号码='" + Mcelllphone + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Mnation != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Manage where 民族 Like'" + Mnation + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }

            }
            catch
            {
                MessageBox.Show("查询语句有误!");
            }
            finally
            {
                sqlConnection.Close();
            }
        }
    }
}

管理员管理学生信息界面:
在这里插入图片描述

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 学生信息管理系统
{
    public partial class manage_student_information : Form
    {
        SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=***********");
        public manage_student_information()
        {
            InitializeComponent();
        }
        public static string EncryptWithMD5(string source)
        {
            byte[] sor = Encoding.UTF8.GetBytes(source);
            MD5 md5 = MD5.Create();
            byte[] result = md5.ComputeHash(sor);
            StringBuilder strbul = new StringBuilder(40);
            for (int i = 0; i < result.Length; i++)
            {
                strbul.Append(result[i].ToString("x2"));//加密结果"x2"结果为32位,"x3"结果为48位,"x4"结果为64位
            }
            return strbul.ToString();
        }

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

        private void Close_Click(object sender, EventArgs e)
        {
            manager_manage manager_manage1 = new manager_manage();
            manager_manage1.Show();
            this.Hide();
        }

        private void Insert_Click(object sender, EventArgs e)
        {
            String Mno = textBox1.Text.Trim();
            String Mname = textBox2.Text.Trim();
            String Msex = textBox3.Text.Trim();
            String Mbirth = textBox4.Text.Trim();
            String Mnative = textBox5.Text.Trim();//籍贯
            String Mcelllphone = textBox6.Text.Trim();
            String Mnation = textBox7.Text.Trim();//民族
            String Mgrade = textBox8.Text.Trim();
            String Mdept = textBox9.Text.Trim();
            String Mpassword = EncryptWithMD5(Mno);//密码
            try
            {
                con.Open();
                string insertStr = "INSERT INTO Student(学号,姓名,性别,出生日期,籍贯,手机号码,民族,年级,专业,密码) " +
                    "VALUES('" + Mno + "','" + Mname + "','" + Msex + "','" + Mbirth + "','" + Mnative + "','" + Mcelllphone + "','" + Mnation + "','" + Mgrade + "','" + Mdept + "','" + Mpassword + "')";
                SqlCommand cmd = new SqlCommand(insertStr, con);
                cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("输入数据违反要求");
            }
            finally
            {
                con.Dispose();
            }
            this.studentTableAdapter.Fill(this.student_information_management_systemDataSet3.Student);
        }

        private void manage_student_information_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“student_information_management_systemDataSet3.Student”中。您可以根据需要移动或删除它。
            this.studentTableAdapter.Fill(this.student_information_management_systemDataSet3.Student);

        }

        private void Delete_Click(object sender, EventArgs e)
        {
            try
            {
                con.Open();
                string select_id = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();//选择的当前行第一列的值,也就是ID
                string delete_by_id = "delete from Student where 学号=" + select_id;//sql删除语句
                SqlCommand cmd = new SqlCommand(delete_by_id, con);
                cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("请正确选择行!");
            }
            finally
            {
                con.Dispose();
            }
            this.studentTableAdapter.Fill(this.student_information_management_systemDataSet3.Student);
        }

        private void Update_Click(object sender, EventArgs e)
        {
            String Mno = textBox1.Text.Trim();
            String Mname = textBox2.Text.Trim();
            String Msex = textBox3.Text.Trim();
            String Mbirth = textBox4.Text.Trim();
            String Mnative = textBox5.Text.Trim();//籍贯
            String Mcelllphone = textBox6.Text.Trim();
            String Mnation = textBox7.Text.Trim();//民族
            String Mgrade = textBox8.Text.Trim();
            String Mdept = textBox9.Text.Trim();
            try
            {
                con.Open();
                if (Mname != "")
                {
                    string insertStr = "UPDATE Student SET 姓名 = '" + Mname + "' WHERE   学号='" + Mno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Msex != "")
                {
                    string insertStr = "UPDATE Student SET 性别 = '" + Msex + "' WHERE   学号='" + Mno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Mbirth != "")
                {
                    string insertStr = "UPDATE Student SET 出生日期 = '" + Mbirth + "' WHERE   学号='" + Mno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Mnative != "")
                {
                    string insertStr = "UPDATE Student SET 籍贯 = '" + Mnative + "' WHERE   学号='" + Mno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Mcelllphone != "")
                {
                    string insertStr = "UPDATE Student SET 手机号码 = '" + Mcelllphone + "' WHERE   学号='" + Mno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Mnation != "")
                {
                    string insertStr = "UPDATE Student SET 民族 = '" + Mnation + "' WHERE   学号='" + Mno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Mgrade != "")
                {
                    string insertStr = "UPDATE Student SET 年级 = '" + Mgrade + "' WHERE   学号='" + Mno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Mdept != "")
                {
                    string insertStr = "UPDATE Student SET 专业 = '" + Mdept + "' WHERE   学号='" + Mno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
            }
            catch
            {
                MessageBox.Show("输入数据违反要求!");
            }
            finally
            {
                con.Dispose();
            }
            this.studentTableAdapter.Fill(this.student_information_management_systemDataSet3.Student);
        }

        private void Select_Click(object sender, EventArgs e)
        {
            String Mno = textBox1.Text.Trim();
            String Mname = textBox2.Text.Trim();
            String Msex = textBox3.Text.Trim();
            String Mbirth = textBox4.Text.Trim();
            String Mnative = textBox5.Text.Trim();//籍贯
            String Mcelllphone = textBox6.Text.Trim();
            String Mnation = textBox7.Text.Trim();//民族
            String Mgrade = textBox8.Text.Trim();
            String Mdept = textBox9.Text.Trim();
            String conn = "Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=***********";
            SqlConnection sqlConnection = new SqlConnection(conn);
            try
            {
                if (Mno != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Manage where 工号='" + Mno + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Mname != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Student where 姓名 Like'" + Mname + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Msex != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Student where 性别='" + Msex + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Mbirth != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Student where 出生日期 Like'" + Mbirth + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Mnative != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Student where 籍贯 Like'" + Mnative + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Mcelllphone != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Student where 手机号码='" + Mcelllphone + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Mnation != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Student where 民族 Like'" + Mnation + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Mgrade != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Student where 年级='" + Mgrade + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Mdept != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Student where 专业 Like'" + Mdept + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }

            }
            catch
            {
                MessageBox.Show("查询语句有误!");
            }
            finally
            {
                sqlConnection.Close();
            }
        }
    }
}

管理员管理课程界面:
在这里插入图片描述

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

namespace 学生信息管理系统
{
    public partial class manage_course : Form
    {
        SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=**********");
        public manage_course()
        {
            InitializeComponent();
        }

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

        private void Close_Click(object sender, EventArgs e)
        {
            manager_manage manager_manage1 = new manager_manage();
            manager_manage1.Show();
            this.Hide();
        }

        private void Insert_Click(object sender, EventArgs e)
        {
            String Cno = textBox1.Text.Trim();//课程号
            String Cname = textBox2.Text.Trim();//课程名
            String Credit = textBox3.Text.Trim();//学分
            String Cplace = textBox4.Text.Trim();//上课地点
            String Ctime = textBox5.Text.Trim();//上课时间
            try
            {
                con.Open();
                string insertStr = "INSERT INTO Course(课程号,课程名,学分,上课地点,上课时间) " +
                    "VALUES('" + Cno + "','" + Cname + "','" + Credit + "','" + Cplace + "','" + Ctime + "')";
                SqlCommand cmd = new SqlCommand(insertStr, con);
                cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("输入数据违反要求");
            }
            finally
            {
                con.Dispose();
            }
            this.courseTableAdapter.Fill(this.student_information_management_systemDataSet4.Course);
        }

        private void manage_course_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“student_information_management_systemDataSet4.Course”中。您可以根据需要移动或删除它。
            this.courseTableAdapter.Fill(this.student_information_management_systemDataSet4.Course);

        }

        private void Delete_Click(object sender, EventArgs e)
        {
            try
            {
                con.Open();
                string select_id = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();//选择的当前行第一列的值,也就是ID
                string delete_by_id = "delete from Course where 课程号=" + select_id;//sql删除语句
                SqlCommand cmd = new SqlCommand(delete_by_id, con);
                cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("请正确选择行!");
            }
            finally
            {
                con.Dispose();
            }
            this.courseTableAdapter.Fill(this.student_information_management_systemDataSet4.Course);
        }

        private void Update_Click(object sender, EventArgs e)
        {
            String Cno = textBox1.Text.Trim();//课程号
            String Cname = textBox2.Text.Trim();//课程名
            String Credit = textBox3.Text.Trim();//学分
            String Cplace = textBox4.Text.Trim();//上课地点
            String Ctime = textBox5.Text.Trim();//上课时间
            try
            {
                con.Open();
                if (Cname != "")
                {
                    string insertStr = "UPDATE Course SET 课程名 = '" + Cname + "' WHERE   课程号='" + Cno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Credit != "")
                {
                    string insertStr = "UPDATE Course SET 学分 = '" + Credit + "' WHERE   课程号='" + Cno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Cplace != "")
                {
                    string insertStr = "UPDATE Course SET 上课地点 = '" + Cplace + "' WHERE   课程号='" + Cno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
                if (Ctime != "")
                {
                    string insertStr = "UPDATE Course SET 上课时间 = '" + Ctime + "' WHERE   课程号='" + Cno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
            }
            catch
            {
                MessageBox.Show("输入数据违反要求!");
            }
            finally
            {
                con.Dispose();
            }
            this.courseTableAdapter.Fill(this.student_information_management_systemDataSet4.Course);
        }

        private void Select_Click(object sender, EventArgs e)
        {
            String Cno = textBox1.Text.Trim();//课程号
            String Cname = textBox2.Text.Trim();//课程名
            String Credit = textBox3.Text.Trim();//学分
            String Cplace = textBox4.Text.Trim();//上课地点
            String Ctime = textBox5.Text.Trim();//上课时间
            String conn = "Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=********";
            SqlConnection sqlConnection = new SqlConnection(conn);
            try
            {
                if (Cno != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Course where 课程号='" + Cno + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Cname != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Course where 课程名 Like'" + Cname + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Credit != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Course where 学分='" + Credit + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Cplace != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Course where 上课地点 Like'" + Cplace + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Ctime != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Course where 上课时间 Like'" + Ctime + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
            }
            catch
            {
                MessageBox.Show("查询语句有误!");
            }
            finally
            {
                sqlConnection.Close();
            }
        }
    }
}

管理员管理成绩界面:

在这里插入图片描述

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

namespace 学生信息管理系统
{
    public partial class manage_SCcs : Form
    {
        SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=*********");
        public manage_SCcs()
        {
            InitializeComponent();
        }

        private void manage_SCcs_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“student_information_management_systemDataSet12.SC”中。您可以根据需要移动或删除它。
            this.sCTableAdapter1.Fill(this.student_information_management_systemDataSet12.SC);
            // TODO: 这行代码将数据加载到表“student_information_management_systemDataSet5.SC”中。您可以根据需要移动或删除它。
            //this.sCTableAdapter.Fill(this.student_information_management_systemDataSet5.SC);

        }

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

        private void Close_Click(object sender, EventArgs e)
        {
            manager_manage manager_manage1 = new manager_manage();
            manager_manage1.Show();
            this.Hide();
        }

        private void Insert_Click(object sender, EventArgs e)
        {

            String Sno = textBox1.Text.Trim();
            String Sname = textBox2.Text.Trim();
            String Cno = textBox3.Text.Trim();
            String Cname = textBox4.Text.Trim();
            String Grade = textBox5.Text.Trim();
            String Credit = textBox6.Text.Trim();

            try
            {
                con.Open();
                if(Grade!="" && Credit != "")
                {
                    string insertStr = "INSERT INTO SC(学号,姓名,课程号,课程名,成绩,学分) " +
                    "VALUES('" + Sno + "','" + Sname + "','" + Cno + "','" + Cname + "'," + Grade + "," + Credit + ")";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
                }
            }
            catch
            {
                MessageBox.Show("输入数据违反要求");
            }
            finally
            {
                con.Dispose();
            }
            this.sCTableAdapter1.Fill(this.student_information_management_systemDataSet12.SC);
        }

        private void Delete_Click(object sender, EventArgs e)
        {
            try
            {
                con.Open();
                string select_id1 = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();//选择的当前行第一列的值,也就是ID
                string select_id2 = dataGridView1.SelectedRows[0].Cells[2].Value.ToString().Trim();
                string delete_by_id = "delete from SC where 学号='" + select_id1+ "' AND 课程号='"+select_id2+ "'";//sql删除语句
                SqlCommand cmd = new SqlCommand(delete_by_id, con);
                cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("请正确选择行!");
            }
            finally
            {
                con.Dispose();
            }
            this.sCTableAdapter1.Fill(this.student_information_management_systemDataSet12.SC);
        }

        private void Update_Click(object sender, EventArgs e)
        {
            String Sno = textBox1.Text.Trim();
            String Cno = textBox3.Text.Trim();
            String Grade = textBox5.Text.Trim();
            try
            {
                con.Open();
                    string insertStr = "UPDATE SC SET 成绩 = " + Grade + " WHERE   学号='" + Sno + "' AND 课程号='"+ Cno + "'";
                    SqlCommand cmd = new SqlCommand(insertStr, con);
                    cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("输入数据违反要求!");
            }
            finally
            {
                con.Dispose();
            }
            this.sCTableAdapter1.Fill(this.student_information_management_systemDataSet12.SC);
        }

        private void Select_Click(object sender, EventArgs e)
        {
            String Sno = textBox1.Text.Trim();
            String Sname = textBox2.Text.Trim();
            String Cno = textBox3.Text.Trim();
            String Cname = textBox4.Text.Trim();
            String  Grade =textBox5.Text.Trim();
            String Credit = textBox6.Text.Trim();
            String conn = "Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=********";
            SqlConnection sqlConnection = new SqlConnection(conn);
            try
            {
                if (Sno != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from SC where 学号='" + Sno + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Sname != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from SC where 姓名 Like'" + Sname + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Cno != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from SC where 课程号='" + Cno + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Cname != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from SC where 课程名 Like'" + Cname + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Grade != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from SC where 成绩 =" + Grade ;
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Credit != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from SC where 学分=" + Credit;
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
              

            }
            catch
            {
                MessageBox.Show("查询语句有误!");
            }
            finally
            {
                sqlConnection.Close();
            }
        }
    }
}

学生功能界面:
在这里插入图片描述

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 学生信息管理系统
{
    public partial class student_manage : Form
    {
        public student_manage()
        {
            InitializeComponent();
        }

        private void student_manage_Load(object sender, EventArgs e)
        {
            label1.Text = Class1.UserID + " 你好,欢迎进入系统";
        }

        private void button5_Click(object sender, EventArgs e)
        {
            Form1 form1 = new Form1();
            form1.Show();
            this.Hide();
        }

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

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

        private void button2_Click(object sender, EventArgs e)
        {
            student_course student_course1 = new student_course();
            student_course1.Show();
            this.Hide();
        }
    }
}

学生查询成绩界面:
在这里插入图片描述

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

namespace 学生信息管理系统
{
    public partial class student_SC : Form
    {
        SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=************");
        public student_SC()
        {
            InitializeComponent();
        }

        private void student_SC_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“student_information_management_systemDataSet11.SC”中。您可以根据需要移动或删除它。
            this.sCTableAdapter1.Fill(this.student_information_management_systemDataSet11.SC);
            // TODO: 这行代码将数据加载到表“student_information_management_systemDataSet7.SC”中。您可以根据需要移动或删除它。
            this.sCTableAdapter.Fill(this.student_information_management_systemDataSet7.SC);
            String Sno = Class1.UserID;
            String conn = "Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=**************";
            SqlConnection sqlConnection = new SqlConnection(conn);
            try
            {
                sqlConnection.Open();
                String select_by_id = "select * from SC where 学号='" + Sno + "'";
                SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                BindingSource bindingSource = new BindingSource();
                bindingSource.DataSource = sqlDataReader;
                dataGridView1.DataSource = bindingSource;
            }
            catch
            {

            }
            finally
            {
                sqlConnection.Close();
            }
        }

        private void Close_Click(object sender, EventArgs e)
        {
            student_manage student_manage1 = new student_manage();
            student_manage1.Show();
            this.Hide();
        }

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

        private void button2_Click(object sender, EventArgs e)
        {
            String conn = "Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=****************";
            SqlConnection sqlConnection = new SqlConnection(conn);
            String str = Class1.UserID;
            try
            {
                sqlConnection.Open();
                String select_by_id = "select * from SC where 成绩<60 AND 学号='" + str + "'";
                SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                BindingSource bindingSource = new BindingSource();
                bindingSource.DataSource = sqlDataReader;
                dataGridView1.DataSource = bindingSource;
            }
            catch
            {
                MessageBox.Show("查询语句有误!");
            }
            finally
            {
                sqlConnection.Close();
            }
        }

        private void Select_Click(object sender, EventArgs e)
        {

            String Cno = textBox1.Text.Trim();
            String Cname = textBox2.Text.Trim();
            String str = Class1.UserID;
            String conn = "Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=****************";
            SqlConnection sqlConnection = new SqlConnection(conn);
            try
            {
                if (Cno != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from SC where 学号='" + str + "'AND 课程号='"+Cno+"'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Cname != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from SC where 学号='" + str + "'AND 课程名 Like'" + Cname + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }

            }
            catch
            {
                MessageBox.Show("查询语句有误!");
            }
            finally
            {
                sqlConnection.Close();
            }
        }
    }
}

学生选择课程、查询课程界面:
在这里插入图片描述

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

namespace 学生信息管理系统
{
    public partial class student_course : Form
    {
        SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=***********");
        public student_course()
        {
            InitializeComponent();
        }

        private void student_course_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“student_information_management_systemDataSet10.SC”中。您可以根据需要移动或删除它。
            this.sCTableAdapter1.Fill(this.student_information_management_systemDataSet10.SC);
            // TODO: 这行代码将数据加载到表“student_information_management_systemDataSet9.SC”中。您可以根据需要移动或删除它。
            this.sCTableAdapter.Fill(this.student_information_management_systemDataSet9.SC);
            // TODO: 这行代码将数据加载到表“student_information_management_systemDataSet8.Course”中。您可以根据需要移动或删除它。
            this.courseTableAdapter.Fill(this.student_information_management_systemDataSet8.Course);
            String Sno = Class1.UserID;
            String conn = "Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=**********";
            SqlConnection sqlConnection = new SqlConnection(conn);
            try
            {
                sqlConnection.Open();
                String select_by_id = "select * from SC where 学号='" + Sno + "'";
                SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                BindingSource bindingSource = new BindingSource();
                bindingSource.DataSource = sqlDataReader;
                dataGridView2.DataSource = bindingSource;
            }
            catch
            {

            }
            finally
            {
                sqlConnection.Close();
            }
        }

        private void Select_Click(object sender, EventArgs e)
        {
            String Cno = textBox1.Text.Trim();//课程号
            String Cname = textBox2.Text.Trim();//课程名
            String Credit = textBox3.Text.Trim();//学分
            String Cplace = textBox4.Text.Trim();//上课地点
            String Ctime = textBox5.Text.Trim();//上课时间
            String conn = "Data Source=.;Initial Catalog=student_information_management_system;User ID=sa;Password=**********";
            SqlConnection sqlConnection = new SqlConnection(conn);
            try
            {
                if (Cno != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Course where 课程号='" + Cno + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Cname != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Course where 课程名 Like'" + Cname + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Credit != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Course where 学分='" + Credit + "'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Cplace != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Course where 上课地点 Like'" + Cplace + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }
                if (Ctime != "")
                {
                    sqlConnection.Open();
                    String select_by_id = "select * from Course where 上课时间 Like'" + Ctime + "%'";
                    SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
                    SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = sqlDataReader;
                    dataGridView1.DataSource = bindingSource;
                }

            }
            catch
            {
                MessageBox.Show("查询语句有误!");
            }
            finally
            {
                sqlConnection.Close();
            }
        }

        private void Close_Click(object sender, EventArgs e)
        {
            student_manage student_manage1 = new student_manage();
            student_manage1.Show();
            this.Hide();
        }

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

        private void Insert_Click(object sender, EventArgs e)
        {
            String Cno = textBox1.Text.Trim();//课程号
            String Cname = textBox2.Text.Trim();//课程名
            String Sno = Class1.UserID;//学号
            try
            {
                con.Open();
                string insertStr = "INSERT INTO SC(课程号,课程名,学号) " +
                    "VALUES('" + Cno + "','" + Cname + "','" + Sno + "')";
                SqlCommand cmd = new SqlCommand(insertStr, con);
                cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("输入数据违反要求");
            }
            finally
            {
                con.Dispose();
            }
            this.sCTableAdapter.Fill(this.student_information_management_systemDataSet9.SC);
            /*this.sCTableAdapter1.Fill(this.student_information_management_systemDataSet10.SC);*/
        }
    }
}

实验效果讲解视频链接:

【2019-2020春学期】数据库实验大作业——学生信息管理系统功能讲解

心得:

终于完成大作业啦,开心
在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章