C# 实现学生管理系统【源码】

用c#实现学生管理系统,使用的是vs2019 windows10
数据库源码 和 源代码
制作不易请点赞收藏加关注
本人微-信-公-众-号
【云日记Journal】

学生管理系统

导入数据库和获取链接池

可以查看这一篇文章
sqlserver链接字符串

- 创建数据库   
CREATE DATABASE DATA_STU
ON   PRIMARY
 (NAME = 'DATA_STU', 
FILENAME = 'Z:\DATA\DATA_STU.MDF' , 
SIZE = 5MB, 
MAXSIZE = 20MB, 
FILEGROWTH = 20%)
LOG ON 
(NAME ='DATA_STU_LOG', 
FILENAME = 'Z:\DATA\DATA_STU_LOG. LDF', 
SIZE = 5MB, 
MAXSIZE = 10MB,
FILEGROWTH = 2MB)


--使用数据库
USE DATA_STU;

-- 创建表 

--课程表
IF OBJECT_ID('Course_Info') IS NOT NULL   
            DROP TABLE Course_Info
CREATE TABLE Course_Info (
  Id INT IDENTITY(1,1) PRIMARY KEY,
  Course_Name VARCHAR(50) NOT NULL,
  Credit INT NOT NULL,
  Teacher VARCHAR(50) NOT NULL
);
-- 学生信息表
IF OBJECT_ID('Student_Info') IS NOT NULL   
            DROP TABLE Student_Info
CREATE TABLE Student_Info (
  StudentId VARCHAR(20) PRIMARY KEY,
  Name VARCHAR(50) NOT NULL,
  Gender VARCHAR(10) NOT NULL,
  School VARCHAR(50),
);


-- 成绩表
IF OBJECT_ID('Score_Info') IS NOT NULL   
            DROP TABLE Score_Info
CREATE TABLE Score_Info (
  Id INT IDENTITY(1,1) PRIMARY KEY,
  StudentId VARCHAR(20) NOT NULL,
  Course_Id INT NOT NULL,
  Score DECIMAL(5,2) NOT NULL,
  FOREIGN KEY (StudentId)
    REFERENCES Student_Info (StudentId)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  FOREIGN KEY (Course_Id)
    REFERENCES Course_Info (Id)
    ON DELETE CASCADE
    ON UPDATE CASCADE
);

-- 考勤表
IF OBJECT_ID('Attendance_Info') IS NOT NULL   
            DROP TABLE Attendance_Info
CREATE TABLE Attendance_Info (
  Id INT IDENTITY(1,1) PRIMARY KEY,
  Course_Name VARCHAR(50) NOT NULL,
  Student_Id VARCHAR(20) NOT NULL,
  Attendance_Date DATE NOT NULL,
  Attendance_Status VARCHAR(50) NOT NULL,
  CONSTRAINT FK_AttendanceInfo_StudentInfo FOREIGN KEY (Student_Id) REFERENCES Student_Info (StudentId)
);

-- 账号
-- 学生账号
IF OBJECT_ID('Student_Account') IS NOT NULL   
            DROP TABLE Student_Account
CREATE TABLE Student_Account (
  StudentId VARCHAR(20) PRIMARY KEY,
  Password VARCHAR(50) NOT NULL,
  CONSTRAINT FK_StudentAccount_StudentInfo FOREIGN KEY (StudentId) REFERENCES Student_Info (StudentId)
);
select *from Student_Info;
-- 管理员账号
IF OBJECT_ID('Admin_Account') IS NOT NULL   
            DROP TABLE Admin_Account
CREATE TABLE Admin_Account (
  Id INT IDENTITY(1,1) PRIMARY KEY,
  Username VARCHAR(50) NOT NULL,
  Password VARCHAR(50) NOT NULL
);

-- 排名表
IF OBJECT_ID('Ranking') IS NOT NULL   
            DROP TABLE Ranking
CREATE TABLE Ranking (
  Ranking_Id INT PRIMARY KEY,
  StudentId VARCHAR(20),
  TotalScore FLOAT,
  Ranking INT,
  FOREIGN KEY (StudentId) REFERENCES Student_Info(StudentId)
);



-- 向课程表中添加4个课程
INSERT INTO Course_Info (Course_Name, Credit, Teacher)
VALUES ('Java', 4, 'Mr. Zhang');

INSERT INTO Course_Info (Course_Name, Credit, Teacher)
VALUES ('C#面向对象程序设计', 3, 'Ms. Li');

INSERT INTO Course_Info (Course_Name, Credit, Teacher)
VALUES ('Android开发', 5, 'Mr. Wang');

INSERT INTO Course_Info (Course_Name, Credit, Teacher)
VALUES ('微信小程序开发', 2, 'Ms. Zhao');

-- 向学生信息表中添加4个学生
INSERT INTO Student_Info (StudentId, Name, Gender, School)
VALUES ('2023000', '张三', '男', 'No.1 High School');

INSERT INTO Student_Info (StudentId, Name, Gender, School)
VALUES ('2023001', '李四', '女', 'No.1 High School');

INSERT INTO Student_Info (StudentId, Name, Gender, School)
VALUES ('2023002', '王五', '男', 'No.1 High School');

INSERT INTO Student_Info (StudentId, Name, Gender, School)
VALUES ('2023003', '赵六', '女', 'No.1 High School');

-- 向成绩表中添加相应的成绩数据
-- 为学号为2023000的学生添加Java和微信小程序开发两门成绩
INSERT INTO Score_Info(StudentId, Course_Id, Score)
VALUES ('2023000', 1, 85.0);

INSERT INTO Score_Info (StudentId, Course_Id, Score)
VALUES ('2023000', 4, 78.5);

-- 为学号为2023001的学生添加C#面向对象程序设计成绩
INSERT INTO Score_Info (StudentId, Course_Id, Score)
VALUES ('2023001', 2, 92.0);

-- 为学号为2023002的学生添加Android开发成绩
INSERT INTO Score_Info (StudentId, Course_Id, Score)
VALUES ('2023002', 3, 87.5);

-- 为学号为2023003的学生添加Java和Android开发两门成绩
INSERT INTO Score_Info (StudentId, Course_Id, Score)
VALUES ('2023003', 1, 95.5);

INSERT INTO Score_Info (StudentId, Course_Id, Score)
VALUES ('2023003', 3, 89.0);


--创建账号

-- 插入自定义学号(即主键)
INSERT INTO Student_Account(StudentId, Password)
VALUES ( '2023000','123456');
INSERT INTO Student_Account(StudentId, Password)
VALUES ( '2023001','123456');
INSERT INTO Student_Account(StudentId, Password)
VALUES ( '2023002','123456');
INSERT INTO Student_Account(StudentId, Password)
VALUES ( '2023003','123456');



INSERT INTO Admin_Account 
VALUES ( 'admin','12345');


-- 插入考勤数据
INSERT INTO Attendance_Info (Course_Name, Student_Id, Attendance_Date, Attendance_Status)
VALUES
('Java', '2023000', '2023-06-01', '出勤'),
('Java', '2023001', '2023-06-01', '缺勤'),
('Java', '2023002', '2023-06-01', '迟到'),
('Java', '2023003', '2023-06-01', '出勤'),
('C#面向对象程序设计', '2023000', '2023-06-01', '出勤'),
('C#面向对象程序设计', '2023001', '2023-06-01', '缺勤'),
('C#面向对象程序设计', '2023002', '2023-06-01', '迟到'),
('C#面向对象程序设计', '2023003', '2023-06-01', '出勤'),
('Android开发', '2023000', '2023-06-01', '出勤'),
('Android开发', '2023001', '2023-06-01', '缺勤'),
('Android开发', '2023002', '2023-06-01', '迟到'),
('Android开发', '2023003', '2023-06-01', '出勤'),
('微信小程序开发', '2023000', '2023-06-01', '出勤'),
('微信小程序开发', '2023001', '2023-06-01', '缺勤'),
('微信小程序开发', '2023002', '2023-06-01', '迟到'),
('微信小程序开发', '2023003', '2023-06-01', '出勤');



----------------------------------------------------------------------


如果是高版本的导入会遇到
问题

这个问题,然后选择第一个就好了,然后就可以进去项目了。

启动

login
登录界面
管理员登录
这里用管理员展示
账号 :admin
密码:12345

主页
查询
修改学生信息
设置
还有一些不展示了,兄弟们获取源码,自己去琢磨!
赞赏
感谢支持,创作不易

获取源码

   关注

微-信-公-众-号
【云日记Journal】
发送: c#项目