Afzzal87

Untitled

Jul 6th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. private void btnSimpanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSimpanActionPerformed
  2. // TODO add your handling code here:
  3. if (txtNoPol.getText().isEmpty()) {
  4. JOptionPane.showMessageDialog(this, "Nomor polisi belum diisi!");
  5. } else if (cbJenis.getSelectedItem().equals("-Pilih Jenis Kendaraan-")) {
  6. JOptionPane.showMessageDialog(this, "Jenis kendaraan belum dipilih");
  7. } else {
  8. String nopol, jenis, sql;
  9. nopol = txtNoPol.getText();
  10. jenis = cbJenis.getSelectedItem().toString();
  11.  
  12. sql = "INSERT INTO tb_parkir(no_pol,jenis,tgl_masuk,jam_masuk)"
  13. + "VALUES('"+nopol+"','"+jenis+"',CURDATE(),CURTIME())";
  14. try{
  15. konek.st = konek.conn.createStatement();
  16. konek.st.execute(sql);
  17. }
  18. catch (SQLException e){
  19. JOptionPane.showMessageDialog(this, "Data gagal disimpan"+e);
  20. return;
  21. }
  22. JOptionPane.showMessageDialog(this, "Data berhasil disimpan");
  23. }
  24. resetAll();
  25. tampil_masuk();
  26. tampil_keluar();
  27. }//GEN-LAST:event_btnSimpanActionPerformed
Advertisement
Add Comment
Please, Sign In to add comment