❥ 项目采用多种设计模式设计,功能丰富,能很好地应对课设答辩 ❥
目录
⭐️项目功能简介
⭐️部分代码展示
❥ ClassDao.java
❥ CourseDao.java
⭐️具体功能展示
❀ 登录界面
❀ 查看课本价钱
❀ 管理员界面
❀ 管理员查看老师档案
❀ 管理员查看学生档案
❀ 管理员查看学生课程
❀ 管理员查看学生选课
❀ 老师界面
❀ 学生选课
❀ 学生请假
❀ 学生上课签到
❀ 学生修改密码
⭐️设计模式类图设计
❥ 策略模式如下
设计一个允许多人管理使用的,多功能的信息管理系统,主要功能包括:
- ☀️导航菜单
- ☀️学生档案管理
- ☀️课程类型管理
- ☀️老师档案管理
- ☀️学生课程管理
- ☀️选课信息管理
- ☀️学生到课管理
- ☀️请假信息管理
- ☀️教材费用信息列表
package com.ischoolbar.programmer.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.ischoolbar.programmer.model.Clazz;
import com.ischoolbar.programmer.model.Page;
import com.ischoolbar.programmer.util.StringUtil;
public class ClazzDao extends BaseDao {
public List getClazzList(Clazz clazz,Page page){
List ret = new ArrayList();
String sql = "select * from s_clazz ";
if(!StringUtil.isEmpty(clazz.getName())){
sql += "where name like '%" + clazz.getName() + "%'";
}
sql += " limit " + page.getStart() + "," + page.getPageSize();
ResultSet resultSet = query(sql);
try {
while(resultSet.next()){
Clazz cl = new Clazz();
cl.setId(resultSet.getInt("id"));
cl.setName(resultSet.getString("name"));
cl.setInfo(resultSet.getString("info"));
ret.add(cl);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ret;
}
public int getClazzListTotal(Clazz clazz){
int total = 0;
String sql = "select count(*)as total from s_clazz ";
if(!StringUtil.isEmpty(clazz.getName())){
sql += "where name like '%" + clazz.getName() + "%'";
}
ResultSet resultSet = query(sql);
try {
while(resultSet.next()){
total = resultSet.getInt("total");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return total;
}
public boolean addClazz(Clazz clazz){
String sql = "insert into s_clazz values(null,'"+clazz.getName()+"','"+clazz.getInfo()+"') ";
return update(sql);
}
public boolean deleteClazz(int id){
String sql = "delete from s_clazz where id = "+id;
return update(sql);
}
public boolean editClazz(Clazz clazz) {
// TODO Auto-generated method stub
String sql = "update s_clazz set name = '"+clazz.getName()+"',info = '"+clazz.getInfo()+"' where id = " + clazz.getId();
return update(sql);
}
}
package com.ischoolbar.programmer.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.ischoolbar.programmer.model.Clazz;
import com.ischoolbar.programmer.model.Course;
import com.ischoolbar.programmer.model.Page;
import com.ischoolbar.programmer.util.StringUtil;
public class CourseDao extends BaseDao {
public boolean addCourse(Course course){
String sql = "insert into s_course values(null,'"+course.getName()+"',"+course.getTeacherId()+",'"+course.getCourseDate()+"',0,"+course.getMaxNum()+",'"+course.getInfo()+"') ";
return update(sql);
}
public List getCourseList(Course course,Page page){
List ret = new ArrayList();
String sql = "select * from s_course ";
if(!StringUtil.isEmpty(course.getName())){
sql += "and name like '%" + course.getName() + "%'";
}
if(course.getTeacherId() != 0){
sql += " and teacher_id = " + course.getTeacherId() + "";
}
sql += " limit " + page.getStart() + "," + page.getPageSize();
ResultSet resultSet = query(sql.replaceFirst("and", "where"));
try {
while(resultSet.next()){
Course cl = new Course();
cl.setId(resultSet.getInt("id"));
cl.setName(resultSet.getString("name"));
cl.setTeacherId(resultSet.getInt("teacher_id"));
cl.setCourseDate(resultSet.getString("course_date"));
cl.setSelectedNum(resultSet.getInt("selected_num"));
cl.setMaxNum(resultSet.getInt("max_num"));
cl.setInfo(resultSet.getString("info"));
ret.add(cl);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ret;
}
public int getCourseListTotal(Course course){
int total = 0;
String sql = "select count(*)as total from s_course ";
if(!StringUtil.isEmpty(course.getName())){
sql += "and name like '%" + course.getName() + "%'";
}
if(course.getTeacherId() != 0){
sql += " and teacher_id = " + course.getTeacherId() + "";
}
ResultSet resultSet = query(sql.replaceFirst("and", "where"));
try {
while(resultSet.next()){
total = resultSet.getInt("total");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return total;
}
public boolean editCourse(Course course) {
// TODO Auto-generated method stub
String sql = "update s_course set name = '"+course.getName()+"',teacher_id = "+course.getTeacherId()+",course_date = '"+course.getCourseDate()+"',max_num = "+course.getMaxNum()+" ,info = '"+course.getInfo()+"' where id = " + course.getId();
return update(sql);
}
public boolean deleteCourse(String ids) {
// TODO Auto-generated method stub
String sql = "delete from s_course where id in("+ids+")";
return update(sql);
}
public boolean isFull(int courseId){
boolean ret = false;
String sql = "select * from s_course where selected_num >= max_num and id = " + courseId;
ResultSet query = query(sql);
try {
if(query.next()){
return true;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ret;
}
public void updateCourseSelectedNum(int courseId ,int num){
String sql = "";
if(num > 0){
sql = "update s_course set selected_num = selected_num + "+ num + " where id = " + courseId;
}else{
sql = "update s_course set selected_num = selected_num - " + Math.abs(num) + " where id = " + courseId;
}
update(sql);
}
public List getCourse(String ids){
List ret = new ArrayList();
String sql = "select * from s_course where id in("+ids+")";
ResultSet query = query(sql);
try {
while(query.next()){
Course cl = new Course();
cl.setId(query.getInt("id"));
cl.setName(query.getString("name"));
cl.setTeacherId(query.getInt("teacher_id"));
cl.setCourseDate(query.getString("course_date"));
cl.setSelectedNum(query.getInt("selected_num"));
cl.setMaxNum(query.getInt("max_num"));
cl.setInfo(query.getString("info"));
ret.add(cl);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ret;
}
public Course getCourse(int id){
Course course = null;
String sql = "select * from s_course where id = " + id;
ResultSet query = query(sql);
try {
while(query.next()){
course = new Course();
course.setId(query.getInt("id"));
course.setName(query.getString("name"));
course.setTeacherId(query.getInt("teacher_id"));
course.setCourseDate(query.getString("course_date"));
course.setSelectedNum(query.getInt("selected_num"));
course.setMaxNum(query.getInt("max_num"));
course.setInfo(query.getString("info"));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return course;
}
}
老师查看课程
包含 观察者模式,装饰者式,工厂模式,单例模式和策略模式 等设计模式,放个策略模式样图