一、引言
学生信息管理系统是现代学校管理的重要组成部分,它能够有效地管理学生的基本信息、课程信息、成绩信息等,提高学校管理的效率和质量。本文将介绍如何使用SQL Server数据库和C#语言在.NET平台上开发一个学生信息管理系统的课程设计项目。
二、项目概述
学生信息管理系统旨在为学校提供一个完善的学生信息管理平台,包括注册登录、专业管理、班级管理和学生信息管理等功能。该系统将采用C#语言进行开发,利用.NET平台提供的丰富功能和框架,同时使用SQL Server作为数据库支持,以确保系统的稳定性和性能。
三、系统功能
注册登录功能:
注册:学生和教师用户可以通过输入用户名、密码和个人信息完成注册。登录:已注册的用户可以使用用户名和密码进行登录,以访问系统的其他功能模块。专业管理功能:
添加专业:管理员用户可以添加新的专业信息,包括专业名称、专业代码等。修改专业:管理员用户可以修改已有专业的信息,如名称、代码等。删除专业:管理员用户可以删除不再需要的专业信息。班级管理功能:
添加班级:管理员用户可以添加新的班级信息,包括班级名称、所属专业、班级编号等。修改班级:管理员用户可以修改已有班级的信息,如名称、所属专业等。删除班级:管理员用户可以删除不再需要的班级信息。学生信息管理功能:
添加学生:管理员用户和教师用户可以添加新的学生信息,包括学号、姓名、性别、年龄、联系方式等。修改学生信息:管理员用户和教师用户可以修改已有学生的信息。删除学生:管理员用户和教师用户可以删除不再需要的学生信息。查询学生信息:管理员用户和教师用户可以根据条件查询学生信息,如学号、姓名、班级等。四、数据库分析
在学生信息管理系统中,我们设计了以下表来存储学校的相关信息:
college(学院表):
该表存储学校的各个学院信息。包括字段:Id(学院编号,自增主键)、Name(学院名称)。major(专业表):
该表存储各个学院下的专业信息。包括字段:Id(专业编号,自增主键)、Name(专业名称)、CollegeId(所属学院编号,外键关联到college表的Id字段,级联删除)。majorClass(班级表):
该表存储各个专业下的班级信息。包括字段:Id(班级编号,自增主键)、Name(班级名称)、MajorId(所属专业编号,外键关联到major表的Id字段,级联删除)。student(学生表):
该表存储学生的基本信息。包括字段:Id(学号,主键)、Name(姓名)、MajorClassId(所属班级编号,外键关联到majorClass表的Id字段,级联删除)、Age(年龄)、Sex(性别)。siuser(系统用户表):
该表存储系统用户的信息,包括管理员和教师用户。包括字段:Id(用户编号,自增主键)、Username(用户名)、Pwd(密码)、CollegeId(所属学院编号,外键关联到college表的Id字段,级联删除)。这些表之间通过外键关联建立了关系,以便于实现数据的一致性和完整性。同时,对于学院、专业和班级信息的层级结构,我们通过相应的外键关联来实现了级联删除,以确保数据的完整性和关联性。
五、关键代码
StudentManagementWindow
using NPOI.Util;using StudentInfoManagmentSystem.Model;using StudentInfoManagmentSystem.ViewModel;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Shapes;namespace StudentInfoManagmentSystem.View { /// <summary> /// Interaction logic for StudentManagementWindow.xaml /// </summary> public partial class StudentManagementWindow { StudentManagementViewModel _smvm; public StudentManagementWindow() { InitializeComponent(); _smvm = Grid.DataContext as StudentManagementViewModel; for (int i = 12; i < 51; i++) { CBAge.Items.Add(i); } } private void Window_MouseDown(object sender, MouseButtonEventArgs e) { DragMove(); } private void BtnReSelect_Click(object sender, RoutedEventArgs e) { CurrentMajorClass.ID = -1; new MajorClassManagementWindow().Show(); Close(); } private void BtnExport_Click(object sender, RoutedEventArgs e) { var sfd = Util.FileDialogFactory.GetSFD("Excel 97-2003|*.xls|Excel 2007|*.xlsx"); if (!(bool) sfd.ShowDialog()) return; var dt = _smvm.ToDataTable(); Util.ExcelIO.Write(sfd.FileName, dt); } private void BtnSave_Click(object sender, RoutedEventArgs e) { _smvm.Save(); } private void BtnAdd_Click(object sender, RoutedEventArgs e) { TBProm.Visibility = Visibility.Hidden; TBProm.Foreground = Brushes.Red; var id = TBId.Text.Trim(); var name = TBName.Text.Trim(); if (Util.StringUtil.IsAnyNullOrEmpty(id, name)) { TBProm.Text = "请填写完整信息"; TBProm.Visibility = Visibility.Visible; return; } if (DBHelper.ExistStudent(id)) { TBProm.Text = "已存在相同学号学生"; TBProm.Visibility = Visibility.Visible; return; } if (CBAge.SelectedIndex < 0) { TBProm.Text = "请选择年龄"; TBProm.Visibility = Visibility.Visible; return; } var age = (int) (CBAge.SelectedItem); var sex = (bool) RBMale.IsChecked ? "男" : "女"; var s = new Student { Id = id, Age = age, Name = name, Sex = sex, MajorClassId = CurrentMajorClass.ID }; _smvm.Add(s); TBProm.Foreground = Brushes.SeaGreen; TBProm.Text = "添加成功"; TBProm.Visibility = Visibility.Visible; } private void BtnDelete_Click(object sender, RoutedEventArgs e) { _smvm.Remove(); } private void CBAll_Checked(object sender, RoutedEventArgs e) { foreach (var item in _smvm.Students) { item.IsSelected = true; } } private void CBAll_Unchecked(object sender, RoutedEventArgs e) { foreach (var item in _smvm.Students) { item.IsSelected = false; } } }}
MajorManagementWindw
using StudentInfoManagmentSystem.Model;using StudentInfoManagmentSystem.ViewModel;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Shapes;namespace StudentInfoManagmentSystem.View { /// <summary> /// Interaction logic for MajorManagementWindow.xaml /// </summary> public partial class MajorManagementWindow { MajorManagementViewModel _mmvm; public MajorManagementWindow() { InitializeComponent(); _mmvm = Grid.DataContext as MajorManagementViewModel; } private void MetroWindow_MouseDown(object sender, MouseButtonEventArgs e) { DragMove(); } private void BTNSignOff_Click(object sender, RoutedEventArgs e) { CurrentUser.SignOff(); new MainWindow().Show(); Close(); } private void BtnDelete_Click(object sender, RoutedEventArgs e) { var ret = MessageBox.Show("确定删除?", "提示", MessageBoxButton.YesNo); if (ret == MessageBoxResult.No) return; _mmvm.Remove(int.Parse((sender as Button).Tag.ToString())); } private void BtnSelect_Click(object sender, RoutedEventArgs e) { int id = int.Parse((sender as Button).Tag.ToString()); CurrentMajor.ID = id; new MajorClassManagementWindow().Show(); Close(); } private void BtnExport_Click(object sender, RoutedEventArgs e) { var sfd = Util.FileDialogFactory.GetSFD("Excel 97-2003|*.xls|Excel 2007|*.xlsx"); if (!(bool) sfd.ShowDialog()) return; var dt = _mmvm.ToDataTable(); Util.ExcelIO.Write(sfd.FileName, dt); } private void BtnAdd_Click(object sender, RoutedEventArgs e) { var newMajorName = TBNewMajor.Text.Trim(); if (string.IsNullOrEmpty(newMajorName)) return; _mmvm.Add(new Major { Name = newMajorName, CollegeId = CurrentUser.GetCollegeId() }); } }}
MajorClassManagementWindow
using StudentInfoManagmentSystem.Model;using StudentInfoManagmentSystem.ViewModel;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Shapes;namespace StudentInfoManagmentSystem.View { /// <summary> /// Interaction logic for MajorClassMagementWindow.xaml /// </summary> public partial class MajorClassManagementWindow { MajorClassManagementViewModel _mcmvm; public MajorClassManagementWindow() { InitializeComponent(); _mcmvm = Grid.DataContext as MajorClassManagementViewModel; } private void MetroWindow_MouseDown(object sender, MouseButtonEventArgs e) { DragMove(); } private void BtnReSelect_Click(object sender, RoutedEventArgs e) { CurrentMajor.ID = -1; new MajorManagementWindow().Show(); Close(); } private void BtnDelete_Click(object sender, RoutedEventArgs e) { var ret = MessageBox.Show("确定删除?", "提示", MessageBoxButton.YesNo); if (ret == MessageBoxResult.No) return; _mcmvm.Remove(int.Parse((sender as Button).Tag.ToString())); } private void BtnSelect_Click(object sender, RoutedEventArgs e) { int id = int.Parse((sender as Button).Tag.ToString()); CurrentMajorClass.ID = id; new StudentManagementWindow().Show(); Close(); } private void BtnAdd_Click(object sender, RoutedEventArgs e) { var newMajorClassName = TBNewMajorClass.Text.Trim(); if (string.IsNullOrEmpty(newMajorClassName)) return; _mcmvm.Add(new MajorClass { Name = newMajorClassName, MajorId = CurrentMajor.ID }); } private void BtnExport_Click(object sender, RoutedEventArgs e) { var sfd = Util.FileDialogFactory.GetSFD("Excel 97-2003|*.xls|Excel 2007|*.xlsx"); if (!(bool) sfd.ShowDialog()) return; var dt = _mcmvm.ToDataTable(); Util.ExcelIO.Write(sfd.FileName, dt); } }}
六、程序截图
七、联系与交流
q:969060742 完整代码、sql