Advertisement
Guest User

backup colombus source code

a guest
May 30th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 coloumbus;
  7.  
  8. import java.sql.ResultSet;
  9. import java.sql.Statement;
  10. import javax.swing.ImageIcon;
  11. import javax.swing.JOptionPane;
  12. import koneksi.config;
  13.  
  14. /**
  15.  *
  16.  * @author server2
  17.  */
  18. public class login extends javax.swing.JFrame {
  19.  
  20.     /**
  21.      * Creates new form login
  22.      */
  23.     public login() {
  24.         initComponents();
  25.         ImageIcon ico = new ImageIcon ("src/coloumbus/logo.jpeg");
  26.         setIconImage(ico.getImage());
  27.         setResizable(false);
  28.     }
  29.  
  30.     /**
  31.      * This method is called from within the constructor to initialize the form.
  32.      * WARNING: Do NOT modify this code. The content of this method is always
  33.      * regenerated by the Form Editor.
  34.      */
  35.     @SuppressWarnings("unchecked")
  36.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  37.     private void initComponents() {
  38.  
  39.         jLabel4 = new javax.swing.JLabel();
  40.         jPanel1 = new javax.swing.JPanel();
  41.         jLabel1 = new javax.swing.JLabel();
  42.         jPanel2 = new javax.swing.JPanel();
  43.         jLabel2 = new javax.swing.JLabel();
  44.         jLabel3 = new javax.swing.JLabel();
  45.         tusername = new javax.swing.JTextField();
  46.         tpassword = new javax.swing.JPasswordField();
  47.         jButton1 = new javax.swing.JButton();
  48.         jLabel5 = new javax.swing.JLabel();
  49.  
  50.         jLabel4.setText("jLabel4");
  51.  
  52.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  53.         setTitle("Coloumbus : Form Login - Copy Right @2017 | Iqbal Fasyah");
  54.  
  55.         jPanel1.setBackground(new java.awt.Color(255, 102, 51));
  56.  
  57.         jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
  58.         jLabel1.setForeground(new java.awt.Color(255, 204, 51));
  59.         jLabel1.setText("COLUMBUS : Form Login");
  60.  
  61.         jPanel2.setBackground(new java.awt.Color(255, 255, 51));
  62.  
  63.         jLabel2.setText("Username");
  64.  
  65.         jLabel3.setText("Password");
  66.  
  67.         tpassword.addActionListener(new java.awt.event.ActionListener() {
  68.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  69.                 tpasswordActionPerformed(evt);
  70.             }
  71.         });
  72.  
  73.         jButton1.setText("Login");
  74.         jButton1.addActionListener(new java.awt.event.ActionListener() {
  75.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  76.                 jButton1ActionPerformed(evt);
  77.             }
  78.         });
  79.  
  80.         jLabel5.setFont(new java.awt.Font("Trajan Pro", 3, 120)); // NOI18N
  81.         jLabel5.setForeground(new java.awt.Color(255, 102, 0));
  82.         jLabel5.setText("C");
  83.  
  84.         javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
  85.         jPanel2.setLayout(jPanel2Layout);
  86.         jPanel2Layout.setHorizontalGroup(
  87.             jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  88.             .addGroup(jPanel2Layout.createSequentialGroup()
  89.                 .addGap(19, 19, 19)
  90.                 .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
  91.                 .addGap(28, 28, 28)
  92.                 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  93.                     .addGroup(jPanel2Layout.createSequentialGroup()
  94.                         .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  95.                             .addComponent(jLabel2)
  96.                             .addComponent(jLabel3))
  97.                         .addGap(28, 28, 28)
  98.                         .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  99.                             .addComponent(tusername)
  100.                             .addComponent(tpassword, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)))
  101.                     .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))
  102.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  103.         );
  104.         jPanel2Layout.setVerticalGroup(
  105.             jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  106.             .addGroup(jPanel2Layout.createSequentialGroup()
  107.                 .addGap(17, 17, 17)
  108.                 .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
  109.                 .addContainerGap(32, Short.MAX_VALUE))
  110.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
  111.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  112.                 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  113.                     .addComponent(jLabel2)
  114.                     .addComponent(tusername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  115.                 .addGap(18, 18, 18)
  116.                 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  117.                     .addComponent(tpassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  118.                     .addComponent(jLabel3))
  119.                 .addGap(18, 18, 18)
  120.                 .addComponent(jButton1)
  121.                 .addGap(23, 23, 23))
  122.         );
  123.  
  124.         javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  125.         jPanel1.setLayout(jPanel1Layout);
  126.         jPanel1Layout.setHorizontalGroup(
  127.             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  128.             .addGroup(jPanel1Layout.createSequentialGroup()
  129.                 .addGap(34, 34, 34)
  130.                 .addComponent(jLabel1)
  131.                 .addContainerGap(278, Short.MAX_VALUE))
  132.             .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  133.         );
  134.         jPanel1Layout.setVerticalGroup(
  135.             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  136.             .addGroup(jPanel1Layout.createSequentialGroup()
  137.                 .addContainerGap()
  138.                 .addComponent(jLabel1)
  139.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  140.                 .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  141.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  142.         );
  143.  
  144.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  145.         getContentPane().setLayout(layout);
  146.         layout.setHorizontalGroup(
  147.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  148.             .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  149.         );
  150.         layout.setVerticalGroup(
  151.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  152.             .addGroup(layout.createSequentialGroup()
  153.                 .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  154.                 .addGap(0, 0, 0))
  155.         );
  156.  
  157.         pack();
  158.     }// </editor-fold>                        
  159.  
  160.     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  161.        String user = tusername.getText();
  162.        String pw= tpassword.getText();
  163.         try {
  164.             Statement stat = (Statement) koneksi.config.GetConnection().createStatement();
  165.             ResultSet rs = stat.executeQuery("SELECT * FROM user WHERE username ='"+user+"' and password='"+pw+"' ");
  166.             if (rs.next()) {
  167.                 int a  = stat.executeUpdate("UPDATE user SET status='Y' WHERE username='"+user+"' and password='"+pw+"'");
  168.                 new main().show();
  169.                 this.dispose();
  170.             }else {
  171.                  JOptionPane.showMessageDialog(null,"Maaf Data tidak valid !!");
  172.             }
  173.            
  174.         } catch (Exception e) {
  175.              JOptionPane.showMessageDialog(null, e.getMessage());
  176.         }
  177.     }                                        
  178.  
  179.     private void tpasswordActionPerformed(java.awt.event.ActionEvent evt) {                                          
  180.        String user = tusername.getText();
  181.        String pw= tpassword.getText();
  182.         try {
  183.             Statement stat = (Statement) koneksi.config.GetConnection().createStatement();
  184.             ResultSet rs = stat.executeQuery("SELECT * FROM user WHERE username ='"+user+"' and password='"+pw+"' ");
  185.             if (rs.next()) {
  186.                 int a  = stat.executeUpdate("UPDATE user SET status='Y' WHERE username='"+user+"' and password='"+pw+"'");
  187.                 new main().show();
  188.                 this.dispose();
  189.             }else {
  190.                  JOptionPane.showMessageDialog(null,"Maaf Data tidak valid !!");
  191.             }
  192.            
  193.         } catch (Exception e) {
  194.              JOptionPane.showMessageDialog(null, e.getMessage());
  195.         }
  196.     }                                        
  197.  
  198.     /**
  199.      * @param args the command line arguments
  200.      */
  201.     public static void main(String args[]) {
  202.         /* Set the Nimbus look and feel */
  203.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  204.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  205.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  206.          */
  207.         try {
  208.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  209.                 if ("Nimbus".equals(info.getName())) {
  210.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  211.                     break;
  212.                 }
  213.             }
  214.         } catch (ClassNotFoundException ex) {
  215.             java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  216.         } catch (InstantiationException ex) {
  217.             java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  218.         } catch (IllegalAccessException ex) {
  219.             java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  220.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  221.             java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  222.         }
  223.         //</editor-fold>
  224.  
  225.         /* Create and display the form */
  226.         java.awt.EventQueue.invokeLater(new Runnable() {
  227.             public void run() {
  228.                 new login().setVisible(true);
  229.             }
  230.         });
  231.     }
  232.  
  233.     // Variables declaration - do not modify                    
  234.     private javax.swing.JButton jButton1;
  235.     private javax.swing.JLabel jLabel1;
  236.     private javax.swing.JLabel jLabel2;
  237.     private javax.swing.JLabel jLabel3;
  238.     private javax.swing.JLabel jLabel4;
  239.     private javax.swing.JLabel jLabel5;
  240.     private javax.swing.JPanel jPanel1;
  241.     private javax.swing.JPanel jPanel2;
  242.     private javax.swing.JPasswordField tpassword;
  243.     private javax.swing.JTextField tusername;
  244.     // End of variables declaration                  
  245. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement