/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.zzu.web.action;
import java.util.Iterator;
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.actions.DispatchAction;
import com.zzu.biz.CourseBiz;
import com.zzu.biz.StudentBiz;
import com.zzu.biz.TeacherBiz;
import com.zzu.biz.impl.CourseBizImpl;
import com.zzu.biz.impl.StudentBizImpl;
import com.zzu.biz.impl.TeacherBizImpl;
import com.zzu.dao.entity.Course;
import com.zzu.dao.entity.Sc;
import com.zzu.dao.entity.Student;
import com.zzu.dao.entity.Teacher;
import com.zzu.dao.impl.CourseDaoImpl;
import com.zzu.web.form.TeacherForm;
/**
* MyEclipse Struts
* Creation date: 12-17-2008
*
* XDoclet definition:
* @struts.action parameter="operate" scope="request" validate="true"
* @struts.action-forward name="book" path="/student/book.jsp"
* @struts.action-forward name="chooseCourseList" path="/student/chooseCourseList.jsp"
* @struts.action-forward name="seeGrade" path="/student/seeGrade.jsp"
* @struts.action-forward name="exitCourseDo" path="/student/exitCourseDo.jsp"
* @struts.action-forward name="updateInfo" path="/student/updateInfo.jsp"
*/
public class TeacherAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
StudentBiz studentbiz=new StudentBizImpl();
TeacherBiz teacherbiz=new TeacherBizImpl();
CourseBiz coursebiz=new CourseBizImpl();
//修改个人信息
public ActionForward updateInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("修改个人信息action");
TeacherForm tf=(TeacherForm)form;
System.out.println("==="+tf.getTname()+tf.getTno()+"===");
Teacher teacher=teacherbiz.findTeacherById(tf.getTno());
teacher.setTname(tf.getTname());
teacher.setTpwd(tf.getTpwd());
teacherbiz.updateTeacher(teacher);
Teacher tea=teacherbiz.findTeacherById(tf.getTno());
request.getSession().setAttribute("teacher", tea);
return mapping.findForward("teaIndex");
}
//我带的选课列表
public ActionForward myCourseList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("我带的选课列表");
String tno=request.getParameter("tno");
List list=teacherbiz.findAllCourse(tno);
// for(Iterator it=list.iterator();it.hasNext();)
// {
// //Student student=(Student)it.next();
// Tc tc=(Tc)it.next();
// System.out.println("我的选修课程列表:"+tc.getTeacher().getTname()+"-"+tc.getCourse().getCname());
// }
request.getSession().setAttribute("mycourselist", list);
return mapping.findForward("myCourseList");
}
//我要添加学生 -提交方法
public ActionForward addMyStuDo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("我要添加学生-action");
TeacherForm tf=(TeacherForm)form;
String cno=request.getParameter("cno");
Student student=new Student();
student.setSno(tf.getSno());
student.setSname(tf.getSname());
student.setSsex(tf.getSsex());
student.setSage(tf.getSage());
student.setSdept(tf.getSdept());
student.setSpwd(tf.getSpwd());
teacherbiz.addStudent(student, cno);
//重定向mgrCourseStu页面
return mapping.findForward("mgrCourseStu");
}
//增减学生
public ActionForward mgrStudent(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("增减学生-action");
String sno=request.getParameter("tno");
String tno=request.getParameter("tno");
List list=teacherbiz.findAllCourse(tno);
request.getSession().setAttribute("mycourselist", list);
return mapping.findForward("mgrCourseStu");
}
//删除学生
public ActionForward delMyStu(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("减学生-action");
String tno=request.getParameter("tno");
String cno=request.getParameter("cno");
List list=teacherbiz.findMyStudent(tno, cno);
request.getSession().setAttribute("mystulist", list);
return mapping.findForward("delMyStu");
}
//删除学生 提交方法
public ActionForward delMyStuDo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("删除学生 提交方法-action");
String sno=request.getParameter("sno");
String cno=request.getParameter("cno");
String tno=request.getParameter("tno");
teacherbiz.decStudent(sno, cno);
//重定向到删除学生页面
List list=teacherbiz.findMyStudent(tno, cno);
request.getSession().setAttribute("mystulist", list);
return mapping.findForward("delMyStu");
}
//教师修改选课信息
public ActionForward modifyCourse(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("教师修改选课信息action");
String cno=request.getParameter("cno");
//先保证所选的课程是以前未选的课程
Course course=teacherbiz.findCourseById(cno);
request.setAttribute("course", course);
//重新定位到我的选修列表
//List list2=studentbiz.findMyCourse(sno);
//request.getSession().setAttribute("mycourselist", list2);
return mapping.findForward("modifyCourse");
}
//教师修改选课信息 提交方法
public ActionForward modifyCourseDone(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("教师修改选课信息-提交方法action");
String cno=request.getParameter("cno");
String tno=request.getParameter("tno");
TeacherForm tf=(TeacherForm)form;
System.out.println(tf.getCno());
Course course=teacherbiz.findCourseById(tf.getCno());
System.out.println(course);
course.setCname(tf.getCname());
course.setCcredit(tf.getCcredit());
teacherbiz.updateCourse(course);
//重定向到教师选修课列表页面
List list=teacherbiz.findAllCourse(tno);
request.getSession().setAttribute("mycourselist", list);
return mapping.findForward("myCourseList");
}
//教师删除选课信息
public ActionForward delCourse(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("教师删除选课信息action");
String tno=request.getParameter("tno");
String cno=request.getParameter("cno");
teacherbiz.delCourse(tno, cno);
//重新定位到我的选修列表
List list=teacherbiz.findAllCourse(tno);
request.getSession().setAttribute("mycourselist", list);
return mapping.findForward("myCourseList");
}
//给学生评分 编辑页面
public ActionForward gradeStudentEdit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("给学生评分-编辑页面");
String tno=request.getParameter("tno");
List list=teacherbiz.findAllCourse(tno);
request.getSession().setAttribute("mycourselist", list);
return mapping.findForward("courseStuList");
}
//给学生评分 提交方法
public ActionForward gradeStudentDo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("给学生评分");
String tno=request.getParameter("tno");
String cno=request.getParameter("