public void actionPerformed(ActionEvent ev) {
        try {
          // stok
          String query = "DELETE FROM stok_produk WHERE id_produk=" + idProduk;
          int hasil1 = stm.executeUpdate(query);

          // pemasukkan
          query = "DELETE FROM pemasukan WHERE id_produk=" + idProduk;
          int hasil2 = stm.executeUpdate(query);

          // pengeluaran
          query = "DELETE FROM pengeluaran WHERE id_produk=" + idProduk;
          int hasil3 = stm.executeUpdate(query);

          // produk
          query = "DELETE FROM produk WHERE id_produk=" + idProduk;
          int hasil4 = stm.executeUpdate(query);

          if (hasil1 == 1 || hasil2 == 1 || hasil3 == 1 && hasil4 == 1) {
            setDataTabel();
            JOptionPane.showMessageDialog(null, "berhasil hapus");
          } else {
            JOptionPane.showMessageDialog(null, "gagal");
          }
        } catch (SQLException SQLerr) {
          SQLerr.printStackTrace();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
Exemple #2
0
  private void btnDeleteActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnDeleteActionPerformed
    // TODO add your handling code here:

    if (txtKodeAbsen.getText().equals("")) {
      JOptionPane.showMessageDialog(
          null, "Isi Kode Absen yang Akan dihapus !!!", "Peringatan", JOptionPane.ERROR_MESSAGE);
      txtKodeAbsen.requestFocus();
    } else {
      try {
        Class.forName(KoneksiDatabase.driver);
        java.sql.Connection c =
            DriverManager.getConnection(
                KoneksiDatabase.database, KoneksiDatabase.user, KoneksiDatabase.pass);
        Statement s = c.createStatement();
        String sql = "DELETE FROM absensi_lembur where kd_absen ='" + txtKodeAbsen.getText() + "'";
        s.executeUpdate(sql);
        JOptionPane.showMessageDialog(null, "Data Berhasil Dihapus !");
        Baru();
      } catch (Exception e) {
        JOptionPane.showMessageDialog(
            null, "Kemungkinan terjadi kegagalan koneksi", "Warning", JOptionPane.ERROR_MESSAGE);
      }
    }
  } // GEN-LAST:event_btnDeleteActionPerformed
Exemple #3
0
 public void totalExport() {
   File expf = new File("export");
   if (expf.exists()) rmrf(expf);
   expf.mkdirs();
   for (int sto = 0; sto < storeLocs.size(); sto++) {
     try {
       String sl =
           storeLocs.get(sto).getAbsolutePath().replaceAll("/", "-").replaceAll("\\\\", "-");
       File estore = new File(expf, sl);
       estore.mkdir();
       File log = new File(estore, LIBRARY_NAME);
       PrintWriter pw = new PrintWriter(log);
       for (int i = 0; i < store.getRowCount(); i++)
         if (store.curStore(i) == sto) {
           File enc = store.locate(i);
           File dec = sec.prepareMainFile(enc, estore, false);
           pw.println(dec.getName());
           pw.println(store.getValueAt(i, Storage.COL_DATE));
           pw.println(store.getValueAt(i, Storage.COL_TAGS));
           synchronized (jobs) {
             jobs.addLast(expJob(enc, dec));
           }
         }
       pw.close();
     } catch (IOException exc) {
       exc.printStackTrace();
       JOptionPane.showMessageDialog(frm, "Exporting Failed");
       return;
     }
   }
   JOptionPane.showMessageDialog(frm, "Exporting to:\n   " + expf.getAbsolutePath());
 }
Exemple #4
0
  private void Simpan() {

    if (btnSave.getText().equals("Edit")) {
      try {
        Class.forName(KoneksiDatabase.driver);
        java.sql.Connection c =
            DriverManager.getConnection(
                KoneksiDatabase.database, KoneksiDatabase.user, KoneksiDatabase.pass);
        Statement s = c.createStatement();

        String sql;
        sql = "update absensi_lembur set tipehari = '";
        sql += cmbJenisHari.getSelectedItem() + "', tot_waktu_lembur='";
        sql += txtTotalLembur.getText() + "'";
        sql += "where kd_absen = '" + txtKodeAbsen.getText() + "'";
        s.executeQuery(sql);

        JOptionPane.showMessageDialog(
            null, "Data Berhasil Disimpan!!!", "Informasi", JOptionPane.INFORMATION_MESSAGE);
      } catch (Exception e) {
        JOptionPane.showMessageDialog(
            null,
            "Gagal Disimpan, Data Harus Lengkap !!!",
            "Peringatan",
            JOptionPane.WARNING_MESSAGE);
      }
    }
    Baru();
  }
Exemple #5
0
 @Override
 public void actionPerformed(ActionEvent e) {
   ID = (Integer) hashRoomType.get(boxRoomTypeID.getSelectedItem().toString());
   IDSTATUS = (Integer) hashRoomStatus.get(boxRoomStatusID.getSelectedItem().toString());
   if (e.getSource() == buttonInsert) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       RoomsController.roomsController.save(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "ok");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonUpdate) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       rooms.setRoomID(IDROOM);
       RoomsController.roomsController.update(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "Update to succeed !");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonDelete) {
     try {
       List<CheckIn> temp = CheckInController.checkInController.all();
       for (int i = 0; i < temp.size(); i++) {
         if (IDROOM == temp.get(i).getRoomID()) {
           this.error = 0;
         } else {
           this.error = 0;
           RoomsController.roomsController.delete(IDROOM);
           int c = model.getRowCount();
           for (int ii = c - 1; ii >= 0; ii--) {
             model.removeRow(ii);
             jRoom.revalidate();
           }
           all();
         }
       }
       JOptionPane.showMessageDialog(this, "Delete to succeed !");
     } catch (Exception ex) {
       JOptionPane.showMessageDialog(this, "can't delete row bcause check still !");
     }
   }
   if (e.getSource() == buttonRefresh) {}
 }
 private void prosesEdit(String query) {
   try {
     int hasil = stm.executeUpdate(query);
     if (hasil == 1) {
       setDataTabel();
       JOptionPane.showMessageDialog(null, "edit berhasil");
     } else {
       JOptionPane.showMessageDialog(null, "gagal");
     }
   } catch (SQLException SQLerr) {
     SQLerr.printStackTrace();
   }
 }
 @Override
 public void actionPerformed(ActionEvent e) {
   // Object o = table.getModel().getValueAt(table.getSelectedRow(), 0);
   int row = table.convertRowIndexToModel(table.getEditingRow());
   Object o = table.getModel().getValueAt(row, 0);
   JOptionPane.showMessageDialog(table, "Editing: " + o);
 }
 public int submit() {
   String newName = produktgruppeFormular.nameField.getText();
   if (isProdGrAlreadyKnown(newName)) {
     // not allowed: changing name to one that is already registered in DB
     JOptionPane.showMessageDialog(
         this,
         "Fehler: Produktgruppe '" + newName + "' bereits vorhanden!",
         "Info",
         JOptionPane.INFORMATION_MESSAGE);
     produktgruppeFormular.nameField.setText("");
     return 0;
   }
   Integer parentProdGrID =
       produktgruppeFormular.parentProdGrIDs.get(
           produktgruppeFormular.parentProdGrBox.getSelectedIndex());
   Vector<Integer> idsNew = produktgruppeFormular.idsOfNewProdGr(parentProdGrID);
   Integer topID = idsNew.get(0);
   Integer subID = idsNew.get(1);
   Integer subsubID = idsNew.get(2);
   Integer mwstID =
       produktgruppeFormular.mwstIDs.get(produktgruppeFormular.mwstBox.getSelectedIndex());
   Integer pfandID =
       produktgruppeFormular.pfandIDs.get(produktgruppeFormular.pfandBox.getSelectedIndex());
   return insertNewProdGr(topID, subID, subsubID, newName, mwstID, pfandID);
 }
Exemple #9
0
 public void secureDelete() {
   int rw = tblItems.getSelectedRow();
   if (rw == -1) {
     JOptionPane.showMessageDialog(frm, "No item selected", "Error", JOptionPane.ERROR_MESSAGE);
     return;
   }
   int idx = tblItems.convertRowIndexToModel(rw);
   if (JOptionPane.showConfirmDialog(
           frm,
           "Delete " + store.plainName(idx) + "?",
           "Confirm Delete",
           JOptionPane.YES_NO_OPTION)
       != JOptionPane.YES_OPTION) return;
   File del = store.delete(idx);
   store.fireTableDataChanged();
   if (del != null) {
     if (del.delete()) {
       // successful
       needsSave = true;
     } else {
       System.err.println("Delete " + del.getAbsolutePath() + " failed");
     }
   }
   updateStatus();
 }
Exemple #10
0
  /**
   * Make the selected line of the table to the given line, if it is displayed. Otherwise a warning
   * message is displayed.
   */
  private void gotoLine() {
    if (gotoTextField.getText().equals("")) {
      return;
    }

    int index = Integer.parseInt(gotoTextField.getText());
    ConstantPoolTableModel model = (ConstantPoolTableModel) table.getModel();

    if (model.isEmpty()) {
      gotoTextField.setText("");
      return;
    }

    if (index < 0 || (model.getFullRowCount() - 1) < index) {
      JOptionPane.showMessageDialog(
          this,
          gotoTextField.getText()
              + " is not in the allowed range [0.."
              + (model.getFullRowCount() - 1)
              + "] !",
          "Warning:",
          JOptionPane.ERROR_MESSAGE);
      gotoTextField.setText("");
      return;
    }

    int indexes[] = model.getIndexes();
    boolean found = false;
    for (int i = 0; i < indexes.length; ++i) {
      if (found = (indexes[i] == index)) {
        table.changeSelection(i, 0, false, false);
        break;
      }
    }

    if (!found) {
      JOptionPane.showMessageDialog(
          this,
          "Index " + gotoTextField.getText() + " is not present in the filtered pool!",
          "Warning:",
          JOptionPane.ERROR_MESSAGE);
      gotoTextField.setText("");
      return;
    }

    gotoTextField.setText("");
  } // gotoLine
Exemple #11
0
  private void Baru() {
    btnSave.setText("Save");
    txtNip.requestFocus();
    txtNip.setText("");

    try {
      Class.forName(KoneksiDatabase.driver);
      java.sql.Connection c =
          DriverManager.getConnection(
              KoneksiDatabase.database, KoneksiDatabase.user, KoneksiDatabase.pass);
      Statement s = c.createStatement();
      String sql = "select * from absensi_lembur";
      ResultSet rs = s.executeQuery(sql);

      final String[] headers = {
        "Kd Absen",
        "NIP",
        "Tgl Absen",
        "Masuk",
        "Pulang",
        "Hari",
        "Tipe Hari",
        "Terlambat",
        "Lembur",
        "Tipe Lembur",
        "Tot Lembur",
        "Tunj Makan",
        "Tunj Transport"
      };
      rs.last();

      int n = rs.getRow();
      Object[][] data = new Object[n][13];
      int p = 0;
      rs.beforeFirst();
      while (rs.next()) {
        data[p][0] = rs.getString(1);
        data[p][1] = rs.getString(2);
        data[p][2] = rs.getString(3);
        data[p][3] = rs.getString(4);
        data[p][4] = rs.getString(5);
        data[p][5] = rs.getString(6);
        data[p][6] = rs.getString(7);
        data[p][7] = rs.getString(8);
        data[p][8] = rs.getString(9);
        data[p][9] = rs.getString(10);
        data[p][10] = rs.getString(11);
        data[p][11] = rs.getString(12);
        data[p][12] = rs.getString(13);
        p++;
      }
      tblLembur.setModel(new DefaultTableModel(data, headers));
      tblLembur.setAlignmentX(CENTER_ALIGNMENT);

    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          null, "Gagal Koneksi, Ada Kesalahan.", "Warning", JOptionPane.WARNING_MESSAGE);
    }
  }
  void find() {
    String query = "";
    try {
      query = m_table.getCriterion();
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(this, ex.getMessage());
      return;
    }

    try {
      HRMBusinessLogic logic = new HRMBusinessLogic(m_conn);
      m_panel.reset(
          logic.getEmployeeByCriteria(m_sessionid, IDBConstants.MODUL_MASTER_DATA, query));
      if (m_panel.m_panel_rptEmployeProfile != null)
        m_panel.m_panel_rptEmployeProfile.m_employee = null;
      else if (m_panel.m_panel_rptPaycheq != null) m_panel.m_panel_rptPaycheq.m_employee = null;
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(this, ex.getMessage(), "Warning", JOptionPane.WARNING_MESSAGE);
    }
  }
    /** Runs this thread. */
    public void run() {
      CommonFileChooser file_chooser = new CommonFileChooser();
      file_chooser.setDialogTitle("Save selected data.");
      file_chooser.setMultiSelectionEnabled(false);

      if (file_chooser.showSaveDialog(pane) == JFileChooser.APPROVE_OPTION) {
        try {
          File file = file_chooser.getSelectedFile();
          if (file.exists()) {
            String message = "Overwrite to " + file.getPath() + " ?";
            if (0
                != JOptionPane.showConfirmDialog(
                    pane, message, "Confirmation", JOptionPane.YES_NO_OPTION)) {
              return;
            }
          }

          AstrometricaWriter writer = new AstrometricaWriter(file);
          writer.open();

          int check_column = getCheckColumn();
          for (int i = 0; i < model.getRowCount(); i++) {
            if (((Boolean) getValueAt(i, check_column)).booleanValue()) {
              Variability record = (Variability) record_list.elementAt(index.get(i));
              writer.write(record.getStar());
            }
          }

          writer.close();

          String message = "Completed.";
          JOptionPane.showMessageDialog(pane, message);
        } catch (IOException exception) {
          String message = "Failed to save file.";
          JOptionPane.showMessageDialog(pane, message, "Error", JOptionPane.ERROR_MESSAGE);
        } catch (UnsupportedStarClassException exception) {
          String message = "Failed to save file.";
          JOptionPane.showMessageDialog(pane, message, "Error", JOptionPane.ERROR_MESSAGE);
        }
      }
    }
Exemple #14
0
    public void actionPerformed(ActionEvent clickEvent) {

      RecorderDialog recorderInfo = new RecorderDialog(parent);

      recorderInfo.show();

      JOptionPane.showMessageDialog(null, "Clock Reset\nrecordingRTP session...");

      stopRTPrecording.setEnabled(true);

      startRTPrecording.setEnabled(false);
    }
    /** Runs this thread. */
    public void run() {
      CommonFileChooser file_chooser = new CommonFileChooser();
      file_chooser.setDialogTitle("Save package file.");
      file_chooser.setMultiSelectionEnabled(false);
      file_chooser.addChoosableFileFilter(new XmlFilter());
      file_chooser.setSelectedFile(new File("package.xml"));

      if (file_chooser.showSaveDialog(pane) == JFileChooser.APPROVE_OPTION) {
        try {
          File file = file_chooser.getSelectedFile();
          if (file.exists()) {
            String message = "Overwrite to " + file.getPath() + " ?";
            if (0
                != JOptionPane.showConfirmDialog(
                    pane, message, "Confirmation", JOptionPane.YES_NO_OPTION)) {
              return;
            }
          }

          // Outputs the variability XML file.

          XmlVariabilityHolder holder = new XmlVariabilityHolder();

          Variability[] records = getSelectedRecords();
          for (int i = 0; i < records.length; i++) {
            XmlVariability variability = new XmlVariability(records[i]);
            holder.addVariability(variability);
          }

          holder.write(file);

          String message = "Completed.";
          JOptionPane.showMessageDialog(pane, message);
        } catch (IOException exception) {
          String message = "Failed.";
          JOptionPane.showMessageDialog(pane, message, "Error", JOptionPane.ERROR_MESSAGE);
        }
      }
    }
Exemple #16
0
 public void secureMove() {
   int rw = tblItems.getSelectedRow();
   if (rw == -1) {
     JOptionPane.showMessageDialog(frm, "No item selected", "Error", JOptionPane.ERROR_MESSAGE);
     return;
   }
   int idx = tblItems.convertRowIndexToModel(rw);
   String[] opts = new String[storeLocs.size()];
   for (int i = 0; i < opts.length; i++) opts[i] = storeLocs.get(i).getAbsolutePath();
   JComboBox cmbMove = new JComboBox(opts);
   cmbMove.setSelectedIndex(store.curStore(idx));
   if (JOptionPane.showConfirmDialog(frm, cmbMove, "Move item", JOptionPane.OK_CANCEL_OPTION)
       != JOptionPane.OK_OPTION) return;
   File newLoc = store.move(idx, cmbMove.getSelectedIndex());
   if (newLoc == null) System.err.println("move " + store.plainName(idx) + " unsuccessful");
   else needsSave = true;
 }
  void okButton_actionPerformed(ActionEvent e) {
    int num_rows = filtersTable.getRowCount();
    EditableDefinablePlugin edp = m_data.getPlugin();
    for (int row = 0; row < num_rows; row++) {
      String mimeType = (String) filtersTable.getValueAt(row, 0);
      String mimeTypeValue = (String) filtersTable.getValueAt(row, 1);

      try {
        mimeTypeEditorBuilder.checkValue(edp, mimeType, mimeTypeValue);
      } catch (DynamicallyLoadedComponentException dlce) {
        String logMessage =
            "Failed to set the "
                + mimeTypeEditorBuilder.getValueName()
                + " for MIME type "
                + mimeType
                + " to "
                + mimeTypeValue;
        logger.error(logMessage, dlce);
        if (!EDPInspectorTableModel.handleDynamicallyLoadedComponentException(this, dlce)) {
          return;
        } else {
          logger.debug("User override; allow " + mimeTypeValue);
        }
      }
    }
    mimeTypeEditorBuilder.clear(edp);
    for (int row = 0; row < num_rows; row++) {
      String mimeType = (String) filtersTable.getValueAt(row, 0);
      String mimeTypeValue = (String) filtersTable.getValueAt(row, 1);

      try {
        mimeTypeEditorBuilder.put(edp, mimeType, mimeTypeValue);
      } catch (DynamicallyLoadedComponentException dlce) {
        String logMessage =
            "Internal error; MIME type " + mimeType + " not set to " + mimeTypeValue;
        logger.error(logMessage, dlce);
      } catch (PluginException.InvalidDefinition ex) {
        JOptionPane.showMessageDialog(
            this,
            ex.getMessage(),
            WordUtils.capitalize(mimeTypeEditorBuilder.getValueName()) + " Warning",
            JOptionPane.WARNING_MESSAGE);
      }
    }
    setVisible(false);
  }
 /**
  * * Each non abstract class that implements the ActionListener must have this method.
  *
  * @param e the action event.
  */
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == submitButton) {
     int result = submit();
     if (result == 0) {
       JOptionPane.showMessageDialog(
           this,
           "Fehler: Produktgruppe "
               + produktgruppeFormular.nameField.getText()
               + " konnte nicht eingefügt werden.",
           "Fehler",
           JOptionPane.ERROR_MESSAGE);
     } else {
       produktgruppenListe.updateAll();
       closeButton.doClick();
     }
     return;
   }
   super.actionPerformed(e);
 }
 public MimeTypeEditor(
     MimeTypeEditorBuilder mimeTypeEditorBuilder, Frame frame, String title, boolean modal) {
   super(frame, title, modal);
   this.mimeTypeEditorBuilder = mimeTypeEditorBuilder;
   this.m_model = new MimeTypeTableModel();
   try {
     jbInit();
     pack();
   } catch (Exception exc) {
     String logMessage =
         "Could not set up the " + mimeTypeEditorBuilder.getValueName() + " editor";
     logger.critical(logMessage, exc);
     JOptionPane.showMessageDialog(
         frame,
         logMessage,
         WordUtils.capitalize(mimeTypeEditorBuilder.getValueName()) + " Editor",
         JOptionPane.ERROR_MESSAGE);
   }
 }
Exemple #20
0
  public TableDeneme() {
    super("Dictionary Window");
    qtm = new QueryTableModel();
    table = new JTable(qtm);
    scrollpane = new JScrollPane(table);
    p1 = new JPanel();
    jb = new JButton("get em all");
    p1.add(jb);

    getContentPane().add(p1, BorderLayout.NORTH);
    getContentPane().add(scrollpane, BorderLayout.CENTER);
    addWindowListener(new BasicWindowMonitor());
    setSize(500, 500);
    setVisible(true);

    JOptionPane.showMessageDialog(
        new Frame(),
        "Press the button,\n"
            + "It will fill the table with all records.\n"
            + "Then you can edit the cells.\n"
            + "When you select another cell, the previous one will updated.\n\n"
            + "*****@*****.**");

    /**
     * ****show selection***** table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); rowSM =
     * table.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener(){ public
     * void valueChanged(ListSelectionEvent e){ if (e.getValueIsAdjusting()) return;
     * ListSelectionModel lsm = (ListSelectionModel)e.getSource(); if (lsm.isSelectionEmpty()){
     * System.out.println("No rows are selected."); } else{
     * System.out.println(table.getValueAt(table.getSelectionModel().getMinSelectionIndex(),0));
     * System.out.println(table.getValueAt(table.getSelectionModel().getMinSelectionIndex(),1)); } }
     * }); ********************
     */
    jb.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            qtm.setHostURL(
                "jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);UID=admin;UserCommitSync=Yes;Threads=3;SafeTransactions=0;PageTimeout=5;MaxScanRows=8;MaxBufferSize=2048;FIL=MS Access;DriverId=281;DBQ=db1.mdb");
            qtm.setQuery("select * from soz");
          }
        });
  }
Exemple #21
0
  /** Finds the previous occurance of the given string in the 3rd column of the table. */
  private void findPrev() {
    String infix = findTextField.getText();
    if (infix.equals("")) {
      return;
    }

    if (!matchCase) {
      infix = infix.toLowerCase();
    }

    String desc[] = ((ConstantPoolTableModel) table.getModel()).getDescriptions();
    if (null == desc) {
      return;
    }

    if (table.getSelectedRowCount() != 0) {
      actIndex = table.getSelectedRow();
    }

    int rows = ((ConstantPoolTableModel) table.getModel()).getRowCount();
    boolean found = false, end = false;
    int start = actIndex;

    while (!end && !found) {
      if (0 < actIndex) {
        actIndex--;
      } else {
        actIndex = (rows - 1);
      }

      found = desc[actIndex].toLowerCase().contains(infix);
      end = (start == actIndex) && !found;
    }

    if (found) {
      table.changeSelection(actIndex, 0, false, false);
    } else if (end) {
      Toolkit.getDefaultToolkit().beep();
      JOptionPane.showMessageDialog(
          this, "String " + infix + " was not found.", "Alert:", JOptionPane.ERROR_MESSAGE);
    }
  } // findPrev
Exemple #22
0
 public void genSeed(ActionEvent e) {
   long seed = 0;
   boolean redo = false;
   do {
     redo = false;
     String seedString =
         JOptionPane.showInputDialog(
             this, "Enter a number:", Long.toString(rand.nextLong(), 36)
             // "Random Seed", JOptionPane.QUESTION_MESSAGE
             );
     if (seedString == null) return;
     try {
       seed = Long.parseLong(seedString, 36);
     } catch (NumberFormatException ex) {
       JOptionPane.showMessageDialog(this, "Use only letters and numbers, max 12 characters.");
       redo = true;
     }
   } while (redo);
   genSeed(seed);
 }
Exemple #23
0
  @SuppressWarnings("unused")
  @Override
  public void mouseClicked(MouseEvent e) {
    int iDongDaChon = jRoom.getSelectedRow();
    if (iDongDaChon == -1) {
      JOptionPane.showMessageDialog(this, "you select 1 row");
    } else {
      buttonDelete.setVisible(true);
      buttonUpdate.setEnabled(true);
      Vector vDongDaChon = (Vector) tableRecords.get(iDongDaChon);
      IDROOM = Integer.parseInt(vDongDaChon.get(0).toString());
      String roomNumber = vDongDaChon.get(1).toString();
      String roomType = vDongDaChon.get(2).toString();
      String numBeds = vDongDaChon.get(3).toString();
      String roomTypeRate = vDongDaChon.get(4).toString();
      String roomStatus = vDongDaChon.get(5).toString();
      String des = vDongDaChon.get(6).toString();

      txtRoomNumber.setText(roomNumber);
      boxRoomTypeID.setSelectedItem(roomType.toString());
      boxRoomStatusID.setSelectedItem(roomStatus.toString());
      txtDescription.setText(des);
      try {
        List<CheckIn> temp = CheckInController.checkInController.all();
        for (int i = 0; i < temp.size(); i++) {
          if (IDROOM == temp.get(i).getRoomID()) {
            this.error = 0;
            buttonUpdate.setEnabled(false);
            buttonDelete.setEnabled(false);
            break;
          } else {
            this.error = 0;
            buttonUpdate.setEnabled(true);
            buttonDelete.setEnabled(true);
          }
        }
      } catch (Exception e2) {
        e2.printStackTrace();
      }
    }
  }
  public void actionPerformed(ActionEvent e) {
    JButton b = (JButton) e.getSource();
    if (b == bu) {
      j14 = new JLabel("NEW IMAGE");
      j14.setBounds(840, 200, 300, 300);
      q.add(j14);

      JFileChooser filechooser = new JFileChooser();
      int result = filechooser.showOpenDialog(this);
      f = filechooser.getSelectedFile();
      try {
        String dir1 = f.getAbsolutePath();
        // setText(dir);
        str = dir1;
        // ResizeImage.resize(dir);
        f = new File(dir1);
      } catch (Exception e1) {
      }
      repaint();
      // b=(JButton)e.getSource();

    }
    if (b == ba) {
      try {
        read();
        patient.add(tadd.getText(), tsym.getText(), f, str);
        JOptionPane.showMessageDialog(null, "Patient ID: " + patient.pid + " Record Added");
      } catch (Exception e4) {
        System.out.println("" + e4);
      }
    }
    if (b == bm) {
      try {
        setVisible(false);
      } catch (Exception e4) {
        System.out.println("" + e4);
      }
    }
  }
Exemple #25
0
 @Override
 public void mouseClicked(MouseEvent e) {
   // TODO Auto-generated method stub
   if (e.getSource() == table) {
     if (e.getClickCount() == 2) {
       int row = table.getSelectedRow();
       String sabun = model.getValueAt(row, 0).toString();
       EmpDAO dao = new EmpDAO();
       EmpDTO d = dao.empDetailData(Integer.parseInt(sabun));
       String msg =
           "사번:"
               + d.getEmpno()
               + "\n"
               + "이름:"
               + d.getEname()
               + "\n"
               + "직위:"
               + d.getJob()
               + "\n"
               + "사수번호:"
               + d.getMgr()
               + "\n"
               + "입사일:"
               + d.getHiredate().toString()
               + "\n"
               + "급여:"
               + d.getSal()
               + "\n"
               + "성과급:"
               + d.getComm()
               + "\n"
               + "부서번호:"
               + d.getDeptno();
       JOptionPane.showMessageDialog(this, msg);
     }
   }
 }
      public void tableChanged(TableModelEvent tme) {
        int baris = tme.getFirstRow();
        int kolom = tme.getColumn();

        TableModel model = (TableModel) tme.getSource();
        int id = (Integer) model.getValueAt(baris, 0);

        String query = "";
        switch (kolom) {
          case 1:
            String nama = (String) model.getValueAt(baris, kolom);
            query = "UPDATE produk SET nama_produk='" + nama + "' WHERE id_produk=" + id;
            prosesEdit(query);
            break;
          case 2:
            String jenis = (String) model.getValueAt(baris, kolom);
            try {
              query = "select * from jenis where nama_jenis='" + jenis + "'";
              ResultSet rs = stm.executeQuery(query);
              if (rs.next()) {
                int idJenis = rs.getInt("id_jenis");
                query = "UPDATE produk SET id_jenis=" + idJenis + " WHERE id_produk=" + id;
                prosesEdit(query);
              } else {
                setDataTabel();
                JOptionPane.showMessageDialog(null, "gagal,jenis tidak ada");
              }
            } catch (SQLException SQLerr) {
              SQLerr.printStackTrace();
            }
            break;
          case 3:
            int stok = (Integer) model.getValueAt(baris, kolom);
            query = "UPDATE `stok_produk` SET stok=" + stok + " WHERE id_produk=" + id;
            prosesEdit(query);
            break;
          case 4:
            int harga = (Integer) model.getValueAt(baris, kolom);
            query = "UPDATE produk SET harga=" + harga + " WHERE id_produk=" + id;
            prosesEdit(query);
            break;
          case 5:
            String suplier = (String) model.getValueAt(baris, kolom);
            try {
              query = "SELECT * FROM suplier WHERE nama_suplier='" + suplier + "'";
              ResultSet rs = stm.executeQuery(query);
              if (rs.next()) {
                int idSuplier = rs.getInt("id_suplier");
                query = "UPDATE produk SET id_suplier=" + idSuplier + " WHERE id_produk=" + id;
                prosesEdit(query);
              } else {
                setDataTabel();
                JOptionPane.showMessageDialog(null, "gagal,suplier belum terdaftar");
              }
            } catch (SQLException SQLerr) {
              SQLerr.printStackTrace();
            }
            break;
          default:
            break;
        }
      }
  // Method:
  private void populateData() {

    textpadSeq_ = new RCT.TextpadMsgHistSeqHolder();
    data_ = new Object[0][0];

    if (ARCH_SEL_TODAY == selectionType_) {

      // Get today's date
      Date now = new Date();
      Calendar cal = Calendar.getInstance();
      cal.setTime(now);
      int day = cal.get(Calendar.DAY_OF_MONTH);
      int month = cal.get(Calendar.MONTH) + 1;
      int year = cal.get(Calendar.YEAR);

      String fromDate = year + "-" + month + "-" + day + " 00:00:00";

      String toDate = year + "-" + month + "-" + day + " 23:59:59";

      try {

        TeamModule.getTextpadArchiveTimeRange(className_, teamName_, fromDate, toDate, textpadSeq_);
      } catch (RCT.TeamServerPackage.DataSelectionExceedsLimit dsel) {

        JOptionPane.showMessageDialog(
            SessionModule.getFrame(),
            LangModule.i18n.getString("ExceptionDialog3"),
            LangModule.i18n.getString("ExceptionDialog1"),
            JOptionPane.WARNING_MESSAGE);
        return;
      }
    } else if (ARCH_SEL_TIMERANGE == selectionType_) {

      try {

        TeamModule.getTextpadArchiveTimeRange(
            className_, teamName_, fromDate_, toDate_, textpadSeq_);
      } catch (RCT.TeamServerPackage.DataSelectionExceedsLimit dsel) {

        JOptionPane.showMessageDialog(
            SessionModule.getFrame(),
            LangModule.i18n.getString("ExceptionDialog3"),
            LangModule.i18n.getString("ExceptionDialog1"),
            JOptionPane.WARNING_MESSAGE);
        return;
      }
    }

    // Check if we received any textpads
    if (0 < textpadSeq_.value.length) {

      data_ = new Object[textpadSeq_.value.length][TEXTPAD_N_FIELDS];

      for (int i = 0; i < textpadSeq_.value.length; i++) {

        data_[i][TEXTPAD_ID] = textpadSeq_.value[i].id;
        data_[i][TEXTPAD_NAME] = textpadSeq_.value[i].name;
        data_[i][TEXTPAD_DATE] = Utility.getDateAndTime(textpadSeq_.value[i].date);
      }
    }
  }
Exemple #28
0
  public void setContent(String cat) {
    cat = cat.trim();
    selectAllCB.setVisible(false);
    selectAllCB.setSelected(false);
    deleteBut.setVisible(false);
    restoreBut.setVisible(false);
    refreshBut.setVisible(true);
    Object columns[] = null;
    int count = 0;
    switch (cat) {
      case "Inbox":
        columns = new Object[] {"", "From", "Date", "Subject", "Content"};
        count = Database.getCount("Inbox");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id desc");
        ;
        break;
      case "SentMail":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Sentmail");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id desc");
        break;
      case "Draft":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Draft");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id desc");
        break;
      case "Outbox":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Outbox");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id desc");
        break;
      case "Trash":
        //                restoreBut.setVisible(true);
        columns = new Object[] {"", "To/From", "Date", "Subject", "Content"};
        count = Database.getCount("Trash");
        workingSet =
            db.getData(
                "SELECT * FROM messages,trash WHERE messages.tag='trash' and messages.msg_id=trash.msg_id ORDER BY deleted_at desc");
        break;
      default:
        System.out.println("in default case");
    }
    if (count > 0) {
      selectAllCB.setVisible(true);
      rows = new Object[count][];
      msgID = new int[count];
      try {
        workingSet.beforeFirst();
        for (int i = 0; i < count && workingSet.next(); i++) {
          msgID[i] = workingSet.getInt(1);
          rows[i] =
              new Object[] {
                false,
                workingSet.getString(2),
                workingSet.getDate(3),
                workingSet.getString(4),
                workingSet.getString(5)
              };
        }
      } catch (SQLException sqlExc) {
        JOptionPane.showMessageDialog(null, sqlExc, "EXCEPTION", JOptionPane.ERROR_MESSAGE);
        sqlExc.printStackTrace();
      }

      tableModel = new MyDefaultTableModel(rows, columns);
      table = new JTable(tableModel);
      table.getSelectionModel().addListSelectionListener(this);
      table.addMouseListener(this);
      table.getTableHeader().setOpaque(true);
      table.getTableHeader().setReorderingAllowed(false);
      //            table.getTableHeader().setBackground(Color.blue);
      table.getTableHeader().setForeground(Color.blue);
      //        table.setRowSelectionAllowed(false);
      //            table.setColumnSelectionAllowed(false);
      table.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14));
      table.setRowHeight(20);
      table.setFillsViewportHeight(true);

      TableColumn column = null;
      for (int i = 0; i < 5; i++) {
        column = table.getColumnModel().getColumn(i);
        if (i == 0) {
          column.setPreferredWidth(6);
        } else if (i == 3) {
          column.setPreferredWidth(250);
        } else if (i == 4) {
          column.setPreferredWidth(450);
        } else {
          column.setPreferredWidth(40);
        }
      }
      table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

      remove(contentPan);
      contentPan = new JScrollPane(table);
      contentPan.setBackground(Color.orange);
      contentPan.setOpaque(true);
      contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      add(contentPan, "Center");
      Home.home.homeFrame.setVisible(true);
    } else {
      JPanel centPan = new JPanel(new GridBagLayout());
      centPan.setBackground(new Color(52, 86, 70));
      JLabel label = new JLabel("No Messages In This Category");
      label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 22));
      label.setForeground(Color.orange);
      centPan.add(label);
      remove(contentPan);
      contentPan = new JScrollPane(centPan);
      contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      add(contentPan, "Center");
      contentPan.repaint();
    }
  }
Exemple #29
0
  public Ssys3() {
    store = new Storage();
    tableSorter = new TableRowSorter<Storage>(store);
    jobs = new LinkedList<String>();

    makeGUI();
    frm.setSize(800, 600);
    frm.addWindowListener(
        new WindowListener() {
          public void windowActivated(WindowEvent evt) {}

          public void windowClosed(WindowEvent evt) {
            try {
              System.out.println("joining EDT's");
              for (EDT edt : encryptDecryptThreads) {
                edt.weakStop();
                try {
                  edt.join();
                  System.out.println("  - joined");
                } catch (InterruptedException e) {
                  System.out.println("  - Not joined");
                }
              }
              System.out.println("saving storage");
              store.saveAll(tempLoc);
            } catch (IOException e) {
              e.printStackTrace();
              System.err.println(
                  "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nFailed to save properly\n\n!!!!!!!!!!!!!!!!!!!!!!!!!");
              System.exit(1);
            }
            clean();
            System.exit(0);
          }

          public void windowClosing(WindowEvent evt) {
            windowClosed(evt);
          }

          public void windowDeactivated(WindowEvent evt) {}

          public void windowDeiconified(WindowEvent evt) {}

          public void windowIconified(WindowEvent evt) {}

          public void windowOpened(WindowEvent evt) {}
        });
    ImageIcon ico = new ImageIcon(ICON_NAME);
    frm.setIconImage(ico.getImage());
    frm.setLocationRelativeTo(null);
    frm.setVisible(true);

    // load config
    storeLocs = new ArrayList<File>();
    String ossl = "openssl";
    int numThreadTemp = 2;
    boolean priorityDecryptTemp = true;
    boolean allowExportTemp = false;
    boolean checkImportTemp = true;
    try {
      Scanner sca = new Scanner(CONF_FILE);
      while (sca.hasNextLine()) {
        String ln = sca.nextLine();
        if (ln.startsWith(CONF_SSL)) {
          ossl = ln.substring(CONF_SSL.length());
        } else if (ln.startsWith(CONF_THREAD)) {
          try {
            numThreadTemp = Integer.parseInt(ln.substring(CONF_THREAD.length()));
          } catch (Exception exc) {
            // do Nothing
          }
        } else if (ln.equals(CONF_STORE)) {
          while (sca.hasNextLine()) storeLocs.add(new File(sca.nextLine()));
        } else if (ln.startsWith(CONF_PRIORITY)) {
          try {
            priorityDecryptTemp = Boolean.parseBoolean(ln.substring(CONF_PRIORITY.length()));
          } catch (Exception exc) {
            // do Nothing
          }
        } else if (ln.startsWith(CONF_EXPORT)) {
          try {
            allowExportTemp = Boolean.parseBoolean(ln.substring(CONF_EXPORT.length()));
          } catch (Exception exc) {
            // do Nothing
          }
        } else if (ln.startsWith(CONF_CONFIRM)) {
          try {
            checkImportTemp = Boolean.parseBoolean(ln.substring(CONF_CONFIRM.length()));
          } catch (Exception exc) {
            // do Nothing
          }
        }
      }
      sca.close();
    } catch (IOException e) {

    }
    String osslWorks = OpenSSLCommander.test(ossl);
    while (osslWorks == null) {
      ossl =
          JOptionPane.showInputDialog(
              frm,
              "Please input the command used to run open ssl\n  We will run \"<command> version\" to confirm\n  Previous command: "
                  + ossl,
              "Find open ssl",
              JOptionPane.OK_CANCEL_OPTION);
      if (ossl == null) {
        System.err.println("Refused to provide openssl executable location");
        System.exit(1);
      }
      osslWorks = OpenSSLCommander.test(ossl);
      if (osslWorks == null)
        JOptionPane.showMessageDialog(
            frm, "Command " + ossl + " unsuccessful", "Unsuccessful", JOptionPane.ERROR_MESSAGE);
    }
    if (storeLocs.size() < 1)
      JOptionPane.showMessageDialog(
          frm,
          "Please select an initial sotrage location\nIf one already exists, or there are more than one, please select it");
    while (storeLocs.size() < 1) {
      JFileChooser jfc = new JFileChooser();
      jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      if (jfc.showOpenDialog(frm) != JFileChooser.APPROVE_OPTION) {
        System.err.println("Refused to provide an initial store folder");
        System.exit(1);
      }
      File sel = jfc.getSelectedFile();
      if (sel.isDirectory()) storeLocs.add(sel);
    }
    numThreads = numThreadTemp;
    priorityExport = priorityDecryptTemp;
    allowExport = allowExportTemp;
    checkImports = checkImportTemp;

    try {
      PrintWriter pw = new PrintWriter(CONF_FILE);
      pw.println(CONF_SSL + ossl);
      pw.println(CONF_THREAD + numThreads);
      pw.println(CONF_PRIORITY + priorityExport);
      pw.println(CONF_EXPORT + allowExport);
      pw.println(CONF_CONFIRM + checkImports);
      pw.println(CONF_STORE);
      for (File fi : storeLocs) {
        pw.println(fi.getAbsolutePath());
      }
      pw.close();
    } catch (IOException e) {
      System.err.println("Failed to save config");
    }

    File chk = null;
    for (File fi : storeLocs) {
      File lib = new File(fi, LIBRARY_NAME);
      if (lib.exists()) {
        chk = lib;
        // break;
      }
    }

    char[] pass = null;
    if (chk == null) {
      JOptionPane.showMessageDialog(
          frm,
          "First time run\n  Create your password",
          "Create Password",
          JOptionPane.INFORMATION_MESSAGE);
      char[] p1 = askPassword();
      char[] p2 = askPassword();
      boolean same = p1.length == p2.length;
      for (int i = 0; i < Math.min(p1.length, p2.length); i++) {
        if (p1[i] != p2[i]) same = false;
      }
      if (same) {
        JOptionPane.showMessageDialog(
            frm, "Password created", "Create Password", JOptionPane.INFORMATION_MESSAGE);
        pass = p1;
      } else {
        JOptionPane.showMessageDialog(
            frm, "Passwords dont match", "Create Password", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
      }
    } else {
      pass = askPassword();
    }
    sec = OpenSSLCommander.getCommander(chk, pass, ossl);
    if (sec == null) {
      System.err.println("Wrong Password");
      System.exit(1);
    }
    store.useSecurity(sec);
    store.useStorage(storeLocs);

    tempLoc = new File("temp");
    if (!tempLoc.exists()) tempLoc.mkdirs();
    // load stores
    try {
      store.loadAll(tempLoc);
      store.fireTableDataChanged();
    } catch (IOException e) {
      System.err.println("Storage loading failure");
      System.exit(1);
    }

    needsSave = false;
    encryptDecryptThreads = new EDT[numThreads];
    for (int i = 0; i < encryptDecryptThreads.length; i++) {
      encryptDecryptThreads[i] = new EDT(i);
      encryptDecryptThreads[i].start();
    }

    updateStatus();
    txaSearch.grabFocus();
  }
  public void read() {
    try {
      // patient.dt=""+tdt.getText();
      patient.pid = Integer.parseInt(tpid.getText());
      patient.pfnm = tpfnm.getText();
      patient.pmnm = tpmnm.getText();
      patient.plnm = tplnm.getText();
      patient.gen = cbg.getSelectedCheckbox().getLabel();

      try {
        patient.age = Integer.parseInt(tage.getText());
        tage.setText("" + patient.age);

      } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Invalid age inputed.");
        patient.age = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid age:"));
        tage.setText("" + patient.age);
      }

      try {
        int wet = Integer.parseInt(twt.getText());
        twt.setText("" + wet);
      } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Invalid weight inputed.");
        int wet = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid weight:"));
        twt.setText("" + wet);
      }
      patient.wt = twt.getText();
      patient.addr = tadd.getText();
      this.ad = tadd.getText();
      System.out.println(tadd.getText());

      while (true) {
        patient.cno = tcno.getText();
        if (patient.cno.length() == 10) break;
        else {
          JOptionPane.showMessageDialog(null, "Invalid Phone No.");
          patient.cno = JOptionPane.showInputDialog("Please enter valid 10-digit Phone No.:");
          tcno.setText(patient.cno);
        }
      }
      patient.dnm = tdnm.getText();
      patient.sym = tsym.getText();
      System.out.println(tsym.getText());

      patient.dig = tdig.getText();
      try {
        patient.fee = Integer.parseInt(tfee.getText());
        tfee.setText("" + patient.fee);

      } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Invalid Fee inputed.");
        patient.fee = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid Fee:"));
        tfee.setText("" + patient.fee);
      }

      patient.bg = tbg.getText();
      patient.path = str;
    } catch (Exception e) {
    }
  }