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

📄 gradedao.java

📁 中应用程序的访问权限对Java Web Console 中应用程序的访问权限 成功登录 Web 控制台后,可能无法自动访问在该控制台中注册的所有应用程序。通常,必须安装应用程序,才能让所有的用户在控制
💻 JAVA
字号:
package edu.yinhe.mis.model;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import edu.yinhe.mis.dto.GradeDTO;
import edu.yinhe.mis.dto.Reply_cardDTO;
import edu.yinhe.mis.dto.TestpaperruleDTO;
import edu.yinhe.mis.vo.ExamineeVO;
import edu.yinhe.mis.vo.GradeVO;
import edu.yinhe.mis.vo.QuestionTypeVO;
import edu.yinhe.mis.vo.Reply_cardVO;
import edu.yinhe.mis.vo.TestpaperruleVO;
import edu.yinhe.system.model.BaseDAO;
/**
 * 
 * @author 何亮
 *
 */
public class GradeDAO extends BaseDAO {

	public Object delete(Object arg0) throws SQLException {
		return arg0;
		
	}
/**
 * 从questiontype表中查询题目类型(诸如单选,多选之类)的id,将其封装在ArrayList()中
* @param 
* @return  ArrayList
* @exception SQLException
*/
	public Object find() throws SQLException {
		String sql=null;
		PreparedStatement patst=null;
		ResultSet rst=null;
		ArrayList alist2=null;
		QuestionTypeVO qvo=null;
		try {
			
			sql="SELECT QUESTIONTYPE_ID FROM questiontype";
			patst=conn.prepareStatement(sql);
			rst=patst.executeQuery();
			alist2=new ArrayList();
			while(rst.next()){
				qvo=new QuestionTypeVO();
				qvo.setQuestionTypeID(rst.getInt("QUESTIONTYPE_ID"));
				alist2.add(qvo);
			}
		} catch (SQLException e) {
			System.out.println("在执行GradeDAO的find()方法时出现错误");
			e.printStackTrace();
		}finally{
			if(patst==null){
				patst.close();
			}if(rst==null){
				rst.close();
			}
			sql=null;
		}
		return alist2;
	}
/**
 * 从考生表中根据考生考号获得科目名,将其封装在ArrayList()中
 * @param ExamineeVO
 * @return  ArrayList
 * @exception SQLException
 */
	public Object find(Object arg0) throws SQLException {
		String sql=null;
		PreparedStatement patst=null;
		ResultSet rst=null;
		Reply_cardDTO rdto=new Reply_cardDTO();
		ArrayList alist1=null;
		String exam_no=null;
		try {
			
			rdto=(Reply_cardDTO) arg0;
			exam_no=rdto.getExam_no();
			sql="SELECT OBJECT_NAME FROM examinee WHERE EXAM_NO="+exam_no;
			patst=conn.prepareStatement(sql);
			rst=patst.executeQuery();
			alist1=new ArrayList();
			while(rst.next()){
				ExamineeVO evo = new ExamineeVO();
				evo.setObject_name(rst.getString("OBJECT_NAME"));
				alist1.add(evo);
			}
		}catch (SQLException e) {
			System.out.println("在执行Gradedao中的find(Object arg0)方法是出现错误");
			e.printStackTrace();
		}finally{
			if(rst==null){
				rst.close();
			}if(patst==null){
				patst.close();
			}
			sql=null;
		}
		return alist1;
	}
	/**
	 * 
	 * @param 
	 * @return  ArrayList
	 * @exception SQLException
	 */
	public Object findAll() throws SQLException {
		String sql=null;
		PreparedStatement patst=null;
		ResultSet rst=null;	
		ExamineeVO evo=null;
		ArrayList alist3=null;
		try {
			sql="select EXAM_NO FROM examinee";
			patst=conn.prepareStatement(sql);
			rst=patst.executeQuery();
			alist3=new ArrayList();
				while(rst.next()){
					evo = new ExamineeVO();
					evo.setExam_NO(rst.getString("EXAM_NO"));
					alist3.add(evo);
			}
		}catch (SQLException e) {
			System.out.println("在执行Gradedao中的findAll()方法是出现错误");
			e.printStackTrace();
		}finally{
			if(rst==null){
				rst.close();
			}if(patst==null){
				patst.close();
			}
			sql=null;
		}
		return alist3;
	}
/**
 * @param Reply_cardDTO.getObject_name() Reply_cardDTO.getQuestion_type()
 * @return 	ArrayList	
 * @exception SQLException
 */
	public Object findAll(Object arg0) throws SQLException {
		String sql=null;
		Reply_cardDTO rdto=new Reply_cardDTO();
		Reply_cardVO rvo=null;
		rdto=(Reply_cardDTO) arg0;
		Integer questiontype=0;
		String object_name=null;
		String exam_no=null;
		object_name=rdto.getObject_name();
		questiontype=rdto.getQuestion_type();
		exam_no=rdto.getExam_no();
		PreparedStatement patst=null;
		ResultSet rst=null;
		ArrayList alist=null;
		try {
			sql="SELECT STUDENT_KEY,STANDARD_KEY FROM reply_card " +
				  "WHERE QUESTION_TYPE="+questiontype+" AND " +
					"OBJECT_NAME='"+object_name+"' AND "+
					  "EXAM_NO="+exam_no;
			patst=conn.prepareStatement(sql);
			rst=patst.executeQuery();
			alist=new ArrayList();
			while(rst.next()){
				rvo=new Reply_cardVO();
				if(rst.getString("STUDENT_KEY")==null){
					rvo.setStudent_key("0");				
				}
				if(rst.getString("STANDARD_KEY")==null){
					rvo.setStandard_key("0");
				}
				rvo.setStudent_key(rst.getString("STUDENT_KEY"));
				rvo.setStandard_key(rst.getString("STANDARD_KEY"));
				alist.add(rvo);
			}
		} catch (SQLException e) {
			System.out.println("在执行Gradedao中的findAll(Object arg0)方法是出现错误");
			e.printStackTrace();
		}finally{
			if(rst==null){
				rst.close();
			}if(patst==null){
				patst.close();
			}
			sql=null;
		}
		return alist;
	}
	/**
	 * @param TestpaperruleDTO
	 * @return  TestpaperruleVO
	 * @exception SQLException
	 */
	public Object findById(Object arg0) throws SQLException {
		String sql=null;
		PreparedStatement patst=null;
		ResultSet rst=null;
		TestpaperruleDTO tdto = new TestpaperruleDTO();
		TestpaperruleVO tvo=null;
		String objectname=null;
		tdto=(TestpaperruleDTO) arg0;
		Integer questiontypeid=0;
		objectname=tdto.getObjectName();
		questiontypeid=tdto.getQuestionTypeID();
		try {
			sql="SELECT QUESTION_VALUE,QUESTIONAMOUNT FROM testpaperrule WHERE " +
					"OBJECT_NAME='"+objectname+"' AND QUESTIONTYPE_ID="+
					questiontypeid;
			patst=conn.prepareStatement(sql);
			rst=patst.executeQuery();
			while(rst.next()){
				tvo=new TestpaperruleVO();
				tvo.setQuestionValue(rst.getInt("QUESTION_VALUE"));
				tvo.setQuestionAmount(rst.getInt("QUESTIONAMOUNT"));
			}
		}catch (SQLException e) {
			System.out.println("在执行Gradedao中的findById(Object arg0)方法是出现错误");
			e.printStackTrace();
		}finally{
			if(rst==null){
				rst.close();
			}if(patst==null){
				patst.close();
			}
			sql=null;
		}
		return tvo;
	}

	public Object findByObject(Object arg0) throws SQLException {
		String sql=null;
		PreparedStatement pstat=null;
		ResultSet rst=null;
		ExamineeVO evo=null;
		evo = (ExamineeVO) arg0;
		try {
			sql="SELECT estate FROM examinee";
			pstat=conn.prepareStatement(sql);
			rst=pstat.executeQuery();
			while(rst.next()){
				evo=new ExamineeVO();
				evo.setEstate(rst.getInt("estate"));
			}
		} catch (RuntimeException e) {
			e.printStackTrace();
		}finally{
			if(rst==null){
				rst.close();
			}if(pstat==null){
				pstat.close();
			}
			sql=null;
		}
		return evo;
	}

	public int getCount(Object arg0) throws SQLException {
		return 0;
	}

	public Object getMaxId(Object arg0) throws SQLException {
		
		return null;
	}

	public Object insert(Object arg0) throws SQLException {
		String sql=null;
		PreparedStatement pstat=null;
		String selectonepoint = null;
		String selectmanypoint=null;
		String judgementpoint = null;
		String follow_score = null;
		String object_name = null;
		String exam_no = null;
		GradeVO gvo=new GradeVO();
		gvo=(GradeVO) arg0;
		exam_no=gvo.getExamno();
		object_name=gvo.getObjectname();
		selectonepoint=gvo.getSelectonepoint();
		selectmanypoint=gvo.getSelectmanypoint();
		judgementpoint=gvo.getJudgementpoint();
		if(selectonepoint==null){
			selectonepoint="0";
		}
		if(selectmanypoint==null){
			selectmanypoint="0";
		}
		if(judgementpoint==null){
			judgementpoint="0";
		}
		String sum = follow_score=String.valueOf(Integer.valueOf(selectonepoint)+Integer.valueOf(selectmanypoint)+Integer.valueOf(judgementpoint));
		if(follow_score==null){
			follow_score="0";
		}
		if(sum==null){
			sum="0";
		}
		int i = 0;
		try {
			sql="INSERT INTO grade_table(SELECTONEPOINT,SELECTMANYPOINT,JUDGEMENTPOINT,"+
					"FOLLOW_SCORE,OBJECT_NAME,EXAM_NO,SUMSCORE) VALUES("+selectonepoint+","
					+selectmanypoint+","+judgementpoint+","+follow_score+",'"+object_name+"',"
					+exam_no+","+sum+")";
			pstat=conn.prepareStatement(sql);
			pstat.executeUpdate();
			conn.commit();
			i = 1;
		} catch (SQLException e) {
			System.out.println("在执行GradeDAO中的insert(}方法时出现异常");
			e.printStackTrace();
		}finally{
			if(pstat==null){
				pstat.close();
			}
		
			sql=null;
		}
		
		return i;
	}

	

	public Object update(Object arg0) throws SQLException {
		String sql = null;
		PreparedStatement pstat=null;
		ResultSet rst=null;
		GradeDTO gdto = (GradeDTO) arg0;
		Integer i=0;
		try {
			sql = "UPDATE examinee SET ESTATE=1";
			pstat=conn.prepareStatement(sql);
			pstat.executeUpdate();
			conn.commit();
			i=1;
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			if(rst==null){
				rst.close();
			}if(pstat==null){
				pstat.close();
			}
			sql=null;
		}
		return i;
	}

}

⌨️ 快捷键说明

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