Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /*
- * jRegister.java
- *
- * Created on 06 Mei 10, 7:33:53
- */
- package form;
- import db.Koneksi;
- import java.sql.ResultSet;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.swing.JOptionPane;
- /**
- *
- * @author Lenovo
- */
- public class jRegister extends javax.swing.JFrame {
- /** Creates new form jRegister */
- public jRegister() {
- initComponents();
- }
- private void jSubmitActionPerformed(java.awt.event.ActionEvent evt) {
- if (jUsername.getText()==null && jPassword.getPassword()==null){
- JOptionPane.showMessageDialog(null, "Isi Data Anda Dengan Lengkap ! ");
- } else {
- Insert();
- }
- }
- private void jCancelActionPerformed(java.awt.event.ActionEvent evt) {
- jUsername.setText("");
- jPassword.setText("");
- }
- private void Insert(){
- try {
- String username = jUsername.getText();
- String password = new String(jPassword.getPassword());
- String tipe = "";
- switch (jTipe.getSelectedIndex()){
- case 0 :
- tipe = "admin";
- break;
- case 1 :
- tipe = "kasir";
- break;
- case 2 :
- tipe = "bos";
- break;
- case 3 :
- tipe = "entry";
- break;
- }
- String sql = "INSERT INTO user (username, password,tipe) VALUES ('" + username + "', '" + password + "', '"+ tipe +"')";
- ResultSet query = Koneksi.execute(sql);
- } catch (Exception ex) {
- Logger.getLogger(jRegister.class.getName()).log(Level.SEVERE, null, ex);
- System.out.println(ex.getMessage());
- JOptionPane.showMessageDialog(null, "Maaf, register gagal !");
- }
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new jRegister().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JButton jCancel;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JLabel jLabel5;
- private javax.swing.JLabel jLabel6;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JPanel jPanel2;
- private javax.swing.JPanel jPanel3;
- private javax.swing.JPasswordField jPassword;
- private javax.swing.JButton jSubmit;
- private javax.swing.JComboBox jTipe;
- private javax.swing.JTextField jUsername;
- // End of variables declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement