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

📄 threselectaction.java

📁 这是一个可以让学生选择自己喜欢的课题
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.yourcompany.struts.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import allBeans.FirstStudentTittle;
import allBeans.Tittles;
import allDAOFactory.IFirstStudentTittleDAO;
import allDAOFactory.ILastStudentTittleDAO;
import allDAOFactory.IStudentDAO;
import allDAOFactory.ITittleDAO;

import com.yourcompany.struts.form.ThensurestudentForm;

/** 
 * MyEclipse Struts
 * Creation date: 08-07-2008
 * 
 * XDoclet definition:
 * @struts.action path="/threselect" name="thensurestudentForm" scope="request" validate="true"
 */
public class ThreselectAction extends Action {
	/*
	 * Generated Methods
	 */

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ThensurestudentForm thensurestudentForm = (ThensurestudentForm) form;// TODO Auto-generated method stub

		String thid=(String)request.getSession().getAttribute("userID"); //得到教师的id
		if(thid==null)
			return mapping.findForward("tologinth");
		
			String stiid=request.getParameter("tiid");  //得到要选择的题目的id
			request.setAttribute("stiid",stiid);      //将这个id放入request中
			Integer tiid=Integer.parseInt(stiid);   //将这个id 转换成整型
			ITittleDAO tidao=new ITittleDAO();
			Tittles tittle=tidao.tiget(tiid);     //得到这个题目的所有信息
			request.setAttribute("tittle", tittle); //将这个题目信息保存于request中
			
			IFirstStudentTittleDAO fstdao=new IFirstStudentTittleDAO();
			List list=fstdao.fstgetbytiid(tiid);
			if(list.size()>0)
			{
				//将选择这个题目的第一个学生的信息保存于request中
				String stid1=((FirstStudentTittle)list.get(0)).getFiStid();
				
				//判断这个stid是否已经被选,如果存在于最后选定表中,再判断是否是这个题目
				String isth1=null;
				ILastStudentTittleDAO lstdao=new ILastStudentTittleDAO();
				if(lstdao.lstget(stid1)!=null)  //最后选定表中有这个学生
				{
					if(lstdao.lstget(stid1).getLaThid().equals(tiid))
					{
						isth1="1";   //这个学生是被这个老师所选
						if(isth1.equals("1"))
							thensurestudentForm.setStid1("on");
					}
					else
					{
						//如果这个学生选其他老师的题目志愿大于选这个老师的题目志愿,那么这个老师可以强选
					    Integer p1=Integer.parseInt(((FirstStudentTittle)list.get(0)).getFiPrior());
					    Integer p2=Integer.parseInt(lstdao.lstget(stid1).getLaPrior());
						if(p1<p2)
						{
							isth1="1";
						}
						else
						   isth1="0";
					}
				}
				else
				{
					isth1="1";
				}
				request.setAttribute("isth1", isth1);
				
				String word1=((FirstStudentTittle)list.get(0)).getFiWord();
				String prior1=((FirstStudentTittle)list.get(0)).getFiPrior();
				IStudentDAO stdao=new IStudentDAO();
				String stname1=stdao.stget(stid1).getStName();
				request.setAttribute("stid1",stid1);
				request.setAttribute("stname1", stname1);
				request.setAttribute("word1", word1);
				request.setAttribute("prior1", prior1);
			}
			if(list.size()>1)
			{
//				将选择这个题目的第二个学生的信息保存于request中
				String stid2=((FirstStudentTittle)list.get(1)).getFiStid();
				
				//判断这个stid是否已经被选,如果存在于最后选定表中,再判断是否是这个老师所选
				String isth2=null;
				ILastStudentTittleDAO lstdao=new ILastStudentTittleDAO();
				if(lstdao.lstget(stid2)!=null)
				{
					if(lstdao.lstget(stid2).getLaThid().equals(tiid))
					{
						isth2="1";
						if(isth2.equals("1"))
							thensurestudentForm.setStid2("on");
					}
					else
					{
						//如果这个学生选其他老师的题目志愿大于选这个老师的题目志愿,那么这个老师可以强选
					    Integer p1=Integer.parseInt(((FirstStudentTittle)list.get(1)).getFiPrior());
					    Integer p2=Integer.parseInt(lstdao.lstget(stid2).getLaPrior());
						if(p1<p2)
						{
							isth2="1";
						}
						else
						   isth2="0";
					}
				}
				else
				{
					isth2="1";
				}
				request.setAttribute("isth2", isth2);
				String word2=((FirstStudentTittle)list.get(1)).getFiWord();
				String prior2=((FirstStudentTittle)list.get(1)).getFiPrior();
				IStudentDAO stdao=new IStudentDAO();
				String stname2=stdao.stget(stid2).getStName();
				request.setAttribute("stid2",stid2);
				request.setAttribute("stname2", stname2);
				request.setAttribute("word2", word2);
				request.setAttribute("prior2", prior2);
			}
			if(list.size()>2)
			{
//				将选择这个题目的第三个学生的信息保存于request中
				String stid3=((FirstStudentTittle)list.get(2)).getFiStid();
				
				//判断这个stid是否已经被选,如果存在于最后选定表中,再判断是否是这个老师所选
				String isth3=null;
				ILastStudentTittleDAO lstdao=new ILastStudentTittleDAO();
				if(lstdao.lstget(stid3)!=null)
				{
					if(lstdao.lstget(stid3).getLaThid().equals(tiid))
					{
						isth3="1";
						if(isth3.equals("1"))
							thensurestudentForm.setStid3("on");
					}
					else
					{
						//如果这个学生选其他老师的题目志愿大于选这个老师的题目志愿,那么这个老师可以强选
					    Integer p1=Integer.parseInt(((FirstStudentTittle)list.get(2)).getFiPrior());
					    Integer p2=Integer.parseInt(lstdao.lstget(stid3).getLaPrior());
						if(p1<p2)
						{
							isth3="1";
						}
						else
						   isth3="0";
					}
				}
				else
				{
					isth3="1";
				}
				request.setAttribute("isth3", isth3);
				String word3=((FirstStudentTittle)list.get(2)).getFiWord();
				String prior3=((FirstStudentTittle)list.get(2)).getFiPrior();
				IStudentDAO stdao=new IStudentDAO();
				String stname3=stdao.stget(stid3).getStName();
				request.setAttribute("stid3",stid3);
				request.setAttribute("stname3", stname3);
				request.setAttribute("word3", word3);
				request.setAttribute("prior3", prior3);
			}
			request.setAttribute("iscommit", "1");
			request.setAttribute("size", String.valueOf(list.size()));
			return mapping.findForward("tothensurestudent");	
	}
}

⌨️ 快捷键说明

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