⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 studentaction.java

📁 基本分数查询功能,自己的毕业设计作品!希望能给大家一点帮助!
💻 JAVA
字号:
package org.xk.action;

import java.sql.SQLException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

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 org.xk.po.*;
import org.xk.util.ServiceUtil;
import org.xk.util.StringUtil;
import org.xk.form.StudentForm;
import org.xk.form.TeacherForm;
import org.xk.util.*;

public class StudentAction extends DispatchAction {
	

	public ActionForward addStudent(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws SQLException {
		StudentForm sf = (StudentForm) form;
		int teacher_id = Integer.parseInt(request.getParameter("teacher_id"));
		List ls = ServiceUtil.getSelectSomethingService().getClassInfo(
				teacher_id);
		request.setAttribute("ls", ls);
		if (ServiceUtil.getAddSomethingService().addStudent(
				StringUtil.toUtf8Code(sf.getStu_user()),
				StringUtil.toUtf8Code(sf.getStu_password()),
				StringUtil.toUtf8Code(sf.getStu_name()),
				StringUtil.toUtf8Code(sf.getStu_sex()),
				StringUtil.toUtf8Code(sf.getStu_number()),
				StringUtil.toUtf8Code(sf.getStu_age()), sf.getClass_id(),
				sf.getPort_id())) {
			request.setAttribute("msg", "添加学生信息成功,系统将在两秒后自动转到页面");
			request.setAttribute("gowhere", "addStu.do?a=addStu&&teacher_id="
					+ teacher_id);
		} else {
			request.setAttribute("msg", "添加学生信息失败,请联系管理员");
			request.setAttribute("gowhere", "addStu.do?a=addStu&&teacher_id="
					+ teacher_id);
		}
		return mapping.findForward("go");

	}

	public ActionForward updateStudent(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws SQLException {
		StudentForm sf = (StudentForm) form;
		String stu_number = StringUtil.toUtf8Code(request
				.getParameter("stu_number"));
		int class_id = Integer.parseInt(request.getParameter("class_id"));

		if (ServiceUtil.getAddSomethingService().updateStudent(
				StringUtil.toUtf8Code(sf.getStu_user()),
				StringUtil.toUtf8Code(sf.getStu_password()),
				StringUtil.toUtf8Code(sf.getStu_name()),
				StringUtil.toUtf8Code(sf.getStu_sex()),
				StringUtil.toUtf8Code(sf.getStu_number()),
				StringUtil.toUtf8Code(sf.getStu_age()), sf.getClass_id(),
				sf.getPort_id())) {
			request.setAttribute("msg", "修改学生信息成功,系统将在两秒后自动转到页面");
			request.setAttribute("gowhere",
					"selectStudent.do?a=selectStudent&class_id=" + class_id);
		} else {
			request.setAttribute("msg", "修改学生信息失败,请联系管理员");
			request.setAttribute("gowhere",
					"selectStudent.do?a=selectStudent&class_id=" + class_id);
		}
		return mapping.findForward("go");

	}

	public ActionForward delStudent(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws SQLException {
		String stu_number = StringUtil.toUtf8Code(request
				.getParameter("stu_number"));
		int class_id = Integer.parseInt(request.getParameter("class_id"));

		if (ServiceUtil.getAddSomethingService().deleteStudent(stu_number)) {
			request.setAttribute("msg", " 删除学生信息成功,系统将在两秒后自动转到页面");
			request.setAttribute("gowhere",
					"selectStudent.do?a=selectStudent&&class_id=" + class_id);
		} else {
			request.setAttribute("msg", " 删除学生信息失败,请联系管理员");
			request.setAttribute("gowhere",
					"selectStudent.do?a=selectStudent&&class_id=" + class_id);
		}
		return mapping.findForward("go");

	}

	public ActionForward updateStudentInfo(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws SQLException {
		StudentForm sf = (StudentForm) form;

		int stu_id = Integer.parseInt(request
				.getParameter("stu_id"));
		int class_id = Integer.parseInt(request
				.getParameter("class_id"));
		int port_id = Integer.parseInt(request
				.getParameter("port_id"));
		StudentUser su = new StudentUser();
		su.setStu_id(stu_id);
		su.setStu_name(StringUtil.toUtf8Code(sf.getStu_name()));
		su.setStu_sex(StringUtil.toUtf8Code(sf.getStu_sex()));
		su.setStu_number(StringUtil.toUtf8Code(sf.getStu_number()));
		su.setStu_age(StringUtil.toUtf8Code(sf.getStu_age()));
		if (ServiceUtil.getAddSomethingService().updateStudentInfo(su)){
			request.setAttribute("msg", "修改个人信息成功,系统将在两秒后自动转到页面");
			request.setAttribute("gowhere",
					"selectStudentInfo.do?a=selectStudentInfo&stu_id="+stu_id+"&class_id="+class_id+"&port_id="
					+ port_id);
		} else {
			request.setAttribute("msg", "修改个人信息失败,请联系管理员");
			request.setAttribute("gowhere",
					"selectStudentInfo.do?a=selectStudentInfo&stu_id="+stu_id+"&class_id="+class_id+"&port_id="
					+ port_id);
		}
		return mapping.findForward("go");

	}
	
	public ActionForward updateStuPassword(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws SQLException {
		StudentForm sf = (StudentForm) form;
		int stu_id = Integer.parseInt(request
				.getParameter("stu_id"));
		StudentUser su = new StudentUser();
		su.setStu_id(stu_id);
        su.setStu_password(StringUtil.toUtf8Code(sf.getStu_password()));
		if (ServiceUtil.getAddSomethingService().updateStuPassword(su)){
			request.setAttribute("msg", "修改密码成功,系统将在两秒后自动转到页面");
			request.setAttribute("gowhere",
					"selectStudentUser.do?a=selectStudentUser&stu_id="+stu_id);
		} else {
			request.setAttribute("msg", "修改密码失败,请联系管理员");
			request.setAttribute("gowhere",
					"selectStudentUser.do?a=selectStudentUser&stu_id="+stu_id);
		}
		return mapping.findForward("go");

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -