功能清单:
1.成绩加减分
2.加减分分值幅度可更改
3.可实现批量加分,按小组
4.查询
5.班级品均分、统计图等
6.课堂点名
7.课堂提问
8.考勤登记
9.考勤勘误
部分关键代码如下:
实现表格数据显示和单元格可编辑,单元格事件监听。
package application;
C1.setCellValueFactory(new PropertyValueFactory<Student,String>("rank"));
C2.setCellValueFactory(new PropertyValueFactory<Student,String>("numberrank"));
C3.setCellValueFactory(new PropertyValueFactory<Student,String>("fullName"));
C4.setCellValueFactory(new PropertyValueFactory<Student,String>("yourGender"));
C5.setCellValueFactory(new PropertyValueFactory<Student,String>("scholor"));
C6.setCellValueFactory(new PropertyValueFactory<Student,String>("major"));
C7.setCellValueFactory(new PropertyValueFactory<Student,String>("classrank"));
C8.setCellValueFactory(new PropertyValueFactory<Student,String>("totalabsences"));
C9.setCellValueFactory(new PropertyValueFactory<Student,String>("course1grade"));//+
C10.setCellValueFactory(new PropertyValueFactory<Student,String>("course2grade"));
C11.setCellValueFactory(new PropertyValueFactory<Student,String>("course3grade"));
C12.setCellValueFactory(new PropertyValueFactory<Student,String>("course4grade"));
C13.setCellValueFactory(new PropertyValueFactory<Student,String>("course5grade"));
Cgroup.setCellValueFactory(new PropertyValueFactory<Student,String>("groupname"));
C8.setCellFactory(TextFieldTableCell.forTableColumn());
//TextField tf = new TextField();
//String up = new String("+");
//String down = new String("-");
//up = up+DETAL.getText();
//down = down + DETAL.getText();
options = //可以写一个输入框获取用户满意的分值递增幅度,改
FXCollections.observableArrayList(
"+"+DETAL.getText(),
"-"+DETAL.getText(),
"小组加分"
);
C9.setCellFactory(tc -> {//combobox定义与监听,往后+
ComboBox<String> combo = new ComboBox<String>();
combo.setItems(options);
combo.setEditable(true);
TableCell<Student, String> cell = new TableCell<Student, 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 -> {if(TABLE.isFocused()||this.TEXT.isFocused()||this.Usehelp.isFocused()||this.SEARCH.isFocused()||this.xiangqing.isFocused()||DETAL.isFocused()){return;}
String keyname = TABLE.getItems().get(cell.getIndex()).getFullName();
// System.out.println("options.get(1)"+options.get(1));
String value = combo.getValue();
// System.out.println("options.get(2)"+options.get(2));
System.out.println("zzzzzz"+value);
if(value.equals(options.get(0)) || value.equals(options.get(1) ))//1 2选项
{ value =String.valueOf(Integer.valueOf(value)+Integer.valueOf(TABLE.getItems().get(cell.getIndex()).getCourse1grade()));
if(Integer.valueOf(value)>100){value = "100";}
if(Integer.valueOf(value)<0){value = "0";}
for (int i=0;i < students_bake.size();i++){
if( (students_bake.get(i).getFullName().equals(keyname)) || (students_bake.get(i).getNumberrank().endsWith(keyname) ) )
{
students_bake.get(i).setCourse1grade(value);
update(students_bake.get(i));//改成数据库输出
TABLE.refresh();
break;}
}
}
if(value.equals(options.get(2))){//3选项
int valuq = Integer.valueOf(DETAL.getText()) ;
System.out.println("valuq:"+valuq);
System.out.println("1"+TABLE.getItems().get(cell.getIndex()).getGroupname());
for (int i=0;i < students_bake.size();i++){
if( (students_bake.get(i).getGroupname().equals(TABLE.getItems().get(cell.getIndex()).getGroupname()))){
System.out.println(students_bake.get(i).getGroupname());
int gradeq = Integer.valueOf(students_bake.get(i).getCourse1grade());
int sum = valuq+gradeq;
if(sum > 100){sum = 100;}
students_bake.get(i).setCourse1grade(String.valueOf(sum));
update(students_bake.get(i));
}
}
TABLE.refresh();
}
else{
System.out.println("aiwudniuwadq"+value);
for (int i=0;i < students_bake.size();i++){
if( (students_bake.get(i).getFullName().equals(keyname)) || (students_bake.get(i).getNumberrank().endsWith(keyname) ) )
{
students_bake.get(i).setCourse1grade(value);
update(students_bake.get(i));
//TABLE.getItems().get(cell.getIndex()).setCourse1grade(value);
TABLE.refresh();
break;}}
}
});
return cell;
});
|