Пример #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();
   }
 }
Пример #2
0
 public void workerNameForCurrentWorker() throws Exception {
   userIdForCurrentUser();
   if (Global.user_id == 0) {
     return;
   }
   if (!newConnection()) {
     return;
   }
   try {
     /* PreparedStatement to issue SQL query */
     // Search worker using worker_id
     preparedStatement =
         connection.prepareStatement(
             "select last_name, first_name from workers where id = " + Global.worker_id);
     resultSet = preparedStatement.executeQuery();
     resultSet.first();
     String _worker_last_name = resultSet.getString("last_name");
     String _worker_first_name = resultSet.getString("first_name");
     Global.worker_name = _worker_last_name + ", " + _worker_first_name;
   } catch (Exception e) {
     throw e;
   } finally {
     closeDataObjects();
   }
 }
Пример #3
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();
   }
 }