package scoreInfo;

import java.sql.*;
public class classp  {

  private String id;
  private String cour_id;
  private String tea_id;
  private String room_id;
  private String cour_time;
  public String getId() {
    return id;
  }
  public void setId(String id) {
    this.id = id;
  }
  public String getCour_id() {
    return cour_id;
  }
  public void setCour_id(String cour_id) {
    this.cour_id = cour_id;
  }
  public String getTea_id() {
    return tea_id;
  }
  public void setTea_id(String tea_id) {
    this.tea_id = tea_id;
  }
  public String getRoom_id() {
    return room_id;
  }
  public void setRoom_id(String room_id) {
    this.room_id = room_id;
  }
  public String getCour_time() {
    return cour_time;
  }
  public void setCour_time(String time) {
    this.cour_time = time;
  }
  
  public ResultSet getClassById(String classid){
  	String sql="select *  from classes where id ='"+classid+"'";
  	sqlBean db = new sqlBean();
  	ResultSet rs = db.executeQuery(sql);
  	return rs;
  	       }
  	
  public ResultSet getTeachers(){
	  	String sql="select id,name from teacher  ";
	  	sqlBean db = new sqlBean();
	  	ResultSet rs = db.executeQuery(sql);
	  	return rs;
	  	       }
  
  public ResultSet getCourses(){
  	  	String sql="select id,name from course  ";
  	sqlBean db = new sqlBean();
  	ResultSet rs = db.executeQuery(sql);
  	return rs;  	          
                              }
                              
   	public boolean hasLogin(String id){   
  	boolean f=false;
    String sql="select id from classes where id ='"+id+"'";
  	sqlBean db =new sqlBean();
  	try{
  	ResultSet rs=db.executeQuery(sql);
  	if(rs.next()){ f=true;}
  	else{ f=false;}
  	}catch(Exception e){ e.getMessage();}
  	return f;
  	                       }
  	                                                                              
   public String hasMoreclass(String tea_id,String cour_time){   //检查教师是否同一时间上两门课程
    
    String temp="";
    String sql="select id from classes  "+
               "where tea_id='"+tea_id+"' and cour_time='"+cour_time+"'   "; 
      sqlBean db =new sqlBean();         	
    	try{
  	ResultSet rs=db.executeQuery(sql);
  	if(rs.next()){ temp=rs.getString("id");}
  	else{ temp="no";}
  	}catch(Exception e){ System.out.print(e.getMessage());}
  	return temp;        
  	                  }
  	                  
  	                  
  public void addClass(){
  		
  	String sql="insert into classes(id,tea_id,cour_id,room_id,cour_time)  "+
  	           "values('"+id+"','"+tea_id+"','"+cour_id+"','"+room_id+"','"+cour_time+"') ";
  	    try{       
  		sqlBean db =new sqlBean(); 
  		db.executeInsert(sql);} catch(Exception e){System.out.print(e.toString());}
  		}
  		
  		
   public void updateClass(String id,String tea_id,String cour_id,
                           String room_id,String cour_time){    	
      String sql="update classes "+
                 " set tea_id='"+tea_id+"',cour_id='"+cour_id+"',"+
                 "room_id='"+room_id+"',cour_time='"+cour_time+"'  "+
                 " where id='"+id+"' ";
                 sqlBean db= new sqlBean();
                 db.executeInsert(sql);
                 }
                 
  public void updateClass(String id,String cour_id,
                          String room_id){    	
      String sql="update classes "+
                 " set cour_id='"+cour_id+"',"+
                 "room_id='"+room_id+"' "+
                 " where id='"+id+"' ";
                 sqlBean db= new sqlBean();
                 db.executeInsert(sql);
                 }       
                 
   public int deleteClass(String id){  
        int num=0; 	
    	String sql="delete  from classes where id ='"+id+"' ";
    	sqlBean db= new sqlBean();
        num=db.executeDelete(sql);
        return num;
    	}
    	
   public ResultSet getClasses(){
   	
   	String sql="select classes.id,tea_id,cour_id,room_id,cour_time, "+
			"course.name as cour_name,teacher.name as tea_name "+
      		"from classes ,course,teacher  "+
     		"where classes.cour_id=course.id "+
    		"and classes.tea_id=teacher.id ";
   			sqlBean db= new sqlBean();
		ResultSet rs = db.executeQuery(sql);
		 return rs;           
   	} 	    
   
   public ResultSet  getClasspRecd(int curpag){
		  ///String sql="select * from student limit "+ currec"4 " ;
		  int row=(curpag-1)*4;
		  String sql="select top 4 classes.id,tea_id,cour_id,room_id,cour_time, "+
			"course.name as cour_name,teacher.name as tea_name from  classes ,course,teacher where classes.id not in (select top "+row+"classes.id,tea_id,cour_id,room_id,cour_time, "+
			"course.name as cour_name,teacher.name as tea_name from  classes ,course,teacher ) and classes.cour_id=course.id "+
    		"and classes.tea_id=teacher.id ";
			sqlBean db= new sqlBean();
			ResultSet rs = db.executeQuery(sql);
			 return rs;
	     } 
	 
   
   
   
   public int  getAllCount(){
		String sql="select tea_id,cour_time from classes ";
		sqlBean db= new sqlBean();
		ResultSet rs = db.executeQuery(sql);
		int count=0;
		try {
			while(rs.next()){
				count++;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
			System.out.println(count);
		 return count;
} 
 
   
 	   
   public ResultSet getClassesById(String classid){
	   	
	   	String sql="select classes.id,tea_id,cour_id,room_id,cour_time, "+
				"course.name as cour_name,teacher.name as tea_name "+
	      		"from classes ,course,teacher  "+
	     		"where classes.cour_id=course.id "+
	    		"and classes.tea_id=teacher.id and classes.id='"+classid+"'";
	   			sqlBean db= new sqlBean();
			ResultSet rs = db.executeQuery(sql);
			 return rs;           
	   	} 	
  
}
最近下载更多
123456cjj  LV1 6月2日
wcheng  LV2 2023年10月18日
lsj123456798  LV3 2022年12月30日
lyzzz520  LV1 2022年12月18日
485415187  LV6 2022年11月22日
微信网友_5970838873509888  LV2 2022年5月23日
微信网友_5764743416303616  LV6 2022年4月22日
roygugu  LV2 2022年4月9日
illkih  LV2 2022年3月17日
17771013609  LV4 2021年12月27日
最近浏览更多
sariel_zeng 7月7日
暂无贡献等级
asdfgh112 7月4日
暂无贡献等级
时光海  LV2 6月30日
taoshen95  LV15 6月25日
suhaifeng 6月21日
暂无贡献等级
15719908287  LV9 6月19日
xzg123456  LV6 6月18日
暂无贡献等级
你好啊213123 6月4日
暂无贡献等级
123456cjj  LV1 6月1日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友