Exemplo n.º 1
0
  @FXML
  public void Selecteditem() throws SQLException {

    TuserPermission InsertData = (TuserPermission) tableUser.getSelectionModel().getSelectedItem();
    selected = InsertData.getId();
    String Sql = " SELECT * FROM users WHERE id =  '" + InsertData.getId() + "'";
    DB.rs = DB.statemen.executeQuery(Sql);

    if (DB.rs.next()) {

      User_name.setText(DB.rs.getString("user_name"));
      pass.setText(DB.rs.getString("pass"));
      note.setText(DB.rs.getString("note"));
      CB1.setSelected(DB.rs.getBoolean("permission1"));
      CB2.setSelected(DB.rs.getBoolean("permission2"));
    }
  }
Exemplo n.º 2
0
  public void FillTable() throws SQLException {
    System.out.println("FillTable");
    data.clear();
    count = 0;
    DB.rs = DB.statemen.executeQuery("SELECT * FROM users");

    while (DB.rs.next()) {
      count++;

      data.add(
          new TuserPermission(
              DB.rs.getInt("id"),
              DB.rs.getString("user_name"),
              DB.rs.getString("pass"),
              DB.rs.getString("note"),
              DB.rs.getBoolean("permission1"),
              DB.rs.getBoolean("permission2")));
    }
    CustomerN.setText("" + count);
    Erromassage.setText("");
  }
Exemplo n.º 3
0
  @FXML
  public void InsertUser() throws SQLException {

    int selectedOption =
        JOptionPane.showConfirmDialog(
            null, "هل انت متاكد من هذة العملية  ؟", "Choose", JOptionPane.YES_NO_OPTION);
    if (selectedOption == JOptionPane.YES_OPTION) {
      boolean value1 = CB1.isSelected();
      boolean value2 = CB2.isSelected();

      DB.rs =
          DB.statemen.executeQuery(
              "SELECT * FROM users WHERE user_name ='" + User_name.getText() + "'");
      if (User_name.getText().equals("")) {
        Erromassage.setText("من فضلك ادخل البياناتالمطلوبة");
        User_name.requestFocus();
      } else if (DB.rs.next()) {
        Erromassage.setText("هذا الاسم موجود مسبقا");
        User_name.requestFocus();
      } else {

        DB.statemen.executeUpdate(
            "INSERT INTO users( user_name, pass, note, permission1, permission2) VALUES ('"
                + User_name.getText()
                + "','"
                + pass.getText()
                + "','"
                + note.getText()
                + "','"
                + value1
                + "','"
                + value2
                + "')");

        FillTable();
        clear();
      }
    }
  }