package com.sanqing.course.action;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.sanqing.course.dao.CourseDAO;
import com.sanqing.course.dao.CourseScheduleDAO;
import com.sanqing.course.dao.MarkDAO;
import com.sanqing.course.dao.StudentDAO;
import com.sanqing.course.dao.TeamDAO;
import com.sanqing.course.form.MarkForm;
import com.sanqing.course.model.Course;
import com.sanqing.course.model.Mark;
import com.sanqing.course.model.Student;
import com.sanqing.course.model.Team;
import com.sanqing.course.util.PageModel;
public class MarkAction extends BaseDispatchAction {
private MarkDAO markDao;
private CourseDAO courseDao;
private StudentDAO studentDao;
private TeamDAO teamDao;
private CourseScheduleDAO courseScheduleDao;
/**
* @param courseScheduleDao the courseScheduleDao to set
*/
public void setCourseScheduleDao(CourseScheduleDAO courseScheduleDao) {
this.courseScheduleDao = courseScheduleDao;
}
/**
* @param markDao the markDao to set
*/
public void setMarkDao(MarkDAO markDao) {
this.markDao = markDao;
}
/**
* @param teamDao the teamDao to set
*/
public void setTeamDao(TeamDAO teamDao) {
this.teamDao = teamDao;
}
/**
* @param courseDao the courseDao to set
*/
public void setCourseDao(CourseDAO courseDao) {
this.courseDao = courseDao;
}
/**
* @param studentDao the studentDao to set
*/
public void setStudentDao(StudentDAO studentDao) {
this.studentDao = studentDao;
}
/**
* 动态检索成绩
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
@SuppressWarnings("unchecked")
public ActionForward list(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
//获取从页面表单中提交过来的值
MarkForm mf = (MarkForm)form;
Mark mark = new Mark();
String flag = request.getParameter("flag");
String teamId = request.getParameter("teamId");
Team team = null;
PageModel pageModel = new PageModel();
if("true".equals(flag)) {
if(mf != null) {
if(mf.getCourseId() != null && mf.getCourseId().trim().length() > 0) {
Course course = courseDao.findCourseById(mf.getCourseId());
mark.setCourse(course);
}
if(mf.getStudentId() != null && mf.getStudentId().trim().length() > 0) {
Student student = studentDao.findStudentById(mf.getStudentId());
mark.setStudent(student);
}
BeanUtils.copyProperties(mark, form);
request.getSession().setAttribute("markMar", mark);
} else {
request.getSession().setAttribute("markMar", null);
}
if(null != teamId && teamId.trim().length() > 0) {
team = teamDao.findTeamById(teamId);
request.getSession().setAttribute("teamMark", team);
} else {
request.getSession().setAttribute("teamMark", null);
}
} else {
mark = (Mark) request.getSession().getAttribute("markMar");
team = (Team)request.getSession().getAttribute("teamMark");
}
//调用业务逻辑操作
pageModel = markDao.listMark(mf.getPageNo(), mark, team);
//将查询结果放到request中
request.setAttribute("pageModel", pageModel);
return mapping.findForward("list");
}
/**
* 检索所有的成绩
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward findAll(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
List<Mark> list = markDao.findAllMarks();
request.setAttribute("marks", list);
return mapping.findForward("list");
}
/**
* 删除成绩
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
//获取从页面表单中提交过来的值
MarkForm mf = (MarkForm)form;
//调用业务逻辑操作
markDao.deleteMark(mf.getSelectFlag());
saveMessage(request, "markForm.deleted");
ActionForward af = new ActionForward("mark.do?p=list&pageNo=1", true);
return af;
}
/**
* 编辑成绩:进入新建页面,进入更新页面
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward edit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String id = request.getParameter("id");
if(id != null && id.trim().length() > 0) {
Mark mark = markDao.findMarkById(id);
//将Mark的值复制给form
if(mark != null) {
request.setAttribute("mark", mark);
}
}
return mapping.findForward("edit");
}
/**
* 保存成绩:更新,创建
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
@SuppressWarnings({ "deprecation", "unchecked" })
public ActionForward save(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
List<Mark> marks = (List<Mark>)request.getSession().getAttribute("marks");
for(int i=0; i<marks.size(); i++) {
Mark mark = marks.get(i);
markDao.addMark(mark);
}
saveMessage(request, "markForm.added");
request.getSession().removeAttribute("marks");
ActionForward af = new ActionForward("courseSchedule.do?p=input&flag=added", true);
return af;
}
/**
* 获取用户输入信息,组装成绩,转发到确认成绩页面
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
@SuppressWarnings("deprecation")
public ActionForward confirm(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String num = request.getParameter("num");
int total = Integer.valueOf(num);
List<Mark> marks = new ArrayList<Mark>();
String courseId = request.getParameter("courseId");
Course course = courseDao.findCourseById(courseId);
try {
for(int i=1; i<=total; i++) {
String studentId = request.getParameter("studentId"+i);
Float score = Float.valueOf(request.getParameter("score"+i));
Student student = studentDao.findStudentById(studentId);
Mark mark = new Mark();
mark.setStudent(student);
mark.setCourse(course);
mark.setScore(score);
marks.add(mark);
}
} catch(Exception e) {
e.printStackTrace();
saveMessage(request, "markForm.added.error");
ActionForward af = new ActionForward("courseSchedule.do?p=input", true);
return af;
}
request.getSession().setAttribute("marks", marks);
return mapping.findForward("confirm");
}
/**
* 修改成绩:更新,创建
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
@SuppressWarnings({ "deprecation", "unchecked" })
public ActionForward modify(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
MarkForm markForm = (MarkForm) form;
Mark mark = markDao.findMarkById(markForm.getId());
mark.setScore(Float.valueOf(markForm.getScore()));
markDao.modifyMark(mark);
saveMessage(request, "markForm.updated");
ActionForward af = new ActionForward("mark.d
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
学生信息管理系统由用户管理、班级管理、学生信息管理、教师信息管理、课程管理以及成绩管理等功能模块组成。具体的功能模块说明如下。 用户管理模块:该模块主要负责管理系统的用户信息,包括用户名、用户密码和身份信息。 班级管理模块:该模块主要负责管理学校的所有班级,包括浏览班级、班级添加、班级查询等功能,还可以设置和查询各班级的开课信息。 学生管理模块:该模块主要负责管理学生的个人信息,包括浏览学生信息、学生信息添加以及学生信息查询等功能
资源推荐
资源详情
资源评论
收起资源包目录
学生毕业设计学生管理系统java项目源码 (335个子文件)
native.bat 142B
native.bat 142B
MarkAction.class 10KB
MD5Code.class 8KB
TeacherAction.class 7KB
CourseScheduleAction.class 7KB
CourseScheduleDAOImpl.class 7KB
StudentAction.class 7KB
StudentDAOImpl.class 6KB
UserAction.class 6KB
MarkDAOImpl.class 6KB
CourseAction.class 5KB
TeamAction.class 5KB
Functions.class 5KB
UserDAOImpl.class 4KB
InitData.class 4KB
TeacherDAOImpl.class 4KB
CourseDAOImpl.class 4KB
TeamDAOImpl.class 4KB
BaseDispatchAction.class 3KB
UserForm.class 3KB
StudentForm.class 2KB
UserLoginFilter.class 2KB
CourseScheduleDAO.class 2KB
CourseScheduleForm.class 2KB
CourseSchedule.class 2KB
Student.class 2KB
MarkForm.class 2KB
PageModel.class 2KB
Functions$2.class 1KB
Teacher.class 1KB
TeacherForm.class 1KB
MarkDAO.class 1KB
Mark.class 1KB
HibernateUtils.class 1KB
Functions$1.class 1KB
CourseForm.class 1KB
Course.class 1KB
TeamForm.class 1KB
User.class 1KB
Team.class 1KB
StudentDAO.class 832B
ExportDB.class 791B
UserDAO.class 717B
TeacherDAO.class 660B
CourseDAO.class 648B
TeamDAO.class 624B
.classpath 4KB
style.css 10KB
drp.css 3KB
admin.css 2KB
default.css 1KB
JSCalendar.css 630B
Thumbs.db 373KB
Thumbs.db 3KB
Entries 168B
maintop.gif 60KB
client_level_chart.gif 10KB
footer_kefu.gif 3KB
topoint2024.gif 2KB
banner_help_button.gif 2KB
admin.gif 1KB
realTimeInfoShow.gif 1KB
chart3.gif 1KB
login_button.gif 1KB
download1.gif 1KB
look.gif 1KB
search.gif 908B
plus.gif 870B
minus.gif 861B
top_right.gif 857B
command_bottom_right.gif 855B
1d.gif 843B
command_bottom_left.gif 843B
top_left.gif 840B
logobar_mid.gif 834B
middle_right.gif 834B
command_top_right.gif 826B
middle_left.gif 826B
logobar_left.gif 818B
command_top_left.gif 818B
left.gif 814B
right.gif 808B
command_mid_right.gif 807B
spacer.gif 807B
top.gif 806B
command_bottom.gif 806B
command_mid_left.gif 804B
command_top.gif 804B
compactset.gif 717B
background.gif 668B
record.gif 608B
down.gif 420B
openfold.gif 376B
closedfold.gif 372B
showtoc.gif 359B
alarm.gif 328B
direction.gif 312B
help.gif 295B
import.gif 278B
共 335 条
- 1
- 2
- 3
- 4
资源评论
且行好事莫问前程
- 粉丝: 2w+
- 资源: 443
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功