Ejemplo n.º 1
0
 public void workerIdForCurrentUser() throws Exception {
   userIdForCurrentUser();
   if (Global.user_id == 0) {
     Global.worker_id = 0;
     return;
   }
   if (!newConnection()) {
     Global.worker_id = 0;
     return;
   }
   try {
     /* PreparedStatement to issue SQL query */
     // Search worker using user_id to extract worker_id
     preparedStatement =
         connection.prepareStatement(
             "select id, last_name, first_name from workers where user_id = " + Global.user_id);
     resultSet = preparedStatement.executeQuery();
     resultSet.first();
     Integer _worker_id = resultSet.getInt("id");
     if (_worker_id == null) {
       _worker_id = 0;
     }
     Global.worker_id = _worker_id;
   } catch (Exception e) {
     throw e;
   } finally {
     closeDataObjects();
   }
 }
Ejemplo n.º 2
0
 public void userIdForCurrentUser() throws Exception {
   if (!newConnection()) {
     return;
   }
   try {
     /* PreparedStatement to issue SQL query */
     // Search user using current_user to extract user_id
     preparedStatement =
         connection.prepareStatement(
             "select id from users where name = '" + Global.current_user + "'");
     resultSet = preparedStatement.executeQuery();
     resultSet.first();
     Integer _user_id = resultSet.getInt("id");
     if (_user_id == null) {
       Global.user_id = 0;
     } else {
       Global.user_id = _user_id;
     }
   } catch (Exception e) {
     throw e;
   } finally {
     closeDataObjects();
   }
 }
Ejemplo n.º 3
0
 public void readTimeRecordCodes() throws Exception {
   try {
     if (!newConnection()) {
       return;
     }
     // PreparedStatement to issue SQL query
     preparedStatement =
         connection.prepareStatement("select id, name from timerecord_codes order by id");
     // SQL query's ResultSet with PreparedStatement
     resultSet = preparedStatement.executeQuery();
     // Load codes list
     Global.codesList.clear();
     while (resultSet.next()) {
       Integer _id = resultSet.getInt("id");
       String _name = resultSet.getString("name");
       TimeRecordCode _code = new TimeRecordCode(_id, _name);
       Global.codesList.add(_code);
     }
   } catch (Exception e) {
     throw e;
   } finally {
     closeDataObjects();
   }
 }