use of com.cas.sim.tis.entity.User in project TeachingInSimulation by ScOrPiOzzy.
the class SettingDialog method modifyPwd.
@FXML
private void modifyPwd() {
String oldPwd = this.oldPwd.getText();
if (StringUtils.isEmpty(oldPwd)) {
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("setting.password.old")));
return;
}
String newPwd = this.newPwd.getText();
if (StringUtils.isEmpty(newPwd)) {
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("setting.password.new")));
return;
}
String pwdAgain = this.pwdAgain.getText();
if (StringUtils.isEmpty(pwdAgain)) {
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("setting.password.again")));
return;
}
if (!newPwd.equals(oldPwd)) {
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.password.cant.same"));
return;
}
if (!newPwd.equals(pwdAgain)) {
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.password.unmatch"));
return;
}
User user = SpringUtil.getBean(UserAction.class).findUserByID(Session.get(Session.KEY_LOGIN_ID));
if (!user.getPassword().equals(oldPwd)) {
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.password.error"));
return;
}
user.setPassword(newPwd);
SpringUtil.getBean(UserAction.class).modifyUser(user);
dialog.close();
AlertUtil.showAlert(AlertType.INFORMATION, MsgUtil.getMessage("alert.information.data.update.success"));
}
use of com.cas.sim.tis.entity.User in project TeachingInSimulation by ScOrPiOzzy.
the class StudentList method reload.
private void reload(Integer pageIndex) {
int pageSize = 10;
PageInfo<User> pageInfo = SpringUtil.getBean(UserAction.class).findStudents(pageIndex + 1, pageSize, classId);
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 StudentList 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;
}
com.cas.sim.tis.entity.Class clazz = SpringUtil.getBean(ClassAction.class).findClass(classId);
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("student.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("student.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("student.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("student.name"), String.valueOf(20));
AlertUtil.showAlert(AlertType.WARNING, reason);
return;
}
User user = new User();
user.setCode(code);
user.setName(name);
user.setClassId(classId);
user.setTeacherId(clazz.getTeacherId());
user.setRole(RoleConst.STUDENT);
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) {
e.printStackTrace();
AlertUtil.showAlert(AlertType.ERROR, e.getMessage());
}
}
use of com.cas.sim.tis.entity.User in project TeachingInSimulation by ScOrPiOzzy.
the class PreparationDetail method loadPreparation.
private void loadPreparation() {
int cid = task.getId();
int role = Session.get(Session.KEY_LOGIN_ROLE);
int creator = Session.get(Session.KEY_LOGIN_ID);
if (RoleConst.STUDENT == role) {
User user = SpringUtil.getBean(UserAction.class).findUserByID(creator);
creator = user.getTeacherId();
}
// 查询是否存在自定义备课内容
preparation = SpringUtil.getBean(PreparationAction.class).findPreparationByTaskIdAndCreator(cid, creator);
// 查询是否存在模版备课内容
if (preparation == null) {
// XXX 暂时规定默认备课模版创建人编号为0
preparation = SpringUtil.getBean(PreparationAction.class).findPreparationByTaskIdAndCreator(cid, 0);
}
if (preparation == null && RoleConst.TEACHER == role) {
preparation = new Preparation();
preparation.setCatalogId(cid);
preparation.setCreator(creator);
preparation = SpringUtil.getBean(PreparationAction.class).addPreparation(preparation);
}
}
use of com.cas.sim.tis.entity.User in project TeachingInSimulation by ScOrPiOzzy.
the class UserAction method deleteUser.
public void deleteUser(int id) {
UserService service = getService();
User user = service.findById(id);
if (user != null) {
user.setDel(true);
modifyUser(user);
}
}
Aggregations