Beispiel #1
0
 public void setViewEva(Integer id) {
   User user = getUserDatas(id);
   user.setViewEav(1);
   HibernateUtil.beginTransaction();
   getSession().merge(user);
   HibernateUtil.commitTransaction();
 }
Beispiel #2
0
 public void setUserEvaGrade(Integer id, String evaGrade) {
   User user = getUserDatas(id);
   user.setEvaGrade(evaGrade);
   HibernateUtil.beginTransaction();
   getSession().merge(user);
   HibernateUtil.commitTransaction();
 }
Beispiel #3
0
 public void Updateimage(String value, Integer id) {
   User user = getUserDatas(id);
   user.setImange(value);
   HibernateUtil.beginTransaction();
   getSession().merge(user);
   //        getSession().flush();
   //        getSession().clear();
   HibernateUtil.commitTransaction();
 }
Beispiel #4
0
 public void resetPassword(Integer id, String newPass) {
   User user = getUserDatas(id);
   user.setPassword(newPass);
   HibernateUtil.beginTransaction();
   getSession().merge(user);
   //        getSession().flush();
   //        getSession().clear();
   HibernateUtil.commitTransaction();
 }
Beispiel #5
0
 public void setUserValidate(String id) {
   User user = getUserDatas(Integer.parseInt(id));
   user.setValidateStu(1);
   HibernateUtil.beginTransaction();
   getSession().merge(user);
   //        getSession().flush();
   //        getSession().clear();
   HibernateUtil.commitTransaction();
 }
Beispiel #6
0
  public List insertUser(User user, String piority, String usernameInsert, boolean isPM) {
    //        user.setId(1);
    Integer countPiority = 0;
    StringBuffer newPiority = new StringBuffer();
    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.US);

    Date date = new Date();
    String dateStr = dateFormat.format(date);
    HibernateUtil.beginTransaction();
    if (user.getStatus() == 3) {
      user.setValidateStu(0);
      user.setViewEav(0);
    } else {
      user.setValidateStu(1);
    }
    user.setUserCreate(usernameInsert);
    user.setDateCreate(dateStr);

    if (isPM) {
      countPiority = 0;
    } else {
      countPiority = findPiority(piority, user.getStatus());
    }

    if (countPiority > 0) {

      if (countPiority < 10) {
        newPiority.append("00" + countPiority);
      } else if (countPiority < 100) {
        newPiority.append("0" + countPiority);
      } else {
        newPiority.append(countPiority);
      }
    } else {
      newPiority.append("");
    }
    user.setPiority(piority + newPiority.toString());
    getSession().save(user);
    HibernateUtil.commitTransaction();
    closeSession();

    Criteria criteria = getSession().createCriteria(User.class);
    criteria.add(Restrictions.eq("userName", user.getUserName()));
    List<User> list = criteria.list();
    closeSession();
    return list;
  }
Beispiel #7
0
  public void editProfileStaff(User user, String pioruty) {
    User user1 = getUserDatas(user.getUserId());

    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.US);

    Date date = new Date();
    String dateStr = dateFormat.format(date);
    user.setUserUpdate(user.getUserName());
    user.setDateUpdate(dateStr);
    user.setPassword(user1.getPassword());
    user.setValidateStu(user1.getValidateStu());
    user.setStatus(user1.getStatus());
    user.setUserCreate(user1.getUserCreate());
    user.setDateCreate(user1.getDateCreate());
    user.setImange(user1.getImange());

    if (user.getTeamId().toString().equals(user1.getTeamId().toString())) { // No change team
      user.setPiority(user1.getPiority());
    } else { // Chang teame
      if (pioruty.length() <= 0) { // Not PM
        StringBuffer newPiority = new StringBuffer();
        Integer countPiority = findPiority(user.getPiority(), 2);
        if (countPiority > 0) {
          if (countPiority < 10) {
            newPiority.append("00" + countPiority);
          } else if (countPiority < 100) {
            newPiority.append("0" + countPiority);
          } else {
            newPiority.append(countPiority);
          }
        } else {
          newPiority.append("");
        }
        user.setPiority(user.getPiority() + newPiority.toString());
      } else { // PM of new team
        user.setPiority(pioruty);
        // edit team and section
      }
    }

    HibernateUtil.beginTransaction();
    getSession().merge(user);
    HibernateUtil.commitTransaction();
  }
Beispiel #8
0
  public void EditProfile(User user) {
    User user1 = getUserDatas(user.getUserId());

    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.US);

    Date date = new Date();
    String dateStr = dateFormat.format(date);
    user.setViewEav(user1.getViewEav());
    user.setUserUpdate(user.getUserName());
    user.setDateUpdate(dateStr);
    user.setPassword(user1.getPassword());
    user.setValidateStu(user1.getValidateStu());
    user.setStatus(user1.getStatus());
    user.setUserCreate(user1.getUserCreate());
    user.setDateCreate(user1.getDateCreate());
    user.setPiority(user1.getPiority());
    user.setImange(user1.getImange());
    if (!user.getStaffId().equals(user1.getStaffId())) {
      StringBuffer newPiority = new StringBuffer();
      User userBuffer = getUserDatas(user.getStaffId());
      Integer countPiority = findPiority(userBuffer.getPiority(), 3);
      if (countPiority > 0) {
        if (countPiority < 10) {
          newPiority.append("00" + countPiority);
        } else if (countPiority < 100) {
          newPiority.append("0" + countPiority);
        } else {
          newPiority.append(countPiority);
        }
      } else {
        newPiority.append("");
      }
      user.setPiority(userBuffer.getPiority() + newPiority.toString());
    }

    HibernateUtil.beginTransaction();
    getSession().merge(user);
    HibernateUtil.commitTransaction();
  }
Beispiel #9
0
 public void deleteUser(Integer id) {
   User user = getUserDatas(id);
   HibernateUtil.beginTransaction();
   getSession().delete(user);
   HibernateUtil.commitTransaction();
 }