use of com.cas.sim.tis.entity.User in project TeachingInSimulation by ScOrPiOzzy.
the class LeftMenu method initialize.
@Override
public void initialize(URL location, ResourceBundle resources) {
User user = SpringUtil.getBean(UserAction.class).findUserByID(Session.get(Session.KEY_LOGIN_ID));
name.setText(user.getName());
code.setText(user.getCode());
}
use of com.cas.sim.tis.entity.User in project TeachingInSimulation by ScOrPiOzzy.
the class StudentList method modify.
private void modify(int id) {
User student = SpringUtil.getBean(UserAction.class).findUserByID(id);
Dialog<User> dialog = new Dialog<>();
dialog.setDialogPane(new TeacherModifyDialog(student));
dialog.setTitle(MsgUtil.getMessage("student.dialog.modify"));
dialog.setPrefSize(635, 320);
dialog.showAndWait().ifPresent(user -> {
if (user == null) {
return;
}
try {
SpringUtil.getBean(UserAction.class).modifyUser(user);
AlertUtil.showAlert(AlertType.INFORMATION, MsgUtil.getMessage("alert.information.data.update.success"));
pagination.reload();
} catch (Exception e) {
e.printStackTrace();
AlertUtil.showAlert(AlertType.ERROR, e.getMessage());
LOG.error("修改User对象失败,User编号{}:{}", user.getId(), e.getMessage());
}
});
}
use of com.cas.sim.tis.entity.User in project TeachingInSimulation by ScOrPiOzzy.
the class TeacherList method modify.
private void modify(int id) {
User teacher = SpringUtil.getBean(UserAction.class).findUserByID(id);
Dialog<User> dialog = new Dialog<>();
dialog.setDialogPane(new TeacherModifyDialog(teacher));
dialog.setTitle(MsgUtil.getMessage("teacher.dialog.modify"));
dialog.setPrefSize(635, 320);
dialog.showAndWait().ifPresent(user -> {
if (user == null) {
return;
}
try {
SpringUtil.getBean(UserAction.class).modifyUser(user);
AlertUtil.showAlert(AlertType.INFORMATION, MsgUtil.getMessage("alert.information.data.update.success"));
pagination.reload();
} catch (Exception e) {
e.printStackTrace();
AlertUtil.showAlert(AlertType.ERROR, e.getMessage());
LOG.error("修改User对象失败,User编号{}:{}", user.getId(), e.getMessage());
}
});
}
use of com.cas.sim.tis.entity.User in project TeachingInSimulation by ScOrPiOzzy.
the class TeacherList method reload.
private void reload(Integer pageIndex) {
int pageSize = 10;
PageInfo<User> pageInfo = SpringUtil.getBean(UserAction.class).findTeachers(pageIndex + 1, pageSize);
if (pageInfo == null) {
pagination.setPageCount(0);
table.setItems(null);
table.build();
} else {
pagination.setPageCount((int) pageInfo.getPages());
JSONArray array = new JSONArray();
array.addAll(pageInfo.getList());
table.setItems(array);
table.build();
}
}
use of com.cas.sim.tis.entity.User in project TeachingInSimulation by ScOrPiOzzy.
the class TeacherList method importExcel.
@FXML
private void importExcel() {
FileChooser chooser = new FileChooser();
chooser.setInitialDirectory(FileSystemView.getFileSystemView().getHomeDirectory());
chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(MsgUtil.getMessage("resource.excel"), "*.xls"));
File source = chooser.showOpenDialog(GUIState.getStage());
if (source == null) {
return;
}
List<User> users = new ArrayList<User>();
Object[][] result = ExcelUtil.readExcelSheet(source.getAbsolutePath(), "Sheet1", 2);
for (int i = 2; i < result.length; i++) {
Object codeObj = result[i][0];
if (Util.isEmpty(codeObj)) {
String reason = MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("teacher.code"));
AlertUtil.showAlert(AlertType.WARNING, reason);
return;
}
String code = String.valueOf(codeObj).trim();
if (code.length() > 20) {
String reason = MsgUtil.getMessage("alert.warning.over.length", MsgUtil.getMessage("teacher.code"), String.valueOf(20));
AlertUtil.showAlert(AlertType.WARNING, reason);
return;
}
Object nameObj = result[i][1];
if (Util.isEmpty(nameObj)) {
String reason = MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("teacher.name"));
AlertUtil.showAlert(AlertType.WARNING, reason);
return;
}
String name = String.valueOf(nameObj).trim();
if (name.length() > 20) {
String reason = MsgUtil.getMessage("alert.warning.over.length", MsgUtil.getMessage("teacher.name"), String.valueOf(20));
AlertUtil.showAlert(AlertType.WARNING, reason);
return;
}
User user = new User();
user.setCode(code);
user.setName(name);
user.setRole(RoleConst.TEACHER);
user.setCreator(Session.get(Session.KEY_LOGIN_ID));
users.add(user);
}
try {
SpringUtil.getBean(UserAction.class).addUsers(users);
AlertUtil.showAlert(AlertType.INFORMATION, MsgUtil.getMessage("excel.import.success"));
pagination.reload();
} catch (Exception e) {
AlertUtil.showAlert(AlertType.ERROR, e.getMessage());
e.printStackTrace();
}
}
Aggregations