public void actionPerformed(ActionEvent ae) {
    AbstractButton jlab = null;
    if ((count > 7)) {
      JOptionPane.showMessageDialog(
          jlab, "UnSuccessful Submit", "Error", JOptionPane.ERROR_MESSAGE);

    } else if ((count == 0)) {
      AbstractButton jlab1 = null;

      JOptionPane.showMessageDialog(
          jlab1, "UnSuccessful Submit", "Error", JOptionPane.ERROR_MESSAGE);

    } else if ((ae.getActionCommand().equals("Submit"))) {
      AbstractButton jlab2 = null;

      System.out.println("Submitted");
      // JOptionPane.showMessageDialog(jlab1, "Successfully Submitted.");

      JOptionPane.showMessageDialog(
          jlab2, "Submited Successfully!" + "\n" + "Choices are:  " + choices);
      String nameofuser;

      // change username with passed parameter here

      nameofuser = arg;
      System.out.println("Username:"******"select * from user where username= '******'";

      try {
        pst = con.prepareStatement(sql);
        rs = pst.executeQuery();
        if (rs.next()) {
          this.hide();

          allowedchoices.insert(0, rs.getString(9));
          threshold = rs.getFloat(7);
        }

        int i;
        StringBuffer temp;
        temp = new StringBuffer("-------");

        for (i = 0; i < 7; i++) {
          if (allowedchoices.charAt(i) != choices.charAt(i)) {

            temp.setCharAt(i, choices.charAt(i));
          }
        }

        double risk = 0.0;
        for (i = 0; i < 7; i++) {
          switch (temp.charAt(i)) {
            case 'r':
              risk = risk + 0.15;
              break;
            case 'c':
              risk = risk + 0.0;
              break;
            case 'a':
              risk = risk + 0.20;
              break;
            case 'u':
              risk = risk + 0.0;
              break;
            case 'd':
              risk = risk + 0.5;
              break;
            case 'p':
              risk = risk + 0.3;
              break;
            case 'e':
              risk = risk + 0.25;
              break;
          }
        }
        System.out.println("Current Risk Value: " + risk);
        System.out.println(
            "PREMISSION ALLOWED(BY DEFAULT):" + allowedchoices + "THRESHOLD:" + threshold);

        if (threshold < risk) {
          con = ClientConnect.ConnectDB();
          String sql1 =
              "update user set accountstatus = '" + 0 + "' where username= '******'";
          JOptionPane.showMessageDialog(
              jlab1,
              "Account Has Been Disabled! \n \t Contact Administrator!",
              "Error",
              JOptionPane.ERROR_MESSAGE);
          Statement stmt = con.createStatement();
          stmt.execute(sql1.toString());
          stmt.close();
        } else {
          GUIFRfetch gf = new GUIFRfetch();
        }

      } catch (SQLException | HeadlessException e) {
        JOptionPane.showMessageDialog(null, e);
      }
    }
  }
Example #2
0
 static String dirForFqcn(String fqcn) {
   int last_dot = fqcn.lastIndexOf('.');
   StringBuffer sb = new StringBuffer(fqcn.substring(0, last_dot + 1));
   for (int i = 0, len = sb.length(); i < len; ++i) if (sb.charAt(i) == '.') sb.setCharAt(i, '/');
   return sb.toString();
 }
  /** Listens to the check boxes. */
  public void itemStateChanged(ItemEvent e) {
    int index = 0;
    char c = '-';
    Object source = e.getItemSelectable();

    if (source == readButton) {
      index = 0;
      c = 'r';
      choices.setCharAt(index, c);
      System.out.println("" + choices);
      if (readButton.isSelected()) {
        count++;
        System.out.println("" + count);
      }

      if (source != readButton) {
        count--;
        // System.out.println("out");
      }
    } else if (source == createButton) {
      index = 1;
      c = 'c';
      choices.setCharAt(index, c);
      System.out.println("" + choices);

      if (createButton.isSelected()) {
        count++;
        System.out.println("" + count);
      }
      if (source != createButton) {
        count--;
        // System.out.println("out");
      }

    } else if (source == editButton) {
      index = 2;
      c = 'e';
      choices.setCharAt(index, c);
      System.out.println("" + choices);
      // count++;
      // System.out.println(""+ count);

      if (editButton.isSelected()) {
        count++;
        System.out.println("" + count);
      }
      if (source != editButton) {
        count--;
        // System.out.println("out");
      }

    } else if (source == appendButton) {
      index = 3;
      c = 'a';
      choices.setCharAt(index, c);
      System.out.println("" + choices);
      // count++;
      // System.out.println(""+ count);
      if (appendButton.isSelected()) {
        count++;
        System.out.println("" + count);
      }
      if (source != appendButton) {
        count--;
        // System.out.println("out");
      }
    } else if (source == uploadButton) {
      index = 4;
      c = 'u';
      choices.setCharAt(index, c);
      System.out.println("" + choices);
      // count++;
      // System.out.println(""+ count);
      if (uploadButton.isSelected()) {
        count++;
        System.out.println("" + count);
      }
      if (source != uploadButton) {
        count--;
        // System.out.println("out");
      }
    } else if (source == downloadButton) {
      index = 5;
      c = 'd';
      choices.setCharAt(index, c);
      System.out.println("" + choices);
      //  count++;
      // System.out.println(""+ count);
      if (downloadButton.isSelected()) {
        count++;
        System.out.println("" + count);
      }
      if (source != downloadButton) {
        count--;
        // System.out.println("out");
      }

    } else if (source == printButton) {
      index = 6;
      c = 'p';
      choices.setCharAt(index, c);
      System.out.println("" + choices);
      // count++;
      // System.out.println(""+ count);
      if (printButton.isSelected()) {
        count++;
        System.out.println("" + count);
      }
      if (source != printButton) {
        count--;
        // System.out.println("out");
      }

    } else if ((source == submitbutton)) {

    }

    // Now that we know which button was pushed, find out
    // whether it was selected or deselected.
    if ((e.getStateChange() == ItemEvent.DESELECTED)) {
      c = '-';
      choices.setCharAt(index, c);
      count--;
      System.out.println("" + count);

      System.out.println("" + choices);
    }

    // Apply the change to the string.

    updatePicture();
  }