Ejemplo n.º 1
0
  public void UpdateDepartment(HashMap d) throws Exception {
    HashMap db_d = GetDepartment(d.get("id").toString());

    Iterator iter = d.entrySet().iterator();
    while (iter.hasNext()) {
      Map.Entry entry = (Map.Entry) iter.next();
      Object key = entry.getKey();
      Object val = entry.getValue();

      db_d.put(key, val);
    }

    String sql =
        "update t_department "
            + " set "
            + " name = ?, "
            + " manager = ?, "
            + " manager_name = ? "
            + " where id = ?";

    Connection conn = getConn();

    PreparedStatement stmt = conn.prepareStatement(sql);

    stmt.setString(1, ToString(db_d.get("name")));
    stmt.setString(2, ToString(db_d.get("manager")));
    stmt.setString(3, ToString(db_d.get("manager_name")));
    stmt.setString(4, ToString(db_d.get("id")));

    stmt.executeUpdate();
    stmt.close();
    conn.close();
  }
Ejemplo n.º 2
0
  public void UpdateEmployee(HashMap user) throws Exception {
    HashMap db_user = GetEmployee(user.get("id").toString());

    Iterator iter = user.entrySet().iterator();
    while (iter.hasNext()) {
      Map.Entry entry = (Map.Entry) iter.next();
      Object key = entry.getKey();
      Object val = entry.getValue();

      db_user.put(key, val);
    }

    DeleteEmployee(user.get("id").toString());
    InsertEmployee(db_user);
  }