//返回类型,0:密码更改成功,1:旧密码错误,2:密码更改不成功,请重试 public int ChangePassword(int studentId, string oldPassword, string newPassword) { //IStudentDao studentDao = new StudentDao(sessionFactory); Student selectedStudent=studentDao.Get(studentId); if (selectedStudent != null) { if (oldPassword!=selectedStudent.studentPassword) { return 1; } else { selectedStudent.studentPassword = newPassword; ISystemUserDao systemUserDao = new SystemUserDao(sessionFactory); SystemUser selectedSystemUser = systemUserDao.Get(selectedStudent.studentID.ToString()); selectedSystemUser.systemUserPassword = newPassword; try { studentDao.Update(selectedStudent); systemUserDao.Update(selectedSystemUser); return 0; } catch (Exception e) { return 2; } } } else { return 2; } }
//登陆 public Domain.SystemUser Login(string id, string password) { ISystemUserDao newUserDao = new SystemUserDao(sessionFactory); SystemUser newUser = newUserDao.Get(id); if (newUser != null){ if (password == newUser.systemUserPassword){ return newUser; } else{ return null; } } else{ return null; } }