首页>代码>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; } } }
最近下载更多
PISCESPLUS LV4
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日
dusk red LV2
2023年6月6日
最近浏览更多
PISCESPLUS LV4
9月3日
xiao小果 LV13
8月19日
暂无贡献等级
时光海 LV2
7月1日
wkq888 LV17
6月15日
nurgul LV1
6月8日
ma406805131 LV15
6月2日
钝感力 LV1
3月24日
pangzhihui LV14
1月6日
暂无贡献等级