Exemplo n.º 1
0
  public static int updateOneUser(User user) {
    int uid = user.getUid();
    String userName = user.getUserName();
    String email = user.getEmail();
    String password = user.getPassword();
    try {
      conn = RDSManagement.getConnection();
      st = (Statement) conn.createStatement();
      String sql =
          "update User set email ='"
              + email
              + "', password ='******' where uid = "
              + uid
              + ";";
      System.out.println(sql);
      st.executeUpdate(sql);
      System.out.println("Update user: " + uid);

    } catch (SQLException e) {
      System.out.println(e.getMessage());
    } catch (Exception e) {
      System.out.println(e.getMessage());
    } finally {
      try {
        st.close();
        conn.close();
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    return uid;
  }
Exemplo n.º 2
0
 public UserTree(User user) {
   this.setUid(user.getUid());
   this.setUsername(user.getUsername());
   this.setPassword(user.getPassword());
   this.setIsadmin(user.isIsadmin());
   this.setEmployeename(user.getEmployeename());
   this.setUsertype(user.getUsertype());
   this.setUsertypename(user.getUsertypename());
   this.setEmail(user.getEmail());
   this.setComment(user.getComment());
   this.setCreateby(user.getCreateby());
   this.setCreatetime(user.getCreatetime());
   this.setEditby(user.getEditby());
   this.setEdittime(user.getEdittime());
   this.setLastlogin(user.getLastlogin());
   this.setSex(user.getSex());
   this.setBirthday(user.getBirthday());
   this.setIdcard(user.getIdcard());
   this.setAddress(user.getAddress());
   this.setMobile(user.getMobile());
   this.setTelephone(user.getTelephone());
   this.setEmergencycontact(user.getEmergencycontact());
   this.setAvatarurl(user.getAvatarurl());
   this.setPostuid(user.getPostuid());
   this.setPostname(user.getPostname());
   this.setParentuid(user.getParentuid());
 }
Exemplo n.º 3
0
  /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    // TODO Auto-generated method stub

    HttpSession session = request.getSession();
    User curuser = (User) session.getAttribute("curuser");
    String uemail = curuser.getEmail();

    double price = (Double) session.getAttribute("cprice");
    String name = (String) session.getAttribute("cname");
    String temp_quant = request.getParameter("quantity");
    int quant = Integer.parseInt(temp_quant);

    Cart cartentry = new Cart();
    cartentry.setName(name);
    cartentry.setPrice(price);
    cartentry.setQuant(quant);
    cartentry.setUemail(uemail);
    cartentry.setBought(0);

    Utils<Cart> db = new Utils<Cart>();
    db.insert(cartentry);

    // Prod prod = new Prod();
    // prod.setName(name);
    // prod.setPrice(price);
    // prod.setQuant(quant);

    // List<Prod> items = (List<Prod>) session.getAttribute("items");
    // items.add(prod);

    response.setContentType("text/html");

    getServletContext().getRequestDispatcher("/ProductList").forward(request, response);
  }
Exemplo n.º 4
0
  /**
   * Update the list of managed parks of a Park Manager.
   *
   * @author Taylor Gorman
   */
  public void updateParkList(String theEmail, List<String> theManagedParks) {
    List<User> myManagerList = myUserList.getParkManagerListCopy();

    for (User manager : myManagerList) {
      if (manager.getEmail().equals(theEmail)) {
        ((ParkManager) manager).setManagedParks(theManagedParks);
      }
    }
  }
Exemplo n.º 5
0
  public static int insertOneUser(User user) {
    int uid = getMaxUserID() + 1;
    String userName = user.getUserName();
    String email = user.getEmail();
    String password = user.getPassword();
    try {
      conn = RDSManagement.getConnection();
      st = (Statement) conn.createStatement();
      String sql =
          "insert into User values("
              + uid
              + ",'"
              + userName
              + "', '"
              + email
              + "','"
              + password
              + "');";
      System.out.println(sql);
      int count = st.executeUpdate(sql);
      System.out.println("Inserted " + count + " items into Event");

    } catch (SQLException e) {
      System.out.println(e.getMessage());
    } catch (Exception e) {
      System.out.println(e.getMessage());
    } finally {
      try {
        st.close();
        conn.close();
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    return uid;
  }
  public void updateUserBd(User user, String id) {

    Session session = HibernateUtil.openSession();
    Transaction transaction = null;

    try {
      transaction = session.getTransaction();
      transaction.begin();

      SQLQuery query =
          session.createSQLQuery(
              "UPDATE user SET surname=?, name=?, middleName=?, login=?, password=?, mobileTelephone=?, email=? WHERE id=?;");
      query.setParameter(0, user.getSurname());
      query.setParameter(1, user.getName());
      query.setParameter(2, user.getMiddleName());
      query.setParameter(3, user.getLogin());
      query.setParameter(4, user.getPassword());
      query.setParameter(5, user.getMobileTelephone());
      query.setParameter(6, user.getEmail());
      query.setParameter(7, id);
      int resultUpdate =
          query.executeUpdate(); // возвращает количество субъектов которые были изменены

      System.out.println("Update отчет " + resultUpdate);

      // session.saveOrUpdate(user);
      transaction.commit(); // применяем транзакцию
    } catch (Exception e) {

      // отменяем транзакцию
      transaction.rollback();
      e.printStackTrace();
    } finally {
      session.close();
    }
  }