<repo_name>andychen199/Student-management-system<file_sep>/src/attendance/dao/TeachDao.java
package attendance.dao;
//任职记录DAO,给管理员看的
import java.sql.*;
import javax.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import attendance.bean.Course;
import attendance.bean.Teach;
import attendance.bean.TeachforUI;;
public class TeachDao {
	public TeachDao(){
		 try {
	            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	          // System.out.println("加载驱动成功！");
	        } catch (ClassNotFoundException e) {
	            e.printStackTrace();
	            System.out.println("加载驱动失败！");
	        }
	}
	public Connection getConnection()throws SQLException{
     //抛出异常
		return DriverManager.getConnection("jdbc:sqlserver://sql.cerny.cn:1433;DatabaseName=attendance", "sa", "Myclassdesign330");
		//数据库的名字叫attendance，我的数据库账户是sa,密码是sa
		//这里我建立连接的时候不是用try-catcth来捕捉异常，而是主动抛出，那么我下面调用这个函数时要么继续抛出，要么用try-catcth捕捉，我选择用try-catcth捕捉，到时候主函数就不用处理了
     }
	public int getTotal() {
		//得到目前表Teach总数有多少条
       int total = 0;
       try (Connection c = getConnection(); Statement s = c.createStatement();) {          
           String sql = "select count(*) from Teach"; 
           ResultSet rs = s.executeQuery(sql);
           while (rs.next()) {
               total = rs.getInt(1);//	这里getInt是因为rs这个结果集这里是返回的结果行数
           }
           // System.out.println("total:" + total); 
       } catch (SQLException e) {  
           e.printStackTrace();
       }
       return total;
   }
	public boolean add(int Tno,int Cno,int  Tschool,int Tsgrade) {
		//任课老师职工号，课程号，学时，学分
        String sql = " insert into Teach(Tno, Cno,Tschool,Tsgrade) values(?,?,?,?) ";
        try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);) { 
        	ps.setInt(1,Tno);
        	ps.setInt(2,Cno);
        	ps.setInt(3,Tschool);
        	ps.setInt(4,Tsgrade);
            ps.execute();  
            return true;
            //ResultSet rs = ps.getGeneratedKeys();//如果因为主码自增不插，然后通过这里得到主码赋值给对象对应的属性
        } catch (SQLException e) {  
            e.printStackTrace();
            return false;
        }
    }
	public boolean update(int Tno,int Cno,int Tno1,int Cno1,int  Tschool,int Tsgrade) {
		//任课老师职工号，课程号，学时，学分	
		//因为这个任课表的主码是参照别的表的，可以修改，Tno,Cno是原来的主码，Tno1,Cno1是后来要修改的
         String sql = "update Teach set Tno=?, Cno=? ,Tschool=?, Tsgrade=? where Cno ="+Cno+" and "+"Tno="+Tno; 
	    	 try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);){	    		
	    		 ps.setInt(1,Tno1); 	    		 
	    		 ps.setInt(2,Cno1);
	    		 ps.setInt(3,Tschool); 	    		 
	    		 ps.setInt(4,Tsgrade);
	    		 ps.execute();
	    		 return true;
	    	//	 System.out.println("修改成功");	    		 
	    	 }catch (SQLException e1) {
		            e1.printStackTrace();		     
		      }catch (Exception e2) {// 捕获其他异常
		    	  e2.printStackTrace();// 打印异常产生的过程信息
		      }
	    	 return false;
	    	}
	public void delete(int Tno,int Cno) {
		 //删除函数
		 try (Connection c = getConnection(); Statement s = c.createStatement();) {				  
	            String sql = "delete from Course where Cno ="+Cno+"and"+"Tno="+Tno; 
	            s.execute(sql);	
	            //System.out.println("删除成功");
	      }catch(SQLException e1) {
	            e1.printStackTrace();
	      }catch(Exception e2) {// 捕获其他异常
	    	  e2.printStackTrace();// 打印异常产生的过程信息
	      }
	    }	
	 public List<Teach> list1(int Tno,int Cno) {
	        List<Teach> teachs = new ArrayList<Teach>();
	  //把符合条件的Teach数据查询出来，转换为Teach对象后，放在一个集合中返回
	   //String sql = "select * from hero order by id desc limit ?,? ";		       	         
	        int Tschool=0;//学时
	        int Tsgrade=0;//学分
	        //按即主码查询，单个
	        //System.out.println("请输入要查询任课老师职工号，课程号:");	        	
	        String sql = "select * from Teach where Cno ="+Cno+"and"+"Tno="+Tno; 
		    try (Connection c = getConnection(); Statement s = c.createStatement();) {
		        	ResultSet rs = s.executeQuery(sql);
		            while (rs.next()) {
		            	/*定义一个类型为Teach的对象teach ，在while里查询出来的属性赋值给它，接着把对象该给集合，然后返回集合
		                 * 下面的一样道理*/  
		            	Teach teach=new Teach() ;
		            	Tno= rs.getInt(1);
		            	Cno=rs.getInt(2);
		            	Tschool = rs.getInt("Tschool");	
		            	Tsgrade=rs.getInt(4);
		            	teach.Tno=Tno;
		            	teach.Cno=Cno;
		            	teach.Tschool=Tschool;
		            	teach.Tsgrade=Tsgrade;
		            	teachs.add(teach);
		            }
		        }catch (SQLException e) {
		            e.printStackTrace();}
		     return teachs;//返回系集合，符合条件的系的信息
	    }
	 public List<Teach> list2() {
	        List<Teach> teachs = new ArrayList<Teach>();
	  //把Teach数据查询出来，转换为Teach对象后，放在一个集合中返回
	   //String sql = "select * from hero order by id desc limit ?,? ";	
	        int Tno=0;//任课老师职工号
	        int Cno=0;//课程号
	        int Tschool=0;//学时
	        int Tsgrade=0;//学分
	      //都查询出来
	        //System.out.println("请输入要查询任课老师职工号，课程号:");	        	
	        String sql = "select * from Teach ";
		    try (Connection c = getConnection(); Statement s = c.createStatement();) {
		        	ResultSet rs = s.executeQuery(sql);
		            while (rs.next()) {
		            	Teach teach=new Teach() ;
		            	Tno= rs.getInt(1);
		            	Cno=rs.getInt(2);
		            	Tschool = rs.getInt("Tschool");	
		            	Tsgrade=rs.getInt(4);
		            	teach.Tno=Tno;
		            	teach.Cno=Cno;
		            	teach.Tschool=Tschool;
		            	teach.Tsgrade=Tsgrade;
		            	teachs.add(teach);
		            }
		        }catch (SQLException e) {
		            e.printStackTrace();}
		     return teachs;//返回系集合，符合条件的系的信息
	    }
	 public List<Teach> list3(int Tno) {
	        List<Teach> teachs = new ArrayList<Teach>();
	  //把符合条件的Teach数据查询出来，转换为Teach对象后，放在一个集合中返回
	   //String sql = "select * from hero order by id desc limit ?,? ";		       	         
	        int Cno = 0;
	        int Tschool=0;//学时
	        int Tsgrade=0;//学分
	        //按即主码查询，单个
	        //System.out.println("请输入要查询任课老师职工号，课程号:");	        	
	        String sql = "select * from Teach where Tno ="+Tno; 
		    try (Connection c = getConnection(); Statement s = c.createStatement();) {
		        	ResultSet rs = s.executeQuery(sql);
		            while (rs.next()) {
		            	/*定义一个类型为Teach的对象teach ，在while里查询出来的属性赋值给它，接着把对象该给集合，然后返回集合
		                 * 下面的一样道理*/  
		            	Teach teach=new Teach() ;
		            	Tno= rs.getInt(1);
		            	Cno=rs.getInt(2);
		            	Tschool = rs.getInt("Tschool");	
		            	Tsgrade=rs.getInt(4);
		            	teach.Tno=Tno;
		            	teach.Cno=Cno;
		            	teach.Tschool=Tschool;
		            	teach.Tsgrade=Tsgrade;
		            	teachs.add(teach);
		            }
		        }catch (SQLException e) {
		            e.printStackTrace();}
		     return teachs;//返回系集合，符合条件的系的信息
	    }
	 public List<TeachforUI> list3forUI(int Tno) {
	        List<TeachforUI> teachs = new ArrayList<TeachforUI>();
	  //把符合条件的Teach数据查询出来，转换为Teach对象后，放在一个集合中返回
	   //String sql = "select * from hero order by id desc limit ?,? ";		       	         
	        int Cno = 0;
	        String Cname=null;
	        int Tschool=0;//学时
	        int Tsgrade=0;//学分
	        //按即主码查询，单个
	        //System.out.println("请输入要查询任课老师职工号，课程号:");	        	
	        String sql = "select distinct Course.Cno,Cname,Tschool,Tsgrade from Course,Teach where Course.Cno=Teach.Cno and Tno="+Tno; 
		    try (Connection c = getConnection(); Statement s = c.createStatement();) {
		        	ResultSet rs = s.executeQuery(sql);
		            
		        	while (rs.next()) {
		            	/*定义一个类型为Teach的对象teach ，在while里查询出来的属性赋值给它，接着把对象该给集合，然后返回集合
		                 * 下面的一样道理*/  
		            	TeachforUI teach=new TeachforUI();
		            	Cno= rs.getInt(1);
		            	Cname=rs.getString(2);
		            	Tschool = rs.getInt("Tschool");	
		            	Tsgrade=rs.getInt(4);
		            	teach.Cno=Cno;
		            	teach.setCname(Cname);
		            	teach.Tschool=Tschool;
		            	teach.Tsgrade=Tsgrade;
		            	teachs.add(teach);
		            }
		        }catch (SQLException e) {
		            e.printStackTrace();}
		     return teachs;//返回系集合，符合条件的系的信息
	    }
	
}
<file_sep>/src/teacher/TRController.java
package teacher;

import java.time.format.DateTimeFormatter;
import java.sql.SQLException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

import admin.studentUI.pwdtrans;
import admin.teachinfoUI.TeachInfoUI.TeachCourse;
import attendance.bean.AC;
import attendance.bean.Course;
import attendance.bean.PC;
import attendance.bean.SC;
import attendance.bean.Student;
import attendance.bean.Teach;
import attendance.bean.TeachforUI;
import attendance.dao.ACDao;
import attendance.dao.CourseDao;
import attendance.dao.PCDao;
import attendance.dao.SCDao;
import attendance.dao.StudentDao;
import attendance.dao.TeachDao;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.TableColumn.CellEditEvent;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.util.Callback;
import javafx.util.StringConverter;
import jdk.nashorn.internal.runtime.options.Options;

public class TRController {
	@FXML private ComboBox classcombo;
	@FXML private ComboBox coursecombo;
	@FXML private ComboBox namecombo;
	@FXML private DatePicker datecombo;
	@FXML private TableView tablecombo;
	@FXML private Button savebutton;
	@FXML private Button loadbutton;
	@FXML private ComboBox findchoose;
	@FXML private RadioButton insertcheck;
	@FXML private RadioButton findcheck;
	@FXML private TableColumn<TeachRoutine, String> classid;
	@FXML private TableColumn<TeachRoutine, String> id;
	@FXML private TableColumn<TeachRoutine, String> name;
	@FXML private TableColumn<TeachRoutine, String> courseid;
	@FXML private TableColumn<TeachRoutine, String> coursename;
	@FXML private TableColumn<TeachRoutine, String> date;
	@FXML private TableColumn<TeachRoutine, String> situation;
	@FXML private ToggleGroup group;
	@FXML private Label totallabel;
	@FXML private Button deleteall;
    final ObservableList<TeachRoutine> data = FXCollections.observableArrayList();
    int max = 0;
    private final String pattern = "yyyy-MM-dd";
	@FXML
	protected void save(ActionEvent event) {
//		PCDao pcdao= new PCDao();
//	    List<PC> pcis =new ArrayList<PC>();
//	    pcis=pcdao.list2();
//	    for(PC c:pcis) {
//	    	System.out.println(c.Pname);
//  	      	//classcombo.getItems().addAll(c.Pname);
//	    	classcombo.getItems().addAll(pcis);
//  	    }
//	    TeachRoutine t1 = (TeachRoutine) tablecombo.getSelectionModel().selectedItemProperty().getBean();
//		System.out.println(t1.getTcname());
		ACDao dao = new ACDao();
		//解决检测选中删除后重复删除提示成功的问题
		if(TeachRoutineTrans.getClassname()==null&&TeachRoutineTrans.getCourseid()==0&&TeachRoutineTrans.getCoursename()==null&&TeachRoutineTrans.getDate()==null&&TeachRoutineTrans.getId()==0&&TeachRoutineTrans.getName()==null&&TeachRoutineTrans.getSituation()==null) {
			Alert alert = new Alert(Alert.AlertType.ERROR);
			
			alert.setTitle("提示");
			alert.setHeaderText(null);
			alert.setContentText("请先选中一行再执行删除操作");
			
			alert.showAndWait();
			return;
		}
		else {
			if(dao.delete(TeachRoutineTrans.getId(), TeachRoutineTrans.getCourseid(), TeachRoutineTrans.getDate())) {
//				LoadTableView();
				Alert alert = new Alert(Alert.AlertType.INFORMATION);
				
				alert.setTitle("提示");
				alert.setHeaderText(null);
				alert.setContentText("删除成功");
				if(max!=0) {
					max = max - 1;
				}
				else if(max==0) {
					savebutton.setDisable(true);
					deleteall.setDisable(true);
				}


				
				tablecombo.getItems().clear();
		    	try {
		    		if(group.getSelectedToggle().getUserData().toString().equals("查询")) {
		    			
		    			//situation.setCellFactory(TextFieldTableCell.<TeachRoutine>forTableColumn());
		    			
		    		    
		    			
		    			System.out.println("当前是查询模式");
		    			if(findchoose.getValue().equals("班级")) {
		    				System.out.println("查询班级");
		    				ACDao acdao = new ACDao();
		    				List<AC> ac = new ArrayList<AC>();
//		    				CourseDao cdao = new CourseDao();
//		    				List<Course> course = new ArrayList<Course>();
//		    				course = cdao.list2();
//		    				int Cno = 0;
//		    				for(Course c:course) {
//		    					if(c.Cname.equals(coursecombo.getValue().toString())) {
//		    						Cno = c.Cno;
//		    						System.out.println(Cno);
//		    					}
//		    				}
		    				ac = acdao.list3(classcombo.getValue().toString());
		    				max = 0;
		    				for(AC a:ac) {
		    					System.out.printf("%d\t%d\t%s\t%s\t%s\t%s\n", a.Cno, a.Sno, a.Aname, a.APname,a.Acdate,a.Asituation);
		    					data.add(new TeachRoutine(a.APname,String.valueOf(a.Sno), a.Aname, String.valueOf(a.Cno), a.Cname, a.Acdate, a.Asituation));
		    					max++;
		    				}
		    				if(max!=0) {
		    					savebutton.setDisable(false);
		    					deleteall.setDisable(false);
		    				}
		    				else if(max==0) {
		    					savebutton.setDisable(true);
		    					deleteall.setDisable(true);
		    				}
		    				
		    				totallabel.setText("获得数据"+max+"条");
		    				tablecombo.setItems(data);
		    				tablecombo.refresh();
		    			}
		    			else if(findchoose.getValue().equals("课程名")) {
		    				System.out.println("查询课程名");
		    				
		    				TeachDao tdao = new TeachDao();
		    			    List<TeachforUI> tis =new ArrayList<TeachforUI>();
		    			    tis = tdao.list3forUI(TeachIdentity.getTno());
		    			    max = 0;
		    			    for(TeachforUI t:tis) {
		    		    		System.out.println(t.Cno);
		    		        	//coursecombo.getItems().addAll(t.Cname);
		    		        	ACDao acdao = new ACDao();
		    					List<AC> ac = new ArrayList<AC>();
		    					ac = acdao.list6(t.Cname);
		    					String match = coursecombo.getValue().toString();
		    					for(AC a:ac) {
		    						if(a.Cname.equals(match)) {
		    							data.add(new TeachRoutine(a.APname,String.valueOf(a.Sno), a.Aname, String.valueOf(a.Cno), a.Cname, a.Acdate, a.Asituation));
		    							max++;
		    						}
		    					}
		    		    	}
		    			    if(max!=0) {
		    					savebutton.setDisable(false);
		    					deleteall.setDisable(false);
		    				}
		    			    else if(max==0) {
		    					savebutton.setDisable(true);
		    					deleteall.setDisable(true);
		    				}
		    			    totallabel.setText("获得数据"+max+"条");
		    			    //System.out.println(data.get(max-1).getTname());
		    				tablecombo.setItems(data);
		    				tablecombo.refresh();
		    			}
		    			else if(findchoose.getValue().equals("姓名")) {
		    				System.out.println("查询姓名");
		    				int idstart = 0;
		    				String item = namecombo.getValue().toString();
		    				for(int i=0;i<item.length();i++) {
		    		    		if(Character.isDigit(item.charAt(i))) {
		    		    			idstart=Integer.parseInt(item.substring(i));
		    		    			//System.out.println(item.substring(i));
		    		    		}
		    		    	}
		    				ACDao acdao = new ACDao();
		    				List<AC> ac = new ArrayList<AC>();
		    				ac = acdao.list5(idstart);
		    				max = 0;
		    				for(AC a:ac) {
		    					data.add(new TeachRoutine(a.APname,String.valueOf(a.Sno), a.Aname, String.valueOf(a.Cno), a.Cname, a.Acdate, a.Asituation));
		    						//break;	
		    					max++;
		    				}
		    				if(max!=0) {
		    					savebutton.setDisable(false);
		    					deleteall.setDisable(false);
		    				}
		    				else if(max==0) {
		    					savebutton.setDisable(true);
		    					deleteall.setDisable(true);
		    				}
		    				totallabel.setText("获得数据"+max+"条");
		    				tablecombo.setItems(data);
		    				tablecombo.refresh();
		    			}
		    			else if(findchoose.getValue().equals("日期")) {
		    				System.out.println("查询日期");
		    				int idstart = 0;
		    				
		    				TeachDao tdao = new TeachDao();
		    			    List<TeachforUI> tis =new ArrayList<TeachforUI>();
		    			    tis = tdao.list3forUI(TeachIdentity.getTno());
		    			    max = 0;
		    			    for(TeachforUI t:tis) {
		    		    		//System.out.println(t.Cno);
		    		        	//coursecombo.getItems().addAll(t.Cname);
		    		        	ACDao acdao = new ACDao();
		    					List<AC> ac = new ArrayList<AC>();
		    					ac = acdao.list4(datecombo.getValue().toString());
		    					//String match = coursecombo.getValue().toString();
		    					for(AC a:ac) {
		    						if(t.Cno==a.Cno) {
		    							data.add(new TeachRoutine(a.APname,String.valueOf(a.Sno), a.Aname, String.valueOf(a.Cno), a.Cname, a.Acdate, a.Asituation));
		    							max++;
		    						}
		    					}
		    		    	}
		    			    if(max!=0) {
		    					savebutton.setDisable(false);
		    					deleteall.setDisable(false);
		    				}
		    			    else if(max==0) {
		    					savebutton.setDisable(true);
		    					deleteall.setDisable(true);
		    				}
		    			    totallabel.setText("获得数据"+max+"条");
		    				tablecombo.setItems(data);
		    				tablecombo.refresh();
		    			}
		    		}
		    		else if(group.getSelectedToggle().getUserData().toString().equals("插入")) {
		    			ACDao acdao = new ACDao();
		    			List<AC> ac = new ArrayList<AC>();
		    			
		    			
		    			//try()
		    			//int idstart = 0;
		    			//String item = namecombo.getValue().toString();
//		    			for(int i=0;i<item.length();i++) {
//		    	    		if(Character.isDigit(item.charAt(i))) {
//		    	    			idstart=Integer.parseInt(item.substring(i));
//		    	    			//System.out.println(item.substring(i));
//		    	    		}
//		    	    	}
		    			
		    				String classname = classcombo.getValue().toString();
		    				String date = datecombo.getValue().toString();
		    				String coursename = coursecombo.getValue().toString();
		    				CourseDao coursedao = new CourseDao();
		    				List<Course> cis = new ArrayList<Course>();
		    				cis = coursedao.list3(coursename);
		    				int courseid = 0;
		    				for(Course c:cis) {
		    					courseid = c.getCno();
		    				}
		    				System.out.println(courseid);
//		    				if(acdao.add(classname, courseid, date)) {
//		    					
//		    				}else {
//		    					Alert alert = new Alert(Alert.AlertType.ERROR);
//		    					alert.setTitle("提示");
//		    					alert.setHeaderText(null);
//		    					alert.setContentText("所选班级中有同学已录入考勤！请删除后重试。");
//		    					alert.showAndWait();
//		    					
//		    				}
		    				ac = acdao.list7(classname,coursename,date);
		    				max = 0;
		    				for(AC a:ac) {
		    					data.add(new TeachRoutine(a.APname,String.valueOf(a.Sno), a.Aname, String.valueOf(a.Cno), a.Cname, a.Acdate, a.Asituation));
		    						//break;	
		    					max++;
		    				}
		    				if(max!=0) {
		    					savebutton.setDisable(false);
		    					deleteall.setDisable(false);
		    				}
		    				else if(max==0) {
		    					savebutton.setDisable(true);
		    					deleteall.setDisable(true);
		    				}
		    				totallabel.setText("获得数据"+max+"条");
		    				tablecombo.setItems(data);
		    				tablecombo.refresh();
		    		}
		    	}catch(Exception e){
		    		//System.out.println(e);
		    		e.printStackTrace();
		    		totallabel.setText("");
					savebutton.setDisable(true);
					deleteall.setDisable(true);
		    		Alert alert1 = new Alert(Alert.AlertType.ERROR);
					alert1.setTitle("提示");
					alert1.setHeaderText(null);
					alert1.setContentText("未选择对象！");
					alert1.showAndWait();
		    	}
				
				
				
				
				
				
				
				alert.showAndWait();
				TeachRoutineTrans.setClassname(null);
				TeachRoutineTrans.setCourseid(0);
				TeachRoutineTrans.setCoursename(null);
				TeachRoutineTrans.setDate(null);
				TeachRoutineTrans.setId(0);
				TeachRoutineTrans.setName(null);
				TeachRoutineTrans.setSituation(null);
			}
			else {
				Alert alert = new Alert(Alert.AlertType.ERROR);
				
				alert.setTitle("提示");
				alert.setHeaderText(null);
				alert.setContentText("删除失败！");
				
				alert.showAndWait();
			}
		}
		
		
	}
	@FXML
	protected void FindCheckSelected(ActionEvent event) {
		System.out.print("Hello");
	}
	@FXML
	protected void DeleteAll(ActionEvent event) {
		//System.out.print("Hello");
		if(max==0) {
			Alert alert = new Alert(Alert.AlertType.ERROR);
			alert.setTitle("提示");
			alert.setHeaderText(null);
			alert.setContentText("表中无内容");
			alert.showAndWait();
		}
		else {
			ACDao dao = new ACDao();
			for(int i=0;i<max;i++) {
				dao.delete(Integer.valueOf(data.get(i).getTid()), Integer.valueOf(data.get(i).getTcid()), data.get(i).getTdate());
			}
			Alert alert = new Alert(Alert.AlertType.INFORMATION);
			alert.setTitle("提示");
			alert.setHeaderText(null);
			alert.setContentText("删除成功！");
			TeachRoutineTrans.setClassname(null);
			TeachRoutineTrans.setCourseid(0);
			TeachRoutineTrans.setCoursename(null);
			TeachRoutineTrans.setDate(null);
			TeachRoutineTrans.setId(0);
			TeachRoutineTrans.setName(null);
			TeachRoutineTrans.setSituation(null);
			max=0;
			savebutton.setDisable(true);
			deleteall.setDisable(true);
			alert.showAndWait();
			
		}
	}
	@FXML
	protected void Load(ActionEvent event) {
		tablecombo.getItems().clear();
		ObservableList<String> options = FXCollections.observableArrayList("出勤", "请假", "旷课", "迟到", "早退");
	    situation.setCellFactory(tc -> {
	    	ComboBox<String>combo = new ComboBox<String>();
	    	combo.setItems(options);
	    	combo.setEditable(false);
	    	TableCell<TeachRoutine, String> cell = new TableCell<TeachRoutine, String>(){
	    		protected void updateItem(String chuzhi,boolean empty) {
	    			super.updateItem(chuzhi, empty);
	    			if(empty) {
	    				setGraphic(null);
	    			}
	    			else {
	    				combo.setValue(chuzhi);
	    				setGraphic(combo);
	    			}
	    		}
	    	};
	    	combo.setOnAction(e -> {
	    		int rank = cell.getIndex();
	    		String value = combo.getValue();
	    		
	    		//System.out.println(onetemp);
	    		String two = classid.getTableView().getItems().get(
                        rank).getTid();
	    		String three = classid.getTableView().getItems().get(
                        rank).getTname();
	    		String four = classid.getTableView().getItems().get(
                        rank).getTcid();
	    		String six = classid.getTableView().getItems().get(
                        rank).getTdate();
	    		String seventemp = classid.getTableView().getItems().get(
                        rank).getTroutine();
	    		String seven = value;
            	
            	ACDao dao = new ACDao();
	    		if(dao.update(Integer.valueOf(two), Integer.valueOf(four), six, seven)) {
	    			System.out.println(three + "的考勤修改成功！！");
	    		}
	    		else {
	    			Alert alert = new Alert(Alert.AlertType.ERROR);
					alert.setTitle("提示");
					alert.setHeaderText(null);
					alert.setContentText("修改失败");
					alert.showAndWait();
	    		}
	    		if(value.equals(options.get(0))){
	    			System.out.println("选择了出勤");
	    			
	    		}
	    		else if(value.equals(options.get(1))) {
	    			
	    		}
	    		else if(value.equals(options.get(2))) {
	    			
	    		}
	    		else if(value.equals(options.get(3))) {
	    			
	    		}
	    		else if(value.equals(options.get(4))) {
	
	    		}
	    	});
	    	return cell;
	    });
	    LoadTableView();

		
	}
	public static class TeachRoutine {

        private final SimpleStringProperty Tclassid;
        private final SimpleStringProperty Tid;
        private final SimpleStringProperty Tname;
        private final SimpleStringProperty Tcid;
        private final SimpleStringProperty Tcname;
        private final SimpleStringProperty Tdate;
        private final SimpleStringProperty Troutine;

        private TeachRoutine(String Tclassid1, String Tid1, String Tname1, String Tcid1, String Tcname1, String Tdate1, String Troutine1) {
            this.Tclassid = new SimpleStringProperty(Tclassid1);
            this.Tid = new SimpleStringProperty(Tid1);
            this.Tname = new SimpleStringProperty(Tname1);
            this.Tcid = new SimpleStringProperty(Tcid1);
            this.Tcname = new SimpleStringProperty(Tcname1);
            this.Tdate = new SimpleStringProperty(Tdate1);
            this.Troutine = new SimpleStringProperty(Troutine1);
        }

        public String getTclassid() {
            return Tclassid.get();
        }

        public void setTClassid(String TClassid1) {
        	Tclassid.set(TClassid1);
        }

        public String getTid() {
            return Tid.get();
        }

        public void setTid(String Tid1) {
        	Tid.set(Tid1);
        }

        public String getTname() {
            return Tname.get();
        }

        public void setTname(String Tname1) {
        	Tname.set(Tname1);
        }
        
        public String getTcid() {
            return Tcid.get();
        }

        public void setTcid(String Tcid1) {
        	Tcname.set(Tcid1);
        }
        
        public String getTcname() {
            return Tcname.get();
        }

        public void setTcname(String Tcname1) {
        	Tcname.set(Tcname1);
        }

		public String getTdate() {
			return Tdate.get();
		}

		public String getTroutine() {
			return Troutine.get();
		}

		
    }
    public void InitUI() {
    	TeachRoutineTrans.setClassname(null);
		TeachRoutineTrans.setCourseid(0);
		TeachRoutineTrans.setCoursename(null);
		TeachRoutineTrans.setDate(null);
		TeachRoutineTrans.setId(0);
		TeachRoutineTrans.setName(null);
		TeachRoutineTrans.setSituation(null);
		deleteall.setDisable(true);
		savebutton.setDisable(true);
    	//日期切换格式yyyy-mm-dd
    	StringConverter converter = new StringConverter<LocalDate>() {
            DateTimeFormatter dateFormatter =
                DateTimeFormatter.ofPattern(pattern);
            @Override
            public String toString(LocalDate date) {
                if (date != null) {
                    return dateFormatter.format(date);
                } else {
                    return "";
                }
            }

            @Override
            public LocalDate fromString(String string) {
                if (string != null && !string.isEmpty()) {
                    return LocalDate.parse(string, dateFormatter);
                } else {
                    return null;
                }
            }
        };    
        //设置日期选择不能选择未来的时间
        final Callback<DatePicker, DateCell> dayCellFactory = 
                new Callback<DatePicker, DateCell>() {
                    @Override
                    public DateCell call(final DatePicker datePicker) {
                        return new DateCell() {
                            @Override
                            public void updateItem(LocalDate item, boolean empty) {
                                super.updateItem(item, empty);
                               
                                if (item.isAfter(LocalDate.now().plusDays(0))) {
                                        setDisable(true);
                                        setStyle("-fx-background-color: #ffc0cb;");
                                }   
                        }
                    };
                }
            };
        datecombo.setDayCellFactory(dayCellFactory);
        datecombo.setConverter(converter);
        
        //加载选项框数据
    	PCDao pcdao= new PCDao();
	    List<PC> pcis =new ArrayList<PC>();
	    pcis=pcdao.list2();
	    for(PC c:pcis) {
	    	System.out.println(c.Pname);
  	      	classcombo.getItems().addAll(c.Pname);
	    	//classcombo.getItems().addAll(pcis);
  	    }
	    CourseDao dao = new CourseDao();
	    List<Course> is =new ArrayList<Course>();
	    TeachDao tdao = new TeachDao();
	    List<TeachforUI> tis =new ArrayList<TeachforUI>();
	    tis = tdao.list3forUI(TeachIdentity.getTno());
	    for(TeachforUI t:tis) {
    		System.out.println(t.Cno);
        	coursecombo.getItems().addAll(t.Cname);
    	}
	    
	    classcombo.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
        	@Override
        	public void changed(ObservableValue observable, Object oldValue, Object newValue) {
        		StudentDao stdao= new StudentDao();
        	    List<Student> stis =new ArrayList<Student>();
        	    stis=stdao.list3();
        		namecombo.getItems().clear();

        		//必须加入判断，否则会出错
        		if(group.getSelectedToggle().getUserData().toString().equals("查询")) {
        			if(findchoose.getValue().toString().equals("姓名")) {
            			stis=stdao.list3();
            		}
            		else if(findchoose.getValue().toString().equals("班级")){
            			stis=stdao.list2(classcombo.getValue().toString());
            		}
        		}
        		else if(group.getSelectedToggle().getUserData().toString().equals("插入")) {
        			stis=stdao.list2(classcombo.getValue().toString());
        		}
        		
        		
//        		int count1 = pwdtrans.getCount();
//        		if(fileList.getSelectionModel().getSelectedItem().equals("新建学生")&&count1==0) {
//        			pcis=pcdao.list3("计算机系");
//        		}
        		
        		
        		for(Student s:stis) {
          	      	//classoptions.add(c.Pname);
//        			int count = pwdtrans.getCount();
//        			if(count==0)break;
        			String longname = s.Sname + "    " + s.Sno;
        			namecombo.getItems().addAll(longname);
        			//System.out.println(count);
        			
          	    }
        	}
        });
	    StudentDao stdao = new StudentDao();
	    List<Student> stis =new ArrayList<Student>(); 
	    stis = stdao.list3();
	    for(Student s:stis) {
	    	String longname = s.Sname + "    " + s.Sno;
	    	namecombo.getItems().addAll(longname);
	    }
	    
	    findchoose.getItems().addAll("班级", "姓名", "课程名", "日期");
		//System.out.print(group.getSelectedToggle().getUserData().toString());
	    //final ToggleGroup group = new ToggleGroup();
		findcheck.setToggleGroup(group);
		findcheck.setUserData("查询");
		insertcheck.setUserData("插入");
		insertcheck.setToggleGroup(group);
		findcheck.setSelected(true);
		findchoose.setVisible(true);
		
		classcombo.setDisable(true);
		coursecombo.setDisable(true);
		datecombo.setDisable(true);
		namecombo.setDisable(true);
//		group.getSelectedToggle().selectedProperty().addListener()
		findchoose.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
        	@Override
        	public void changed(ObservableValue observable, Object oldValue, Object newValue) {
        		if(findchoose.getValue().equals("班级")) {
        			classcombo.setDisable(false);
        			namecombo.setDisable(true);
        			coursecombo.setDisable(true);
        			datecombo.setDisable(true);
        			classcombo.getSelectionModel().clearSelection();
        			namecombo.getSelectionModel().clearSelection();
        			coursecombo.getSelectionModel().clearSelection();
        			datecombo.setValue(null);
        			classcombo.setPromptText("班级");
        			namecombo.setPromptText("不可用");
        			coursecombo.setPromptText("不可用");
        			datecombo.setPromptText("不可用");
        		}
        		else if(findchoose.getValue().equals("姓名")) {
        			classcombo.setDisable(true);
        			namecombo.setDisable(false);
        			coursecombo.setDisable(true);
        			datecombo.setDisable(true);
        			classcombo.getSelectionModel().clearSelection();
        			namecombo.getSelectionModel().clearSelection();
        			coursecombo.getSelectionModel().clearSelection();
        			datecombo.setValue(null);
        			classcombo.setPromptText("不可用");
        			namecombo.setPromptText("姓名");
        			coursecombo.setPromptText("不可用");
        			datecombo.setPromptText("不可用");
        		}
        		else if(findchoose.getValue().equals("课程名")) {
        			classcombo.setDisable(true);
        			namecombo.setDisable(true);
        			coursecombo.setDisable(false);
        			datecombo.setDisable(true);
        			classcombo.getSelectionModel().clearSelection();
        			namecombo.getSelectionModel().clearSelection();
        			coursecombo.getSelectionModel().clearSelection();
        			datecombo.setValue(null);
        			classcombo.setPromptText("不可用");
        			namecombo.setPromptText("不可用");
        			coursecombo.setPromptText("课程名");
        			datecombo.setPromptText("不可用");
        		}
        		else if(findchoose.getValue().equals("日期")) {
        			classcombo.setDisable(true);
        			namecombo.setDisable(true);
        			coursecombo.setDisable(true);
        			datecombo.setDisable(false);
        			classcombo.getSelectionModel().clearSelection();
        			namecombo.getSelectionModel().clearSelection();
        			coursecombo.getSelectionModel().clearSelection();
        			datecombo.setValue(null);
        			classcombo.setPromptText("不可用");
        			namecombo.setPromptText("不可用");
        			coursecombo.setPromptText("不可用");
        			datecombo.setPromptText("日期(yyyy-mm-dd)");
        		}
        		else {
        			System.out.println("选项框被清空啦~");
        		}
        	}
        });
	    group.selectedToggleProperty().addListener(
                (ObservableValue<? extends Toggle> ov, Toggle old_Toggle,
                Toggle new_Toggle) -> {
                    if (group.getSelectedToggle() != null) {
                    	if(group.getSelectedToggle().getUserData().toString().equals("查询")) {
                    		namecombo.getItems().clear();
                    		loadbutton.setText("查询");
                    		tablecombo.getItems().clear();
                    		findchoose.getSelectionModel().clearSelection();
                    		classcombo.getSelectionModel().clearSelection();
                    		namecombo.getSelectionModel().clearSelection();
                			coursecombo.getSelectionModel().clearSelection();
                			datecombo.setValue(null);
                    		findchoose.setVisible(true);
                    		namecombo.setDisable(true);
                    		classcombo.setDisable(true);
                			coursecombo.setDisable(true);
                			datecombo.setDisable(true);
                			StudentDao stdao1= new StudentDao();
                    	    List<Student> stis1 =new ArrayList<Student>();
                    	    stis1=stdao.list3();
                    	    for(Student s:stis1) {
                    	    	String longname = s.Sname + "    " + s.Sno;
                    	    	namecombo.getItems().addAll(longname);
                    	    }
                    	}
                    	else if(group.getSelectedToggle().getUserData().toString().equals("插入")) {
                    		loadbutton.setText("插入");
                    		tablecombo.getItems().clear();
                    		findchoose.setVisible(false);
                    		classcombo.setDisable(false);
                    		namecombo.setDisable(true);
                			coursecombo.setDisable(false);
                			datecombo.setDisable(false);
                			classcombo.getSelectionModel().clearSelection();
                			namecombo.getSelectionModel().clearSelection();
                			coursecombo.getSelectionModel().clearSelection();
                			datecombo.setValue(null);
                			classcombo.setPromptText("班级");
                			namecombo.setPromptText("姓名");
                			coursecombo.setPromptText("课程名");
                			datecombo.setPromptText("日期");
                    	}
//                        final Image image = new Image(
//                            getClass().getResourceAsStream(
//                            group.getSelectedToggle().getUserData().toString() +
//                            ".jpg"));
//                    icon.setImage(image);
                }
            });
	    
	    
	    		
	    
	    
    	classid.setCellValueFactory(
                new PropertyValueFactory<>("Tclassid"));
    	classid.setCellFactory(TextFieldTableCell.<TeachRoutine>forTableColumn());
    	
        id.setCellValueFactory(
                new PropertyValueFactory<>("Tid"));
        id.setCellFactory(TextFieldTableCell.<TeachRoutine>forTableColumn());
        
        name.setCellValueFactory(
                new PropertyValueFactory<>("Tname"));
        name.setCellFactory(TextFieldTableCell.<TeachRoutine>forTableColumn());

        courseid.setCellValueFactory(
                new PropertyValueFactory<>("Tcid"));
        courseid.setCellFactory(TextFieldTableCell.<TeachRoutine>forTableColumn());
        
        coursename.setCellValueFactory(
                new PropertyValueFactory<>("Tcname"));
        coursename.setCellFactory(TextFieldTableCell.<TeachRoutine>forTableColumn());
        
        date.setCellValueFactory(
                new PropertyValueFactory<>("Tdate"));
        date.setCellFactory(TextFieldTableCell.<TeachRoutine>forTableColumn());
        
        situation.setCellValueFactory(
                new PropertyValueFactory<>("Troutine"));
        //situation.setCellFactory(TextFieldTableCell.<TeachRoutine>forTableColumn());
		classid.setStyle("-fx-alignment: CENTER;");
		id.setStyle("-fx-alignment: CENTER;");
		name.setStyle("-fx-alignment: CENTER;");
		courseid.setStyle("-fx-alignment: CENTER;");
		coursename.setStyle("-fx-alignment: CENTER;");
		date.setStyle("-fx-alignment: CENTER;");
		situation.setStyle("-fx-alignment: CENTER;");
		//tablecombo.setEditable(true);
        classid.setOnEditCommit(
                (CellEditEvent<TeachRoutine, String> t) -> {
                	
                	String onetemp = classid.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getTclassid();
                	((TeachRoutine) t.getTableView().getItems().get(
                            t.getTablePosition().getRow())
                            ).setTClassid(t.getNewValue());
                	String one = t.getNewValue();
                	//System.out.println("Test");
                	String two = id.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getTid();
                    //System.out.println(tc.getCoName());
                	String three = name.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getTname();
                	String four = courseid.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getTcid();
                	String five = coursename.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getTcname();
                	String six = date.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getTdate();
                	String seven = situation.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getTroutine();
                    ACDao acdao = new ACDao();
                    List<AC> ac = new ArrayList<AC>();
                    acdao.update(Integer.valueOf(two), Integer.valueOf(four), six, seven);
                    int idstart = pwdtrans.getSno();
                    System.out.println(t.getNewValue());
                    if(acdao.update(Integer.valueOf(two), Integer.valueOf(four), six, seven)) {
                    	System.out.println("修改成功");
                    	
                    }
                    else {
                    	Alert alert = new Alert(Alert.AlertType.ERROR);
						alert.setTitle("提示");
						alert.setHeaderText(null);
						alert.setContentText("修改失败");
						alert.showAndWait();
                    	((TeachRoutine) t.getTableView().getItems().get(
  	                            t.getTablePosition().getRow())
  	                            ).setTcname(onetemp);
						tablecombo.refresh();
                    }
                    
            });
        tablecombo.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
		    if (newValue != null) {
		        System.out.println("Selected Person: "
		            + ((TeachRoutine) newValue).getTcname() + " | "
		            + ((TeachRoutine) newValue).getTname() 
		        );
		        TeachRoutineTrans.setClassname(((TeachRoutine) newValue).getTcname());
		        TeachRoutineTrans.setId(Integer.valueOf(((TeachRoutine) newValue).getTid()));
		        TeachRoutineTrans.setName(((TeachRoutine) newValue).getTname());
		        TeachRoutineTrans.setCourseid(Integer.valueOf(((TeachRoutine) newValue).getTcid()));
		        TeachRoutineTrans.setCoursename(((TeachRoutine) newValue).getTcname());
		        TeachRoutineTrans.setDate(((TeachRoutine) newValue).getTdate());
		        TeachRoutineTrans.setSituation(((TeachRoutine) newValue).getTroutine());
		        System.out.printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\n", ((TeachRoutine) newValue).getTcname(), ((TeachRoutine) newValue).getTid(), ((TeachRoutine) newValue).getTname(), ((TeachRoutine) newValue).getTcid(), ((TeachRoutine) newValue).getTcname(), ((TeachRoutine) newValue).getTdate(), ((TeachRoutine) newValue).getTroutine());
		   }
		});
        
        
    }
    public void LoadTableView() {
    	tablecombo.getItems().clear();
    	try {
    		if(group.getSelectedToggle().getUserData().toString().equals("查询")) {
    			
    			//situation.setCellFactory(TextFieldTableCell.<TeachRoutine>forTableColumn());
    			
    		    
    			
    			System.out.println("当前是查询模式");
    			if(findchoose.getValue().equals("班级")) {
    				System.out.println("查询班级");
    				ACDao acdao = new ACDao();
    				List<AC> ac = new ArrayList<AC>();
//    				CourseDao cdao = new CourseDao();
//    				List<Course> course = new ArrayList<Course>();
//    				course = cdao.list2();
//    				int Cno = 0;
//    				for(Course c:course) {
//    					if(c.Cname.equals(coursecombo.getValue().toString())) {
//    						Cno = c.Cno;
//    						System.out.println(Cno);
//    					}
//    				}
    				ac = acdao.list3(classcombo.getValue().toString());
    				max = 0;
    				for(AC a:ac) {
    					System.out.printf("%d\t%d\t%s\t%s\t%s\t%s\n", a.Cno, a.Sno, a.Aname, a.APname,a.Acdate,a.Asituation);
    					data.add(new TeachRoutine(a.APname,String.valueOf(a.Sno), a.Aname, String.valueOf(a.Cno), a.Cname, a.Acdate, a.Asituation));
    					max++;
    				}
    				if(max!=0) {
    					savebutton.setDisable(false);
    					deleteall.setDisable(false);
    				}
    				else if(max==0) {
    					savebutton.setDisable(true);
    					deleteall.setDisable(true);
    				}
    				
    				totallabel.setText("获得数据"+max+"条");
    				tablecombo.setItems(data);
    				tablecombo.refresh();
    			}
    			else if(findchoose.getValue().equals("课程名")) {
    				System.out.println("查询课程名");
    				
    				TeachDao tdao = new TeachDao();
    			    List<TeachforUI> tis =new ArrayList<TeachforUI>();
    			    tis = tdao.list3forUI(TeachIdentity.getTno());
    			    max = 0;
    			    for(TeachforUI t:tis) {
    		    		System.out.println(t.Cno);
    		        	//coursecombo.getItems().addAll(t.Cname);
    		        	ACDao acdao = new ACDao();
    					List<AC> ac = new ArrayList<AC>();
    					ac = acdao.list6(t.Cname);
    					String match = coursecombo.getValue().toString();
    					for(AC a:ac) {
    						if(a.Cname.equals(match)) {
    							data.add(new TeachRoutine(a.APname,String.valueOf(a.Sno), a.Aname, String.valueOf(a.Cno), a.Cname, a.Acdate, a.Asituation));
    							max++;
    						}
    					}
    		    	}
    			    if(max!=0) {
    					savebutton.setDisable(false);
    					deleteall.setDisable(false);
    				}
    			    else if(max==0) {
    					savebutton.setDisable(true);
    					deleteall.setDisable(true);
    				}
    			    totallabel.setText("获得数据"+max+"条");
    			    //System.out.println(data.get(max-1).getTname());
    				tablecombo.setItems(data);
    				tablecombo.refresh();
    			}
    			else if(findchoose.getValue().equals("姓名")) {
    				System.out.println("查询姓名");
    				int idstart = 0;
    				String item = namecombo.getValue().toString();
    				for(int i=0;i<item.length();i++) {
    		    		if(Character.isDigit(item.charAt(i))) {
    		    			idstart=Integer.parseInt(item.substring(i));
    		    			//System.out.println(item.substring(i));
    		    		}
    		    	}
    				ACDao acdao = new ACDao();
    				List<AC> ac = new ArrayList<AC>();
    				ac = acdao.list5(idstart);
    				max = 0;
    				for(AC a:ac) {
    					data.add(new TeachRoutine(a.APname,String.valueOf(a.Sno), a.Aname, String.valueOf(a.Cno), a.Cname, a.Acdate, a.Asituation));
    						//break;	
    					max++;
    				}
    				if(max!=0) {
    					savebutton.setDisable(false);
    					deleteall.setDisable(false);
    				}
    				else if(max==0) {
    					savebutton.setDisable(true);
    					deleteall.setDisable(true);
    				}
    				totallabel.setText("获得数据"+max+"条");
    				tablecombo.setItems(data);
    				tablecombo.refresh();
    			}
    			else if(findchoose.getValue().equals("日期")) {
    				System.out.println("查询日期");
    				int idstart = 0;
    				
    				TeachDao tdao = new TeachDao();
    			    List<TeachforUI> tis =new ArrayList<TeachforUI>();
    			    tis = tdao.list3forUI(TeachIdentity.getTno());
    			    max = 0;
    			    for(TeachforUI t:tis) {
    		    		//System.out.println(t.Cno);
    		        	//coursecombo.getItems().addAll(t.Cname);
    		        	ACDao acdao = new ACDao();
    					List<AC> ac = new ArrayList<AC>();
    					ac = acdao.list4(datecombo.getValue().toString());
    					//String match = coursecombo.getValue().toString();
    					for(AC a:ac) {
    						if(t.Cno==a.Cno) {
    							data.add(new TeachRoutine(a.APname,String.valueOf(a.Sno), a.Aname, String.valueOf(a.Cno), a.Cname, a.Acdate, a.Asituation));
    							max++;
    						}
    					}
    		    	}
    			    if(max!=0) {
    					savebutton.setDisable(false);
    					deleteall.setDisable(false);
    				}
    			    else if(max==0) {
    					savebutton.setDisable(true);
    					deleteall.setDisable(true);
    				}
    			    totallabel.setText("获得数据"+max+"条");
    				tablecombo.setItems(data);
    				tablecombo.refresh();
    			}
    		}
    		else if(group.getSelectedToggle().getUserData().toString().equals("插入")) {
    			ACDao acdao = new ACDao();
    			List<AC> ac = new ArrayList<AC>();
    			
    			
    			//try()
    			//int idstart = 0;
    			//String item = namecombo.getValue().toString();
//    			for(int i=0;i<item.length();i++) {
//    	    		if(Character.isDigit(item.charAt(i))) {
//    	    			idstart=Integer.parseInt(item.substring(i));
//    	    			//System.out.println(item.substring(i));
//    	    		}
//    	    	}
    			
    				String classname = classcombo.getValue().toString();
    				String date = datecombo.getValue().toString();
    				String coursename = coursecombo.getValue().toString();
    				CourseDao coursedao = new CourseDao();
    				List<Course> cis = new ArrayList<Course>();
    				cis = coursedao.list3(coursename);
    				int courseid = 0;
    				for(Course c:cis) {
    					courseid = c.getCno();
    				}
    				System.out.println(courseid);
    				if(acdao.add(classname, courseid, date)) {
    					
    				}else {
    					Alert alert = new Alert(Alert.AlertType.ERROR);
    					alert.setTitle("提示");
    					alert.setHeaderText(null);
    					alert.setContentText("所选班级中有同学已录入考勤！请删除后重试。");
    					alert.showAndWait();
    					
    				}
    				ac = acdao.list7(classname,coursename,date);
    				max = 0;
    				for(AC a:ac) {
    					data.add(new TeachRoutine(a.APname,String.valueOf(a.Sno), a.Aname, String.valueOf(a.Cno), a.Cname, a.Acdate, a.Asituation));
    						//break;	
    					max++;
    				}
    				if(max!=0) {
    					savebutton.setDisable(false);
    					deleteall.setDisable(false);
    				}
    				else if(max==0) {
    					savebutton.setDisable(true);
    					deleteall.setDisable(true);
    				}
    				totallabel.setText("获得数据"+max+"条");
    				tablecombo.setItems(data);
    				tablecombo.refresh();
    		}
    	}catch(Exception e){
    		//System.out.println(e);
    		e.printStackTrace();
    		totallabel.setText("");
			savebutton.setDisable(true);
			deleteall.setDisable(true);
    		Alert alert = new Alert(Alert.AlertType.ERROR);
			alert.setTitle("提示");
			alert.setHeaderText(null);
			alert.setContentText("未选择对象！");
			alert.showAndWait();
    	}
    	
    }
}


<file_sep>/src/attendance/test/QimoTestDao.java
package attendance.test;
import java.util.ArrayList;
import java.util.List;
import attendance.dao.QimoDao;
import attendance.bean.Qimo;
public class QimoTestDao {
	public static void main(String[] args){
	QimoDao dao= new QimoDao();
    List<Qimo> is =new ArrayList<Qimo>();
    //dao.add(1, 1, "2020");
  // dao.add("计算机181", 1, "2020-02-02");
   // dao.update1(2, 1, "2020-02-02", "旷课");
    //is =dao.list4("2020-02-02",1);
   /* for(Qimo b:is){
  	  System.out.printf("%d\t%d\t%s\t%s\t%s\t%s\t%s\n",b.Sno,b.Cno,b.Cname,b.APname,b.Aname,b.Acdate,b.Asituation);	           
      	System.out.println();
  	  }*/
    //dao.add(1, 2, "2020");
    //dao.add(Sno, Cno, Qstartdate, Qenddate);
    //is =dao.list1(1);
    for(Qimo b:is){
    	  //System.out.printf("%s\t%s\t%d\t%s\t%d\t%s\t%s\t%d\t%d\t%d\t%d\n",b.Pcname,b.Pname,b.Sno,b.Sname,b.Cno,b.Cname,b.Qtimeyear,b.Qan,b.Qaln,b.Qtn,b.Qlen);	           
        	System.out.println();
    	  }
    }
}
<file_sep>/src/admin/teachinfoUI/changeController.java
package admin.teachinfoUI;

import java.util.ArrayList;
import java.util.List;

import attendance.bean.Teacher;
import attendance.dao.TeacherDao;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.stage.Stage;

public class changeController {
	@FXML private Button confirmButton;
	@FXML private TextField pwdField;
	@FXML
	protected void comfirmAction(ActionEvent event) {
		//Stage stage = (Stage) rootGridPane.getScene().getWindow();
	    //stage.close();
		
		TeacherDao dao= new TeacherDao();
    	  List<Teacher> is =new ArrayList<Teacher>();
    	  
    	  //FileItem item = fileList.data().get(index);
    	  is =dao.list3();
    		
    		for (Teacher b : is) {
    			if(pwdtrans.getName().equals(b.Tname))
            	{
    				//System.out.printf("%s\t%s\t%s\t%d\t%s\t%d\t%s\t%s\n",b.Tcname,b.Tname,b.Tname,b.Sno,b.Sex,b.Sage,b.Sbirthtime,b.Snative);	           
    				//System.out.printf("%d\t%s\t%s\t%d\t%s\t%s\n",b.Sno,b.Tname,b.Sex,b.Sage,b.Snative,b.Spassword);
        			//System.out.println();
        			//String item = String.valueOf(b.Sno);
        			System.out.print(b);
        				if(b.Tno==pwdtrans.getSno()) {
        					if(dao.update2(pwdtrans.getSno(), pwdField.getText())==true) {
        						Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        						
        						alert.setTitle("提示");
        						alert.setHeaderText(null);
        						alert.setContentText("修改成功");
        						pwdtrans.setpwd(pwdField.getText());
        						alert.showAndWait();
        					}
        				}
        			
            	}
    			else continue;
        	  //openFile(item);
            }
		Stage stage = (Stage)confirmButton.getScene().getWindow();
	    stage.close();
    }
	public void Initpwd() {
		pwdField.setText(pwdtrans.getpwd());
	}
	
}


<file_sep>/src/attendance/bean/SC.java
package attendance.bean;
//选课表
//课程名，姓名是为了查询，实际SC表没有
public class SC {
	public int Sno ;//学号
	public int Cno ;//课程号
	public String Sname;//姓名
	public String Cname;//课程名
	public int getSno() {
		return Sno;
	}
	public void setSno(int sno) {
		this.Sno = sno;
	}
	public int getCno() {
		return Cno;
	}
	public void setCno(int cno) {
		this.Cno = cno;
	}
	public String getSname() {
		return Sname;
	}
	public void setSname(String sname) {
		this.Sname = sname;
	}
	public String getCname() {
		return Cname;
	}
	public void setCname(String cname) {
		this.Cname = cname;
	}
	public SC() {
		super();
		// TODO Auto-generated constructor stub
	}
	public SC(int sno, int cno, String sname, String cname) {
		super();
		this.Sno = sno;
		this.Cno = cno;
		this.Sname = sname;
		this.Cname = cname;
	}
	@Override
	public String toString() {
		return "SC [Sno=" + Sno + ", Cno=" + Cno + ", Sname=" + Sname + ", Cname=" + Cname + "]";
	}
	
	
	
}
<file_sep>/src/attendance/dao/StudentDao.java
package attendance.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import attendance.bean.Student;
//学生Dao，有些操作给管理员做的，有些给学生做的
public class StudentDao {
	public StudentDao(){
		 try {
	            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	          // System.out.println("加载驱动成功！");
	        } catch (ClassNotFoundException e) {
	            e.printStackTrace();
	            System.out.println("加载驱动失败！");
	        }
	}
	public Connection getConnection()throws SQLException{
      //抛出异常
		return DriverManager.getConnection("jdbc:sqlserver://sql.cerny.cn:1433;DatabaseName=attendance", "sa", "Myclassdesign330");
		//数据库的名字叫attendance，我的数据库账户是sa,密码是sa
		//这里我建立连接的时候不是用try-catcth来捕捉异常，而是主动抛出，那么我下面调用这个函数时要么继续抛出，要么用try-catcth捕捉，我选择用try-catcth捕捉，到时候主函数就不用处理了
      }
	public int getTotal() {
		//得到目前表Teacher总数有多少条
      int total = 0;
      try (Connection c = getConnection(); Statement s = c.createStatement();) {
        
          String sql = "select count(*) from Student";

          ResultSet rs = s.executeQuery(sql);
          while (rs.next()) {
              total = rs.getInt(1);//	这里getInt是因为rs这个结果集这里是返回的结果行数
          }
          // System.out.println("total:" + total); 
      } catch (SQLException e) {

          e.printStackTrace();
      }
      return total;
  }
	public boolean add(int Sno,String Sname,String Sex,int Sage,String Snative,int SPno) {
		//给管理员用的
		//这里增加函数学号（本来主码可以自增不插，但我这里还是打开自增规则插进去）学号，姓名，性别，年龄，籍贯，专业班级号
		//密码在增加函数这里不插，默认，后期再自己改密码
        String sql = "set identity_insert Student ON insert into Student(Sno,Sname,Sex,Sage,Snative,SPno) values(?,?,?,?,?,?) set identity_insert Student OFF";
        try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);) { 
        	ps.setInt(1,Sno);
        	ps.setString(2,Sname);
            ps.setString(3,Sex);
            ps.setInt(4,Sage); 
            ps.setString(5,Snative); 
            ps.setInt(6,SPno); 
            ps.execute();  
            return true;
            //ResultSet rs = ps.getGeneratedKeys();//如果因为主码自增不插，然后通过这里得到主码赋值给对象对应的属性
        } catch (SQLException e) {  
            e.printStackTrace();
        }
		return false;
    }
	public boolean delete(int Sno) {
		 //删除函数
		//给管理员用
		 try (Connection c = getConnection(); Statement s = c.createStatement();) {				  
	            String sql = "delete from Student where Sno= " +"'"+Sno+"'";
	            s.execute(sql);	
	            return true;
	            //System.out.println("删除成功");
	      }catch(SQLException e1) {
	            e1.printStackTrace();
	      }catch(Exception e2) {// 捕获其他异常
	    	  e2.printStackTrace();// 打印异常产生的过程信息
	      }
		return false;
	    }
	public void update1(int Sno,String Sname,String Sex,int Sage,String Snative,int SPno) {
		//给管理员用，不更新密码，因为管理员没有权限
		//学号，姓名，性别，年龄，籍贯，专业班级号
		//不更新主码，主码一般不允许更新，一般允许更新主码的数据库设计都是不合理的		
         String sql = "update  Student set Sname=?,Sex=? ,Sage=?,Snative=?,SPno=? where Sno ="+Sno; 
	    	 try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);){	    		
	    		 ps.setString(1, Sname);
	    		 ps.setString(2, Sex);
	    		 ps.setInt(3, Sage);
	    		 ps.setString(4, Snative);
	    		 ps.setInt(5, SPno);   		 
	    		 ps.execute();
	    	//	 System.out.println("修改成功");	    		 
	    	 }catch (SQLException e1) {
		            e1.printStackTrace();		     
		      }catch (Exception e2) {// 捕获其他异常
		    	  e2.printStackTrace();// 打印异常产生的过程信息
		      }
	    	}
	public boolean update2(int Sno,String Spassword) {
		//给学生用，新密码
		//不更新主码，主码一般不允许更新，一般允许更新主码的数据库设计都是不合理的		
         String sql = "update Student set Spassword=? where Sno ="+Sno; 
	    	 try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);){	    		
	    		 ps.setString(1, Spassword);	    		 
	    		 ps.execute();
	    		 return true;
	    	//	 System.out.println("修改成功");	    		 
	    	 }catch (SQLException e1) {
		            e1.printStackTrace();		     
		      }catch (Exception e2) {// 捕获其他异常
		    	  e2.printStackTrace();// 打印异常产生的过程信息
		      }
			return false;
	    	}
	public List<Student> list1(int Sno) {
        List<Student> students = new ArrayList<Student>();
  //把符合条件的Student数据查询出来，转换为Student对象后，放在一个集合中返回
  //从视图里查询，看不到密码，给学生用，查询某个人或者自己
   //String sql = "select * from hero order by id desc limit ?,? ";	 
        String Pcname=null;
        String Pname=null;
        String Sname=null;
        String Sex=null;
        int Sage=0;
        String Sbirthtime=null;
        String Snative=null;
        //按即主码查询，单个	       	        	
        String sql = "select * from Student_view where 学号="+Sno;
	    try (Connection c = getConnection(); Statement s = c.createStatement();) {
	        	ResultSet rs = s.executeQuery(sql);
	            while (rs.next()) {
	            	/*定义一个类型为Teacher的对象 Teacher ，在while里查询出来的属性赋值给它，接着把对象该给集合，然后返回集合
	                 * 下面的一样道理*/  
	            	Student student=new Student() ;
	            	Pcname= rs.getString(1);
	            	Pname = rs.getString(2);
	            	Sname=rs.getString(3);
	            	Sno = rs.getInt(4);
	            	Sex=rs.getString(5);
	            	Sage=rs.getInt(6);
	            	Sbirthtime=rs.getString(7);
	            	Snative=rs.getString(8);
	            	student.Pcname=Pcname;
	            	student.Pname=Pname;
	            	student.Sname=Sname;
	            	student.Sno=Sno;
	            	student.Sex=Sex;
	            	student.Sage=Sage;
	            	student.Sbirthtime=Sbirthtime;
	            	student.Snative=Snative;
	            	students.add(student);
	            }
	        }catch (SQLException e) {
	            e.printStackTrace();}
	     return students;//返回系集合，符合条件的系的信息
    }
	public List<Student> list2(String Pname) {
        List<Student> students = new ArrayList<Student>();
  //把符合条件的Student数据查询出来，转换为Student对象后，放在一个集合中返回
  //从视图里查询，看不到密码，给别的用，查询一个班级
   //String sql = "select * from hero order by id desc limit ?,? ";	 
        String Pcname=null;
        String Sname=null;
        int Sno=0;
        String Sex=null;
        int Sage=0;
        String Sbirthtime=null;
        String Snative=null;
        //按即主码查询，单个	       	        	
        String sql = "select * from Student_view where 专业班级="+"'"+Pname+"'";
	    try (Connection c = getConnection(); Statement s = c.createStatement();) {
	        	ResultSet rs = s.executeQuery(sql);
	            while (rs.next()) {
	            	/*定义一个类型为Teacher的对象 Teacher ，在while里查询出来的属性赋值给它，接着把对象该给集合，然后返回集合
	                 * 下面的一样道理*/  
	            	Student student=new Student() ;
	            	Pcname= rs.getString(1);
	            	Pname = rs.getString(2);
	            	Sname=rs.getString(3);
	            	Sno = rs.getInt(4);
	            	Sex=rs.getString(5);
	            	Sage=rs.getInt(6);
	            	Sbirthtime=rs.getString(7);
	            	Snative=rs.getString(8);
	            	student.Pcname=Pcname;
	            	student.Pname=Pname;
	            	student.Sname=Sname;
	            	student.Sno=Sno;
	            	student.Sex=Sex;
	            	student.Sage=Sage;
	            	student.Sbirthtime=Sbirthtime;
	            	student.Snative=Snative;
	            	students.add(student);
	            }
	        }catch (SQLException e) {
	            e.printStackTrace();}
	     return students;//返回系集合，符合条件的系的信息
    }
	public String getpwd(int Sno) {
        
  //把符合条件的Student数据查询出来，转换为Student对象后，放在一个集合中返回
  //从表查询，给管理员用，看得到密码，查询所有人
   //String sql = "select * from hero order by id desc limit ?,? ";	 
        //int Sno=0;
//        String Sname=null;
//        String Sex=null;
//        int Sage=0;
//        String Snative=null;
//        int SPno=0;
        String Spassword=null;
        //按即主码查询，单个	       	        	
        String sql = "select Spassword from Student where Sno="+Sno;
	    try (Connection c = getConnection(); Statement s = c.createStatement();) {
	        	ResultSet rs = s.executeQuery(sql);
	            while (rs.next()) { 
	            	
	            	
	            	Spassword=rs.getString(1);
	            	
	            }
	        }catch (SQLException e) {
	            e.printStackTrace();}
	     return Spassword;//返回系集合，符合条件的系的信息
    }
	 public List<Student> list3() {
	        List<Student> students = new ArrayList<Student>();
	  //把符合条件的Student数据查询出来，转换为Student对象后，放在一个集合中返回
	  //从表查询，给管理员用，看得到密码，查询所有人
	   //String sql = "select * from hero order by id desc limit ?,? ";	 
	        int Sno=0;
	        String Sname=null;
	        String Sex=null;
	        int Sage=0;
	        String Snative=null;
	        int SPno=0;
	        String Spassword=null;
	        //按即主码查询，单个	       	        	
	        String sql = "select * from Student";
		    try (Connection c = getConnection(); Statement s = c.createStatement();) {
		        	ResultSet rs = s.executeQuery(sql);
		            while (rs.next()) { 
		            	Student student=new Student() ;
		            	Sno = rs.getInt(1);	
		            	Sname=rs.getString(2);
		            	Sex = rs.getString(3);
		            	Sage=rs.getInt(4);
		            	Snative=rs.getString(5);
		            	SPno=rs.getInt(6);
		            	Spassword=rs.getString(7);
		            	student.Sno=Sno;
		            	student.Sname=Sname;
		            	student.Sex=Sex;
		            	student.Sage=Sage;
		            	student.Snative=Snative;
		            	student.SPno=SPno;
		            	student.Spassword=Spassword;	            	
		            	students.add(student);
		            }
		        }catch (SQLException e) {
		            e.printStackTrace();}
		     return students;//返回系集合，符合条件的系的信息
	    }
	 public boolean login(int Sno,String pwd) {
		 	int sqlSno = 0;
		 	String sqlpwd = null;
			String sql = "select * from Student where Sno="+Sno+" and "+"Spassword="+"'"+pwd+"'";
			try (Connection c = getConnection(); Statement s = c.createStatement();) {
				ResultSet rs = s.executeQuery(sql);
//				System.out.println(Sno);
//				System.out.println(pwd);
				while (rs.next()) {
					sqlSno = rs.getInt(1);
					sqlpwd = rs.getString(7);
					if(Sno==sqlSno&&pwd.equals(sqlpwd))
					{
						return true;
					}
				
				}
			}
			catch (SQLException e) {  
	        e.printStackTrace();
	        return false;
			}
			return false;
		}
	 public List<Student> list4(int Sno,String Spassword) {
         List<Student> students = new ArrayList<Student>();
   //把符合条件的Student数据查询出来，转换为Student对象后，放在一个集合中返回
   //从表查询，用于登录
    //String sql = "select * from hero order by id desc limit ?,? ";  
         String Sname=null;
         String Sex=null;
         int Sage=0;
         String Snative=null;
         int SPno=0;       
         //按即主码查询，单个                  
         String sql = "select * from Student where Sno="+Sno+" and "+"Spassword="+"'"+Spassword+"'";
      try (Connection c = getConnection(); Statement s = c.createStatement();) {
           ResultSet rs = s.executeQuery(sql);
              while (rs.next()) { 
               Student student=new Student() ;
               Sno = rs.getInt(1); 
               Sname=rs.getString(2);
               Sex = rs.getString(3);
               Sage=rs.getInt(4);
               Snative=rs.getString(5);
               SPno=rs.getInt(6);
               Spassword=rs.getString(7);
               student.Sno=Sno;
               student.Sname=Sname;
               student.Sex=Sex;
               student.Sage=Sage;
               student.Snative=Snative;
               student.SPno=SPno;
               student.Spassword=Spassword;              
               students.add(student);
              }
          }catch (SQLException e) {
              e.printStackTrace();
              return null;}
       return students;
     }
}
<file_sep>/src/admin/studentUI/changeController.java
package admin.studentUI;

import java.util.ArrayList;
import java.util.List;

import attendance.bean.Student;
import attendance.dao.StudentDao;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.stage.Stage;

public class changeController {
	@FXML private Button confirmButton;
	@FXML private TextField pwdField;
	@FXML
	protected void comfirmAction(ActionEvent event) {
		//Stage stage = (Stage) rootGridPane.getScene().getWindow();
	    //stage.close();
		
		StudentDao dao= new StudentDao();
    	  List<Student> is =new ArrayList<Student>();
    	  
    	  //FileItem item = fileList.data().get(index);
    	  is =dao.list3();
    		
    		for (Student b : is) {
    			if(pwdtrans.getName().equals(b.Sname))
            	{
    				System.out.printf("%s\t%s\t%s\t%d\t%s\t%d\t%s\t%s\n",b.Pcname,b.Pname,b.Sname,b.Sno,b.Sex,b.Sage,b.Sbirthtime,b.Snative);	           
    				//System.out.printf("%d\t%s\t%s\t%d\t%s\t%s\n",b.Sno,b.Sname,b.Sex,b.Sage,b.Snative,b.Spassword);
        			System.out.println();
        			//String item = String.valueOf(b.Sno);
        			System.out.print(b);
        				if(b.Sno==pwdtrans.getSno()) {
        					if(dao.update2(pwdtrans.getSno(), pwdField.getText())==true) {
        						Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        						alert.setTitle("提示");
        						alert.setHeaderText(null);
        						alert.setContentText("修改成功");
        						pwdtrans.setpwd(pwdField.getText());
        						alert.showAndWait();
        					}
        				}
        			
            	}
    			else continue;
        	  //openFile(item);
            }
		Stage stage = (Stage)confirmButton.getScene().getWindow();
	    stage.close();
    }
	public void Initpwd() {
		pwdField.setText(pwdtrans.getpwd());
	}
	
}


<file_sep>/src/Login/ChangeAdminpwd.java
package Login;

import java.io.IOException;

import attendance.dao.SuperAdminDao;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.stage.Stage;

public class ChangeAdminpwd {
	public void start(Stage stage) throws IOException {
        stage.setTitle("更改管理员密码");
        Parent root = FXMLLoader.load(getClass().getResource("ChangeAdminpwd.fxml"));
        Scene scene = new Scene(root, 320, 261);
        stage.setScene(scene);
        stage.show();
    }
	@FXML private Button confirmButton;
	@FXML private PasswordField pwdField;
	@FXML
	protected void confirm(ActionEvent event) {
		SuperAdminDao dao = new SuperAdminDao();
        if(dao.changepassword(pwdField.getText().toString())) {
        	Alert alert = new Alert(Alert.AlertType.INFORMATION);
			alert.setTitle("提示");
			alert.setHeaderText(null);
			alert.setContentText("修改成功！");
			alert.showAndWait();
			Stage stage = (Stage)confirmButton.getScene().getWindow();
			stage.close();
        }
        else {
        	Alert alert = new Alert(Alert.AlertType.INFORMATION);
			alert.setTitle("提示");
			alert.setHeaderText(null);
			alert.setContentText("修改失败");
			alert.showAndWait();
        }
	}
}
<file_sep>/src/student/StudAdded.java
package student;

import java.io.IOException;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class StudAdded {
	public void start(Stage stage) throws IOException {
        stage.setTitle("主界面");
        
      //Parent root = FXMLLoader.load(getClass().getResource("TeachChooseUI.fxml"));
        FXMLLoader loader = new FXMLLoader(getClass().getResource("StudAdded.fxml"));
        Parent root =loader.load();
        SAController Controller = loader.getController();
        Scene scene = new Scene(root, 387, 463);
        stage.setScene(scene);
        stage.show();
        Controller.InitUI();
        //Controller.InitUI();
    }
}
<file_sep>/src/attendance/dao/SuperAdminDao.java
package attendance.dao;
//管理员DAO
//给管理员用的
import java.sql.*;

//import attendance.bean.Academy;
public class SuperAdminDao {
	public SuperAdminDao(){
		 try {
	            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	          // System.out.println("加载驱动成功！");
	        } catch (ClassNotFoundException e) {
	            e.printStackTrace();
	            System.out.println("加载驱动失败！");
	        }
	}
	public Connection getConnection()throws SQLException{
        //抛出异常
		return DriverManager.getConnection("jdbc:sqlserver://sql.cerny.cn:1433;DatabaseName=attendance", "sa", "Myclassdesign330");
		//数据库的名字叫attendance，我的数据库账户是sa,密码是sa
		//这里我建立连接的时候不是用try-catcth来捕捉异常，而是主动抛出，那么我下面调用这个函数时要么继续抛出，要么用try-catcth捕捉，我选择用try-catcth捕捉，到时候主函数就不用处理了
        }
	
	public boolean changepassword(String pwd) {
		String sql = "update SuperAdmin set pwd=? where id='Admin'";
		try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);){
			ps.setString(1, pwd);
			ps.execute();
			return true;
		}
		catch (SQLException e) {  
        e.printStackTrace();
        return false;
		}
	}
	public boolean login(String pwd) {
		String sql = "select * from SuperAdmin where id='admin'";
		try (Connection c = getConnection(); Statement s = c.createStatement();) {
			ResultSet rs = s.executeQuery(sql);
			while (rs.next()) {
				String sqlpwd = rs.getString(2);
				if(pwd.equals(sqlpwd))
				{
					return true;
				}
			
			}
		}
		catch (SQLException e) {  
        e.printStackTrace();
        return false;
		}
		return false;
	}
}
<file_sep>/src/attendance/bean/Afl.java
package attendance.bean;

public class Afl {
//请假申请记录（申请成功的保存没成自动从数据库删除）
public int Sno;//学号
public int Cno;//课程号
public String APname;//班级名
public String Aname;//姓名
public String Adate;//申请日期
public String ABegindate;//开始请假日期
public String Aenddate;//请假结束日期
public String Areason;//请假原因
public String Aresults;//请假结果，默认待审核
//数据库中Datetime类型对应java中的java util.data
public int getSno() {
	return Sno;
}
public void setSno(int sno) {
	this.Sno = sno;
}
public int getCno() {
	return Cno;
}
public void setCno(int cno) {
	this.Cno = cno;
}
public String getAPname() {
	return APname;
}
public void setAPname(String aPname) {
	this.APname = aPname;
}
public String getAname() {
	return Aname;
}
public void setAname(String aname) {
	this.Aname = aname;
}
public String getAdate() {
	return Adate;
}
public void setAdate(String adate) {
	this.Adate = adate;
}
public String getABegindat() {
	return ABegindate;
}
public void setABegindat(String aBegindat) {
	this.ABegindate = aBegindat;
}
public String getAenddate() {
	return Aenddate;
}
public void setAenddate(String aenddate) {
	this.Aenddate = aenddate;
}
public String getAreason() {
	return Areason;
}
public void setAreason(String areason) {
	this.Areason = areason;
}
public String getAresults() {
	return Aresults;
}
public void setAresults(String aresults) {
	this.Aresults = aresults;
}
public Afl() {
	super();
	// TODO Auto-generated constructor stub
}
public Afl(int sno, int cno, String aPname, String aname, String adate, String aBegindate, String aenddate, String areason,
		String aresults) {
	super();
	this.Sno = sno;
	this.Cno = cno;
	this.APname = aPname;
	this.Aname = aname;
	this.Adate = adate;
	this.ABegindate = aBegindate;
	this.Aenddate = aenddate;
	this.Areason = areason;
	this.Aresults = aresults;
}
@Override
public String toString() {
	return "Afl [Sno=" + Sno + ", Cno=" + Cno + ", APname=" + APname + ", Aname=" + Aname + ", Adate=" + Adate
			+ ", ABegindate=" + ABegindate + ", Aenddate=" + Aenddate + ", Areason=" + Areason + ", Aresults=" + Aresults
			+ "]";
}

}
<file_sep>/src/teacher/TQController.java
package teacher;

import java.util.ArrayList;
import java.util.List;

import admin.studentUI.pwdtrans;
import attendance.bean.Afl;
import attendance.bean.Course;
import attendance.bean.PC;
import attendance.bean.Student;
import attendance.dao.AflDao;
import attendance.dao.CourseDao;
import attendance.dao.PCDao;
import attendance.dao.StudentDao;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.input.MouseEvent;

public class TQController {
	@FXML private Label id;
	@FXML private Label classname;
	@FXML private Label name;
	@FXML private Label courseid;
	@FXML private Label coursename;
	@FXML private Label applytime;
	@FXML private Label startdate;
	@FXML private Label enddate;
	@FXML private Label label1;
	@FXML private Label label2;
	@FXML private Label label3;
	@FXML private Label label4;
	@FXML private Label label5;
	@FXML private Label label6;
	@FXML private Label label7;
	@FXML private Label label8;
	@FXML private Label label9;
	@FXML private TextArea reason1;
	@FXML private Button accept;
	@FXML private Button inject;
	@FXML private Button reload;
	@FXML private ComboBox ifaccept;
	@FXML private ListView list;
	@FXML
	protected void Accept(ActionEvent event) {
		AflDao dao = new AflDao();
		List<Afl> is = new ArrayList<Afl>();
		dao.update2(Integer.valueOf(id.getText().toString()), Integer.valueOf(courseid.getText().toString()), applytime.getText().toString(), "已批准");
		accept.setDisable(true);
		accept.setText("已批准");
		inject.setDisable(false);
		inject.setText("拒绝");
	}
	@FXML
	protected void Reload(ActionEvent event) {
		list.getItems().clear();
		ReloadList();
	}
	@FXML
	protected void Inject(ActionEvent event) {
		AflDao dao = new AflDao();
		List<Afl> is = new ArrayList<Afl>();
		dao.update2(Integer.valueOf(id.getText().toString()), Integer.valueOf(courseid.getText().toString()), applytime.getText().toString(), "未通过");
		inject.setDisable(true);
		inject.setText("已拒绝");
		accept.setDisable(false);
		accept.setText("批准");
	}
	public void InitUI() {
		id.setVisible(false);
		classname.setVisible(false);
		name.setVisible(false);
		courseid.setVisible(false);
		coursename.setVisible(false);
		applytime.setVisible(false);
		startdate.setVisible(false);
		enddate.setVisible(false);
		reason1.setVisible(false);
		accept.setVisible(false);
		inject.setVisible(false);
		label1.setVisible(false);
		label2.setVisible(false);
		label3.setVisible(false);
		label4.setVisible(false);
		label5.setVisible(false);
		label6.setVisible(false);
		label7.setVisible(false);
		label8.setVisible(false);
		label9.setVisible(false);
		
		ifaccept.getItems().addAll("待审核","已批准","未通过");
		ifaccept.setValue("待审核");
		ifaccept.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
        	@Override
        	public void changed(ObservableValue observable, Object oldValue, Object newValue) {
        		AflDao dao= new AflDao();
        	    List<Afl> is =new ArrayList<Afl>();
        	    is=dao.list(TeachIdentity.getTno());
        		for(Afl a:is) {
          	      	//classoptions.add(c.Pname);
        			
        			list.getItems().clear();
        			
          	    }
        		String results = ifaccept.getValue().toString();
        		System.out.println(results);
        		
        		is = dao.get(TeachIdentity.getTno(), results);
        		System.out.println(TeachIdentity.getTno());
        		for(Afl a:is) {
        			System.out.println(a.Aname);
        			list.getItems().addAll(a.Aname+"    "+a.Sno);
        			
        			
          	    }
        		id.setVisible(false);
        		classname.setVisible(false);
        		name.setVisible(false);
        		courseid.setVisible(false);
        		coursename.setVisible(false);
        		applytime.setVisible(false);
        		startdate.setVisible(false);
        		enddate.setVisible(false);
        		reason1.setVisible(false);
        		accept.setVisible(false);
        		inject.setVisible(false);
        		label1.setVisible(false);
        		label2.setVisible(false);
        		label3.setVisible(false);
        		label4.setVisible(false);
        		label5.setVisible(false);
        		label6.setVisible(false);
        		label7.setVisible(false);
        		label8.setVisible(false);
        		label9.setVisible(false);
        	}
        });
		list.setOnMouseClicked(new EventHandler<MouseEvent>() {
			@Override
			public void handle(MouseEvent event)
			{
				if(event.getClickCount()== 1)
				{
					try {
						
						onFileListDbclicked();
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			}			
		});
		ReloadList();
	}
	public void onFileListDbclicked() {
		//String item = list.selectionModelProperty().getValue().toString();
		String item = list.getSelectionModel().getSelectedItem().toString();
		int idstart = 0;
		for(int i=0;i<item.length();i++) {
    		if(Character.isDigit(item.charAt(i))) {
    			idstart=Integer.parseInt(item.substring(i));
    			//System.out.println(item.substring(i));
    		}
    	}
		int index = list.getSelectionModel().getSelectedIndex();
		id.setVisible(true);
		classname.setVisible(true);
		name.setVisible(true);
		courseid.setVisible(true);
		coursename.setVisible(true);
		applytime.setVisible(true);
		startdate.setVisible(true);
		enddate.setVisible(true);
		reason1.setVisible(true);
		accept.setVisible(true);
		inject.setVisible(true);
		reason1.setEditable(false);
		AflDao dao = new AflDao();
		List<Afl> is = new ArrayList<Afl>();
		String status = ifaccept.getValue().toString();
		is = dao.get(TeachIdentity.getTno(),status);
		CourseDao dao1 = new CourseDao();
		List<Course> is1 = new ArrayList<Course>();
		id.setText(String.valueOf(is.get(index).Sno));
		classname.setText(is.get(index).APname);
		name.setText(is.get(index).Aname);
		courseid.setText(String.valueOf(is.get(index).Cno));
		is1=dao1.list1(is.get(index).Cno);
		coursename.setText(is1.get(0).getCname());
		applytime.setText(is.get(index).Adate);
		startdate.setText(is.get(index).ABegindate);
		enddate.setText(is.get(index).Aenddate);
		reason1.setText(is.get(index).Areason);
		if(is.get(index).Aresults.equals("待审核")) {
			accept.setDisable(false);
			accept.setText("批准");
			inject.setDisable(false);
			inject.setText("拒绝");
		}
		else if(is.get(index).Aresults.equals("未通过")) {
			accept.setDisable(false);
			inject.setDisable(true);
			inject.setText("已拒绝");
			accept.setText("批准");
		}else if(is.get(index).Aresults.equals("已批准")) {
			accept.setDisable(true);
			inject.setDisable(false);
			inject.setText("拒绝");
			accept.setText("已批准");
		}
		label1.setVisible(true);
		label2.setVisible(true);
		label3.setVisible(true);
		label4.setVisible(true);
		label5.setVisible(true);
		label6.setVisible(true);
		label7.setVisible(true);
		label8.setVisible(true);
		label9.setVisible(true);
		//ReloadList();
	}
	public void ReloadList() {
		list.getItems().clear();
		AflDao dao = new AflDao();
		List<Afl> is = new ArrayList<Afl>();
		
		String status = ifaccept.getValue().toString();
		is = dao.get(TeachIdentity.getTno(), status);
		for(Afl a:is) {
			list.getItems().addAll(a.Aname+"    "+a.Sno);
			
		}
		
	}
}
<file_sep>/src/attendance/test/AflDaoTest.java
package attendance.test;

import java.util.ArrayList;
import java.util.List;

import attendance.bean.AC;
import attendance.bean.Afl;
import attendance.dao.ACDao;
import attendance.dao.AflDao;

public class AflDaoTest {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		AflDao dao= new AflDao();
	    List<Afl> is =new ArrayList<Afl>();
	    dao.add(4, 1, "计算机181", "陈世恩", "2020-04-14", "2020-04-15", "2020-04-16", "身体不适，需要请假");
	}

}
<file_sep>/src/teacher/TCController.java
package teacher;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import Login.Main;
import attendance.bean.Afl;
import attendance.bean.PC;
import attendance.bean.Teacher;
import attendance.dao.AflDao;
import attendance.dao.PCDao;
import attendance.dao.TeacherDao;
import javafx.event.ActionEvent;
import javafx.fxml.*;
import javafx.scene.control.*;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;

public class TCController {
	public String name;
	@FXML private Button kaoqinbutton;
	@FXML private Button qingjiabutton;
	@FXML private Button totalbutton;
	@FXML private Button logoutbutton;
	@FXML private Button changepwd;
	@FXML private Label namelabel;
	@FXML private Label qingjia;
	@FXML private ImageView image;
	@FXML
	protected void LoadRoutine(ActionEvent event) throws IOException {
		new TeachRoutineUI().start(new Stage());
	}
	@FXML
	protected void LoadTotal(ActionEvent event) throws IOException {
		new TeachTotalUI().start(new Stage());
	}
	@FXML
	protected void LogOut(ActionEvent event) throws IOException {
		new Main().start(new Stage());
		Stage stage = (Stage)logoutbutton.getScene().getWindow();
		stage.hide();
	}
	@FXML
	protected void Changepwd(ActionEvent event) throws IOException {
		new TeachDetail().start(new Stage());
		
	}
	@FXML
	protected void Qingjia(ActionEvent event) throws IOException {
		new TeachQingjia().start(new Stage());
		
	}
	public void getno() {
		int Tno = TeachIdentity.getTno();
		TeacherDao dao = new TeacherDao();
		List<Teacher> is =new ArrayList<Teacher>();
		is = dao.list3();
		for(Teacher t:is) {
			if(t.Tno==Tno) {
				namelabel.setText(t.Tname);
				break;
			}
		}
//		namelabel.setText("霸道总裁");
		AflDao adao = new AflDao();
		List<Afl> ais =new ArrayList<Afl>();
		ais = adao.get(Tno, "待审核");
		int count = 0;
		for(Afl a:ais) {
			count++;
		}
		if(count==0) {
			image.setVisible(false);
			qingjia.setVisible(false);
		}
		else {
			image.setVisible(true);
			qingjia.setVisible(true);
			qingjia.setText(count+"条请假消息待审核");
		}
		qingjiabutton.setId("button-custom");
	}
}
<file_sep>/src/admin/xueqinfoUI/XueqinfoUI.java
package admin.xueqinfoUI;

import java.io.IOException;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import teacher.TRController;

public class XueqinfoUI {
	public void start(Stage stage) throws IOException {
		FXMLLoader loader = new FXMLLoader(getClass().getResource("XueqinfoUI.fxml"));
        Parent root =loader.load();
        XQController Controller = loader.getController();
        Scene scene = new Scene(root, 784, 482);
        stage.setScene(scene);
        stage.setTitle("学期信息管理");
        stage.show();
        Controller.InitUI();
    }
}
<file_sep>/src/attendance/dao/CourseDao.java
package attendance.dao;
//课程DAO，给管理员用的
import java.sql.*;
import javax.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import attendance.bean.Course;
public class CourseDao {
	public CourseDao(){
		 try {
	            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	          // System.out.println("加载驱动成功！");
	        } catch (ClassNotFoundException e) {
	            e.printStackTrace();
	            System.out.println("加载驱动失败！");
	        }
	}
	public Connection getConnection()throws SQLException{
      //抛出异常
		return DriverManager.getConnection("jdbc:sqlserver://sql.cerny.cn:1433;DatabaseName=attendance", "sa", "Myclassdesign330");
		//数据库的名字叫attendance，我的数据库账户是sa,密码是sa
		//这里我建立连接的时候不是用try-catcth来捕捉异常，而是主动抛出，那么我下面调用这个函数时要么继续抛出，要么用try-catcth捕捉，我选择用try-catcth捕捉，到时候主函数就不用处理了
      }
	public int getTotal() {
		//得到目前表Course总数有多少条
        int total = 0;
        try (Connection c = getConnection(); Statement s = c.createStatement();) {          
            String sql = "select count(*) from Course"; 
            ResultSet rs = s.executeQuery(sql);
            while (rs.next()) {
                total = rs.getInt(1);//	这里getInt是因为rs这个结果集这里是返回的结果行数
            }
            // System.out.println("total:" + total); 
        } catch (SQLException e) {  
            e.printStackTrace();
        }
        return total;
    }
	public boolean add(int Cno,String Cname) {
		//这里增加函数课程号（本来主码可以自增不插，但我这里还是打开自增规则插进去），
		//课程号，课程名
        String sql = "set identity_insert Course ON insert into Course(Cno,Cname) values(?,?) set identity_insert Course OFF";
        try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);) { 
        	ps.setInt(1,Cno);
        	ps.setString(2,Cname);         
            ps.execute();  
            return true;
            //ResultSet rs = ps.getGeneratedKeys();//如果因为主码自增不插，然后通过这里得到主码赋值给对象对应的属性
        } catch (SQLException e) {  
            e.printStackTrace();
        }
		return false;
    }
	public boolean update(int Cno,String Cname) {
		//课程号，课程名
		//不更新主码，主码一般不允许更新，一般允许更新主码的数据库设计都是不合理的		
         String sql = "update Course set Cname=? where Cno ="+Cno; 
	    	 try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);){	    		
	    		 ps.setString(1, Cname); 	    		 
	    		 ps.execute();
	    		 return true;
	    	//	 System.out.println("修改成功");	    		 
	    	 }catch (SQLException e1) {
		            e1.printStackTrace();		     
		      }catch (Exception e2) {// 捕获其他异常
		    	  e2.printStackTrace();// 打印异常产生的过程信息
		      }
	    	 return false;
	    	}
	public boolean delete(int Cno) {
		 //删除函数
		 try (Connection c = getConnection(); Statement s = c.createStatement();) {				  
	            String sql = "delete from Course where Cno ="+Cno;
	            s.execute(sql);	
	            return true;
	            //System.out.println("删除成功");
	      }catch(SQLException e1) {
	            e1.printStackTrace();
	      }catch(Exception e2) {// 捕获其他异常
	    	  e2.printStackTrace();// 打印异常产生的过程信息
	      }
		return false;
	    }	
	 public List<Course> list1(int Cno) {
	        List<Course> courses = new ArrayList<Course>();
	  //把符合条件的Course数据查询出来，转换为Course对象后，放在一个集合中返回
	   //String sql = "select * from hero order by id desc limit ?,? ";		       	         
	        String Cname=null;//课程名
	        //按即主码查询，单个
	        //System.out.println("请输入要查询课程号:");	        	
	        String sql = "select * from Course where Cno ="+Cno;
		    try (Connection c = getConnection(); Statement s = c.createStatement();) {
		        	ResultSet rs = s.executeQuery(sql);
		            while (rs.next()) {
		            	/*定义一个类型为Course的对象course ，在while里查询出来的属性赋值给它，接着把对象该给集合，然后返回集合
		                 * 下面的一样道理*/  
		            	Course course=new Course() ;
		            	Cno= rs.getInt(1);
		            	Cname = rs.getString("Cname");	        
		            	course.Cno=Cno;
		            	course.Cname=Cname;
		            	courses.add(course);
		            }
		        }catch (SQLException e) {
		            e.printStackTrace();}
		     return courses;//返回系集合，符合条件的系的信息
	    }
	 public List<Course> list2() {
	        List<Course> courses = new ArrayList<Course>();
	  //把Course数据查询出来，转换为Course对象后，放在一个集合中返回
	   //String sql = "select * from hero order by id desc limit ?,? ";	
	        int Cno=0;//课程号
	        String Cname=null;//课程名 
	      //都查询出来
	        //System.out.println("请输入要查询课程号:");	        	
	        String sql = "select * from Course ";
		    try (Connection c = getConnection(); Statement s = c.createStatement();) {
		        	ResultSet rs = s.executeQuery(sql);
		            while (rs.next()) {
		            	/*定义一个类型为Course的对象course ，在while里查询出来的属性赋值给它，接着把对象该给集合，然后返回集合
		                 * */  
		            	Course course=new Course() ;
		            	Cno= rs.getInt(1);
		            	Cname = rs.getString("Cname");	        
		            	course.Cno=Cno;
		            	course.Cname=Cname;
		            	courses.add(course);
		            }
		        }catch (SQLException e) {
		            e.printStackTrace();}
		     return courses;//返回系集合，符合条件的系的信息
	    }
	 public List<Course> list3(String Cname) {
	        List<Course> courses = new ArrayList<Course>();
	  //把符合条件的Course数据查询出来，转换为Course对象后，放在一个集合中返回
	   //String sql = "select * from hero order by id desc limit ?,? ";		       	         
	        //String Cname=null;//课程名
	        int Cno = 0;
	        //按即主码查询，单个
	        //System.out.println("请输入要查询课程号:");	        	
	        String sql = "select * from Course where Cname =" + "'" + Cname + "'";
		    try (Connection c = getConnection(); Statement s = c.createStatement();) {
		        	ResultSet rs = s.executeQuery(sql);
		            while (rs.next()) {
		            	/*定义一个类型为Course的对象course ，在while里查询出来的属性赋值给它，接着把对象该给集合，然后返回集合
		                 * 下面的一样道理*/  
		            	Course course=new Course() ;
		            	Cno= rs.getInt(1);
		            	Cname = rs.getString("Cname");	        
		            	course.Cno=Cno;
		            	course.Cname=Cname;
		            	courses.add(course);
		            }
		        }catch (SQLException e) {
		            e.printStackTrace();}
		     return courses;//返回系集合，符合条件的系的信息
	    }
}
<file_sep>/src/teacher/TeachRoutineTrans.java
package teacher;

public class TeachRoutineTrans {
	public static String classname;
	public static int id;
	public static String name;
	public static int courseid;
	public static String coursename;
	public static String date;
	public static String situation;
	public static String getClassname() {
		return classname;
	}
	public static void setClassname(String classname) {
		TeachRoutineTrans.classname = classname;
	}
	public static int getId() {
		return id;
	}
	public static void setId(int id) {
		TeachRoutineTrans.id = id;
	}
	public static String getName() {
		return name;
	}
	public static void setName(String name) {
		TeachRoutineTrans.name = name;
	}
	public static int getCourseid() {
		return courseid;
	}
	public static void setCourseid(int courseid) {
		TeachRoutineTrans.courseid = courseid;
	}
	public static String getCoursename() {
		return coursename;
	}
	public static void setCoursename(String coursename) {
		TeachRoutineTrans.coursename = coursename;
	}
	public static String getDate() {
		return date;
	}
	public static void setDate(String date) {
		TeachRoutineTrans.date = date;
	}
	public static String getSituation() {
		return situation;
	}
	public static void setSituation(String situation) {
		TeachRoutineTrans.situation = situation;
	}
}
<file_sep>/src/student/StuDetail.java
package student;

import java.io.IOException;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class StuDetail {
	public void start(Stage stage) throws IOException {
        stage.setTitle("主界面");
        
      //Parent root = FXMLLoader.load(getClass().getResource("TeachChooseUI.fxml"));
        FXMLLoader loader = new FXMLLoader(getClass().getResource("StuDetail.fxml"));
        Parent root =loader.load();
        SDController Controller = loader.getController();
        Scene scene = new Scene(root, 441, 501);
        stage.setScene(scene);
        stage.show();
        Controller.InitUI();
        //Controller.InitUI();
    }
}
<file_sep>/src/attendance/bean/Xueqi.java
package attendance.bean;

import java.util.Date;

public class Xueqi {
	public Date startdate;
	public Date enddate;
	public int Xueqi;
	public Date getStartdate() {
		return startdate;
	}
	public void setStartdate(Date startdate) {
		this.startdate = startdate;
	}
	public Date getEnddate() {
		return enddate;
	}
	public void setEnddate(Date enddate) {
		this.enddate = enddate;
	}
	public int getXueqi() {
		return Xueqi;
	}
	public void setXueqi(int xueqi) {
		Xueqi = xueqi;
	}
	public Xueqi() {
		super();
	}
	public Xueqi(Date startdate, Date enddate, int Xueqi) {
		this.startdate = startdate;
		this.enddate = enddate;
		this.Xueqi = Xueqi;
	}
}
<file_sep>/src/student/StudIdentityTrans.java
package student;

public class StudIdentityTrans {
	public static int Cno;
	public static String Cname;
	public static int Status;//判断右键菜单是否展开
	public static int getStatus() {
		return Status;
	}
	public static void setStatus(int status) {
		StudIdentityTrans.Status = status;
	}
	public static int getCno() {
		return Cno;
	}
	public static void setCno(int Cno) {
		StudIdentityTrans.Cno = Cno;
	}
	public static String getCname() {
		return Cname;
	}
	public static void setCname(String Cname) {
		StudIdentityTrans.Cname = Cname;
	}
}
<file_sep>/src/attendance/test/XueqiDaoTest.java
package attendance.test;

import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import attendance.bean.Qimo;
import attendance.bean.Xueqi;
import attendance.dao.QimoDao;
import attendance.dao.XueqiDao;

public class XueqiDaoTest {
	public static void main(String[] args) throws ParseException{
		XueqiDao dao= new XueqiDao();
	    List<Xueqi> is =new ArrayList<Xueqi>();
	    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
	    //ParsePosition pos = new ParsePosition(0);
	    Date date1 = sdf.parse("2020-01-01");
	    Date date2 = sdf.parse("2020-04-10");
	    //System.out.println(date1);
	    //System.out.println(date2);
	    //dao.add(date1, date2,2);
//	    is = dao.getList();
//	    for(Xueqi x:is) {
//	    	String s = new SimpleDateFormat("yyyy").format(x.startdate);
//	    	System.out.println(s);
//	    	System.out.println(x.enddate);
//	    	System.out.println(x.Xueqi);
//	    }
	    dao.delete("2020-01-01", "2020-04-10");
	}
	
}
<file_sep>/src/admin/teachinfoUI/TeachInfoUI.java
package admin.teachinfoUI;

import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.TableColumn.CellEditEvent;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.image.Image;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.paint.CycleMethod;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.shape.Ellipse;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import javafx.util.Callback;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.ResourceBundle;

import admin.studentUI.AfImagePane;
import admin.studentUI.FileItem;
import admin.studentUI.TextFileUtils;
import admin.teacherUI.pwdtrans;
import attendance.bean.PC;
import attendance.bean.Student;
import attendance.bean.Teach;
import attendance.bean.Teacher;
import attendance.bean.TeachforUI;
import attendance.dao.PCDao;
import attendance.dao.StudentDao;
import attendance.dao.TeachDao;
import attendance.dao.TeacherDao;

public class TeachInfoUI{
	int idstart = 0;
    ListView fileList = new ListView();
    TabPane tabPane = new TabPane(); // 中间放一个Tab容器
    // 必须static 类型
    final ObservableList<TeachCourse> data = FXCollections.observableArrayList();
    public void start(Stage stage) throws IOException {
    	initList();
//    	tabPane.getSelectionModel().selectedItemProperty().addListener(
//    		    new ChangeListener<Tab>() {
//    		        @Override
//    		        public void changed(ObservableValue<? extends Tab> ov, Tab t, Tab t1) {
//    		        	
//    		        	System.out.println("Tab Selection changed");
//    		        	String item = tabPane.getSelectionModel().getSelectedItem().toString();
//    		        	try {
//							openFile1(item);
//						} catch (Exception e) {
//							// TODO Auto-generated catch block
//							e.printStackTrace();
//						}
//    		        }
//    		    }
//    		);
        stage.setTitle("教师任课信息管理");
        BorderPane border = new BorderPane();
                HBox hbox = addHBox();
        border.setTop(hbox);
        //border.setLeft(addVBox());
        addStackPane(hbox); //添加一个堆栈面板到上方区域的HBox中
        Label label = new Label("色彩块");
        label.setPrefSize(200, 300);
        label.setStyle("-fx-background-color: #ffffff");
        //border.setRight(label);
        border.setLeft(fileList);
        border.setCenter(tabPane);
        //border.setCenter(addGridPane());
        //border.setRight(addFlowPane());
        //Parent root = FXMLLoader.load(getClass().getResource("Student.fxml"));
        Scene scene = new Scene(border, 1327, 547);
        //ListView<String> list = new ListView<>();

        //ObservableList<String> items =FXCollections.observableArrayList (
        //        "Single", "Double", "Suite", "Family App");
        //list.setItems(items);
        
        /**
         * listView的事件处理添加
         */
        
        stage.setScene(scene);
        stage.show();
    }
    public static class TeachCourse {

        private final SimpleStringProperty Cono;
        private final SimpleStringProperty CoName;
        private final SimpleStringProperty Coschool;
        private final SimpleStringProperty Cograde;

        private TeachCourse(String Cono1, String CoName1, String Coschool1, String Cograde1) {
            this.Cono = new SimpleStringProperty(Cono1);
            this.CoName = new SimpleStringProperty(CoName1);
            this.Coschool = new SimpleStringProperty(Coschool1);
            this.Cograde = new SimpleStringProperty(Cograde1);
        }

        public String getCono() {
            return Cono.get();
        }

        public void setCono(String Cono1) {
        	Cono.set(Cono1);
        }

        public String getCoName() {
            return CoName.get();
        }

        public void setCoName(String CoName1) {
        	CoName.set(CoName1);
        }

        public String getCoschool() {
            return Coschool.get();
        }

        public void setCoschool(String Coschool1) {
        	Coschool.set(Coschool1);
        }
        public String getCograde() {
            return Cograde.get();
        }

        public void setCograde(String Cograde1) {
        	Cograde.set(Cograde1);
        }

    }
    private void initList()
	{
		fileList.setPrefWidth(200);
		TeacherDao dao= new TeacherDao();
	    List<Teacher> is =new ArrayList<Teacher>();
	    is =dao.list3();
	    ObservableList<String> items =FXCollections.observableArrayList ();
	    for (Teacher b : is) {
	    	//System.out.printf("%s\t%s\t%s\t%d\t%s\t%d\t%s\t%s\n",b.Pcname,b.Pname,b.Sname,b.Sno,b.Sex,b.Sage,b.Sbirthtime,b.Snative);	           
	    	//System.out.printf("%d\t%s\t%s\t%d\t%s\t%s\n",b.Sno,b.Sname,b.Sex,b.Sage,b.Snative,b.Spassword);
	    	System.out.println();
	    	//String item = String.valueOf(b.Sname);
	    	String item = b.Tname + "    " + b.Tno;
	    	items.add(item);
	    	//System.out.println(item.length());
	    	//Character.isDigit(item.charAt(9));
	    	
	    	
	    	for(int i=0;i<item.length();i++) {
	    		if(Character.isDigit(item.charAt(i))) {
	    			idstart=Integer.parseInt(item.substring(i));
	    			//System.out.println(item.substring(i));
	    		}
	    	}
	    	System.out.println(idstart);
        }
		// 左侧加载examples目录下的文件

		fileList.setItems(items);
		
		// 当双击左侧时，右侧显示内容
		fileList.setOnMouseClicked(new EventHandler<MouseEvent>() {
			@Override
			public void handle(MouseEvent event)
			{
				if(event.getClickCount()== 2)
				{
					try {
						
						onFileListDbclicked();
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			}			
		});
	}
    public void addStackPane(HBox hb){
        StackPane stack = new StackPane();
        Rectangle helpIcon = new Rectangle(30.0, 25.0);
        helpIcon.setFill(new LinearGradient(0,0,0,1, true, CycleMethod.NO_CYCLE,
                new Stop[]{
                        new Stop(0,Color.web("#4977A3")),
                        new Stop(0.5, Color.web("#B0C6DA")),
                        new Stop(1,Color.web("#9CB6CF")),}));
        helpIcon.setStroke(Color.web("#D0E6FA"));
        helpIcon.setArcHeight(3.5);
        helpIcon.setArcWidth(3.5);

        Text helpText = new Text("?");
        helpText.setFont(Font.font("Verdana", FontWeight.BOLD, 18));
        helpText.setFill(Color.WHITE);
        helpText.setStroke(Color.web("#7080A0"));

        stack.getChildren().addAll(helpIcon, helpText);
        stack.setAlignment(Pos.CENTER_RIGHT); //右对齐节点

        StackPane.setMargin(helpText, new Insets(0, 10, 0, 0)); //设置问号居中显示
        hb.getChildren().add(stack); // 将StackPane添加到HBox中
        HBox.setHgrow(stack, Priority.ALWAYS); // 将HBox水平多余的所有空间都给StackPane，这样前面设置的右对齐就能保证问号按钮在最右边
    }
    public VBox addVBox(){
        VBox vbox = new VBox();
        vbox.setPadding(new Insets(10)); //内边距
        vbox.setSpacing(8); //节点间距

        Text title = new Text("Data");
        title.setFont(Font.font("Arial", FontWeight.BOLD, 14));
        vbox.getChildren().add(title);

        Hyperlink options[] = new Hyperlink[] {
                new Hyperlink("Sales"),
                new Hyperlink("Marketing"),
                new Hyperlink("Distribution"),
                new Hyperlink("Costs")};

        for (int i=0; i<4; i++){
            VBox.setMargin(options[i], new Insets(0, 0, 0, 8)); //为每个节点设置外边距
            vbox.getChildren().add(options[i]);
        }

        return vbox;
    }
    public TableView addTableView() {
    	
    	TableView table = new TableView();
    	data.clear();
    	table.setEditable(true);
    	TableColumn<TeachCourse, String> firstCol = 
                new TableColumn<>("课程号");
    	firstCol.setCellValueFactory(
                new PropertyValueFactory<>("Cono"));

            firstCol.setCellFactory(TextFieldTableCell.<TeachCourse>forTableColumn());
            
            table.setRowFactory( tv -> {
            	System.out.println("Test");
    	  		TableRow<TeachCourse> row = new TableRow<TeachCourse>();
    	  		String item = fileList.getSelectionModel().getSelectedItem().toString();
    	  		for(int i=0;i<item.length();i++) {
    	    		if(Character.isDigit(item.charAt(i))) {
    	    			idstart=Integer.parseInt(item.substring(i));
    	    			//System.out.println(item.substring(i));
    	    		}
    	    	}TeachCourse tc=null;
    	  		 tc = row.getItem();
    	                    
    	            
    	            return row ;
    	        });
            
//            table.setRowFactory( tv -> {
//            	  		TableRow<TeachCourse> row = new TableRow<TeachCourse>();
//            	            row.setOnMouseClicked(event -> {
//            	                
//								if (event.getClickCount() == 2 && (! row.isEmpty()) ) {
//            	                    TeachCourse tc = row.getItem();
//            	                    System.out.println(tc.getCoName());
//            	                }
//            	            });
//            	            return row ;
//            	        });
            
            TableColumn<TeachCourse, String> secondCol = 
                    new TableColumn<>("课程名");
            secondCol.setCellValueFactory(
                    new PropertyValueFactory<>("CoName"));
            secondCol.setCellFactory(TextFieldTableCell.<TeachCourse>forTableColumn());
            
            TableColumn<TeachCourse, String> thirdCol = 
                    new TableColumn<>("所需学时");
            thirdCol.setCellValueFactory(
                    new PropertyValueFactory<>("Coschool"));
            thirdCol.setCellFactory(TextFieldTableCell.<TeachCourse>forTableColumn());

            TableColumn<TeachCourse, String> fourthCol = 
                    new TableColumn<>("学分");
            fourthCol.setCellValueFactory(
                    new PropertyValueFactory<>("Cograde"));
            fourthCol.setCellFactory(TextFieldTableCell.<TeachCourse>forTableColumn());
            
    	
    	firstCol.setPrefWidth(170);
    	secondCol.setPrefWidth(270);
    	thirdCol.setPrefWidth(120);
    	fourthCol.setPrefWidth(120);
    	table.getColumns().addAll(firstCol,secondCol,thirdCol,fourthCol);
    	String item = fileList.getSelectionModel().getSelectedItem().toString();
  		
  		
        for(int i=0;i<item.length();i++) {
    		if(Character.isDigit(item.charAt(i))) {
    			idstart=Integer.parseInt(item.substring(i));
    			pwdtrans.setPno(idstart);
    			//System.out.println(item.substring(i));
    		}
        }
    	firstCol.setOnEditCommit(
                (CellEditEvent<TeachCourse, String> t) -> {
                	
                	String onetemp = firstCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCono();
                	((TeachCourse) t.getTableView().getItems().get(
                            t.getTablePosition().getRow())
                            ).setCono(t.getNewValue());
                	String one = t.getNewValue();
                	//System.out.println("Test");
                	String two = secondCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCoName();
                    //System.out.println(tc.getCoName());
                	String three = thirdCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCoschool();
                	String four = fourthCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCograde();
                    TeachDao dao = new TeachDao();
                    List<Teach>is = new ArrayList<Teach>();
                    int idstart = pwdtrans.getSno();
                    System.out.println(t.getNewValue());
                    if(dao.update(idstart, Integer.valueOf(onetemp) , idstart, Integer.valueOf(t.getNewValue()), Integer.valueOf(three), Integer.valueOf(four))) {
                    	
                    	Alert alert = new Alert(Alert.AlertType.INFORMATION);
						alert.setTitle("提示");
						alert.setHeaderText(null);
						alert.setContentText("修改成功");
						alert.showAndWait();
                    }
                    else {
                    	((TeachCourse) t.getTableView().getItems().get(
  	                            t.getTablePosition().getRow())
  	                            ).setCoName(onetemp);
						table.refresh();
                    }
                    
            });
    	
    	
    	secondCol.setOnEditCommit(
                (CellEditEvent<TeachCourse, String> t) -> {
                	
//                	String onetemp = firstCol.getTableView().getItems().get(
//                            t.getTablePosition().getRow()).getCono();
//                	((TeachCourse) t.getTableView().getItems().get(
//                            t.getTablePosition().getRow())
//                            ).setCono(t.getNewValue());
                	String one = firstCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCono();
                	
                	String twotemp = secondCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCoName();
                	//String two = t.getNewValue();
                    //System.out.println(tc.getCoName());
                	String three = thirdCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCoschool();
                	String four = fourthCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCograde();
                    TeachDao dao = new TeachDao();
                    List<Teach>is = new ArrayList<Teach>();
                    int idstart = pwdtrans.getSno();
                    System.out.println(t.getNewValue());
                    //if(dao.update(idstart, Integer.valueOf(twotemp) , idstart, Integer.valueOf(t.getNewValue()), Integer.valueOf(three), Integer.valueOf(four))) {
                    	
                    	Alert alert = new Alert(Alert.AlertType.INFORMATION);
						alert.setTitle("提示");
						alert.setHeaderText(null);
						alert.setContentText("此项目无法更改，请前往课程管理界面修改");
						
						alert.showAndWait();
						System.out.println(twotemp);
						((TeachCourse) t.getTableView().getItems().get(
  	                            t.getTablePosition().getRow())
  	                            ).setCoName(twotemp);
						table.refresh();
						
                    
                    
            });
    	
    	
    	thirdCol.setOnEditCommit(
                (CellEditEvent<TeachCourse, String> t) -> {
                	//System.out.println("Test");
                	String one = firstCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCono();
                	String two = secondCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCoName();
                    //System.out.println(tc.getCoName());
                	String threetemp = thirdCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCoschool();
                	String three = t.getNewValue();
                	String four = fourthCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCograde();
                    TeachDao dao = new TeachDao();
                    List<Teach>is = new ArrayList<Teach>();
                    int idstart = pwdtrans.getSno();
                    System.out.println(t.getNewValue());
                    if(dao.update(idstart, Integer.valueOf(one) , idstart, Integer.valueOf(one), Integer.valueOf(three), Integer.valueOf(four))) {
                    	
                    	Alert alert = new Alert(Alert.AlertType.INFORMATION);
						alert.setTitle("提示");
						alert.setHeaderText(null);
						alert.setContentText("修改成功");
						alert.showAndWait();
                    }
                    else {
                    	((TeachCourse) t.getTableView().getItems().get(
  	                            t.getTablePosition().getRow())
  	                            ).setCoName(threetemp);
						table.refresh();
                    }
                    
            });
    	
    	
    	fourthCol.setOnEditCommit(
                (CellEditEvent<TeachCourse, String> t) -> {
                	
                	String one = firstCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCono();
                	String two = secondCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCoName();
                    //System.out.println(tc.getCoName());
                	String three = thirdCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCoschool();
                	String fourtemp = fourthCol.getTableView().getItems().get(
                            t.getTablePosition().getRow()).getCograde();
                	String four = t.getNewValue();
                    TeachDao dao = new TeachDao();
                    List<Teach>is = new ArrayList<Teach>();
                    int idstart = pwdtrans.getSno();
                    System.out.println(t.getNewValue());
                    if(dao.update(idstart, Integer.valueOf(one) , idstart, Integer.valueOf(one), Integer.valueOf(three), Integer.valueOf(four))) {
                    	
                    	Alert alert = new Alert(Alert.AlertType.INFORMATION);
						alert.setTitle("提示");
						alert.setHeaderText(null);
						alert.setContentText("修改成功");
						alert.showAndWait();
                    }
                    else {
                    	((TeachCourse) t.getTableView().getItems().get(
  	                            t.getTablePosition().getRow())
  	                            ).setCoName(fourtemp);
						table.refresh();
                    }
                    
            });
    	TeachDao dao = new TeachDao();
    	List<TeachforUI> is = new ArrayList<TeachforUI>();
    	
    	is = dao.list3forUI(idstart);
    	for(TeachforUI t:is) {
    		System.out.printf("\n%d\t%s\t%d\t%d\n", t.Cno,t.Cname,t.Tschool,t.Tsgrade);
    		
    		data.add(new TeachCourse(String.valueOf(t.Cno),t.Cname,String.valueOf(t.Tschool),String.valueOf(t.Tsgrade)));
    		//data.add(new TeachCourse("Jacob", "Smith", "<EMAIL>", "Test"));

    		System.out.println();
    	}
    	
    		table.setItems(data);

    	return table;
    }
public void SeletedTabPane(String item) {
    	
//    	TableView table = new TableView();
//    	
//    	table.setEditable(true);
//    	TableColumn firstCol = new TableColumn("课程号");
//    	TableColumn secondCol = new TableColumn("课程名");
//    	TableColumn thirdCol = new TableColumn("所需学时");
//    	TableColumn fourthCol = new TableColumn("学分");
//    	firstCol.setPrefWidth(170);
//    	secondCol.setPrefWidth(270);
//    	thirdCol.setPrefWidth(120);
//    	fourthCol.setPrefWidth(120);
//    	table.getColumns().addAll(firstCol,secondCol,thirdCol,fourthCol);
    	
    	TeachDao dao = new TeachDao();
    	List<TeachforUI> is = new ArrayList<TeachforUI>();
    	
    	
    	int idstart = 0;
    	for(int i=0;i<item.length();i++) {
    		if(Character.isDigit(item.charAt(i))) {
    			idstart=Integer.parseInt(item.substring(i));
    			//System.out.println(item.substring(i));
    		}
    	}
    	is = dao.list3forUI(idstart);
    	for(TeachforUI t:is) {
    		System.out.printf("\n%d\t%s\t%d\t%d\n", t.Cno,t.Cname,t.Tschool,t.Tsgrade);
    		data.add(new TeachCourse(String.valueOf(t.Cno),t.Cname,String.valueOf(t.Tschool),String.valueOf(t.Tsgrade)));
    	}
    	
    }

    public HBox addHBox(){
    	HBox hbox = new HBox();
    	hbox.setAlignment(Pos.CENTER);
    	hbox.setPadding(new Insets(15, 12, 15, 12)); //节点到边缘的距离
        hbox.setSpacing(10);//节点之间的间距
    	hbox.setStyle("-fx-background-color: #336699"); //背景色
        
        Button buttonCurrent = new Button("刷新数据");
        buttonCurrent.setPrefSize(100, 20);

        Button buttonAdd = new Button("新增课程(当前选择)");
        TextField Cno = new TextField();
        TextField Cname = new TextField();
        TextField Tschool = new TextField();
        TextField Tsgrade = new TextField();
        Cno.setPromptText("课程号");
        Cname.setPromptText("课程名");
        Tschool.setPromptText("所需学时");
        Tsgrade.setPromptText("学分");
        //buttonAdd.setPrefSize(100, 20);
        buttonAdd.setOnAction((ActionEvent e) -> {
//        	data.add(new TeachforUI(
//        			Integer.parseInt(Cno.getText()),
//                	Cname.getText().toString(),
//                	Integer.parseInt(Tschool.getText()),
//                	Integer.parseInt(Tsgrade.getText())
//                	));
        	TeachDao dao = new TeachDao();
        	if(tabPane.getTabs().isEmpty()) {
				Alert alert1 = new Alert(Alert.AlertType.ERROR);
				alert1.setTitle("错误");
				alert1.setHeaderText(null);
				alert1.setContentText("添加失败！当前无打开的面板。");
				alert1.showAndWait();
			}
        	else {
        		if(dao.add(idstart, Integer.valueOf(Cno.getText()), Integer.valueOf(Tschool.getText()), Integer.valueOf(Tsgrade.getText()))) {
                	data.add(new TeachCourse(String.valueOf(Cno.getText()),Cname.getText().toString(),Tschool.getText(),Tsgrade.getText()));

            		Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    				alert.setTitle("提示");
    				alert.setHeaderText(null);
    				alert.setContentText("添加成功");
    				alert.showAndWait();
    				Cno.clear();
    				Cname.clear();
    				Tschool.clear();
    				Tsgrade.clear();
            	}
            	else {
            		Alert alert = new Alert(Alert.AlertType.ERROR);
    				alert.setTitle("错误");
    				alert.setHeaderText(null);
    				alert.setContentText("添加失败！请检查课程号与课程名是否对应！");
    				alert.showAndWait();
    				
            	}
        	}
        	
        });
        hbox.getChildren().addAll(buttonCurrent, buttonAdd,Cno ,Cname, Tschool, Tsgrade);
        buttonCurrent.setOnAction((ActionEvent e) -> {
        	initList();
            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("提示");
            alert.setHeaderText(null);
            alert.setContentText("读取成功");
            alert.showAndWait();
        });
        return hbox;
    }
    private void onFileListDbclicked() throws Exception
	{
    	TeacherDao dao= new TeacherDao();
	    List<Teacher> is =new ArrayList<Teacher>();
	    int id=0;
		int index = fileList.getSelectionModel().getSelectedIndex();
		String name_id = fileList.getSelectionModel().getSelectedItem().toString();
		for(int i=0;i<name_id.length();i++) {
    		if(Character.isDigit(name_id.charAt(i))) {
    			id=Integer.parseInt(name_id.substring(i));
    			//System.out.println(item.substring(i));
    		}
    	}
		//FileItem item = fileList.data().get(index);
		
		is =dao.list3();
		
		for (Teacher b : is) {
        	//System.out.printf("%s\t%s\t%s\t%d\t%s\t%d\t%s\t%s\n",b.Pcname,b.Pname,b.Sname,b.Sno,b.Sex,b.Sage,b.Sbirthtime,b.Snative);	           
    	  //System.out.printf("%d\t%s\t%s\t%d\t%s\t%s\n",b.Sno,b.Sname,b.Sex,b.Sage,b.Snative,b.Spassword);
    	  System.out.println();
    	  //String item = String.valueOf(b.Sname);
    	  String item = b.Tname + "    " + b.Tno;
    	  Tab tab = null;
    	  tab = findTab(item);
    	  if(tab!=null) {
    		  tabPane.getTabs().remove(tab);
    	  }
    	  
    	  System.out.print(b);
    	  if(id==b.Tno) {
    		  
        	  openFile(item);
    	  }
    	  
        }
		
		
	}
    private void openFile1(String item) throws Exception
	{
		// 查看选项卡是否已经打开
		Tab tab = findTab ( item );
		if( tab != null)
		{
			int tabIndex = tabPane.getTabs().indexOf(tab);
			tabPane.getSelectionModel().select(tabIndex);
			SeletedTabPane(item);
		}
	}
	// 打开文件
	private void openFile(String item) throws Exception
	{
		// 查看选项卡是否已经打开
		Tab tab = findTab ( item );
		if( tab != null)
		{
			int tabIndex = tabPane.getTabs().indexOf(tab);
			tabPane.getSelectionModel().select(tabIndex);	
			return;
		}

		
		// 打开一个新选项卡
		Node contentView = null;		
		if(true) // text file
		{
			// 注意: 这里演示的文件是GBK的
			//GridPane grid = addGridPane();
			TableView table = addTableView();
			//String text = TextFileUtils.read(item.file, "GBK");
			//TextArea t = new TextArea();
			//t.setText( text );
			contentView = table;
		}
		
		// 添加一个TAB页
		tab = new Tab();
		tab.setText( item );
		
		tab.setContent(contentView);
		tabPane.getTabs().add(tab);		
		int tabIndex = tabPane.getTabs().indexOf(tab);
		tabPane.getSelectionModel().select(tabIndex);
	}
	
	// 查找选项卡是否已经打开
	private Tab findTab (String item)
	{
		ObservableList<Tab> tabs = tabPane.getTabs();
		for(int i=0; i< tabs.size(); i++)
		{
			Tab t = tabs.get(i);
			if( t.getText().equals(item))
			{
				return t;
			}
		}
		return null;
	}

	private void closeFile(String item) throws Exception
	{
		// 查看选项卡是否已经打开
		Tab tab = findTab ( item );
		if( tab != null)
		{
			if(item.equals("新建教师")) {
				int tabIndex = tabPane.getTabs().indexOf(tab);
				tabPane.getTabs().remove(tabIndex);
				
			}
			else {
				int tabIndex = tabPane.getTabs().indexOf(tab);
				for(int i=0;i<tabIndex;i++) {
					tabPane.getSelectionModel().select(tabIndex);
					tabPane.getTabs().remove(tabIndex);
					
					
				}
				
				
			}
			return;
		}
	}
}
<file_sep>/src/student/SXController.java
package student;

import java.util.ArrayList;
import java.util.List;

import attendance.bean.Course;
import attendance.bean.SC;
import attendance.dao.CourseDao;
import attendance.dao.SCDao;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.*;

public class SXController {
	//@FXML private Button commitbutton;
	@FXML private ComboBox select;
	@FXML
	protected void Confirm(ActionEvent event) {
		SCDao dao = new SCDao();
		CourseDao cdao = new CourseDao();
		List<Course> is = new ArrayList<Course>();
		is = cdao.list3(select.getValue().toString());
		if(dao.add(StudIdentityTrans.getCno(), is.get(0).Cno)) {
			Alert alert = new Alert(Alert.AlertType.INFORMATION);
			alert.setTitle("提示");
			alert.setHeaderText(null);
			alert.setContentText("选课成功！");
			select.getItems().clear();
			InitUI();
			alert.showAndWait();
		}
		else {
			Alert alert = new Alert(Alert.AlertType.ERROR);
			alert.setTitle("提示");
			alert.setHeaderText(null);
			alert.setContentText("未选择课程！");
			
			alert.showAndWait();
		}
	}
	public void InitUI() {
		SCDao dao = new SCDao();
		List<Course> is = new ArrayList<Course>();
		is = dao.listweixuan(StudIdentityTrans.getCno());
		for(Course c:is) {
			System.out.println(c.Cname);
			select.getItems().add(c.Cname);
		}
	}
}
<file_sep>/src/admin/banjiinfoUI/XueyuanInfoUI.java
package admin.banjiinfoUI;

import java.io.IOException;

import admin.studentUI.pwdtrans;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;

public class XueyuanInfoUI {
	public void start(Stage stage) throws IOException {
		FXMLLoader loader = new FXMLLoader(getClass().getResource("XueyuanInfoUI.fxml"));
        Parent root =loader.load();
        XIController Controller = loader.getController();
        Scene scene = new Scene(root, 573, 400);
        stage.setScene(scene);
        stage.setTitle("学院信息管理");
        stage.setOnHiding(new EventHandler<WindowEvent>() {
            @Override
            public void handle(WindowEvent event) {
                System.out.println("监听到窗口关闭1");
//                FXMLLoader loader1 = new FXMLLoader(ClassInfoUI.class.getResource("ClassInfoUI.fxml"));
//                CIController Controller1 = loader1.getController();
//                Controller1.ReloadCombo();
                
                
            }
        });
        stage.show();
        Controller.InitUI();
    }
}
<file_sep>/src/teacher/TTController.java
package teacher;

import java.time.format.DateTimeFormatter;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

import admin.studentUI.pwdtrans;
import admin.teachinfoUI.TeachInfoUI.TeachCourse;
import attendance.bean.AC;
import attendance.bean.Course;
import attendance.bean.PC;
import attendance.bean.Qimo;
import attendance.bean.SC;
import attendance.bean.Student;
import attendance.bean.Teach;
import attendance.bean.TeachforUI;
import attendance.bean.Xueqi;
import attendance.dao.ACDao;
import attendance.dao.CourseDao;
import attendance.dao.PCDao;
import attendance.dao.QimoDao;
import attendance.dao.SCDao;
import attendance.dao.StudentDao;
import attendance.dao.TeachDao;
import attendance.dao.XueqiDao;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.TableColumn.CellEditEvent;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.util.Callback;
import javafx.util.StringConverter;
import teacher.TRController.TeachRoutine;

public class TTController {
	@FXML private ComboBox xueqicombo;
	@FXML private ComboBox namecombo;
	@FXML private ComboBox classcombo;
	@FXML private ComboBox coursenamecombo;
	@FXML private Button addbutton;
	@FXML private Button loadbutton;
	@FXML private Button addallbutton;
	@FXML private TableView table;
	@FXML private TableColumn classname;
	@FXML private TableColumn id;
	@FXML private TableColumn name;
	@FXML private TableColumn term;
	@FXML private TableColumn courseid;
	@FXML private TableColumn coursename;
	@FXML private TableColumn Qan;
	@FXML private TableColumn Qaln;
	@FXML private TableColumn Qtn;
	@FXML private TableColumn Qlen;
	@FXML private TableColumn Qlate;
	final ObservableList<TeachTotal> data = FXCollections.observableArrayList();
	int count1 = 0;
	String[][] storage = null;
    int i = 0;
    public static class TeachTotal {

        private final SimpleStringProperty classname;
        private final SimpleStringProperty id;
        private final SimpleStringProperty name;
        private final SimpleStringProperty xueqi;
        private final SimpleStringProperty courseid;
        private final SimpleStringProperty coursename;
        private final SimpleStringProperty Qan;
        private final SimpleStringProperty Qaln;
        private final SimpleStringProperty Qtn;
        private final SimpleStringProperty Qlen;
        private final SimpleStringProperty Qlate;

        private TeachTotal(String classname1, String id1, String name1, String xueqi1, String courseid1, String coursename1, String Qan1, String Qaln1, String Qtn1, String Qlen1, String Qlate1) {
            this.classname = new SimpleStringProperty(classname1);
            this.id = new SimpleStringProperty(id1);
            this.name = new SimpleStringProperty(name1);
            this.xueqi = new SimpleStringProperty(xueqi1);
            this.courseid = new SimpleStringProperty(courseid1);
            this.coursename = new SimpleStringProperty(coursename1);
            this.Qan = new SimpleStringProperty(Qan1);
            this.Qaln = new SimpleStringProperty(Qaln1);
            this.Qtn = new SimpleStringProperty(Qtn1);
            this.Qlen = new SimpleStringProperty(Qlen1);
            this.Qlate = new SimpleStringProperty(Qlate1);
        }
        
		public String getClassname() {
			return classname.get();
		}
		
		public void setclassname(String classname1) {
			classname.set(classname1);
        }
		
		public String getId() {
			return id.get();
		}

		public void setid(String id1) {
			id.set(id1);
        }
		
		public String getName() {
			return name.get();
		}

		public void setname(String xueqi1) {
			xueqi.set(xueqi1);
        }
		
		public String getXueqi() {
			return xueqi.get();
		}

		public void setxueqi(String name1) {
			name.set(name1);
        }
		
		public String getCourseid() {
			return courseid.get();
		}

		public void setcourseid(String courseid1) {
			courseid.set(courseid1);
        }
		
		public String getCoursename() {
			return coursename.get();
		}

		public void setcoursename(String coursename1) {
			coursename.set(coursename1);
        }
		
		public String getQan() {
			return Qan.get();
		}

		public void setQan(String Qan1) {
			Qan.set(Qan1);
        }
		
		public String getQaln() {
			return Qaln.get();
		}

		public void setQaln(String Qaln1) {
			Qaln.set(Qaln1);
        }
		
		public String getQtn() {
			return Qtn.get();
		}

		public void setQtn(String Qtn1) {
			Qtn.set(Qtn1);
        }
		
		public String getQlen() {
			return Qlen.get();
		}

		public void setQlen(String Qlen1) {
			Qlen.set(Qlen1);
        }
		
		public String getQlate() {
			return Qlate.get();
		}
		
		public void setQlate(String Qlate1) {
			Qlate.set(Qlate1);
        }
    }
    @FXML
    protected void Load(ActionEvent event) throws ParseException {
    	table.getItems().clear();
    	int max = 0;
    	QimoDao dao = new QimoDao();
		
		List<Qimo> is = new ArrayList<Qimo>();
		int index = xueqicombo.getSelectionModel().getSelectedIndex();
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    	java.util.Date startd = format.parse(storage[index][0]);
    	java.util.Date endd = format.parse(storage[index][1]);
    	java.sql.Date startd1 = new java.sql.Date(startd.getTime());
    	java.sql.Date endd1 = new java.sql.Date(endd.getTime());
		is = dao.list7(startd1,endd1,TeachIdentity.getTno());
		
		for(Qimo q:is) {
			data.add(new TeachTotal(q.Pname, String.valueOf(q.Sno), q.Sname, q.Qstartdate.toString()+" ~ "+q.Qenddate.toString(), String.valueOf(q.Cno), q.Cname, String.valueOf(q.Qan), String.valueOf(q.Qaln), String.valueOf(q.Qtn), String.valueOf(q.Qlen), String.valueOf(q.Qlate)));
			max++;
		}
		table.setItems(data);
		table.refresh();
    }
    @FXML
    protected void AddAll(ActionEvent event) {
        
        try {
        	xueqicombo.getSelectionModel().getSelectedIndex();
        	coursenamecombo.getValue().toString();
        	StudentDao dao1 = new StudentDao();
            List<Student> is1 = new ArrayList<Student>();
            is1 = dao1.list2(classcombo.getValue().toString());
            for(Student s:is1) {
            	String longname = s.Sname + "    " + s.Sno;
            	SaveData(longname);
            }
        }catch(Exception e) {
        	Alert alert = new Alert(Alert.AlertType.ERROR);
			
			alert.setTitle("提示");
			alert.setHeaderText(null);
			alert.setContentText("请选择所要添加的班级/学期/课程");
			
			alert.showAndWait();
        }
    }
	@FXML
    protected void Add(ActionEvent event) {
        try {
        	SaveData(namecombo.getValue().toString());
        }catch(Exception e) {
        	Alert alert = new Alert(Alert.AlertType.ERROR);
			
			alert.setTitle("提示");
			alert.setHeaderText(null);
			alert.setContentText("请选择所要添加的班级/学期/课程/学生");
			
			alert.showAndWait();
        }
		
    }
	public void SaveData(String item) {
		try{
        	int num = xueqicombo.getSelectionModel().getSelectedIndex();
        	
        	String start = storage[num][0];
        	String end = storage[num][1];
        	int idstart = 0;
        	int Cno = 0;
        	//String item = namecombo.getValue().toString();
        	for(int i=0;i<item.length();i++) {
	    		if(Character.isDigit(item.charAt(i))) {
	    			idstart=Integer.parseInt(item.substring(i));
	    			//System.out.println(item.substring(i));
	    		}
	    	}
        	String kcname = coursenamecombo.getValue().toString();
        	CourseDao dao = new CourseDao();
        	List<Course> is = new ArrayList<Course>();
        	is = dao.list2();
        	for(Course c:is) {
        		if(c.Cname.equals(kcname)) {
        			Cno=c.Cno;
        		}
        	}
        	SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        	java.util.Date startd = format.parse(start);
        	java.util.Date endd = format.parse(end);
        	java.sql.Date startd1 = new java.sql.Date(startd.getTime());
        	java.sql.Date endd1 = new java.sql.Date(endd.getTime());
        	QimoDao qimodao = new QimoDao();
        	System.out.println(idstart);
        	System.out.println(Cno);
        	System.out.println(startd1);
        	System.out.println(endd1);
        	qimodao.add(idstart, Cno, startd1, endd1);
        }catch(Exception e) {
        	e.printStackTrace();
        	Alert alert = new Alert(Alert.AlertType.ERROR);
			
			alert.setTitle("提示");
			alert.setHeaderText(null);
			alert.setContentText("已添加该学生考勤！无法重复添加！");
			
			alert.showAndWait();
        }
	}
	public void InitUI() {
		InitComboBox();
		InitNameComboBox();
		classcombo.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
        	@Override
        	public void changed(ObservableValue observable, Object oldValue, Object newValue) {
        		StudentDao stdao= new StudentDao();
        	    List<Student> stis =new ArrayList<Student>();
        	    stis=stdao.list3();
        		namecombo.getItems().clear();
       		
        		stis=stdao.list2(classcombo.getValue().toString());
       		
        		for(Student s:stis) {
        			String longname = s.Sname + "    " + s.Sno;
        			namecombo.getItems().addAll(longname);
        			//System.out.println(count);
        			
          	    }
        	}
        });
		classname.setCellValueFactory(
                new PropertyValueFactory<>("classname"));
    	classname.setCellFactory(TextFieldTableCell.<TeachTotal>forTableColumn());
    	
    	id.setCellValueFactory(
                new PropertyValueFactory<>("id"));
    	id.setCellFactory(TextFieldTableCell.<TeachTotal>forTableColumn());
    	
    	name.setCellValueFactory(
                new PropertyValueFactory<>("name"));
    	name.setCellFactory(TextFieldTableCell.<TeachTotal>forTableColumn());
    	
    	term.setCellValueFactory(
                new PropertyValueFactory<>("xueqi"));
    	term.setCellFactory(TextFieldTableCell.<TeachTotal>forTableColumn());
    	
    	courseid.setCellValueFactory(
                new PropertyValueFactory<>("courseid"));
    	courseid.setCellFactory(TextFieldTableCell.<TeachTotal>forTableColumn());
    	
    	coursename.setCellValueFactory(
                new PropertyValueFactory<>("coursename"));
    	coursename.setCellFactory(TextFieldTableCell.<TeachTotal>forTableColumn());
    	
    	Qan.setCellValueFactory(
                new PropertyValueFactory<>("Qan"));
    	Qan.setCellFactory(TextFieldTableCell.<TeachTotal>forTableColumn());
    	
    	Qaln.setCellValueFactory(
                new PropertyValueFactory<>("Qaln"));
    	Qaln.setCellFactory(TextFieldTableCell.<TeachTotal>forTableColumn());
    	
    	Qtn.setCellValueFactory(
                new PropertyValueFactory<>("Qtn"));
    	Qtn.setCellFactory(TextFieldTableCell.<TeachTotal>forTableColumn());
    	
    	Qlen.setCellValueFactory(
                new PropertyValueFactory<>("Qlen"));
    	Qlen.setCellFactory(TextFieldTableCell.<TeachTotal>forTableColumn());
    	
    	Qlate.setCellValueFactory(
                new PropertyValueFactory<>("Qlate"));
    	Qlate.setCellFactory(TextFieldTableCell.<TeachTotal>forTableColumn());
    	classname.setStyle("-fx-alignment: CENTER;");
    	id.setStyle("-fx-alignment: CENTER;");
    	name.setStyle("-fx-alignment: CENTER;");
    	term.setStyle("-fx-alignment: CENTER;");
    	courseid.setStyle("-fx-alignment: CENTER;");
    	coursename.setStyle("-fx-alignment: CENTER;");
    	Qan.setStyle("-fx-alignment: CENTER;");
    	Qaln.setStyle("-fx-alignment: CENTER;");
    	Qtn.setStyle("-fx-alignment: CENTER;");
    	Qlen.setStyle("-fx-alignment: CENTER;");
    	Qlate.setStyle("-fx-alignment: CENTER;");
    	LoadTableView();
	}
	public void LoadTableView() {
		int max = 0;
		QimoDao dao = new QimoDao();
		
		List<Qimo> is = new ArrayList<Qimo>();
		is = dao.list6(TeachIdentity.getTno());
		
		for(Qimo q:is) {
			data.add(new TeachTotal(q.Pname, String.valueOf(q.Sno), q.Sname, q.Qstartdate.toString()+" ~ "+q.Qenddate.toString(), String.valueOf(q.Cno), q.Cname, String.valueOf(q.Qan), String.valueOf(q.Qaln), String.valueOf(q.Qtn), String.valueOf(q.Qlen), String.valueOf(q.Qlate)));
			max++;
		}
		table.setItems(data);
		table.refresh();
	}
	public void InitComboBox() {
		XueqiDao xueqi = new XueqiDao();
        List<Xueqi> is = new ArrayList<Xueqi>();
        is = xueqi.getList();
        xueqicombo.getItems().clear();
        for(Xueqi x:is) {
        	count1++;
        }
        storage = new String[count1][2];
        for(Xueqi x:is) {
        	int start = 0;
        	int end = 0;
        	String s = new SimpleDateFormat("yyyy").format(x.startdate);
        	String e = new SimpleDateFormat("yyyy").format(x.enddate);
        	start = Integer.valueOf(s);
        	end = Integer.valueOf(e);
        	if(start==end) {
        		start = start - 1;
        	}
        	else if((start+1)==end) {
        		
        	}
        	String count = null;
        	if(x.Xueqi==1) {
        		count = "一";
        	}
        	else if(x.Xueqi==2) {
        		count = "二";
        	}
        	String all = start + " - " + end + "学年" + "第" + count + "学期" + " ( " + x.startdate + " ~ " + x.enddate + " ) ";
        	xueqicombo.getItems().addAll(all);
        	storage[i][0]=x.startdate.toString();
        	storage[i][1]=x.enddate.toString();
        	i++;
        }
        for(i=0;i<count1;i++) {
        	System.out.println(storage[i][0]);
        	System.out.println(storage[i][1]);
        }
        TeachDao tdao = new TeachDao();
	    List<TeachforUI> tis =new ArrayList<TeachforUI>();
	    tis = tdao.list3forUI(TeachIdentity.getTno());
	    for(TeachforUI t:tis) {
    		System.out.println(t.Cno);
        	coursenamecombo.getItems().addAll(t.Cname);
    	}
	}
	public void InitNameComboBox() {
		classcombo.getItems().clear();
		PCDao pcdao= new PCDao();
	    List<PC> pcis =new ArrayList<PC>();
	    pcis=pcdao.list2();
	    for(PC c:pcis) {
	    	System.out.println(c.Pname);
  	      	classcombo.getItems().addAll(c.Pname);
	    	//classcombo.getItems().addAll(pcis);
  	    }

	}
}
<file_sep>/src/student/StudQingjia.java
package student;

import java.io.IOException;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class StudQingjia {
	public void start(Stage stage) throws IOException {
        stage.setTitle("主界面");
        
      //Parent root = FXMLLoader.load(getClass().getResource("TeachChooseUI.fxml"));
        FXMLLoader loader = new FXMLLoader(getClass().getResource("StudQingjia.fxml"));
        Parent root =loader.load();
        SQController Controller = loader.getController();
        Scene scene = new Scene(root, 832, 558);
        stage.setScene(scene);
        stage.show();
        //Controller.getno();
        Controller.InitUI();
    }
}
<file_sep>/src/student/StudXuanke.java
package student;

import java.io.IOException;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import teacher.TCController;

public class StudXuanke {
	public void start(Stage stage) throws IOException {
        stage.setTitle("主界面");
        
      //Parent root = FXMLLoader.load(getClass().getResource("TeachChooseUI.fxml"));
        FXMLLoader loader = new FXMLLoader(getClass().getResource("StudXuanke.fxml"));
        Parent root =loader.load();
        SXController Controller = loader.getController();
        Scene scene = new Scene(root, 336, 343);
        stage.setScene(scene);
        stage.show();
        //Controller.getno();
        Controller.InitUI();
    }
}
<file_sep>/src/teacher/TeachTotalUI.java
package teacher;

import java.io.IOException;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class TeachTotalUI {
	public void start(Stage stage) throws IOException {
        stage.setTitle("主界面");
        
      //Parent root = FXMLLoader.load(getClass().getResource("TeachChooseUI.fxml"));
        FXMLLoader loader = new FXMLLoader(getClass().getResource("TeachTotalUI.fxml"));
        Parent root =loader.load();
        TTController Controller = loader.getController();
        Scene scene = new Scene(root, 1424, 727);
        stage.setScene(scene);
        stage.show();
        Controller.InitUI();
    }
}
<file_sep>/src/attendance/bean/PC.java
package attendance.bean;

public class PC {
public int Pno;//班级号
public String Pname;//班级名
public int Pnum;//班级总人数
public String Pcname;//系名
public int getPno() {
	return Pno;
}
public void setPno(int pno) {
	this.Pno = pno;
}
public String getPname() {
	return Pname;
}
public void setPname(String pname) {
	this.Pname = pname;
}
public int getPnum() {
	return Pnum;
}
public void setPnum(int pnum) {
	this.Pnum = pnum;
}
public String getPcname() {
	return Pcname;
}
public void setPcname(String pcname) {
	this.Pcname = pcname;
}
public PC() {
	super();
	// TODO Auto-generated constructor stub
}
public PC(int pno, String pname, int pnum, String pcname) {
	super();
	this.Pno = pno;
	this.Pname = pname;
	this.Pnum = pnum;
	this.Pcname = pcname;
}
@Override
public String toString() {
	return "PC [Pno=" + Pno + ", Pname=" + Pname + ", Pnum=" + Pnum + ", Pcname=" + Pcname + "]";
}

}
<file_sep>/src/attendance/bean/Teacher.java
package attendance.bean;

public class Teacher {	
public int Tno;//职工号
public String Tname;//姓名
public String  Tsex;//性别
public int Tage;//教龄
public String Tphone ;//电话
public String Tcname;//系名
public String Tbirthtime;//出生日期
public String Tpassword;//密码
public int getTno() {
	return Tno;
}
public void setTno(int tno) {
	this.Tno = tno;
}
public String getTname() {
	return Tname;
}
public void setTname(String tname) {
	this.Tname = tname;
}
public String getTsex() {
	return Tsex;
}
public void setTsex(String tsex) {
	this.Tsex = tsex;
}
public int getTage() {
	return Tage;
}
public void setTage(short tage) {
	this.Tage = tage;
}
public String getTphone() {
	return Tphone;
}
public void setTphone(String tphone) {
	this.Tphone = tphone;
}
public String getTcname() {
	return Tcname;
}
public void setTcname(String tcname) {
	this.Tcname = tcname;
}
public String getTbirthtime() {
	return Tbirthtime;
}
public void setTbirthtime(String tbirthtime) {
	Tbirthtime = tbirthtime;
}
public String getTpassword() {
	return Tpassword;
}
public void setTpassword(String tpassword) {
	this.Tpassword = tpassword;
}
public Teacher() {
	super();
	// TODO Auto-generated constructor stub
}
public Teacher(int tno, String tname, String tsex, int tage, String tphone, String tcname,String Tpassword, String tpassword) {
	super();
	this.Tno = tno;
	this.Tname = tname;
	this.Tsex = tsex;
	this.Tage = tage;
	this.Tphone = tphone;
	this.Tcname = tcname;
	this.Tpassword=<PASSWORD>;
	this.Tpassword = <PASSWORD>;
}
@Override
public String toString() {
	return "Teacher [Tno=" + Tno + ", Tname=" + Tname + ", Tsex=" + Tsex + ", Tage=" + Tage + ", Tphone=" + Tphone
			+ ", Tcname=" + Tcname + ", Tbirthtime=" + Tbirthtime + ", Tpassword=" + Tpassword + "]";
}




}
<file_sep>/src/admin/studentUI/AfImagePane.java
package admin.studentUI;

import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;

/*
 * 用于显示图片的工具类
 * 
 */

public class AfImagePane extends Pane
{
	ImageView imageView = new ImageView();
	Image image;
	
	public AfImagePane()
	{
		getChildren().add(imageView);
	}
	
	public void showImage(Image image)
	{
		this.image = image;
		imageView.setImage(image);
		layout();
	}

	@Override
	protected void layoutChildren()
	{
		double w = getWidth();
		double h = getHeight();
		
		// 对ImageView进行摆放，使其适应父窗口
		imageView.resizeRelocate(0, 0, w, h);
		imageView.setFitWidth(w);
		imageView.setFitHeight(h);
		imageView.setPreserveRatio(true);	
	}
	
	
}
<file_sep>/src/attendance/bean/Qimo.java
package attendance.bean;

import java.sql.Date;

//期末考勤总记录,给老师用的
//这里的属性系名，班级，姓名，课程名并不是真正的期末考勤表里的属性，而是从期末视图查询出来，插入的是并没有插入期末表
public class Qimo {
public String Pcname;//系名	
public String Pname;//班级
public int Sno;//学号
public String Sname;//姓名
public int Cno;//课程号
public String Cname;//课程名
public Date Qstartdate;//开始学年
public Date Qenddate;//结束学年
public int Qan;//出勤次数
public int Qaln;//请假次数
public int Qtn;//旷课次数
public int Qlen;//早退次数
public int Qlate;//迟到次数
public int getQlate() {
	return Qlate;
}
public void setQlate(int qlate) {
	this.Qlate = qlate;
}

public String getPcname() {
	return Pcname;
}
public void setPcname(String pcname) {
	this.Pcname = pcname;
}
public String getPname() {
	return Pname;
}
public void setPname(String pname) {
	this.Pname = pname;
}
public int getSno() {
	return Sno;
}
public void setSno(int sno) {
	this.Sno = sno;
}
public String getSname() {
	return Sname;
}
public void setSname(String sname) {
	this.Sname = sname;
}
public int getCno() {
	return Cno;
}
public void setCno(int cno) {
	this.Cno = cno;
}
public String getCname() {
	return Cname;
}
public void setCname(String cname) {
	this.Cname = cname;
}

public java.sql.Date getQstartdate() {
	return Qstartdate;
}
public void setQstartdate(Date qstartdate) {
	this.Qstartdate = qstartdate;
}
public Date getQenddate() {
	return Qenddate;
}
public void setQenddate(Date qenddate) {
	this.Qenddate = qenddate;
}
public int getQan() {
	return Qan;
}
public void setQan(int qan) {
	this.Qan = qan;
}
public int getQaln() {
	return Qaln;
}
public void setQaln(int qaln) {
	this.Qaln = qaln;
}
public int getQtn() {
	return Qtn;
}
public void setQtn(int qtn) {
	this.Qtn = qtn;
}
public int getQlen() {
	return Qlen;
}
public void setQlen(int qlen) {
	this.Qlen = qlen;
}
public Qimo() {
	super();
	// TODO Auto-generated constructor stub
}
public Qimo(String pcname, String pname, int sno, String sname, int cno, String cname, Date qstartdate, Date qenddate,
		int qan, int qaln, int qtn, int qlen, int qlate) {
	super();
	this.Pcname = pcname;
	this.Pname = pname;
	this.Sno = sno;
	this.Sname = sname;
	this.Cno = cno;
	this.Cname = cname;
	this.Qstartdate = qstartdate;
	this.Qenddate = qenddate;
	this.Qan = qan;
	this.Qaln = qaln;
	this.Qtn = qtn;
	this.Qlen = qlen;
	this.Qlate = qlate;
	
}
@Override
public String toString() {
	return "Qimo [Pcname=" + Pcname + ", Pname=" + Pname + ", Sno=" + Sno + ", Sname=" + Sname + ", Cno=" + Cno
			+ ", Cname=" + Cname + ", Qstartdate=" + Qstartdate + ", Qenddate=" + Qenddate + ", Qan=" + Qan + ", Qaln="
			+ Qaln + ", Qtn=" + Qtn + ", Qlen=" + Qlen + ", Qlate=" + Qlate + "]";
}





}
<file_sep>/src/attendance/test/PCTestDao.java
package attendance.test;
import java.util.ArrayList;
import java.util.List;
import attendance.dao.PCDao;
import attendance.bean.PC;
public class PCTestDao {
	public static void main(String[] args){
		PCDao dao= new PCDao();
	      List<PC> is =new ArrayList<PC>();
	     // dao.add(1,"计算机81",35,"计算机系");//增加测试
	      //int c=dao.getTotal();
	      //System.out.println(c);//getTotal函数测试
	      is =dao.list2();
	      System.out.printf("%s\t%s\t%s\t%s\n","", "班级号","班级名","总人数","系名");
	        for (PC b : is) {
	        	System.out.printf("%d\t%s\t%d\t%s\n",b.Pno,b.Pname,b.Pnum,b.Pcname);	           
	        	System.out.println();
	        }	
	       // dao.delete(3);//删除测试
	      //  dao.update(2, "电信181", 36,"电信系");
	}
}
<file_sep>/src/attendance/dao/AdminDao.java
package attendance.dao;
//管理员DAO
//给管理员用的
import java.sql.*;
import javax.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//import attendance.bean.Academy;
import attendance.bean.Admin;
public class AdminDao {
	public AdminDao(){
		 try {
	            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	          // System.out.println("加载驱动成功！");
	        } catch (ClassNotFoundException e) {
	            e.printStackTrace();
	            System.out.println("加载驱动失败！");
	        }
	}
	public Connection getConnection()throws SQLException{
        //抛出异常
		return DriverManager.getConnection("jdbc:sqlserver://sql.cerny.cn:1433;DatabaseName=attendance", "sa", "Myclassdesign330");
		//数据库的名字叫attendance，我的数据库账户是sa,密码是sa
		//这里我建立连接的时候不是用try-catcth来捕捉异常，而是主动抛出，那么我下面调用这个函数时要么继续抛出，要么用try-catcth捕捉，我选择用try-catcth捕捉，到时候主函数就不用处理了
        }
	public int getTotal() {
		//得到目前表Admin总数有多少条
        int total = 0;
        try (Connection c = getConnection(); Statement s = c.createStatement();) {
          
            String sql = "select count(*) from Admin";
  
            ResultSet rs = s.executeQuery(sql);
            while (rs.next()) {
                total = rs.getInt(1);//	这里getInt是因为rs这个结果集这里是返回的结果行数
            }
            // System.out.println("total:" + total); 
        } catch (SQLException e) {
  
            e.printStackTrace();
        }
        return total;
    }
	public void add(int Ano,String Aname,String Asex,String Azhichen,String Aphone,int Aage,String Acname) {
		//这里增加函数管理号（本来主码可以自增不插，但我这里还是打开自增规则插进去），姓名，性别，职称，电话，工龄,系名,密码（初始为<PASSWORD>）
		//密码在增加函数这里不插，默认，后期再自己改密码
        String sql = "set identity_insert Admin ON insert into Admin(Ano,Aname,Asex,Azhichen,Aphone,Aage,Acname) values(?,?,?,?,?,?,?) set identity_insert Admin OFF";
        try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);) { 
        	ps.setInt(1,Ano);
        	ps.setString(2,Aname);
            ps.setString(3,Asex);
            ps.setString(4,Azhichen); 
            ps.setString(5,Aphone); 
            ps.setInt(6,Aage); 
            ps.setString(7,Acname);            
            ps.execute();  
            //ResultSet rs = ps.getGeneratedKeys();//如果因为主码自增不插，然后通过这里得到主码赋值给对象对应的属性
        } catch (SQLException e) {  
            e.printStackTrace();
        }
    }
	public void update(int Ano,String Aname,String Asex,String Azhichen,String Aphone,int Aage,String Acname,String Apassword) {
		//姓名，性别，职称，电话，工龄,系名,密码（初始为<PASSWORD>）
		//不更新主码，主码一般不允许更新，一般允许更新主码的数据库设计都是不合理的		
         String sql = "update Admin set Aname=?,Asex=? ,Azhichen=?,Aphone=?,Aage=?,Acname=?,Apassword=? where Ano ="+Ano; 
	    	 try (Connection c = getConnection(); PreparedStatement ps = c.prepareStatement(sql);){	    		
	    		 ps.setString(1, Aname);
	    		 ps.setString(2, Asex);
	    		 ps.setString(3, Azhichen);
	    		 ps.setString(4, Aphone);
	    		 ps.setInt(5, Aage);
	    		 ps.setString(6, Acname);
	    		 ps.setString(7, Apassword);	    		 
	    		 ps.execute();
	    	//	 System.out.println("修改成功");	    		 
	    	 }catch (SQLException e1) {
		            e1.printStackTrace();		     
		      }catch (Exception e2) {// 捕获其他异常
		    	  e2.printStackTrace();// 打印异常产生的过程信息
		      }
	    	}
	 public void delete(int Ano) {
		 //删除函数
		 try (Connection c = getConnection(); Statement s = c.createStatement();) {				  
	            String sql = "delete from Admin where Ano= "+Ano;
	            s.execute(sql);	
	            //System.out.println("删除成功");
	      }catch(SQLException e1) {
	            e1.printStackTrace();
	      }catch(Exception e2) {// 捕获其他异常
	    	  e2.printStackTrace();// 打印异常产生的过程信息
	      }
	    }	
	 public List<Admin> list1(int Ano) {
	        List<Admin> admins = new ArrayList<Admin>();
	  //把符合条件的Admin数据查询出来，转换为Admin对象后，放在一个集合中返回
	   //String sql = "select * from hero order by id desc limit ?,? ";		       	         
	        String Aname=null;//姓名
	        String Asex=null;//性别
	        String Azhichen=null;//职称
	        String Aphone=null;//电话
	        int Aage=0;;//年龄
	        String Acname=null;//任职系名
	        String Apassword=null;//登录密码
	        //按即主码查询，单个
	        //System.out.println("请输入要查询的管理员号:");	        	
	        String sql = "select * from Admin where Ano="+Ano;
		    try (Connection c = getConnection(); Statement s = c.createStatement();) {
		        	ResultSet rs = s.executeQuery(sql);
		            while (rs.next()) {
		            	/*定义一个类型为Admin的对象 admin ，在while里查询出来的属性赋值给它，接着把对象该给集合，然后返回集合
		                 * 下面的一样道理*/  
		            	Admin admin=new Admin() ;
		            	Ano= rs.getInt(1);
		            	Aname = rs.getString("Aname");
		            	Asex = rs.getString(3);
		            	Azhichen=rs.getString(4);
		                Aphone=rs.getString(5);
		    	        Aage=rs.getInt(6);
		    	        Acname=rs.getString(7);
		    	        Apassword=rs.getString(8);
		            	admin.Ano=Ano;
		            	admin.Aname=Aname;
		            	admin.Asex=Asex;
		            	admin.Azhichen=Azhichen;
		            	admin.Aphone=Aphone;
		            	admin.Aage=Aage;
		            	admin.Acname=Acname;
		            	admin.Apassword=Apassword;
		            	admins.add(admin);
		            }
		        }catch (SQLException e) {
		            e.printStackTrace();}
		     return admins;//返回系集合，符合条件的系的信息
	    }
    public List<Admin> list2() {
	 //都查询出来
       List<Admin> admins = new ArrayList<Admin>();
       int Ano=0;//职工号
       String Aname=null;//姓名
       String Asex=null;//性别
       String Azhichen=null;//职称
       String Aphone=null;//电话
       int Aage=0;;//年龄
       String Acname=null;//任职系名
       String Apassword=null;//登录密码
       //按即主码查询，单个
       //System.out.println("请输入要查询的管理员号:");	        	
       String sql = "select * from Admin ";
	    try (Connection c = getConnection(); Statement s = c.createStatement();) {
	        	ResultSet rs = s.executeQuery(sql);
	            while (rs.next()) {
	            	Admin admin=new Admin() ;
	            	Ano= rs.getInt(1);
	            	Aname = rs.getString("Aname");
	            	Asex = rs.getString(3);
	            	Azhichen=rs.getString(4);
	                Aphone=rs.getString(5);
	    	        Aage=rs.getInt(6);
	    	        Acname=rs.getString(7);
	    	        Apassword=rs.getString(8);
	            	admin.Ano=Ano;
	            	admin.Aname=Aname;
	            	admin.Asex=Asex;
	            	admin.Azhichen=Azhichen;
	            	admin.Aphone=Aphone;
	            	admin.Aage=Aage;
	            	admin.Acname=Acname;
	            	admin.Apassword=<PASSWORD>;
	            	admins.add(admin);
	            }
	        }catch (SQLException e) {
	            e.printStackTrace();}
	  return admins;//返回系集合，里面都是各个系的信息
	        }	
    public List<Admin> list3(int Ano, String Apassword) {
        List<Admin> admins = new ArrayList<Admin>();
  //把符合条件的Admin数据查询出来，转换为Admin对象后，放在一个集合中返回
        //用于登录
   //String sql = "select * from hero order by id desc limit ?,? ";                   
        String Aname=null;//姓名
        String Asex=null;//性别
        String Azhichen=null;//职称
        String Aphone=null;//电话
        int Aage=0;;//年龄
        String Acname=null;//任职系名
       
        //按即主码查询，单个
        //System.out.println("请输入要查询的管理员号:");          
        String sql = "select * from Admin where Ano="+Ano+" and "+"Apassword="+"'"+Apassword+"'";
     try (Connection c = getConnection(); Statement s = c.createStatement();) {
          ResultSet rs = s.executeQuery(sql);
             while (rs.next()) {
              /*定义一个类型为Admin的对象 admin ，在while里查询出来的属性赋值给它，接着把对象该给集合，然后返回集合
                  * 下面的一样道理*/  
              Admin admin=new Admin() ;
              Ano= rs.getInt(1);
              Aname = rs.getString("Aname");
              Asex = rs.getString(3);
              Azhichen=rs.getString(4);
                 Aphone=rs.getString(5);
              Aage=rs.getInt(6);
              Acname=rs.getString(7);
              Apassword=rs.getString(8);
              admin.Ano=Ano;
              admin.Aname=Aname;
              admin.Asex=Asex;
              admin.Azhichen=Azhichen;
              admin.Aphone=Aphone;
              admin.Aage=Aage;
              admin.Acname=Acname;
              admin.Apassword=Apassword;
              admins.add(admin);
             }
         }catch (SQLException e) {
             e.printStackTrace();}
      return admins;//返回系集合，符合条件的系的信息
    }
	}


<file_sep>/src/admin/studentUI/FileListView.java
package admin.studentUI;


import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.util.Callback;

/*
 * 左侧文件列表
 * 
 */

public class FileListView extends ListView<FileItem>
{
	// 数据源
	private ObservableList<FileItem> listData = FXCollections.observableArrayList();

	public FileListView()
	{
		// 设置数据源
		setItems(listData);

		// 设置单元格生成器 （工厂）
		setCellFactory(new Callback<ListView<FileItem>, ListCell<FileItem>>()
		{

			@Override
			public ListCell<FileItem> call(ListView<FileItem> param)
			{
				return new MyListCell();
			}
		});

	}

	public ObservableList<FileItem> data()
	{
		return listData;
	}

	////////////////////////////////////////////////
	// 负责单元格Cell的显示
	static class MyListCell extends ListCell<FileItem>
	{

		@Override
		public void updateItem(FileItem item, boolean empty)
		{
			// FX框架要求必须先调用 super.updateItem()
			super.updateItem(item, empty);

			// 自己的代码
			if (item == null)
			{
				this.setText("");
			} else
			{
				this.setText(item.fileName);
			}
		}
	}

}
<file_sep>/src/attendance/test/CourseTestDao.java
package attendance.test;

import java.util.ArrayList;
import java.util.List;

import attendance.bean.Course;
import attendance.bean.Teach;
import attendance.bean.Teacher;
import attendance.bean.TeachforUI;
import attendance.dao.CourseDao;
import attendance.dao.TeachDao;
import attendance.dao.TeacherDao;

public class CourseTestDao {
	public static void main(String[] args){
//		CourseDao dao= new CourseDao();
//	    List<Course> is =new ArrayList<Course>();
//	    is =dao.list2();
//	    for (Course b : is) {
//	    	System.out.printf("%d\t%s\n",b.Cno,b.Cname);	           
//	    	System.out.println();
//	    }	
	    TeachDao dao= new TeachDao();
	    List<TeachforUI> is =new ArrayList<TeachforUI>();
	    is =dao.list3forUI(1);
	    for (TeachforUI b : is) {
	    	System.out.printf("%d\t%s\n",b.Cno,b.Cname);	           
	    	System.out.println();
	    }	
	}
}
<file_sep>/src/student/StudentChooseUI.java
package student;

import java.io.IOException;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class StudentChooseUI {
	public void start(Stage stage) throws IOException {
        stage.setTitle("主界面");
        
      //Parent root = FXMLLoader.load(getClass().getResource("TeachChooseUI.fxml"));
        FXMLLoader loader = new FXMLLoader(getClass().getResource("StudentChooseUI.fxml"));
        Parent root =loader.load();
        SCController Controller = loader.getController();
        Scene scene = new Scene(root, 732, 609);
        stage.setScene(scene);
        stage.show();
        //Controller.getno();
        Controller.InitUI();
    }
}
<file_sep>/src/student/SAController.java
package student;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import attendance.bean.Course;
import attendance.bean.SC;
import attendance.dao.CourseDao;
import attendance.dao.SCDao;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.stage.Stage;


public class SAController {
	@FXML private Button delete;
	@FXML private ListView list;
	@FXML
	protected void Delete(ActionEvent event) throws IOException {
		SCDao dao = new SCDao();
		CourseDao cdao = new CourseDao();
		List<Course> is = new ArrayList<Course>();
		is = cdao.list3(list.getSelectionModel().getSelectedItem().toString());
		if(dao.delete(StudIdentityTrans.getCno(), is.get(0).Cno)) {
			Alert alert = new Alert(Alert.AlertType.INFORMATION);
			alert.setTitle("提示");
			alert.setHeaderText(null);
			alert.setContentText("退选成功！");
			alert.showAndWait();
			list.getItems().clear();
			InitUI();
		}else {
			Alert alert = new Alert(Alert.AlertType.ERROR);
			alert.setTitle("提示");
			alert.setHeaderText(null);
			alert.setContentText("未选择课程！");
			alert.showAndWait();
		}
	}
	public void InitUI() {
		SCDao dao = new SCDao();
		List<SC> is = new ArrayList<SC>();
		is = dao.list2(StudIdentityTrans.getCno());
		for(SC s:is) {
			list.getItems().add(s.Cname);
		}
	}
}
