ASP.NET 学期课程设计(排课系统)

1.开发环境

WIN10 + VS2022 + SQLsever 2019

2.适用对象

本项目适用于初学者,对java有一定的了解,了解前端的基础知识。

对MVC有一定的了解(虽然本项目没有使用MVC三层框架),但是还是需要了解一下的。

知道SQLsever数据库的链接,会对数据库进行增删改查。

3.项目简介

该项目取自其他博主,我在此基础上另加了修改。

项目主要分为两个角色

1.管理员角色

管理员可以增加专业系别,每个系别可以有多个班级。可以添加开设课程,可以添加教师角色,可以安排教学计划,根据教学计划与专业生成教学任务。在添加完教学任务之后,就可以对教学任务进行排课。审批教师申请的禁忌排课。在排课的过程中,可以根据教师的禁忌来避免某一天某一节教师无法上课的情况。

2.教师角色

教师的功能较为单一,教师的功能仅为查看管理员安排的课程以及申请禁忌排课(禁忌排课的意思是,教师选择时间,在该时间段内管理员无法安排上课)

不多bb,直接上代码。

4.代码展示

1.建库

/*
 Navicat Premium Data Transfer

 Source Server         : 2
 Source Server Type    : SQL Server
 Source Server Version : 15002000
 Source Host           : DESKTOP-GPVIVP1\SQLEXPRESS:1433
 Source Catalog        : mke
 Source Schema         : dbo

 Target Server Type    : SQL Server
 Target Server Version : 15002000
 File Encoding         : 65001

 Date: 06/06/2022 21:18:07
*/


-- ----------------------------
-- Table structure for cheap
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[cheap]') AND type IN ('U'))
	DROP TABLE [dbo].[cheap]
GO

CREATE TABLE [dbo].[cheap] (
  [id] int  IDENTITY(1,1) NOT NULL,
  [title] nchar(10) COLLATE Chinese_PRC_CI_AS  NULL,
  [context] nchar(255) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[cheap] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for course
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[course]') AND type IN ('U'))
	DROP TABLE [dbo].[course]
GO

CREATE TABLE [dbo].[course] (
  [id] varchar(50) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [cuorsename] varchar(50) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[course] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for customer
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[customer]') AND type IN ('U'))
	DROP TABLE [dbo].[customer]
GO

CREATE TABLE [dbo].[customer] (
  [id] int  IDENTITY(1,1) NOT NULL,
  [name] nchar(10) COLLATE Chinese_PRC_CI_AS  NULL,
  [pwd] nchar(10) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[customer] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for t_admin
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[t_admin]') AND type IN ('U'))
	DROP TABLE [dbo].[t_admin]
GO

CREATE TABLE [dbo].[t_admin] (
  [id] int  IDENTITY(1,1) NOT NULL,
  [username] varchar(25) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [userpwd] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[t_admin] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for t_courseplan
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[t_courseplan]') AND type IN ('U'))
	DROP TABLE [dbo].[t_courseplan]
GO

CREATE TABLE [dbo].[t_courseplan] (
  [id] int  IDENTITY(1,1) NOT NULL,
  [courseid] varchar(25) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [coursename] varchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [khtype] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL,
  [score] float(53) DEFAULT 0 NULL,
  [xueshiall] int DEFAULT 0 NULL,
  [xueshijiangshou] int DEFAULT 0 NULL,
  [xueshishiyan] int DEFAULT 0 NULL,
  [major] varchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [grade] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[t_courseplan] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for t_coursetable
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[t_coursetable]') AND type IN ('U'))
	DROP TABLE [dbo].[t_coursetable]
GO

CREATE TABLE [dbo].[t_coursetable] (
  [id] int  IDENTITY(1,1) NOT NULL,
  [taskid] int  NOT NULL,
  [weekdays] varchar(5) COLLATE Chinese_PRC_CI_AS  NULL,
  [sections] varchar(5) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[t_coursetable] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for t_coursetask
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[t_coursetask]') AND type IN ('U'))
	DROP TABLE [dbo].[t_coursetask]
GO

CREATE TABLE [dbo].[t_coursetask] (
  [id] int  IDENTITY(1,1) NOT NULL,
  [xuhao] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL,
  [courseid] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL,
  [major] varchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [grade] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL,
  [coursename] varchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [coursexingzhi] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL,
  [xueshiall] int DEFAULT 0 NULL,
  [xueshijiangshou] int DEFAULT 0 NULL,
  [xueshishiyan] int DEFAULT 0 NULL,
  [xueshiallz] int DEFAULT 0 NULL,
  [xueshijiangshouz] int DEFAULT 0 NULL,
  [xueshishiyanz] int DEFAULT 0 NULL,
  [zhouci] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL,
  [khtype] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL,
  [courserongliang] int DEFAULT 0 NULL,
  [teachidz] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL,
  [teachidf] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL,
  [teachids] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL,
  [dianjiao] varchar(10) COLLATE Chinese_PRC_CI_AS  NULL,
  [shuangyu] varchar(10) COLLATE Chinese_PRC_CI_AS  NULL,
  [remark] text COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[t_coursetask] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for t_major
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[t_major]') AND type IN ('U'))
	DROP TABLE [dbo].[t_major]
GO

CREATE TABLE [dbo].[t_major] (
  [id] int  IDENTITY(1,1) NOT NULL,
  [name] varchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [remark] text COLLATE Chinese_PRC_CI_AS  NULL,
  [nums] int  NULL
)
GO

ALTER TABLE [dbo].[t_major] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for t_taboo
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[t_taboo]') AND type IN ('U'))
	DROP TABLE [dbo].[t_taboo]
GO

CREATE TABLE [dbo].[t_taboo] (
  [id] int  IDENTITY(1,1) NOT NULL,
  [weekdays] varchar(5) COLLATE Chinese_PRC_CI_AS  NULL,
  [sections] varchar(5) COLLATE Chinese_PRC_CI_AS  NULL,
  [weeksstart] varchar(5) COLLATE Chinese_PRC_CI_AS  NULL,
  [weeksend] varchar(5) COLLATE Chinese_PRC_CI_AS  NULL,
  [tabootype] varchar(1) COLLATE Chinese_PRC_CI_AS  NULL,
  [teachid] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL,
  [shenhe] varchar(1) COLLATE Chinese_PRC_CI_AS DEFAULT '0' NULL
)
GO

ALTER TABLE [dbo].[t_taboo] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for t_teacher
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[t_teacher]') AND type IN ('U'))
	DROP TABLE [dbo].[t_teacher]
GO

CREATE TABLE [dbo].[t_teacher] (
  [id] int  IDENTITY(1,1) NOT NULL,
  [teachid] varchar(25) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [name] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL,
  [zhicheng] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL,
  [xueli] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL,
  [pwd] varchar(25) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[t_teacher] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Auto increment value for cheap
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[cheap]', RESEED, 3)
GO


-- ----------------------------
-- Primary Key structure for table course
-- ----------------------------
ALTER TABLE [dbo].[course] ADD CONSTRAINT [PK__course__2AAB4BC91CA7902C] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for customer
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[customer]', RESEED, 1)
GO


-- ----------------------------
-- Primary Key structure for table customer
-- ----------------------------
ALTER TABLE [dbo].[customer] ADD CONSTRAINT [PK__customer__3213E83F0EFF8F8E] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for t_admin
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[t_admin]', RESEED, 1)
GO


-- ----------------------------
-- Primary Key structure for table t_admin
-- ----------------------------
ALTER TABLE [dbo].[t_admin] ADD CONSTRAINT [PK__t_admin__3213E83F0E27AD1E] PRIMARY KEY CLUSTERED ([id], [username])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for t_courseplan
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[t_courseplan]', RESEED, 21)
GO


-- ----------------------------
-- Auto increment value for t_coursetable
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[t_coursetable]', RESEED, 34)
GO


-- ----------------------------
-- Auto increment value for t_coursetask
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[t_coursetask]', RESEED, 24)
GO


-- ----------------------------
-- Auto increment value for t_major
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[t_major]', RESEED, 9)
GO


-- ----------------------------
-- Auto increment value for t_taboo
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[t_taboo]', RESEED, 7)
GO


-- ----------------------------
-- Auto increment value for t_teacher
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[t_teacher]', RESEED, 4)
GO


-- ----------------------------
-- Primary Key structure for table t_teacher
-- ----------------------------
ALTER TABLE [dbo].[t_teacher] ADD CONSTRAINT [PK__t_teache__933C7873F3A0936C] PRIMARY KEY CLUSTERED ([teachid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO

2.登录

//核心代码

 if (RadioButton2.Checked)  //管理员
            {
                if (Operation.getDatatable("select * from t_admin where username='" + this.username.Text + "' and userpwd='" + this.password.Text + "'").Rows.Count < 1)
                {
                    WebMessageBox.Show("用户或密码错误"); return;
                }
                Session["username"] = username.Text;
                Response.Redirect("admin/index.aspx");
            }
            else { 
                //教师
                DataTable dt=Operation.getDatatable("select * from t_teacher where teachid='" + this.username.Text + "' and pwd='" + this.password.Text + "'");
                if (dt.Rows.Count < 1)
                {
                    WebMessageBox.Show("用户或密码错误"); return;
                }
                Session["teachid"] = username.Text;
                Session["teachname"] = dt.Rows[0]["name"].ToString();
                Response.Redirect("teacher/index.aspx");

 点击登录按钮后会进行函数调用,若选择管理员从t_amdin 表里查询用户名密码查询是否存在,查询成功后添加管理员session(session存放在客户端还是服务端?),添加完session之后跳转到对应角色的首页,教师同理。

3.管理员

3.1专业管理,教师管理,开设课程

太简单了一看就会

3.2新增教学计划(浅说一下)

//核心代码

Label1.Text = Session["username"].ToString();
                DropDownList1.DataSource = Operation.getDatatable("select name from t_major");//设置数据源
                DropDownList1.DataTextField = "name";//设置所要读取的数据表里的列名

                //课程名称
                DropDownList3.DataSource = Operation.getDatatable("select cuorsename from course");//设置数据源
                DropDownList3.DataTextField = "cuorsename";//设置所要读取的数据表里的列名

                DropDownList1.DataBind();//数据绑定
                DropDownList3.DataBind();//数据绑定
               
                DropDownList2.Items.Add("2018");
                DropDownList2.Items.Add("2019");
                DropDownList2.Items.Add("2020");
                DropDownList2.Items.Add("2021");
                DropDownList2.Items.Add("2022");
                DropDownList2.Items.Add("2023");
                DropDownList2.Items.Add("2024");
                DropDownList2.Items.Add("2025");

 对专业名称,年级,课程名称这三个控件进行数据绑定。(DISTINCT的意思是取唯一值,不会出现重复)

 DataTable dt1 = Operation.getDatatable("select * from t_courseplan where coursename='" + DropDownList3.SelectedValue.ToString() + "' and  major='" + DropDownList1.SelectedValue.ToString() + "' and grade ='"
                + DropDownList2.SelectedValue.ToString() + "'");
            if (dt1.Rows.Count >= 1) {
                WebMessageBox.Show("教学计划已经添加,不要重复添加");return;
            }
            DataTable dt = Operation.getDatatable("select * from course where cuorsename='" + DropDownList3.SelectedValue.ToString() + "'");
            string sql = "insert into t_courseplan(courseid,coursename,khtype,score,xueshiall,xueshijiangshou,xueshishiyan,major,grade) values('"+
                dt.Rows[0]["id"] + "','"+ DropDownList3.SelectedValue.ToString() + "','"+TextBox3.Text+"','"+TextBox4.Text+"','"+
                TextBox5.Text+"','"+TextBox6.Text+"','"+TextBox7.Text+"','"+DropDownList1.SelectedValue.ToString()+"','"+DropDownList2.SelectedValue.ToString()+"')";
            Operation.runSql(sql);
            WebMessageBox.Show("添加完成","courseplan.aspx");

此处为甚有两个查询那首先第一个查询的作用是查询是否存在重复的教学计划,同一个表中不允许出现相同的教学计划(整个数据库没有用外键连接,也没有触发器,外键功能是通过代码逻辑实现的)。第二个select查询是什么意思那?第二个查询是给下面的插入服务的,因为在插入教学计划时没有课程id信息所以需要查询根据课程名查询课程id并且将课程id插入到课程计划表中。插入完成之后会有提示信息,并且将跳转到课程计划展示界面。

(其余功能太多,详细展开篇幅太大,如果有什么问题不会请看完本篇文章之后邮箱联系我)

4.教师

教师功能较为单一,尽可以查看管理员安排的课程。

5.总结

因为我也是个菜鸟,大家如果觉得很捞请在心里默默的说句撒比。如果想获取完整项目的话邮箱d我,或者有问题也请截图说明问题,我看之后会回的。yuzhi6966295@163.com

谢谢各位可以看到这里,感谢!!!

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值