Afzzal87

Untitled

Jul 6th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.43 KB | None | 0 0
  1. *
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package parQr;
  7. import java.awt.Color;
  8. import java.awt.Dimension;
  9. import java.awt.Toolkit;
  10. import java.sql.Connection;
  11. import java.sql.ResultSet;
  12. import java.sql.SQLException;
  13. import java.sql.Statement;
  14. import javax.swing.JOptionPane;
  15.  
  16.  
  17.  
  18. /**
  19. *
  20. * @author EZHAKOVA1687
  21. */
  22. public class fLogin extends javax.swing.JFrame {
  23. koneksi konek = new koneksi();
  24.  
  25. /**
  26. * Creates new form fLogin
  27. */
  28. public fLogin() {
  29. initComponents();
  30. konek.koneksi();
  31.  
  32. //rata kanan kiri
  33. Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  34. Dimension frameSize = getSize();
  35. setLocation ((screenSize.width - frameSize.width)/2,
  36. (screenSize.height - frameSize.height)/3);
  37. }
  38.  
  39. /**
  40. * This method is called from within the constructor to initialize the form.
  41. * WARNING: Do NOT modify this code. The content of this method is always
  42. * regenerated by the Form Editor.
  43. */
  44. private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoginActionPerformed
  45. // TODO add your handling code here:
  46. try {
  47. String sql = "SELECT * FROM tb_pengelola WHERE username = '" + txtUsername.getText() + "' AND password = '" + passwordField.getText() + "'";
  48. konek.st = konek.conn.createStatement();
  49. konek.rs = konek.st.executeQuery(sql);
  50.  
  51. konek.rs.next();
  52. konek.rs.last(); //mengecek jumlah baris pada hasil query
  53. if (konek.rs.getRow()==1){
  54. JOptionPane.showMessageDialog(null, "Unlock Succes!");
  55. new fParkir().setVisible(true); //<-- BILA MAU DIARAHKAN KE Frame Menu Utama
  56. this.dispose();
  57. } else {
  58. JOptionPane.showMessageDialog(null, "Sorry,Failed please try again!");
  59. passwordField.setText("");
  60. passwordField.requestFocus();
  61. }
  62. } catch (SQLException e) {
  63. }
  64. }//GEN-LAST:event_btnLoginActionPerformed
  65.  
  66. private void txtUsernameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtUsernameActionPerformed
  67. // TODO add your handling code here:
  68. }//GEN-LAST:event_txtUsernameActionPerformed
  69.  
  70. private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
  71. // TODO add your handling code here:
  72. int selectedOption = JOptionPane.showConfirmDialog(null,
  73. " Ready To Close System?", "Close Program ParQrest", JOptionPane.YES_NO_OPTION);
  74. if (selectedOption == JOptionPane.YES_OPTION) {
  75. System.exit(0);
  76. }
  77. }//GEN-LAST:event_btnCancelActionPerformed
  78.  
  79. /**
  80. * @param args the command line arguments
  81. */
  82. public static void main(String args[]) {
  83. /* Set the Nimbus look and feel */
  84. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  85. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  86. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  87. */
  88. try {
  89. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  90. if ("Nimbus".equals(info.getName())) {
  91. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  92. break;
  93. }
  94. }
  95. } catch (ClassNotFoundException ex) {
  96. java.util.logging.Logger.getLogger(fLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  97. } catch (InstantiationException ex) {
  98. java.util.logging.Logger.getLogger(fLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  99. } catch (IllegalAccessException ex) {
  100. java.util.logging.Logger.getLogger(fLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  101. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  102. java.util.logging.Logger.getLogger(fLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  103. }
  104. //</editor-fold>
  105. //</editor-fold>
  106.  
  107. /* Create and display the form */
  108. java.awt.EventQueue.invokeLater(new Runnable() {
  109. public void run() {
  110. new fLogin().setVisible(true);
  111. }
  112. });
  113. }
  114.  
  115. // Variables declaration - do not modify//GEN-BEGIN:variables
  116. private javax.swing.JButton btnCancel;
  117. private javax.swing.JButton btnLogin;
  118. private javax.swing.JLabel jLabel1;
  119. private javax.swing.JLabel jLabel2;
  120. private javax.swing.JLabel jLabel3;
  121. private javax.swing.JLabel jLabel4;
  122. private javax.swing.JLabel jLabel5;
  123. private javax.swing.JLabel jLabel6;
  124. private javax.swing.JLabel jLabel7;
  125. private javax.swing.JLabel jLabel8;
  126. private javax.swing.JLabel jLabel9;
  127. private javax.swing.JPanel jPanel1;
  128. private javax.swing.JPanel jPanel2;
  129. private javax.swing.JPanel jPanel3;
  130. private javax.swing.JPasswordField passwordField;
  131. private javax.swing.JTextField txtUsername;
  132. // End of variables declaration//GEN-END:variables
  133. }
Advertisement
Add Comment
Please, Sign In to add comment