Вы находитесь на странице: 1из 23

package payroll_system;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import javax.swing.JOptionPane;

import javax.swing.table.TableModel;

/**

* @author senior high

*/

public class Main_menu extends javax.swing.JFrame {

/**

* Creates new form Main_menu

*/

public Main_menu() {

initComponents();

/**

* This method is called from within the constructor to initialize the form.

* WARNING: Do NOT modify this code. The content of this method is always

* regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {


entityManager = java.beans.Beans.isDesignTime() ? null :
javax.persistence.Persistence.createEntityManagerFactory("payroll_system?zeroDateTimeBehavior=con
vertToNullPU").createEntityManager();

adminQuery = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT a


FROM Admin a");

adminList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :


adminQuery.getResultList();

employeeQuery = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT e


FROM Employee e");

employeeList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :


employeeQuery.getResultList();

employeeQuery1 = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT e


FROM Employee e");

employeeList1 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :


employeeQuery1.getResultList();

employeeQuery2 = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT e


FROM Employee e");

employeeList2 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :


employeeQuery2.getResultList();

employeeQuery3 = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT e


FROM Employee e");

employeeList3 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :


employeeQuery3.getResultList();

employeeQuery4 = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT e


FROM Employee e");

employeeList4 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :


employeeQuery4.getResultList();

employeeQuery5 = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT e


FROM Employee e");

employeeList5 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :


employeeQuery5.getResultList();

employeeQuery6 = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT e


FROM Employee e");
employeeList6 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :
employeeQuery6.getResultList();

salaryQuery = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT s FROM


Salary s");

salaryList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :


salaryQuery.getResultList();

salaryGradeQuery = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT s


FROM SalaryGrade s");

salaryGradeList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :


salaryGradeQuery.getResultList();

employeeQuery7 = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT e


FROM Employee e");

employeeList7 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :


employeeQuery7.getResultList();

employeeQuery8 = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT e


FROM Employee e");

employeeList8 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() :


employeeQuery8.getResultList();

BD = new javax.swing.JTextField();

Salary = new javax.swing.JTextField();

Age = new javax.swing.JTextField();

jLabel13 = new javax.swing.JLabel();

Cs = new javax.swing.JTextField();

jLabel3 = new javax.swing.JLabel();

jLabel14 = new javax.swing.JLabel();

pass = new javax.swing.JTextField();

Bt = new javax.swing.JTextField();

jLabel15 = new javax.swing.JLabel();

Cno = new javax.swing.JTextField();

save = new javax.swing.JButton();

update = new javax.swing.JButton();

delete = new javax.swing.JButton();


Hadd = new javax.swing.JTextField();

jLabel4 = new javax.swing.JLabel();

jLabel17 = new javax.swing.JLabel();

jLabel5 = new javax.swing.JLabel();

jLabel6 = new javax.swing.JLabel();

jLabel18 = new javax.swing.JLabel();

jLabel7 = new javax.swing.JLabel();

Brgy = new javax.swing.JTextField();

jLabel8 = new javax.swing.JLabel();

jLabel19 = new javax.swing.JLabel();

jLabel20 = new javax.swing.JLabel();

jLabel21 = new javax.swing.JLabel();

jLabel11 = new javax.swing.JLabel();

Position = new javax.swing.JTextField();

jLabel12 = new javax.swing.JLabel();

Lname = new javax.swing.JTextField();

jLabel1 = new javax.swing.JLabel();

idnum = new javax.swing.JTextField();

jLabel22 = new javax.swing.JLabel();

Es = new javax.swing.JTextField();

Fname = new javax.swing.JTextField();

jLabel23 = new javax.swing.JLabel();

Mname = new javax.swing.JTextField();

Cp = new javax.swing.JTextField();

gender = new javax.swing.JTextField();

jScrollPane2 = new javax.swing.JScrollPane();

jTable2 = new javax.swing.JTable();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel13.setText("Civil Status");

jLabel3.setText("Password");

jLabel14.setText("Blood Type");

pass.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

passActionPerformed(evt);

});

jLabel15.setText("Contact No.");

save.setText("SAVE");

save.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

saveActionPerformed(evt);

});

update.setText("UPDATE");

update.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

updateActionPerformed(evt);

});
delete.setText("DELETE");

delete.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

deleteActionPerformed(evt);

});

jLabel4.setText("Personal Information");

jLabel17.setText("House No./Street");

jLabel5.setText("Last Name");

jLabel6.setText("First Name");

jLabel18.setText("Barangay/District");

jLabel7.setText("Mid Name");

jLabel8.setText("Gender ");

jLabel19.setText("City/Province");

jLabel20.setText("Service Record");

jLabel21.setText("Position");

jLabel11.setText("Birthday");
jLabel12.setText("Age");

jLabel1.setText("ID Number");

jLabel22.setText("Employment Status");

jLabel23.setText("Salary");

jTable2.setModel(new javax.swing.table.DefaultTableModel(

new Object [][] {

{null, null, null, null},

{null, null, null, null},

{null, null, null, null},

{null, null, null, null}

},

new String [] {

"Title 1", "Title 2", "Title 3", "Title 4"

));

jScrollPane2.setViewportView(jTable2);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(268, 268, 268)

.addComponent(gender, javax.swing.GroupLayout.PREFERRED_SIZE, 177,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(layout.createSequentialGroup()

.addGap(541, 541, 541)

.addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 92,


javax.swing.GroupLayout.PREFERRED_SIZE)))

.addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, 89,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(33, 33, 33)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(Salary, javax.swing.GroupLayout.PREFERRED_SIZE, 169,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(Es, javax.swing.GroupLayout.PREFERRED_SIZE, 169,


javax.swing.GroupLayout.PREFERRED_SIZE)))

.addGroup(layout.createSequentialGroup()

.addGap(195, 195, 195)

.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addContainerGap(2707, Short.MAX_VALUE))

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(179, 179, 179)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 126,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)

.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)

.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 55,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addComponent(Lname)

.addComponent(Fname)

.addComponent(Mname, javax.swing.GroupLayout.DEFAULT_SIZE, 176,


Short.MAX_VALUE))

.addGap(104, 104, 104)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 91,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 91,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(28, 28, 28)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addComponent(Hadd, javax.swing.GroupLayout.PREFERRED_SIZE, 169,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(Brgy, javax.swing.GroupLayout.PREFERRED_SIZE, 169,


javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()

.addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 82,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(0, 0, Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(Cp, javax.swing.GroupLayout.PREFERRED_SIZE, 169,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(Position, javax.swing.GroupLayout.PREFERRED_SIZE, 169,


javax.swing.GroupLayout.PREFERRED_SIZE)))))

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)

.addComponent(jLabel15, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE)

.addComponent(jLabel11, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel12, javax.swing.GroupLayout.Alignment.LEADING))

.addComponent(jLabel3)

.addComponent(jLabel13, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel14, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(17, 17, 17)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(BD, javax.swing.GroupLayout.DEFAULT_SIZE, 181,


Short.MAX_VALUE)
.addComponent(Cs, javax.swing.GroupLayout.DEFAULT_SIZE, 181,
Short.MAX_VALUE)

.addComponent(Bt, javax.swing.GroupLayout.DEFAULT_SIZE, 181,


Short.MAX_VALUE)

.addComponent(Age))

.addGap(122, 122, 122)

.addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 135,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(layout.createSequentialGroup()

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addComponent(pass, javax.swing.GroupLayout.PREFERRED_SIZE, 181,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(54, 54, 54)

.addComponent(save)

.addGap(28, 28, 28)

.addComponent(update)

.addGap(29, 29, 29)

.addComponent(delete))

.addComponent(Cno, javax.swing.GroupLayout.PREFERRED_SIZE, 181,


javax.swing.GroupLayout.PREFERRED_SIZE)))))

.addGroup(layout.createSequentialGroup()

.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 75,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(idnum, javax.swing.GroupLayout.PREFERRED_SIZE, 118,


javax.swing.GroupLayout.PREFERRED_SIZE)))

.addContainerGap(2707, Short.MAX_VALUE)))

);

layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(203, 203, 203)

.addComponent(gender, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(38, 38, 38)

.addComponent(jLabel21)

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel22)

.addComponent(Es, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel23)

.addComponent(Salary, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 121,
Short.MAX_VALUE)

.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(75, 75, 75))

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(43, 43, 43)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel1)

.addComponent(idnum, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel5)

.addComponent(Lname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel6)

.addComponent(Fname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(6, 6, 6)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel7)

.addComponent(Mname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 22,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel11)

.addComponent(BD, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel12)

.addComponent(Age, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(11, 11, 11)


.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(Cs, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel13))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(Bt, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel14))

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(49, 49, 49)

.addComponent(pass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(layout.createSequentialGroup()

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(Cno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel15))

.addGap(18, 18, 18)

.addComponent(jLabel3))))

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel17)

.addComponent(Hadd, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(42, 42, 42)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(Brgy, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel19)

.addComponent(Cp, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(jLabel20)

.addGap(13, 13, 13)

.addComponent(Position, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(110, 110, 110)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(save)

.addComponent(update)

.addComponent(delete))))

.addContainerGap(551, Short.MAX_VALUE)))

);

pack();

}// </editor-fold>

private void passActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

private void saveActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

try {

Class.forName("com.mysql.jdbc.Driver");

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306"

+"/book_rental","root","");

String sql = "INSERT INTO accounts (idnum, Lname, Fname, Mname, gender, Hadd, Hns,)"

+"values (?,?,?,?)";

PreparedStatement pst = con.prepareStatement(sql);

pst.setString(1,idnum.getText());

pst.setString(2,Lname.getText());

pst.setString(3,Fname.getText());

pst.setString(4,Mname.getText());

pst.setString(5,gender.getText());

pst.setString(6,Hadd.getText());

pst.setString(8,Brgy.getText());

pst.setString(9,Cp.getText());

pst.setString(10,BD.getText());

pst.setString(11,Age.getText());

pst.setString(12,Cs.getText());

pst.setString(13,Bt.getText());

pst.setString(14,Cno.getText());

pst.setString(15,pass.getText());

pst.setString(16,pass.getText());

pst.setString(17,Position.getText());

pst.setString(18,Es.getText());

pst.setString(19,Salary.getText());
pst.executeUpdate();

JOptionPane.showMessageDialog(null,"Successfully added.");

con.close();

catch (Exception e){

JOptionPane.showMessageDialog(null,e);

private void updateActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

try {

String value1 = idnum.getText();

String value2 = Lname.getText();

String value3 = Fname.getText();

String value4 = Mname.getText();

String value5 = gender.getText();

String value6 = Hadd.getText();

String value8 = Brgy.getText();

String value9 = Cp.getText();

String value10 = BD.getText();

String value11 = Age.getText();

String value12 = Cs.getText();

String value13 = Bt.getText();

String value14 = Cno.getText();


String value15 = pass.getText();

String value16 = Position.getText();

String value17 = Es.getText();

String value18 = Salary.getText();

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306"

+"/payroll_system","root","");

String sql = "UPDATE accounts SET name=?,username, password, where AuID="+value1;

PreparedStatement pst = con.prepareStatement(sql);

// pst.setString(1,name.getText());

// pst.setString(2,username.getText());

// pst.setString(3,password.getText());

pst.executeUpdate();

JOptionPane.showMessageDialog(null,"Updated");

con.close();

catch (Exception e){

JOptionPane.showMessageDialog(null,e);

private void deleteActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

try {
Class.forName("com.mysql.jdbc.Driver");

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306"

+"/payroll_system","root","");

String sql2 = "DELETE FROM accounts where AuID="+idnum.getText();

PreparedStatement pst = con.prepareStatement(sql2);

JOptionPane.showMessageDialog(null,"Successfully deleted");

pst.executeUpdate();

con.close();

catch (Exception e){

JOptionPane.showMessageDialog(null,e);

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">

/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.

* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

*/

try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Main_menu.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Main_menu.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Main_menu.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Main_menu.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

//</editor-fold>

/* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new Main_menu().setVisible(true);

});
}

// Variables declaration - do not modify

private javax.swing.JTextField Age;

private javax.swing.JTextField BD;

private javax.swing.JTextField Brgy;

private javax.swing.JTextField Bt;

private javax.swing.JTextField Cno;

private javax.swing.JTextField Cp;

private javax.swing.JTextField Cs;

private javax.swing.JTextField Es;

private javax.swing.JTextField Fname;

private javax.swing.JTextField Hadd;

private javax.swing.JTextField Lname;

private javax.swing.JTextField Mname;

private javax.swing.JTextField Position;

private javax.swing.JTextField Salary;

private java.util.List<payroll_system.Admin> adminList;

private javax.persistence.Query adminQuery;

private javax.swing.JButton delete;

private java.util.List<payroll_system.Employee> employeeList;

private java.util.List<payroll_system.Employee> employeeList1;

private java.util.List<payroll_system.Employee> employeeList2;

private java.util.List<payroll_system.Employee> employeeList3;

private java.util.List<payroll_system.Employee> employeeList4;

private java.util.List<payroll_system.Employee> employeeList5;

private java.util.List<payroll_system.Employee> employeeList6;

private java.util.List<payroll_system.Employee> employeeList7;

private java.util.List<payroll_system.Employee> employeeList8;


private javax.persistence.Query employeeQuery;

private javax.persistence.Query employeeQuery1;

private javax.persistence.Query employeeQuery2;

private javax.persistence.Query employeeQuery3;

private javax.persistence.Query employeeQuery4;

private javax.persistence.Query employeeQuery5;

private javax.persistence.Query employeeQuery6;

private javax.persistence.Query employeeQuery7;

private javax.persistence.Query employeeQuery8;

private javax.persistence.EntityManager entityManager;

private javax.swing.JTextField gender;

private javax.swing.JTextField idnum;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel11;

private javax.swing.JLabel jLabel12;

private javax.swing.JLabel jLabel13;

private javax.swing.JLabel jLabel14;

private javax.swing.JLabel jLabel15;

private javax.swing.JLabel jLabel17;

private javax.swing.JLabel jLabel18;

private javax.swing.JLabel jLabel19;

private javax.swing.JLabel jLabel20;

private javax.swing.JLabel jLabel21;

private javax.swing.JLabel jLabel22;

private javax.swing.JLabel jLabel23;

private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel4;

private javax.swing.JLabel jLabel5;

private javax.swing.JLabel jLabel6;


private javax.swing.JLabel jLabel7;

private javax.swing.JLabel jLabel8;

private javax.swing.JScrollPane jScrollPane2;

private javax.swing.JTable jTable2;

private javax.swing.JTextField pass;

private java.util.List<payroll_system.SalaryGrade> salaryGradeList;

private javax.persistence.Query salaryGradeQuery;

private java.util.List<payroll_system.Salary> salaryList;

private javax.persistence.Query salaryQuery;

private javax.swing.JButton save;

private javax.swing.JButton update;

// End of variables declaration

Вам также может понравиться