学生信息管理系统团队博客
团队成员介绍
团队名称: 取名字好难
顾芷菱 | 柯智青(组长) |
---|---|
201521123074 | 201521123069 |
http://www.cnblogs.com/guzhiling | http://www.cnblogs.com/kzq-java-markdown/ |
项目git提交记录截图
(按时间来、提交记录、说明)
项目git地址:码云项目地址
- 2017/6/19
说明:第一天完成大体登录注册功能与界面。 - 2017/6/20
说明:第二天完成学生信息管理系统界面、添加、删除及搜索功能。 - 2017/6/21
说明:第三天完善学生信息管理界面,完成修改、编辑功能。 - 2017/6/22
说明:第四天美化登录及注册界面。
项目功能架构图与主要功能流程图
项目功能架构图
主要功能流程图
项目运行截图
(按功能进行截图)
- 登录界面:首先展现的是登陆界面,需输入正确的账号密码才可进入系统。
- 注册界面:没有账号的可以通过注册获取,注册成功后再登入即可。
- 信息管理系统界面:展现已经存在在数据库中的信息,并展现六个功能。
- 添加功能(add):添加学生信息功能,既能提交到表单也能存入数据库中。(体现学号唯一性)
- 删除功能(delete):删除学生信息功能。
- 展现功能(show):展现学生信息功能。
- 搜索功能(search):搜索学生信息功能。
- 编辑功能(edit):将表单上的一行信息对应填入相应文本框中,方便修改及添加。
- 修改功能(modify):选中信息进行修改。
项目关键代码
// 一行学生信息存入数据库
@Override
public boolean saveInDB(Student student) {
Connection conn = null;
PreparedStatement pstat = null;
String sql = "insert into student(num,name,gender,birthDate,status,address,phoneNum,dormNum)values(?,?,?,?,?,?,?,?) ";
int result = -1;
try {
conn = JDBCUtil.getConnection();
pstat = (PreparedStatement) conn.prepareStatement(sql);
pstat.setString(1, student.getStuNo());
pstat.setString(2, student.getStuName());
pstat.setString(3, student.getGender());
pstat.setString(4, student.getBirthDate());
pstat.setString(5, student.getPoliticalStatus());
pstat.setString(6, student.getHomeAddress());
pstat.setString(7, student.getTelephone());
pstat.setString(8, student.getDormitoryNumber());
result = pstat.executeUpdate();
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
JDBCUtil.realeaseAll(null, pstat, conn);
}
return true;
}
// 根据查询关键字获取数据库中相匹配学生信息
@Override
public ArrayList<Student> searchStudents(String searchKey,
String searchValue) {
// TODO Auto-generated method stub
ArrayList<Student> stulist = new ArrayList<Student>();
Connection conn = null;
PreparedStatement pstat = null;
ResultSet rs = null;
String sql = "select * from student where " + searchKey + " like ?";// 表中有id和name这列
try {
conn = JDBCUtil.getConnection();
pstat = conn.prepareStatement(sql);
pstat.setString(1, searchValue);
rs = pstat.executeQuery();
while (rs.next()) {
String stuNo = rs.getString("num");
String stuName = rs.getString("name");
String gender = rs.getString("gender");
String birthDate = rs.getString("birthDate");
String politicalStatus = rs.getString("status");
String homeAddress = rs.getString("address");
String telephone = rs.getString("phoneNum");
String dormitoryNumber = rs.getString("dormNum");
Student student = new Student(stuNo, stuName, gender,
birthDate, politicalStatus, homeAddress, telephone,
dormitoryNumber);
stulist.add(student);
}
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
JDBCUtil.realeaseAll(rs, pstat, conn);
}
return stulist;
}
// 根据学号删除数据库中对应信息
@Override
public boolean deleteStudent(String stuNo) {
Connection conn = null;
PreparedStatement pstat = null;
int result = 0;
String sql = "delete from student where num like ?";
try {
conn = JDBCUtil.getConnection();
pstat = conn.prepareStatement(sql);
pstat.setString(1, stuNo);
result = pstat.executeUpdate();
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
JDBCUtil.realeaseAll(null, pstat, conn);
}
if (result != 0) {
return true;
} else {
return false;
}
}
// 获取数据库中存在的学生信息
@Override
public ArrayList<Student> getAllStudent() {
// TODO Auto-generated method stub
Connection conn = null;
Statement stat = null;
ResultSet rs = null;
String sql = "select * from student";
ArrayList<Student> stulist = new ArrayList<Student>();
try {
conn = JDBCUtil.getConnection();
stat = conn.createStatement();
rs = stat.executeQuery(sql);
while (rs.next()) {
String stuNo = rs.getString("num");
String stuName = rs.getString("name");
String gender = rs.getString("gender");
String birthDate = rs.getString("birthDate");
String politicalStatus = rs.getString("status");
String homeAddress = rs.getString("address");
String telephone = rs.getString("phoneNum");
String dormitoryNumber = rs.getString("dormNum");
Student student = new Student(stuNo, stuName, gender,
birthDate, politicalStatus, homeAddress, telephone,
dormitoryNumber);
stulist.add(student);
}
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
JDBCUtil.realeaseAll(rs, stat, conn);
}
return stulist;
}
@Override
public Student modifyFindStudent(String stuNo) {
// 找到数据库中相同学号的一行信息
Connection conn = null;
PreparedStatement pstat = null;
ResultSet rs = null;
String sql = "select * from student where num = ?";
Student student = null;
try {
conn = JDBCUtil.getConnection();
pstat = conn.prepareStatement(sql);
pstat.setString(1, stuNo);
rs = pstat.executeQuery();
while (rs.next()) {
String stuNo1 = rs.getString("num");
String stuName = rs.getString("name");
String gender = rs.getString("gender");
String birthDate = rs.getString("birthDate");
String politicalStatus = rs.getString("status");
String homeAddress = rs.getString("address");
String telephone = rs.getString("phoneNum");
String dormitoryNumber = rs.getString("dormNum");
student = new Student(stuNo1, stuName, gender, birthDate,
politicalStatus, homeAddress, telephone,
dormitoryNumber);
}
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
JDBCUtil.realeaseAll(rs, pstat, conn);
}
return student;
}
// 将修改后的信息对应存在数据库中的指定行
public boolean modifySaveInDB(Student student, String stuNo) {
Connection conn = null;
PreparedStatement pstat = null;
String sql = "update student set name=?,gender=?,birthDate=?,status=?,address=?,phoneNum=?,dormNum=? where num = ?";
int result = 0;
try {
conn = JDBCUtil.getConnection();
pstat = (PreparedStatement) conn.prepareStatement(sql);
pstat.setString(1, student.getStuName());
pstat.setString(2, student.getGender());
pstat.setString(3, student.getBirthDate());
pstat.setString(4, student.getPoliticalStatus());
pstat.setString(5, student.getHomeAddress());
pstat.setString(6, student.getTelephone());
pstat.setString(7, student.getDormitoryNumber());
pstat.setString(8, stuNo);
result = pstat.executeUpdate();
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
JDBCUtil.realeaseAll(null, pstat, conn);
}
if (result != 0) {
return true;
} else {
return false;
}
}
// 修改表格上数据
public boolean modifyInTable(int index, String[] content, String num) {
DefaultTableModel model = (DefaultTableModel) jTable.getModel();
model.setValueAt(num, index, 0);
for (int i = 1; i < 8; i++) {
model.setValueAt(content[i], index, i);
}
return true;
}
}
尚待改进或者新的想法
- 只是简单的做成图形界面形式,还可以继续改进为web。
- 从文件中添加数据功能尚未实现。
- 界面还不够美观。
团队成员任务分配
顾芷菱 | 柯智青(组长) |
---|---|
登录界面,学生信息管理系统添加,编辑及修改功能 | 注册界面,学生信息管理系统界面,删除及搜索功能 |
http://www.cnblogs.com/guzhiling/p/7064084.html | http://www.cnblogs.com/kzq-java-markdown/p/7047289.html |