示例#1
0
 /**
  * Check password filled if it is true then save the user data
  *
  * @return true if the data is saved successfully, false if password is entered and it does not
  *     match.
  */
 private boolean save() {
   char[] pchars = password.getPassword();
   String pword = "";
   if (pchars.length > 0) {
     pword = MD5.computeDigest(pchars);
     Arrays.fill(pchars, '\u0000');
     char[] cchars = confirmPassword.getPassword();
     String cword = MD5.computeDigest(cchars);
     Arrays.fill(cchars, '\u0000');
     if (!pword.equals(cword)) {
       Toolkit.getDefaultToolkit().beep();
       JOptionPane.showMessageDialog(
           this,
           "Password must match Confirm Password." + "\nPlease re-enter.",
           "Password Error",
           JOptionPane.ERROR_MESSAGE);
       return false;
     }
   }
   final ClientTask task;
   int teamsId = teamsModel.getSelectedId();
   if (teamsId < 0) {
     teamsId = 0;
   }
   usersData = new UsersData();
   usersData.users_id = usersId;
   usersData.teams_id = teamsId;
   usersData.user_name = userName.getText();
   usersData.first_name = fname.getText();
   usersData.last_name = lname.getText();
   usersData.unitize = unitizeCheckBox.isSelected() ? "Yes" : "No";
   usersData.uqc = uqcCheckBox.isSelected() ? "Yes" : "No";
   usersData.coding = codingCheckBox.isSelected() ? "Yes" : "No";
   usersData.codingqc = codingqcCheckBox.isSelected() ? "Yes" : "No";
   usersData.qa = qaCheckBox.isSelected() ? "Yes" : "No";
   usersData.listing = listingCheckBox.isSelected() ? "Yes" : "No";
   usersData.tally = tallyCheckBox.isSelected() ? "Yes" : "No";
   usersData.teamLeader = tlCheckBox.isSelected() ? "Yes" : "No";
   usersData.admin = adminCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminUsers = adminUsersCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminProject = adminProjectCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminBatch = adminBatchCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminEdit = adminEditCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminImport = adminImportCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminExport = adminExportCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminProfit = adminProfitCheckBox.isSelected() ? "Yes" : "No";
   usersData.password = pword;
   usersData.dateOfJoin = field.getText();
   task = new TaskSendUsersData(usersData);
   task.enqueue(this);
   return true;
 }
示例#2
0
  /**
   * Load the user's data.
   *
   * @param queryResult - ResultSet returned by ClientTask in loadUsersDataEntry
   */
  private void getUserByIdDataEntry(ResultSet queryResult) {
    try {
      if (queryResult.next()) {
        // updating a user
        userName.setText(queryResult.getString(2));
        fname.setText(queryResult.getString(4));
        lname.setText(queryResult.getString(3));
        unitizeCheckBox.setSelected((queryResult.getString(5).equals("Yes") ? true : false));
        uqcCheckBox.setSelected((queryResult.getString(6).equals("Yes") ? true : false));
        codingCheckBox.setSelected((queryResult.getString(7).equals("Yes") ? true : false));
        codingqcCheckBox.setSelected((queryResult.getString(8).equals("Yes") ? true : false));
        listingCheckBox.setSelected(
            ((queryResult.getString(9) == null || queryResult.getString(9).equals("Yes"))
                ? true
                : false));
        tallyCheckBox.setSelected(
            ((queryResult.getString(10) == null || queryResult.getString(10).equals("Yes"))
                ? true
                : false));
        qaCheckBox.setSelected((queryResult.getString(11).equals("Yes") ? true : false));
        tlCheckBox.setSelected((queryResult.getString(12).equals("Yes") ? true : false));
        adminCheckBox.setSelected((queryResult.getString(13).equals("Yes") ? true : false));
        adminUsersCheckBox.setSelected((queryResult.getString(14).equals("Yes") ? true : false));
        adminProjectCheckBox.setSelected((queryResult.getString(15).equals("Yes") ? true : false));
        adminBatchCheckBox.setSelected((queryResult.getString(16).equals("Yes") ? true : false));
        adminEditCheckBox.setSelected((queryResult.getString(17).equals("Yes") ? true : false));
        adminImportCheckBox.setSelected((queryResult.getString(18).equals("Yes") ? true : false));
        adminExportCheckBox.setSelected((queryResult.getString(19).equals("Yes") ? true : false));
        adminProfitCheckBox.setSelected((queryResult.getString(20).equals("Yes") ? true : false));
        teamsCombo.setSelectedIndex(teamsModel.indexOf(queryResult.getInt(1)));
        password.setText("");
        confirmPassword.setText("");
        String date = queryResult.getString(21);

        if (null != date) {
          String[] splitDate = date.split(" ");
          field.setText(splitDate[0]);
        }

        enableAdminPriv();
      }
    } catch (SQLException e) {
      Log.quit(e);
    }
  }