/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.tjsoft.fish.actions.student;
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 javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.actions.DispatchAction;
import com.tjsoft.fish.domain.Cclass;
import com.tjsoft.fish.domain.Operator;
import com.tjsoft.fish.domain.PackageBook;
import com.tjsoft.fish.domain.Student;
import com.tjsoft.fish.domain.StudentInfo;
import com.tjsoft.fish.domain.Textbook;
import com.tjsoft.fish.exception.FishException;
import com.tjsoft.fish.form.student.BookFeeForm;
import com.tjsoft.fish.service.DeliverService;
import com.tjsoft.fish.service.DeliverServiceImpl;
import com.tjsoft.fish.service.ServiceFactory;
import com.tjsoft.fish.service.StudentService;
import com.tjsoft.fish.service.StudentServiceImpl;
import com.tjsoft.fish.service.stockin.StockService;
import com.tjsoft.fish.util.PageInfo;
import com.tjsoft.fish.util.Sort;
/**
* MyEclipse Struts Creation date: 08-02-2006
*
* XDoclet definition:
*
* @struts.action path="/bookFee" name="bookFeeForm"
* input="/module/student/005/pay_fee_query.jsp"
* parameter="method" scope="request" validate="true"
*/
public class BookFeeAction extends DispatchAction {
/**
* Method initialExecute 初始化类别、层次和班级的下拉列表
*/
public ActionForward initialExecute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List list, list2, list3;
String name = "";
StudentService ss = new StudentServiceImpl();
try {
list = ss.queryCategoryByName(null);
list2 = ss.queryLevelByName(name);
list3 = ss.queryMajorByName(name);
} catch (FishException e) {
ActionErrors errors = new ActionErrors();
errors.add("error.daoprocess",
new ActionMessage("error.daoprocess"));
return mapping.findForward("error");
}
request.setAttribute("list", list);
request.setAttribute("list2", list2);
request.setAttribute("list3", list3);
return mapping.findForward("initial");
}
/**
* Method queryInitial 初始化类别、层次和班级的下拉列表
*/
public ActionForward queryInitial(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List list, list2, list3;
String name = "";
StudentService ss = new StudentServiceImpl();
try {
list = ss.queryCategoryByName(name);
list2 = ss.queryLevelByName(name);
list3 = ss.queryMajorByName(name);
} catch (FishException e) {
ActionErrors errors = new ActionErrors();
errors.add("error.daoprocess",
new ActionMessage("error.daoprocess"));
return mapping.findForward("error");
}
request.setAttribute("list", list);
request.setAttribute("list2", list2);
request.setAttribute("list3", list3);
return mapping.findForward("queryInitial");
}
/**
* Method statisticInitial 初始化类别、层次和班级的下拉列表
*/
public ActionForward statisticInitial(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
List list, list2, list3;
String name = "";
StudentService ss = new StudentServiceImpl();
try {
list = ss.queryCategoryByName(name);
list2 = ss.queryLevelByName(name);
list3 = ss.queryMajorByName(name);
} catch (FishException e) {
ActionErrors errors = new ActionErrors();
errors.add("error.daoprocess",
new ActionMessage("error.daoprocess"));
return mapping.findForward("error");
}
request.setAttribute("list", list);
request.setAttribute("list2", list2);
request.setAttribute("list3", list3);
return mapping.findForward("statisticInitial");
}
/**
* 为了查询学生的交费状况而查询学生
*/
public ActionForward getStudentByNumberForQuery(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
BookFeeForm feeQueryForm = (BookFeeForm) form;
String choose = feeQueryForm.getChoose();
Long categoryId = (Long) feeQueryForm.getCategory();
Long levelId = (Long) feeQueryForm.getLevel();
Long majorId = (Long) feeQueryForm.getMajor();
String grade = feeQueryForm.getGrade();
String number = feeQueryForm.getNumber();
StudentService ss = new StudentServiceImpl();
Cclass classs = null; // 存放班级信息
int studentAmount = 0; // 学生人数
List studentList = new ArrayList(); // 学生列表
PageInfo pageInfo = null;// 存放分页信息
// 判断用户查询的方式
if ("1".equals(choose)) { // 用户输入学号进行查询
try {
Student student = ss.getStudentByNumber(number);
// 判断是否有符合条件的记录
if (student != null) {
studentList.add(student);
// 查询出该学生所在的班级
classs = ss.queryCclassById(student.getCclass().getClassId());
// 获得该班级的人数
List allStudentOfSingleClass = ss.listAllStudentsByClassId(student.getCclass().getClassId());
studentAmount = allStudentOfSingleClass.size();
}
} catch (FishException e) {
ActionErrors errors = new ActionErrors();
errors.add("error.daoprocess", new ActionMessage(
"database error!"));
return mapping.findForward("error");
}
} else { // 用户逐个条件筛选查询
Long classId = feeQueryForm.getClassId();
List list0 = null;
List list = null;
List list2 = null;
List list3 = null;
if (classId == null) { // 还没有选择班级, 则要根据查询条件查询出班级来返回到原页面, 在返回时,仍需要初始化类别, 层次, 专业下拉列表,这里还要查询出来
try {
list0 = (List) ss.queryCclass(categoryId, levelId, majorId,
grade);
list = ss.queryCategoryByName(null);
list2 = ss.queryLevelByName(null);
list3 = ss.queryMajorByName(null);
} catch (FishException e) {
e.printStackTrace();
ActionErrors errors = new ActionErrors();
errors.add("error.daoprocess", new ActionMessage(
"database error!"));
return mapping.findForward("error");
}
// 保存数据并转发
request.setAttribute("list0", list0);
request.setAttribute("list", list);
request.setAttribute("list2", list2);
request.setAttribute("list3", list3);
return mapping.findForward("queryInitial");
} else {
try {
classs = ss.queryCclassById(classId); // 根据班级id获得班级
studentList = ss.listAllStudentsByClassId(classId); // 根据班级id获得班级下的所有学生
studentAmount = studentList.size(); // 获得该班级的学生人数
} catch (FishException e) {
e.printStackTrace();
ActionErrors errors = new ActionErrors();
errors.add("error.daoprocess", new ActionMessage(
"database error!"));
return mapping.findForward("error");
}
} // 结束内else
} // 结束外else
// 设置分页信息
pageInfo = new PageInfo(1, 20); // 设置当前页为第1页, 每页显示的记录数为20
pageInfo.setMaxRecordNum(studentList.size());
// 保存数据并转发
// 把班级对象,学生列表, 学生人数, 分页类放在session里
// 如果原来session里有的话, 先移去原来的
HttpSession session = request.getSession();
session.removeAttribute("classsForBookFeeQuery");
session.removeAttribute("studentListForBookFeeQuery");
session.removeAttribute("studentAmountForBookFeeQuery");
session.removeAttribute("pageInfoForBookFeeQuery");
session.setAttribute("classsForBookFeeQuery", classs);
session.setAttribute("studentListForBookFeeQuery", studentList);
session.setAttr