package com.stuman.web.struts.action;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.DynaValidatorForm;
import com.stuman.dao.ClassesDAO;
import com.stuman.dao.EnrolDAO;
import com.stuman.dao.StudentDAO;
import com.stuman.dao.TeacherDAO;
import com.stuman.domain.Classes;
import com.stuman.domain.Course;
import com.stuman.domain.Enrol;
import com.stuman.domain.EnrolId;
import com.stuman.domain.Student;
import com.stuman.domain.Teacher;
import com.stuman.util.DAOFactory;
import com.stuman.util.PageBean;
public class TeacherAction extends BaseAction {
private TeacherDAO teacherDao;
private ClassesDAO classesDAO;
private StudentDAO studentDAO;
private EnrolDAO EnrolDAO;
public TeacherAction() {
teacherDao = DAOFactory.getInstance().createTeacherDAO();
}
public TeacherDAO getTeacherDAO() {
if (this.teacherDao != null) {
return this.teacherDao;
} else {
teacherDao = DAOFactory.getInstance().createTeacherDAO();
return this.teacherDao;
}
}
public ActionForward doDefault(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// return null;
return getTeacherList(mapping, form, request, response);
}
/**
* 取的老师列表
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward getTeacherList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
PageBean page = new PageBean();
int currentPage = request.getParameter("currentPage") == null ? 1
: new Integer(request.getParameter("currentPage")).intValue();
page.setRecordsPerPage(2);
page.setCurrentPage(currentPage);
page.setQueryString("from Teacher tch");
PageBean page2 = this.getTeacherDAO().getTeacherList(page);
request.setAttribute("splitPage", page2);
// return null;
return mapping.findForward("getList.sucess");
}
/**
* 添加一个老师信息
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward addTeacher(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaValidatorForm dform = (DynaValidatorForm) form;
Teacher tch = new Teacher();
try {
this.getBeanUtilsBean().copyProperties(tch, dform);
this.getTeacherDAO().saveTeacher(tch);
log.info("tch==" + tch);
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
tch=null;
return getTeacherList(mapping, form, request, response);
}
/**
* 删除一个老师信息
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward deleteTeacher(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String stuId = request.getParameter("id");
this.getTeacherDAO().deleteTeacherByID(stuId);
return getTeacherList(mapping, form, request, response);
}
/**
* 取得一个老师信息
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward getEditTeacher(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String tchId = request.getParameter("id");
log.info("tch===" + tchId);
Teacher stu = this.getTeacherDAO().getTeacherByID(tchId);
log.info("stu" + stu);
try {
this.getBeanUtilsBean().copyProperties(form, stu);
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return mapping.findForward("getTeacher.sucesss");
}
/**
*更新一个老师信息
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward updateTeacher(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaValidatorForm dform = (DynaValidatorForm) form;
Teacher tch = new Teacher();
try {
this.getBeanUtilsBean().copyProperties(tch, dform);
this.getTeacherDAO().saveTeacher(tch);
log.info("upate tch==" + tch);
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return getTeacherList(mapping, form, request, response);
}
/**
* 初始化老师可接受的班级和课程(进入选择学生的第一步)
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward initSelectStu(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String regedit = "0";
if (request.getParameter("regedit") != null) {
if (Integer.parseInt(request.getParameter("regedit")) != 0) {
regedit = request.getParameter("regedit");
}
}
PageBean page = new PageBean();
int currentPage = request.getParameter("currentPage") == null ? 1
: new Integer(request.getParameter("currentPage")).intValue();
page.setRecordsPerPage(2);
page.setCurrentPage(currentPage);
page.setQueryString("from Classes classes where classes.teacher.id=?");
page.setValues(new Object[] { request.getSession().getAttribute(
"teacherId").toString() });
PageBean page2 = this.getClassesDAO().getClassesListForTeacher(page);
request.setAttribute("splitPage", page2);
request.setAttribute("regedit", regedit);
return mapping.findForward("getClassesCourse.sucesss");
}
/**
* 老师接受此学生
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward regeditStu(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String stuId = request.getParameter("id");
String classesId = request.getParameter("classesId");
Enrol enrol = new Enrol();
Student stu = new Student();
stu.setId(stuId);
Classes cla = new Classes();
cla.setId(classesId);
EnrolId id = new EnrolId();
id.setClasses(cla);
id.setStudent(stu);
enrol.setId(id);
enrol.setClasses(cla);
enrol.setStudent(stu);
enrol.setAccept("1");
this.getEnrolDAO().updateEnrol(enrol);
return initSelectStu(mapping, form, request, response);
}
/**
* 初试化一个班级的选择了课程还未被老师接受学生列表
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward initOpenSelectStu(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
String courseId = request.getParameter("id");
String classesId = request.getParameter("classesId");
StringBuffer str = new StringBuffer();
str
.append("select distinct stu.* from student stu,course cou,classes cla,enrol enr");
str
.append(" where stu.id=enr.stu_id and enr.class_id=cla.id and enr.accept!='1' ");
str.append(" and cla.cour_id=").append(courseId)
.append(" and cla.id= ").append(classesId).append(
" and cla.tea_id= ").append(
request.getSession().getAttribute("teacherId")
.toString());
System.out.prin
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
精通Java EE项目案例-基于Eclipse Spring Struts Hibernate (291个子文件)
TeacherAction.class 10KB
StudentAction.class 7KB
EnrolDAOImp.class 7KB
CasssesAction.class 6KB
StudentDAOImp.class 6KB
LoginAction.class 5KB
CourseDAOImp.class 5KB
CourseAction.class 5KB
BaseDao.class 4KB
ClassesDAOImp.class 4KB
ListStudent.class 4KB
ListCourseForStu.class 4KB
ListClasses.class 4KB
ListCourse.class 3KB
Student.class 3KB
ListTeacher.class 3KB
TeacherDAOImp.class 3KB
ListScore.class 3KB
BaseAction.class 3KB
AdminDAOImp.class 3KB
HibernateUtil.class 3KB
Course.class 2KB
DAOFactory.class 2KB
PageBean.class 2KB
ListCourseIdAndName.class 2KB
SetEncodingFilter.class 2KB
Classes.class 2KB
Teacher.class 2KB
SetCharacterEncodingFilter.class 2KB
CloseSessionFilter.class 2KB
RegCourse.class 2KB
CourseForStu.class 2KB
Enrol.class 2KB
Base64Tools.class 2KB
LoginForm.class 1KB
EnrolId.class 1KB
HibernateDAOFactory.class 1KB
LoadHiberaneFactoryContext.class 1KB
Admin.class 1KB
DAOConfig.class 1KB
Score.class 899B
EnrolDAO.class 722B
CourseDAO.class 551B
StudentDAO.class 534B
ClassesDAO.class 530B
TeacherDAO.class 446B
AdminDAO.class 346B
DAOFactory.class 293B
.classpath 5KB
stylesheet.css 18KB
Thumbs.db 90KB
Thumbs.db 26KB
Entries 4KB
Entries 1KB
Entries 856B
Entries 767B
Entries 750B
Entries 701B
Entries 414B
Entries 414B
Entries 404B
Entries 404B
Entries 360B
Entries 247B
Entries 109B
Entries 65B
Entries 63B
Entries 56B
Entries 48B
Entries 45B
Entries 39B
Entries 29B
Entries 26B
Entries 14B
2-6.gif 6KB
1-1.gif 6KB
2-4.gif 5KB
2-5.gif 5KB
2-3.gif 5KB
2-1.gif 5KB
s08.gif 4KB
s09.gif 3KB
admin_logo.gif 3KB
xong4.gif 3KB
xong9.gif 3KB
xong5.gif 3KB
title.gif 3KB
xong1.gif 3KB
xong8.gif 3KB
xong7.gif 3KB
xong6.gif 3KB
s10.gif 3KB
xong2.gif 3KB
xong3.gif 2KB
admin_left_10.gif 2KB
admin_left_1.gif 2KB
admin_left_5.gif 2KB
admin_left_4.gif 2KB
title_bg_quit.gif 2KB
admin_left_7.gif 1KB
共 291 条
- 1
- 2
- 3
资源评论
- gdccgz2011-12-13不错的内容,只是不知道是那本书的一部分。
Dan_Cooper
- 粉丝: 3
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功