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

📄 impl.java

📁 培训时做的学生管理系统.基于J2SE平台开发
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		PreparedStatement pstmt = null;
		ResultSet set = null;
		conn = DBConnection.getConnectionOracle();
		try {
			pstmt = conn.prepareStatement(ClassSystemDBsql.FINDCLASS_BYTNO);
			pstmt.setInt(1, t_id);
			set = pstmt.executeQuery();
			int number = getNumberByTNo(t_id);
			int max = set.getMetaData().getColumnCount();
			data = new Object[number][max];
			int i = 0;
			while (set.next()) {
				for (int j = 0; j < max; j++) {
					data[i][j] = set.getObject(j + 1);
				}
				i++;
			}

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return data;
	}

	/**
	 * 查询所有的课程
	 */
	public Object[][] allClassFind() {
		Object[][] data = null;
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet set = null;
		conn = DBConnection.getConnectionOracle();
		try {
			pstmt = conn.prepareStatement(ClassSystemDBsql.ALLCLASS_FIND);
			set = pstmt.executeQuery();
			int max = set.getMetaData().getColumnCount();
			int row = getNumber();
			int i = 0;
			data = new Object[row][max];
			while (set.next()) {
				for (int j = 0; j < max; j++) {
					data[i][j] = set.getObject(j + 1);
				}
				i++;

			}

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return data;
	}
	
	/**
	 * 进行首次登记
	 */
	public boolean classBook(int classNo,int stuNo,String className){
		boolean flag = false;
		Connection conn = null;
		PreparedStatement pstmt = null;
		conn = DBConnection.getConnectionOracle();
		try {
			pstmt = conn.prepareStatement(ClassSystemDBsql.CLASS_BOOK);
			pstmt.setInt(1, classNo);
			pstmt.setInt(2, stuNo);
			pstmt.setString(3,className);
			pstmt.setInt(4, 1);
			int count = pstmt.executeUpdate();
			if(count != 0){
			}flag = true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return flag;
	}

	/**
	 *一个学生所有课程出勤情况
	 */
	public Object[][] momerizeABookTime(int stuNo){
		Object[][] data = null;
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet set = null;
		conn = DBConnection.getConnectionOracle();
		try {
			pstmt = conn.prepareStatement(ClassSystemDBsql.BRETRAY_FIND);
			pstmt.setInt(1, stuNo);
			set = pstmt.executeQuery();
			int number = getNumberBySNo(stuNo);
			data = new Object[number][3];
			int i= 0;
			while(set.next()){
				for(int j= 0;j< 3;j++){
					data[i][j] = set.getObject(j+1);
				}
				i++;
			}
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return data;
	}
	/**
	 * 记录登记次数
	 */
	public boolean momerizeBookTime(int stuNo,int classNo){
		boolean flag = false;
		Connection conn = null;
		PreparedStatement pstmt = null;
		conn = DBConnection.getConnectionOracle();
		try {
			pstmt = conn.prepareStatement(ClassSystemDBsql.CLASS_BOOKTIME);
			pstmt.setInt(1, stuNo);
			pstmt.setInt(2, classNo);
			int count = pstmt.executeUpdate();
			if(count != 0){
				flag = true;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return flag;
	}
	
	/**
	 * 获得所选学生出勤情况的信息
	 */
	public Object[][] classBookInfo(int stuNo, int classNo){
		Object[][] data = null;
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet set = null;
		conn = DBConnection.getConnectionOracle();
		try {
			pstmt = conn.prepareStatement(ClassSystemDBsql.BOOKTIME_FIND);
			pstmt.setInt(1, stuNo);
			pstmt.setInt(2, classNo);
			set = pstmt.executeQuery();
			System.out.println(stuNo+"看看"+classNo);
			int row = getClassCount(stuNo,classNo);
			System.out.println(row);
			int i = 0;
			int column = set.getMetaData().getColumnCount();
			data = new Object[row][column];
			while(set.next()){
				for(int j = 0;j<column;j++){
					data[i][j] = set.getObject(j+1);
				}
				i++;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return data;
	}
	/**
	 * 一个学生选的课程数
	 * @param s_id
	 * @return
	 */
	public int getNumberBySNo(int s_id) {
		int number = 0;
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet set = null;
		conn = DBConnection.getConnectionOracle();
		try {
			pstmt = conn.prepareStatement(ClassSystemDBsql.CLASSCOUNT);
			pstmt.setInt(1, s_id);
			set = pstmt.executeQuery();
			set.next();
			number = set.getInt(1);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return number;
	}
	/**
	 * 得到有登记记录的课程总数
	 */
	public int getClassCount(int stuNo,int classNo){
		int number  = 0;
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet set = null;
		conn = DBConnection.getConnectionOracle();
		try {
			pstmt = conn.prepareStatement(ClassSystemDBsql.CLASSBOOK_COUNT);
			System.out.println("stuNo = :"+stuNo);
			pstmt.setInt(1,stuNo);
			pstmt.setInt(2, classNo);
			set = pstmt.executeQuery();
			set.next();
			number = set.getInt(1);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return number;
		
	}
	/**
	 * 把获得的信息传到StudentVo中
	 * 
	 * @param set
	 * @return
	 * @throws SQLException
	 */

	public ClassStudentVo setLableInfo(ResultSet set) throws SQLException {
		ClassStudentVo vo = new ClassStudentVo();
		while (set.next()) {
			vo.setStu_ID(set.getInt(1));
			vo.setG_No(set.getInt(2));
			vo.setStu_name(set.getString(3));
			vo.setStu_sex(set.getString(4));
			vo.setGrade(set.getString(5));
			vo.setSchool(set.getString(6));
			vo.setSpeciality(set.getString(7));
			vo.setStu_tel(set.getInt(8));
			vo.setQqNo(set.getInt(9));
			vo.setStu_email(set.getString(10));
		}
		return vo;
	}
	
	/**
	 * 检索课程的部分信息
	 */
	public ClassVO classPInfo(int classNo){
		ClassVO vo = new ClassVO();
		Connection conn = DBConnection.getConnectionOracle();
		PreparedStatement pstmt = null;
		ResultSet set = null;
		try {
			pstmt = conn.prepareStatement(ClassSystemDBsql.CLASSINFO_PART);
			pstmt.setInt(1, classNo);
			set = pstmt.executeQuery();
			while(set.next()){
				vo.setClassID(set.getInt(1));
				vo.setClassname(set.getString(2));
				vo.setClasstime(set.getString(3));
				vo.setCredithour(set.getInt(4));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
			return vo;
	}
	/**
	 * 检查课程是否有过首次登记
	 * @param classNo
	 * @param stuNo
	 * @return
	 */
	 public boolean checkClassBook(int stuNo, int classNo){
		    boolean flag = false;
		    Connection conn = DBConnection.getConnectionOracle();
		    PreparedStatement pstmt = null;
		    ResultSet set = null;
		    try{
		      pstmt = conn.prepareStatement(ClassSystemDBsql.BOOKTIME_FIND);
		      pstmt.setInt(1,stuNo);
		      pstmt.setInt(2,classNo);
		      set = pstmt.executeQuery();
		      if(set.next()){
		        flag = true;
		      }
		    }catch(SQLException e){
		      System.out.println(e.getMessage());
		    }
		    return flag;
		  }
	 /**
	  * 检查老师是否存在
	  */
	 public boolean checkTeacher(int t_id){
		 boolean flag =  false;
		 Connection conn = DBConnection.getConnectionOracle();
		 PreparedStatement pstmt = null;
		 ResultSet set = null;
		 try {
			pstmt = conn.prepareStatement(ClassSystemDBsql.TEA_CHECK);
			pstmt.setInt(1, t_id);
			set = pstmt.executeQuery();
			while(set.next()){
				flag = true;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		 return flag;
	 }
	 /**
	  * 检查学生是否存在
	  */
	 public boolean checkStudent(int s_id){
		 boolean flag =  false;
		 Connection conn = DBConnection.getConnectionOracle();
		 PreparedStatement pstmt = null;
		 ResultSet set = null;
		 try {
			 pstmt = conn.prepareStatement(ClassSystemDBsql.STU_CHECK);
			 pstmt.setInt(1, s_id);
			 set = pstmt.executeQuery();
			 while(set.next()){
				 flag = true;
			 }
		 } catch (SQLException e) {
			 // TODO Auto-generated catch block
			 e.printStackTrace();
		 }
		 return flag;
	 }
	 
	 /**
	  * 查找所有的老师编号,编号加到添加面板上
	  */
	 public void findTeacherNo(){
		 Connection conn = DBConnection.getConnectionOracle();
		 PreparedStatement pstmt = null;
		 ResultSet set = null;
		 try {
			pstmt = conn.prepareStatement(ClassSystemDBsql.TEA_N_N_FIND);
			set = pstmt.executeQuery();
			while(set.next()){
				ClassIntercalateAdd.c4.addItem(set.getInt(1));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	 }
	 
	 /**
	  * 查找所有的老师编号,编号加到修改面板上
	  */
	 public void findTeacherNo1(){
		 Connection conn = DBConnection.getConnectionOracle();
		 PreparedStatement pstmt = null;
		 ResultSet set = null;
		 try {
			 pstmt = conn.prepareStatement(ClassSystemDBsql.TEA_N_N_FIND);
			 set = pstmt.executeQuery();
			 while(set.next()){
				 ClassUpdate.c4.addItem(set.getInt(1));
			 }
		 } catch (SQLException e) {
			 // TODO Auto-generated catch block
			 e.printStackTrace();
		 }
	 }
	 public boolean classDeleteChoose(int stuNo,int classNo){
		 boolean flag =  false;
		 Connection conn = DBConnection.getConnectionOracle();
		 PreparedStatement pstmt = null;
		
		 try {
			 pstmt = conn.prepareStatement(ClassSystemDBsql.CLASSDELETE_CHOOSE);
			 pstmt.setInt(1, stuNo);
			 pstmt.setInt(2, classNo);
			 int count = pstmt.executeUpdate();
			 if(count != 0){
				 flag = true;
			 }
		 } catch (SQLException e) {
			 // TODO Auto-generated catch block
			 e.printStackTrace();
		 }
		 return flag;
	 }
}

⌨️ 快捷键说明

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