package com.oa.Action;
import java.io.File;
import java.sql.Struct;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import jxl.Cell;
import jxl.Workbook;
import com.oa.ORM.Departement;
import com.oa.ORM.Students;
import com.oa.ORM.Teachers;
import com.oa.ORM.Users;
import com.oa.Service.TeachersService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class TeachersAction extends ActionSupport {
private TeachersService teachersService;
public TeachersService getTeachersService() {
return teachersService;
}
public void setTeachersService(TeachersService teachersService) {
this.teachersService = teachersService;
}
// 查询教师属性
private Integer teacherId;
private String time;
private String depa;
private String major;
Set<Students> students;
private List<Students> listS;
private Map mapset = new HashMap();
// 查询方法
public String getAllStudent() {
Teachers teacher = this.teachersService.findById(this.getTeacherId());
this.setTeacherId(teacher.getTeacherId());
Set<Students> sets = teacher.getStudentses();
Iterator<Students> iters = sets.iterator();
this.setStudents(sets);
return "success";
}
// 级联方法
public String loadme() {
/*
* ActionContext ctx = ActionContext.getContext(); Map session =
* ctx.getContextMap(); session.put(arg0, arg1)
*/;
/*
* List<Users> list = new ArrayList<Users>(); for(int i = 0;i<list.size();i++){
* Users user = list.get(i);
* mapset.put(user.getUserid(),user.getUsername()); }
*/
List<Students> list = new ArrayList<Students>();
Students stu = new Students();
stu.setStudentId(new Long(1));
stu.setStudentName(new String("fds"));
list.add(stu);
try {
for (int i = 0; i < list.size(); i++) {
Students st = list.get(i);
mapset.put(st.getStudentId(), st.getStudentName());
System.out.println(stu.getStudentName());
}
mapset.keySet();
} catch (Exception e) {
e.printStackTrace();
}
return "success";
}
// 按条件查询学生
public String getAllS() {
System.out.println(getTime() + "a" + this.getDepa() + "a"
+ this.getMajor());
return "success";
}
public Integer getTeacherId() {
return teacherId;
}
public void setTeacherId(Integer teacherId) {
this.teacherId = teacherId;
}
public Set<Students> getStudents() {
return students;
}
public void setStudents(Set<Students> students) {
this.students = students;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getDepa() {
return depa;
}
public void setDepa(String depa) {
this.depa = depa;
}
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major;
}
public Map getMapset() {
return mapset;
}
public void setMapset(Map mapset) {
this.mapset = mapset;
}
public List<Students> getListS() {
return listS;
}
public void setListS(List<Students> listS) {
this.listS = listS;
}
// 以下是管理员功能函数
private List<Teachers> teachers;
private Teachers teacher;
private String tipInfo;
public Teachers getTeacher() {
return teacher;
}
public void setTeacher(Teachers teacher) {
this.teacher = teacher;
}
public List<Teachers> getTeachers() {
return teachers;
}
public void setTeachers(List<Teachers> teachers) {
this.teachers = teachers;
}
public String getAllTeacher() {
List<Teachers> list = this.teachersService.getAllTeachers();
this.setTeachers(list);
return "success";
}
// 查询某个教师
public String teacherDetail() throws Exception {
Teachers teacher = this.teachersService.findById(this.getTeacherId());
this.setTeacher(teacher);
return "success";
}
// 确认更新教师信息
public String confirmTeacher() throws Exception {
Teachers teacher = new Teachers();
teacher = this.getTeacher();
if (this.teachersService.mdoradTeacher(teacher)) {
this.setTipInfo("修改或添加成功");
} else {
this.setTipInfo("修改或添加失败");
}
return "success";
}
// 删除教师信息
public String delTeacher() throws Exception {
if (this.teachersService.delTeacher(this.getTeacherId())) {
this.setTipInfo("删除成功");
} else {
this.setTipInfo("删除失败");
}
return "success";
}
public String getTipInfo() {
return tipInfo;
}
public void setTipInfo(String tipInfo) {
this.tipInfo = tipInfo;
}
// 读取excel表
private File excelName;
public File getExcelName() {
return excelName;
}
public void setExcelName(File excelName) {
this.excelName = excelName;
}
public String readContent() throws Exception {
File file = this.getExcelName();
Workbook wb = Workbook.getWorkbook(file);
// 一个工作溥中有三个工作表wb.getNumberOfSheets()取得工作表数量
System.out.println(wb.getNumberOfSheets() + "num");
/*
* 以下是读取所有内容 for (int i = 0; i < wb.getNumberOfSheets(); i++) { //
* 取得工作表中的行数wb.getSheet(i).getRows(); if (wb.getSheet(i).getRows() > 0) {
* for (int j = 0; j < wb.getSheet(i).getRows(); j++) { //
* 取得工作表中的列数wb.getSheet(i).getRows(); // 新建一个Teacher对象 Teachers teacher =
* new Teachers(); for (int k = 0; k < wb.getSheet(i).getColumns(); k++) { //
* 定要注意,单元格的读取是按(列,行)进行读取wb.getSheet(i).getCell(列,行);
*
* Cell cell = wb.getSheet(i).getCell(k, j);
*
* System.out.println(cell.getContents()); } } } }
*/
// 以下是插入数据库
// 向方法中插一个集合,采用Hibernate的缓存机制进行批量数据库
DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
List<Teachers> tlist = new ArrayList<Teachers>();
for (int i = 0; i < wb.getNumberOfSheets(); i++) {
for (int j = 0; j < wb.getSheet(i).getRows(); j++) {
Teachers teacher = new Teachers();
// 姓名
teacher.setTeacherName(wb.getSheet(i).getCell(0, j)
.getContents());
// 性别
teacher.setSex(wb.getSheet(i).getCell(1, j).getContents());
// 住址
teacher.setAddress(wb.getSheet(i).getCell(2, j).getContents());
// 民族
teacher.setOriginal(wb.getSheet(i).getCell(3, j).getContents());
// 参加工作时间
teacher.setIntoTime(df.parse(wb.getSheet(i).getCell(4, j)
.getContents().trim()));
System.out.println(wb.getSheet(i).getCell(4, j).getContents()
.trim());
// 出生年月
teacher.setBirthd(df.parse(wb.getSheet(i).getCell(5, j)
.getContents().trim()));
// 籍贯
teacher.setNation(wb.getSheet(i).getCell(6, j).getContents());
// 邮箱
teacher.setEmail(wb.getSheet(i).getCell(7, j).getContents());
tlist.add(teacher);
}
}
if (this.teachersService.bathSizeAdd(tlist)) {
this.setTipInfo("批量插入成功了");
} else {
this.setTipInfo("插入失败");
}
// 调用批量插入函数
return "success";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
基于Struts2的OA系统
共533个文件
java:165个
class:165个
xml:78个
2星 需积分: 9 90 下载量 201 浏览量
2008-06-11
13:43:09
上传
评论
收藏 437KB RAR 举报
温馨提示
Stru2+Spring2.5+Hibernate3.2+MySql
资源推荐
资源详情
资源评论
收起资源包目录
基于Struts2的OA系统 (533个子文件)
.#applicationContext.xml.1.10 8KB
.#TeachersMoudle.java.1.2 2KB
.#TeachersMoudle.java.1.2 2KB
.#roomsMain.jsp.1.4 2KB
.#applicationContext.xml.1.7 11KB
.#applicationContext.xml.1.7 11KB
.#TeachersAction.java.1.7 7KB
.#TeachersAction.java.1.7 7KB
TeachersAction.class 8KB
UsersAction.class 7KB
TeachersDAOImpl.class 6KB
StudentsAction.class 6KB
RolesAction.class 5KB
GradeAction.class 5KB
ClassroomesAction.class 5KB
GradeDAOImpl.class 5KB
StudentsDAOImpl.class 5KB
UserAdminAction.class 5KB
Users.class 5KB
UserAdminDAOImpl.class 5KB
Students.class 5KB
UsersDAOImpl.class 4KB
ArticleAction.class 4KB
NewstableAction.class 4KB
CourcesDAOImpl.class 4KB
MajorDAOImpl.class 4KB
RolesDAOImpl.class 4KB
DepartementAction.class 4KB
Teachers.class 4KB
AfficheAction.class 4KB
CourcesAction.class 4KB
DepartementDAOImpl.class 4KB
ClassroomesDAOImpl.class 4KB
SummarizeAction.class 3KB
Cources.class 3KB
NewstableDAOImpl.class 3KB
AfficheDAOImpl.class 3KB
ArticleDAOImpl.class 3KB
Category.class 3KB
Sortcourse.class 3KB
MajorAction.class 3KB
Calendar.class 3KB
HibernateSessionFactory.class 3KB
TeachersServiceImpl.class 2KB
AuthorityAction.class 2KB
Summarize.class 2KB
GradeServiceImpl.class 2KB
Telephonesheet.class 2KB
Affiche.class 2KB
CourcesServiceImpl.class 2KB
StudentsServiceImpl.class 2KB
Resourcemanage.class 2KB
ChoosecourseId.class 2KB
Wrapper.class 2KB
Newsfeed.class 2KB
Newstable.class 2KB
UsersServiceImpl.class 2KB
NewstableServiceImpl.class 2KB
Article.class 2KB
Authority.class 2KB
RolesMoudle.class 2KB
Major.class 2KB
UserAdminServiceImpl.class 2KB
UsersMoudle.class 2KB
ClassroomesServiceImpl.class 2KB
DepartementServiceImpl.class 2KB
Termtable.class 2KB
NewstableMoudle.class 2KB
ArticleMoudle.class 2KB
Departement.class 2KB
ClassroomesMoudle.class 2KB
AfficheServiceImpl.class 2KB
GradeMoudle.class 2KB
MajorServiceImpl.class 2KB
RolesServiceImpl.class 2KB
TeacherDecor.class 2KB
StudentsMoudle.class 2KB
Classroomes.class 2KB
depart.class 2KB
Choosecourse.class 2KB
GradeId.class 2KB
RoleDecom.class 2KB
Upload.class 2KB
UserAdminMoudle.class 2KB
ArticleServiceImpl.class 2KB
Grade.class 2KB
ClassroomtypeMoudle.class 2KB
Resourcetypetble.class 2KB
CourseDeco.class 2KB
UserAdmoDec.class 2KB
MajorsDecor.class 2KB
AuthorityMoudle.class 2KB
CalendarMoudle.class 2KB
Test2.class 2KB
Roles.class 2KB
MyTest.class 2KB
Test3.class 2KB
AuthoritySDecmo.class 1KB
MajorMoudle.class 1KB
AfficheMoudle.class 1KB
共 533 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
- yazhen502011-11-09怎么搭建不起来啊?里面东西好像不全啊
wtsoftware
- 粉丝: 12
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功