package cla2sub.servlet; import impl.Cla2SubImpl; import impl.ClassesImpl; import impl.ScoreImpl; import impl.StudentImpl; import impl.SubjectImpl; import impl.TeacherImpl; import java.io.IOException; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import entity.Cla2Sub; import entity.Classes; import entity.Score; import entity.Student; import entity.Subject; import entity.Teacher; public class AddCla2SubServlet extends HttpServlet { private static final long serialVersionUID = 1L; public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub this.doPost(req, resp); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub // 添加班级课程 TeacherImpl teacherImpl = new TeacherImpl(); ClassesImpl classesImpl = new ClassesImpl(); SubjectImpl subjectImpl = new SubjectImpl(); Cla2SubImpl cla2SubImpl = new Cla2SubImpl(); StudentImpl studentImpl = new StudentImpl(); ScoreImpl scoreImpl = new ScoreImpl(); List<Student> list_student; Classes classes = classesImpl.query("cla_id", request.getParameter("cla_id")).get(0); Teacher teacher = teacherImpl.query("tec_id", request.getParameter("tec_id")).get(0); list_student = studentImpl.query("cla_id", classes.getId() + ""); String[] sub_ids = request.getParameterValues("sub_ids"); for (String id : sub_ids) { Subject subject = subjectImpl.query("sub_id", id).get(0); Cla2Sub cla2Sub = new Cla2Sub(); cla2Sub.setClasses(classes); cla2Sub.setSubject(subject); cla2Sub.setTeacher(teacher); int i = cla2SubImpl.add(cla2Sub); // 为该班级的学生添加该门课的成绩 for (Student stu : list_student) { Score score = new Score(); score.setStudent(stu); score.setSubject(subject); score.setCla2sub(cla2SubImpl.findCla2sub(classes.getId(), teacher.getId(), subject.getId())); scoreImpl.add(score); } if (i == 1) { request.getSession().setAttribute("message", "为班级添加课程成功!"); } else { request.getSession().setAttribute("message", "为班级添加课程失败!"); } } response.sendRedirect("/Student/PlanAddCla2SubSevlet"); } }

571818771 LV3
2024年12月16日
3334004690 LV10
2024年6月22日
wkq888 LV17
2024年6月15日
yqlllll LV2
2024年6月12日
124324343 LV1
2024年6月11日
八八八八 LV1
2024年6月1日
微信网友_6906962132258816 LV7
2024年3月16日
asddwh LV13
2023年12月29日
微信网友_6797029372219392 LV2
2023年12月28日
ddzfgh LV1
2023年12月25日

571818771 LV3
2024年12月16日
微信网友_7290996505972736 LV4
2024年12月11日
梁小贤 LV1
2024年12月6日
11onerr
2024年11月22日
暂无贡献等级
111rose LV1
2024年11月22日
asdfgh112
2024年7月4日
暂无贡献等级
时光海 LV2
2024年6月30日
3334004690 LV10
2024年6月22日
zzk3085000785
2024年6月20日
暂无贡献等级
wkq888 LV17
2024年6月15日