毕业设计管理系统(共28页).doc
精选优质文档-倾情为你奉上重 庆 三 峡 学 院数据库原理课程实训内容综合报告实 训 题 目:毕业设计管理系统 专 业:计算机科学与技术 指 导 教 师:方 刚 组 长: 刘智力(8) 成 员 一: 陈建波(2) 成 员 二: 何先果(3) 2015年12月 25日专心-专注-专业一、实训目的掌握数据库的设计方法,将数据库原理理论知识运用于信息管理系统的实践开发中。二、开发环境硬件环境:PC机操作系统:Windows10数据库管理系统:毕业设计管理系统软件环境:myeclipse2015,Navicat for mysql,mysql6.0 Tomcat7.0三、开发文档1. 系统功能概述根据讨论与查阅资料我们得出了系统的功能模型图分为四个模块分别是登录模块、毕业生管理模块、教师管理模块、查询统计模块。 图1. 毕业生设计管理系统功能结构图2. 需求分析根据我们的讨论与设想:以及客观的需求分析我们对此做了以下几个图,有顶层数据流图、详细数据流图以及ER图,并配有相应的数据字典。(1) 数据流图数据流图也称为数据流程图date flow diagram , DFD,是一种便于用户理解和分析系统数据流程的图形工具,他摆脱了系统和具体内容,精确的在逻辑上描述系统的功能、输入、输出和数据存储等,是系统逻辑模型的重要组成部分。我们小组经过仔细讨论决定做出下列数据流图。根据顶层数据流图我么做出了相应的详细数据流图: 图2.详细数据流图(2)数据字典 表1. 教材表数据字典描述项目描述数据存储编号P1数据存储名称毕业生设计管理简述毕业生基本信息、指导教师基本信息、学生选题相关信息以及老师上传题目的信息数据存储组成学生学号+教师编号+教师上传题目名称+学生选题名称相关联的处理毕业生管理处理、教师信息处理、毕业生信息维护处理、毕业生信息查询处理、指导课题处理、毕业生选课处理、用户信息处理、查询处理3. 数据库设计(1)概念设计 图1.毕业生设计ER图逻辑设计 根据ER图做出相应的关系模式:专业(专业名,专业号)毕业生(学号,姓名,年龄)班级(班级号,班级名)课题(课程号,课题名称)指导教师(教师编号,姓名,电话)4. 系统编码(1) 登录界面使用 输入正确的用户信息即可 (2)毕业生信息添加首先,登录到毕业设计管理系统->打开学生管理模块->添加学生资料->添加信息(3)毕业生信息修改首先,登录到毕业设计管理系统->打开学生管理模块->修改学生资料->修改信息功能实现界面图:实现源代码package action; import java.util.List; import entity.Students;import service.StudentsDAO;import service.impl.StudentsDAOImpl; /学生Action类public class StudentsAction extends SuperAction private static final long serialVersionUID = 1L; /查询所有学生的动作public String query()StudentsDAO sdao =new StudentsDAOImpl(); List<Students>list=sdao.queryAllStudents(); /放进session中 if(list!=null&&list.size()>0) session.setAttribute("students_list", list); return "query_success" package action; import org.apache.struts2.interceptor.validation.SkipValidation; import service.UsersDAO; import service.impl.UsersDAOImpl; import com.opensymphony.xwork2.ModelDriven; import entity.Users; public class UsersAction extends SuperAction implements ModelDriven<Users> /* * */private static final long serialVersionUID = 1L;private Users user=new Users();/用户登录动作public String login()UsersDAO udao =new UsersDAOImpl();if(udao.UsersLogin(user)/在session中保存登录成功的用户名session.setAttribute("loginUserNaeme", user.getUsame();return "login_success"elsereturn "login_failure"SkipValidation/用户注销方法public String logout()if(session.getAttribute("loginUserName")!=null)session.removeAttribute("loginUserName");return "logout_success"Overridepublic void validate() / TODO Auto-generated method stub/用户名不能为空if("".equals(user.getUsame().trim()this.addFieldError("usernameError", "用户名不能为空!");if(user.getPassword().length()<6)this.addFieldError("passwordError", "密码长度不少于6");public Users getModel() / TODO Auto-generated method stubreturn this.user; package action; import org.apache.struts2.interceptor.validation.SkipValidation; import service.UsersDAO; import service.impl.UsersDAOImpl;import com.opensymphony.xwork2.ModelDriven; import entity.Users;public class UsersAction extends SuperAction implements ModelDriven<Users> /* * */private static final long serialVersionUID = 1L;private Users user=new Users();/用户登录动作public String login()UsersDAO udao =new UsersDAOImpl();if(udao.UsersLogin(user)/在session中保存登录成功的用户名session.setAttribute("loginUserNaeme", user.getUsame();return "login_success"elsereturn "login_failure"SkipValidation/用户注销方法public String logout()if(session.getAttribute("loginUserName")!=null)session.removeAttribute("loginUserName");return "logout_success" Overridepublic void validate() / TODO Auto-generated method stub/用户名不能为空if("".equals(user.getUsame().trim()this.addFieldError("usernameError", "用户名不能为空!");if(user.getPassword().length()<6)this.addFieldError("passwordError", "密码长度不少于6位");public Users getModel() / TODO Auto-generated method stubreturn this.user;package entity;import java.util.Date;/学生类public class Students private String sid;/学号private String sname;/姓名private String gender;/性别private Date birthday;/出生日期 private String address;/地址 public Students() public Students(String sid, String sname, String gender, Date birthday,String address) super();this.sid = sid;this.sname = sname;this.gender = gender;this.birthday = birthday;this.address = address;public String getSid() return sid;public void setSid(String sid) this.sid = sid;public String getSname() return sname;public void setSname(String sname) this.sname = sname;public String getGender() return gender;public void setGender(String gender) this.gender = gender;public Date getBirthday() return birthday;public void setBirthday(Date birthday) this.birthday = birthday;public String getAddress() return address;public void setAddress(String address) this.address = address;Overridepublic String toString() return "Students sid=" + sid + ", sname=" + sname + ", gender="+ gender + ", birthday=" + birthday + ", address=" + address+ ""package entity;/用户类public class Users private int uid; private String usame; private String password;public int getUid() return uid;public void setUid(int uid) this.uid = uid;public String getUsame() return usame;public void setUsame(String usame) this.usame = usame;public String getPassword() return password;public void setPassword(String password) this.password = password;/接口package service.impl;import java.util.List;import org.hibernate.Query;import org.hibernate.Session;import org.hibernate.Transaction;import db.HibernateUtil;import entity.Students;import service.StudentsDAO;public class StudentsDAOImpl implements StudentsDAO public List<Students> queryAllStudents() / TODO Auto-generated method stubTransaction tx =null;List<Students> list =null;String hql=""trySession session =HibernateUtil.getSessionFactory().getCurrentSession();tx=session.beginTransaction();hql="from Students"Query query =session.createQuery(hql);list =query.list();mit();return list;catch(Exception ex)ex.printStackTrace();mit();return list;finallyif(tx!=null)tx=null;public Students queryStudentsBySid(String sid) / TODO Auto-generated method stubreturn null;public boolean addStudents(Students s) / TODO Auto-generated method stubreturn false;public boolean updateStudents(Students s) / TODO Auto-generated method stubreturn false;public boolean daleteStudents(String sid) / TODO Auto-generated method stubreturn false;package service.impl;import java.util.List;import org.hibernate.Query;import org.hibernate.Session;import org.hibernate.Transaction;import db.HibernateUtil;import entity.Users;import service.UsersDAO;public class UsersDAOImpl implements UsersDAO public boolean UsersLogin(Users u) / TODO Auto-generated method stubTransaction tx=null;String hql=""trySession session=HibernateUtil.getSessionFactory().getCurrentSession();tx=session.beginTransaction();hql =" from Users where username=? and password=? "Query query =session.createQuery(hql);query.setParameter(0, u.getUsame();query.setParameter(1,u.getPassword();List list=query.list();mit();if(list.size()>0)return true;elsereturn false;catch(Exception ex)ex.printStackTrace();return false;finally if(tx!=null) tx=null; package service;import java.util.List;import entity.Students;/学生的业务逻辑接口public interface StudentsDAO /查询所有学生资料public List<Students> queryAllStudents();/根据学生标号查询学生资料public Students queryStudentsBySid(String sid);/添加学生资料public boolean addStudents(Students s);/修改学生资料public boolean updateStudents(Students s);/删除学生资料public boolean daleteStudents(String sid);package service;import entity.Users;public interface UsersDAO /用户登录方法 public boolean UsersLogin(Users u); 四、 系统测试测试一:Testpublic void testSchemaExport() /创建配置对象Configuration config = new Configuration().configure("/hibernate.cfg.xml"); /创建服务注册对象ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties().build(); /创建sessionFactory SessionFactory SessionFactory sessionFactory=config.buildSessionFactory(serviceRegistry); /创建session对象Session Session session=sessionFactory.getCurrentSession(); /创建SchemaExport对象SchemaExport export =new SchemaExport(config);export.create(true,true);测试二: public void testSaveStudents() /创建配置对象Configuration config = new Configuration().configure(); /创建服务注册对象ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties().build(); /创建sessionFactorySessionFactory sessionFactory=config.buildSessionFactory(serviceRegistry);/创建session对象Session session=sessionFactory.getCurrentSession();/创建事务对象Transaction tx=session.beginTransaction();Students s1 =new Students("S","Liuzhi","man",new Date(),"Zunyui");Students s2 =new Students("S","Chenjianbo","man",new Date(),"FenGdu");Students s3 =new Students("S","Hexianguo","man",new Date(),"Kaixian");session.save(s1);session.save(s2);session.save(s3);mit();sessionFactory.close();测试三:Testpublic void testAddStudents()Students s=new Students();s.setSname("Zhansan");s.setGender("man");s.setAddress("Wudangsan");s.setBirthday(new Date();StudentsDAO sdao=new StudentsDAOImpl();Assert.assertEquals(true, sdao.addStudents(s) Testpublic void testQueryAllStudents()StudentsDAO sdao =new StudentsDAOImpl();List<Students> list = sdao.queryAllStudents();for(int i=0;i<list.size();i+)System.out.println(list.get(i);测试四:五、系统评价 优点是:不用创建数据库,代码自动生成;能在网页上运行。 缺点是:功能不完善,还需要继续完善部分功能,然后系统不是很稳定需要进一步调试。六、实训分工小组成员分工情况:1. 需求分析及数据库设计:陈建波、何先果2. 系统实现编码:刘智力