document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.  void CekKode() {
  2.         KodeOtomatis();
  3.         jTextField1.setText("PB-" + jTextField1.getText() + "");
  4.         jTextField2.requestFocus();
  5.     }
  6.  
  7.     void KodeOtomatis() {
  8.         try {
  9.             Connection c = koneksi.getkoneksi();
  10.             Statement stm = c.createStatement();
  11.             ResultSet rsdata = stm.executeQuery("SELECT * FROM beli ORDER BY id_pb DESC");
  12.  
  13.             if (rsdata.next()) {
  14.                 String id_divisi = (rsdata.getString("id_pb"));
  15.                 double nilai1 = Double.parseDouble(id_divisi);
  16.                 DecimalFormat df = new DecimalFormat("#.##");
  17.                 this.jTextField1.setText(df.format(nilai1 + 1));
  18.                 PaketUbahKode();
  19.                 jTextField1.setEnabled(false);
  20.                 jTextField2.requestFocus();
  21.  
  22.             } else {
  23.                 jTextField1.setText("1");
  24.                 PaketUbahKode();
  25.                 jTextField1.setEnabled(false);
  26.                 jTextField2.requestFocus();
  27.             }
  28.         } catch (Exception ex) {
  29.             JOptionPane.showMessageDialog(null, "QUERY ERROR" + ex, "ERROR",
  30.                     JOptionPane.ERROR_MESSAGE);
  31.         }
  32.     }
  33.  
  34.     void SimpanUbahKode() {
  35.         try {
  36.             Connection c = koneksi.getkoneksi();
  37.             Statement stm = c.createStatement();
  38.             stm.executeUpdate("INSERT INTO ubah_kode SET kode=\'" + jTextField1.getText() + "\'");
  39.  
  40.         } catch (Exception e) {
  41.             JOptionPane.showMessageDialog(null, "Error." + e);
  42.         }
  43.     }
  44.  
  45.     void TampilUbahKode() {
  46.         try {
  47.             Connection c = koneksi.getkoneksi();
  48.             Statement stm = c.createStatement();
  49.             Statement stm1 = c.createStatement();
  50.             ResultSet rsdata = stm.executeQuery("SELECT * FROM ubah_kode");
  51.             if (rsdata.next()) {
  52.                 jTextField1.setText(rsdata.getString("kode"));
  53.                 stm1.executeUpdate("DELETE FROM ubah_kode");
  54.             }
  55.         } catch (Exception ex) {
  56.             JOptionPane.showMessageDialog(null, "QUERY ERROR" + ex, "ERROR",
  57.                     JOptionPane.ERROR_MESSAGE);
  58.         }
  59.     }
  60.  
  61.     void PaketUbahKode() {
  62.         SimpanUbahKode();
  63.         TampilUbahKode();
  64.  
  65.     }
');