首页>代码>jsp+servlet+ajax+easyui开发学生信息管理系统,登录及增删改查>/11/StudentInfoManage/src/com/java1234/dao/StudentDao.java
package com.java1234.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import com.java1234.model.PageBean; import com.java1234.model.Student; import com.java1234.util.DateUtil; import com.java1234.util.StringUtil; public class StudentDao { public ResultSet studentList(Connection con,PageBean pageBean,Student student,String bbirthday,String ebirthday)throws Exception{ StringBuffer sb=new StringBuffer("select * from t_student s,t_grade g where s.gradeId=g.id"); if(StringUtil.isNotEmpty(student.getStuNo())){ sb.append(" and s.stuNo like '%"+student.getStuNo()+"%'"); } if(StringUtil.isNotEmpty(student.getStuName())){ sb.append(" and s.stuName like '%"+student.getStuName()+"%'"); } if(StringUtil.isNotEmpty(student.getSex())){ sb.append(" and s.sex ='"+student.getSex()+"'"); } if(student.getGradeId()!=-1){ sb.append(" and s.gradeId ='"+student.getGradeId()+"'"); } if(StringUtil.isNotEmpty(bbirthday)){ sb.append(" and TO_DAYS(s.birthday)>=TO_DAYS('"+bbirthday+"')"); } if(StringUtil.isNotEmpty(ebirthday)){ sb.append(" and TO_DAYS(s.birthday)<=TO_DAYS('"+ebirthday+"')"); } if(pageBean!=null){ sb.append(" limit "+pageBean.getStart()+","+pageBean.getRows()); } PreparedStatement pstmt=con.prepareStatement(sb.toString()); return pstmt.executeQuery(); } public int studentCount(Connection con,Student student,String bbirthday,String ebirthday)throws Exception{ StringBuffer sb=new StringBuffer("select count(*) as total from t_student s,t_grade g where s.gradeId=g.id"); if(StringUtil.isNotEmpty(student.getStuNo())){ sb.append(" and s.stuNo like '%"+student.getStuNo()+"%'"); } if(StringUtil.isNotEmpty(student.getStuName())){ sb.append(" and s.stuName like '%"+student.getStuName()+"%'"); } if(StringUtil.isNotEmpty(student.getSex())){ sb.append(" and s.sex ='"+student.getSex()+"'"); } if(student.getGradeId()!=-1){ sb.append(" and s.gradeId ='"+student.getGradeId()+"'"); } if(StringUtil.isNotEmpty(bbirthday)){ sb.append(" and TO_DAYS(s.birthday)>=TO_DAYS('"+bbirthday+"')"); } if(StringUtil.isNotEmpty(ebirthday)){ sb.append(" and TO_DAYS(s.birthday)<=TO_DAYS('"+ebirthday+"')"); } PreparedStatement pstmt=con.prepareStatement(sb.toString()); ResultSet rs=pstmt.executeQuery(); if(rs.next()){ return rs.getInt("total"); }else{ return 0; } } public int studentDelete(Connection con,String delIds)throws Exception{ String sql="delete from t_student where stuId in("+delIds+")"; PreparedStatement pstmt=con.prepareStatement(sql); return pstmt.executeUpdate(); } public int studentAdd(Connection con,Student student)throws Exception{ String sql="insert into t_student values(null,?,?,?,?,?,?,?)"; PreparedStatement pstmt=con.prepareStatement(sql); pstmt.setString(1, student.getStuNo()); pstmt.setString(2, student.getStuName()); pstmt.setString(3, student.getSex()); pstmt.setString(4, DateUtil.formatDate(student.getBirthday(), "yyyy-MM-dd")); pstmt.setInt(5, student.getGradeId()); pstmt.setString(6, student.getEmail()); pstmt.setString(7, student.getStuDesc()); return pstmt.executeUpdate(); } public int studentModify(Connection con,Student student)throws Exception{ String sql="update t_student set stuNo=?,stuName=?,sex=?,birthday=?,gradeId=?,email=?,stuDesc=? where stuId=?"; PreparedStatement pstmt=con.prepareStatement(sql); pstmt.setString(1, student.getStuNo()); pstmt.setString(2, student.getStuName()); pstmt.setString(3, student.getSex()); pstmt.setString(4, DateUtil.formatDate(student.getBirthday(), "yyyy-MM-dd")); pstmt.setInt(5, student.getGradeId()); pstmt.setString(6, student.getEmail()); pstmt.setString(7, student.getStuDesc()); pstmt.setInt(8, student.getStuId()); return pstmt.executeUpdate(); } public boolean getStudentByGradeId(Connection con,String gradeId)throws Exception{ String sql="select * from t_student where gradeId=?"; PreparedStatement pstmt=con.prepareStatement(sql); pstmt.setString(1, gradeId); ResultSet rs=pstmt.executeQuery(); if(rs.next()){ return true; }else{ return false; } } }

wu0123 LV1
2024年11月24日
PISCESPLUS LV4
2024年9月3日
321170193 LV6
2023年11月14日
jiemomo LV12
2023年11月2日
刘洋66666 LV1
2023年10月31日
卢本伟不开挂 LV4
2023年10月22日
sbbbbbbbbbb LV2
2023年9月7日
DUODUO123456 LV1
2023年7月5日
guyusky LV2
2023年6月30日
微信网友_6184005683466240 LV11
2023年6月12日

shuaiqi
4月22日
暂无贡献等级
zhao44413
2月21日
暂无贡献等级
dongandmin LV8
2024年12月27日
xianyu091012 LV5
2024年12月26日
chinajy LV2
2024年12月8日
wu0123 LV1
2024年11月24日
PISCESPLUS LV4
2024年9月3日
xiao小果 LV13
2024年8月19日
微信网友_7063649166446592
2024年7月3日
暂无贡献等级
时光海 LV2
2024年7月1日