package com.chi.action;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import com.chi.idao.IAttendanceType;
import com.chi.idao.IStat;
import com.chi.idao.Iattendance;
import com.chi.idao.Iemployee;
import com.chi.pojo.AddAttend;
import com.chi.pojo.Attendance;
import com.chi.pojo.AttendanceType;
import com.chi.pojo.Employee;
import com.chi.pojo.PageBean;
import com.chi.pojo.SearchCondition;
import com.chi.pojo.StatAttendance;
import com.chi.service.MemberService;
import com.opensymphony.xwork2.ActionContext;
public class MainAction {
//操作数据方法
private Iemployee employeeImpl;
private Iattendance attendanceImpl;
private IAttendanceType attendanceTypeImpl;
@SuppressWarnings("unused")
private IStat statImpl;
private SearchCondition searchCondition;
public SearchCondition getSearchCondition() {
return searchCondition;
}
public void setSearchCondition(SearchCondition searchCondition) {
this.searchCondition = searchCondition;
}
//pojo
private Attendance attendance;
private Employee employee;
private AttendanceType attendanceType;
private AddAttend addAttend;//添加考勤信息
private StatAttendance stat;//统计考勤信息
private MemberService memberService;//分页
private PageBean pageBean;
private int page=1;
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public void setMemberService(MemberService memberService) {
this.memberService = memberService;
}
public PageBean getPageBean() {
return pageBean;
}
public void setPageBean(PageBean pageBean) {
this.pageBean = pageBean;
}
public void setStatImpl(IStat statImpl) {
this.statImpl = statImpl;
}
public StatAttendance getStat() {
return stat;
}
public void setStat(StatAttendance stat) {
this.stat = stat;
}
public AddAttend getAddAttend() {
return addAttend;
}
public void setAddAttend(AddAttend addAttend) {
this.addAttend = addAttend;
}
public Attendance getAttendance() {
return attendance;
}
public void setAttendance(Attendance attendance) {
this.attendance = attendance;
}
public Employee getEmployee() {
return employee;
}
public void setEmployee(Employee employee) {
this.employee = employee;
}
public AttendanceType getAttendanceType() {
return attendanceType;
}
public void setAttendanceType(AttendanceType attendanceType) {
this.attendanceType = attendanceType;
}
public void setEmployeeImpl(Iemployee employeeImpl) {
this.employeeImpl = employeeImpl;
}
public void setAttendanceImpl(Iattendance attendanceImpl) {
this.attendanceImpl = attendanceImpl;
}
public void setAttendanceTypeImpl(IAttendanceType attendanceTypeImpl) {
this.attendanceTypeImpl = attendanceTypeImpl;
}
/*
* 显示雇员
* 考勤信息
* 考勤类型
* */
@SuppressWarnings("unchecked")
public void showInfo(){
List<Employee> employeeList=employeeImpl.getAllEmployee();
List<Attendance> attendanceList=attendanceImpl.getAllAttendance();
List<AttendanceType> attendanceTypeList=attendanceTypeImpl.getAllAttendanceType();
ActionContext.getContext().put("employeeList",employeeList);//雇员的信息,工号,姓名
ActionContext.getContext().put("attendanceList", attendanceList);//考情信息。考勤日期,备注
ActionContext.getContext().put("attendanceTypeList", attendanceTypeList);//考勤类型
//分页
this.pageBean=memberService.queryForPage(10,page);
}
//--------------------------------------------------------------------------------------------------------
public String toMain(){//首页界面
//分页的pageBean,参数pageSize表示每页显示记录数,page为当前页
//每页显示10条数据,
//List employeeList=employeeImpl.getAllEmployee();
showInfo();
return "success";
}
public String toForward(){ //跳转到考勤录入界面
showInfo();
return "forward";
}
//考勤信息录入
public String toAdd() throws Exception{
String[] employeeId=addAttend.getEmployeeId();
String toAttendanceTime=addAttend.getAttendanceTime();
String[] attendanceTypeId=addAttend.getAttendanceTypeId();
String[] attendanceRemark=addAttend.getAttendanceRemark();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
Date attendTime=sdf.parse(toAttendanceTime);
Timestamp attendanceTime=new Timestamp(attendTime.getTime());
for(int i=0;i<employeeId.length;i++){
Attendance attendance=new Attendance();
attendance.setAttendanceRemark(attendanceRemark[i]);//保存备注信息
attendance.setAttendanceTime(attendanceTime);
attendance.setAttendanceType(attendanceTypeImpl.getById(Integer.parseInt(attendanceTypeId[i])));
attendance.setEmployee(employeeImpl.getById(Integer.parseInt(employeeId[i])));
attendanceImpl.saveAttendance(attendance);//逐个保存对象
}
showInfo();
return "add";
}
//考勤删除
public String toDelete(){
String[] delAttendanceId=addAttend.getDelAttendanceId();
for(int i=0;i<delAttendanceId.length;i++){
//Attendance attendance=new Attendance();
attendanceImpl.deleteAttendanceById(Integer.parseInt(delAttendanceId[i]));
}
showInfo();
return "delete";
}
// 考勤统计
// public String toStat(){
//
// //List<Employee> employeeList=employeeImpl.getAllEmployee();//统计出考勤情况
// //ActionContext.getContext().put("employeeList", employeeList);
// String sql="select distinct employeeNo ,employeeName,attendanceTypeName," +
// "count(attendanceTypeName) attendanceTypeNameTotal from Attendance left join AttendanceType "+
// "on attendanceTypeId=fk_attendanceType"+
// " left join Employee "+
// "on employeeId=fk_employeeId"+
// " group by employeeNo ,employeeName,attendanceTypeName";
// List<StatAttendance> statList=statImpl.getBySql(sql);
// ActionContext.getContext().put("statList", statList);
// return "statist";
// }
//查询
public String doSearch(){
int pageSize=10;
this.pageBean=memberService.queryForPage(10,page);
int offset=PageBean.countOffSet(10,page); //当前页开始记录
//10为每页显示的条数
List<Attendance> attendanceList=attendanceImpl.getByCondition(searchCondition,offset,10);
// PageBean pageBean=new PageBean();
pageBean.setAllRow(attendanceList.size());
int allRow=pageBean.getAllRow();//获取总条数
int totalPage=attendanceList.size()%pageSize==0?allRow/pageSize:allRow/pageSize+1;
pageBean.setTotalPage(totalPage);
// pageBean.setPageSize(pageSize);
// pageBean.setCurrentPage(PageBean.countCurrentpage(page));
pageBean.setList(attendanceList);//将遍历出的数据放入list中
// pageBean.init();
// List attendanceList=attendanceImpl.getByName(searchCondition.getSearchTimeFrom());
List<AttendanceType> attendanceTypeList=attendanceTypeImpl.getAllAttendanceType();
ActionContext.getContext().put("attendanceList", attendanceList);//考情信息。考勤日期,备注
ActionContext.getContext().put("attendanceTypeList", attendanceTypeList);//考勤类型
//this.pageBean=memberService.queryForPage(10,page);
return "success";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
S2SH+MySql做的分页
共76个文件
class:22个
java:21个
xml:13个
2星 需积分: 3 14 下载量 68 浏览量
2011-06-01
10:42:19
上传
评论 1
收藏 61KB RAR 举报
温馨提示
自己边学边做的,想学习分页的很实用,Struts2+hibernate+spring ,每一层都涉及到了,自己测试过能用的,为了上传和下载速度,jar包我取消掉了,你可以自己加上去
资源推荐
资源详情
资源评论
收起资源包目录
分页.rar (76个子文件)
分页
attendance
attendance.sql 4KB
.mystrutsdata 240B
.springBeans 470B
.myhibernatedata 556B
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 500B
org.eclipse.jdt.core.prefs 330B
src
log4j.properties 847B
com
chi
action
SearchAction.java 2KB
MainAction.java 7KB
idao
IStat.java 173B
Iattendance.java 435B
Iemployee.java 330B
IAttendanceType.java 299B
MemberDao.java 534B
pojo
SearchCondition.java 935B
AttendanceType.hbm.xml 973B
AddAttend.java 1KB
Employee.java 2KB
PageBean.java 3KB
Attendance.java 2KB
StatAttendance.java 1KB
AttendanceType.java 1KB
Attendance.hbm.xml 1KB
Employee.hbm.xml 1KB
daoimpl
AttendanceImpl.java 4KB
MemberDaoImpl.java 1KB
StatImpl.java 3KB
EmployeeImpl.java 914B
AttendanceTypeImpl.java 1KB
service
MemberServiceImpl.java 2KB
MemberService.java 333B
struts.xml 2KB
hibernate.cfg.xml 1KB
applicationContext.xml 4KB
.project 2KB
WebRoot
list.jsp 3KB
META-INF
MANIFEST.MF 36B
stat.jsp 2KB
WEB-INF
web.xml 1KB
classes
log4j.properties 847B
com
chi
action
SearchAction.class 2KB
MainAction.class 7KB
idao
Iemployee.class 335B
IStat.class 252B
MemberDao.class 225B
IAttendanceType.class 383B
Iattendance.class 413B
pojo
AttendanceType.hbm.xml 973B
AttendanceType.class 1KB
PageBean.class 2KB
StatAttendance.class 2KB
Attendance.class 2KB
Attendance.hbm.xml 1KB
SearchCondition.class 1KB
Employee.hbm.xml 1KB
AddAttend.class 1KB
Employee.class 2KB
daoimpl
EmployeeImpl.class 2KB
AttendanceImpl.class 4KB
StatImpl.class 2KB
MemberDaoImpl.class 1KB
AttendanceTypeImpl.class 2KB
MemberDaoImpl$1.class 1KB
service
MemberService.class 176B
MemberServiceImpl.class 2KB
struts.xml 2KB
hibernate.cfg.xml 1KB
applicationContext.xml 4KB
lib
main.jsp 6KB
check.jsp 2KB
add.jsp 3KB
index.jsp 830B
.mymetadata 312B
.classpath 3KB
.myeclipse
共 76 条
- 1
资源评论
- wuyanwen882012-12-03垃圾,跑不起来,数据库不是mysql的,是微软sqlserver ,垃圾项目
- itnjj2012-08-02分页是抄袭别人的 浪费积分!
尼梅
- 粉丝: 2
- 资源: 28
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功