Net Beans IDE 6.9.1
3.3. SCOURCE CODE
3.3.2. ADMIN PAGE
// End of variables declaration }
3.3.2. ADMIN PAGE
/*
* To change this template, choose Tools | Templates * and open the template in the editor.
*/
/*
* Admin.java *
* Created on Apr 20, 2014, 2:43:56 PM */
Pckage employeemanagementsystem;
import java.awt.Color;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
/**
*
* @author NIRO */
public class Admin extends javax.swing.JFrame { ResultSet rs;
int i=0;
public Admin() {
initComponents();
txtID.setText(DB.Connect.getEMPID());
txtSearch.setVisible(false);
btnsearch.setVisible(false);
lblemp.setVisible(false);
lblPhone.setVisible(false);
lbl.setVisible(false);
lbldisplay.setVisible(false);
lblname.setVisible(false);
DB.Connect.openConnection();
display();
}
void display() {
try {
String query = "SELECT * FROM emp";
rs = DB.Connect.stat.executeQuery(query);
} catch (SQLException ex) {
//Logger.getLogger(account_register.class.getName()).log(Level.SEVERE, null, ex);
} }
/** 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() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
txtID = new javax.swing.JTextField();
txtName = new javax.swing.JTextField();
txtDOb = new javax.swing.JTextField();
txtQual = new javax.swing.JComboBox();
txtDep = new javax.swing.JComboBox();
txtSal = new javax.swing.JTextField();
txtPhone = new javax.swing.JTextField();
txtEmail = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
btnNext = new javax.swing.JButton();
btnPrevious = new javax.swing.JButton();
btnFirst = new javax.swing.JButton();
btnLast = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
lblemp = new javax.swing.JLabel();
btnsearch = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
txtPass = new javax.swing.JPasswordField();
txtSearch = new javax.swing.JTextField();
lbl = new javax.swing.JLabel();
lblphone = new javax.swing.JLabel();
lblPhone = new javax.swing.JLabel();
lbldisplay = new javax.swing.JLabel();
lblname = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
txtcpass = new javax.swing.JPasswordField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font("Algerian", 1, 18));
jLabel1.setText("Online Apprasial System");
jLabel2.setText("Employee ID");
jLabel3.setText("Employee Name");
jLabel4.setText("DOB");
jLabel5.setText("Department");
jLabel6.setText("Password");
jLabel7.setText("Salary");
jLabel8.setText("Qualificaation");
jLabel9.setText("Phone No");
jLabel10.setText("Email ID");
txtID.setEnabled(false);
txtName.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { txtNameKeyPressed(evt);
}
});
txtQual.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "B.E.", "B.Tech",
"B.A.", "B.B.A" }));
txtDep.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "HR Department", "
" }));
txtSal.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtSalActionPerformed(evt);
} });
txtSal.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { txtSalKeyPressed(evt);
} });
txtPhone.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { txtPhoneKeyPressed(evt);
} });
txtEmail.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { txtEmailKeyPressed(evt);
} });
jButton1.setText("Register");
jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt);
} });
jButton2.setText("Reset");
jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt);
} });
jButton3.setText("Search");
jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
} });
jButton4.setText("Update");
jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt);
} });
btnNext.setText("Next");
btnNext.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNextActionPerformed(evt);
} });
btnPrevious.setText("Previous");
btnPrevious.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPreviousActionPerformed(evt);
} });
btnFirst.setText("First");
btnFirst.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnFirstActionPerformed(evt);
} });
btnLast.setText("Last");
btnLast.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnLastActionPerformed(evt);
} });
jButton5.setText("Delete");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt);
}
});
jButton6.setText("Report");
jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt);
} });
jButton7.setText("Log Out");
jButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton7ActionPerformed(evt);
} });
lblemp.setText("Enter Employee ID");
btnsearch.setText("Get Value");
btnsearch.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) { btnsearchActionPerformed(evt);
}
}); jButton8.setText("New Record");
jButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton8ActionPerformed(evt);
} });
lblPhone.setText("jLabel11");
lbldisplay.setText("jLabel11");
lblname.setText("jLabel11");
jLabel11.setText("Confirm Password");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(141, 141, 141)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel10)
.addComponent(lblemp) .addComponent(jLabel2) .addComponent(jLabel3) .addComponent(jLabel4) .addComponent(jLabel6) .addComponent(jLabel7) .addComponent(jLabel9) .addComponent(jLabel5) .addComponent(jLabel8) .addComponent(jLabel11)) .addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(txtQual, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(txtDep, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(txtName,javax.swing.GroupLayout.DEFAULT_SIZE,120,Short.MAX_VALUE ) .addComponent(txtID, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE) .addComponent(txtDOb, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
.addComponent(txtSearch,javax.swing.GroupLayout.DEFAULT_SIZE,120, Short.MAX_VALUE)
.addComponent(txtSal, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
.addComponent(txtPhone javax.swing.GroupLayout.DEFAULT_SIZE,120, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL ING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(lblPhone,javax.swing.GroupLayout.PREFERRED_SIZE,61, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGap(10, 10, 10)
.addComponent(lbldisplay,javax.swing.GroupLayout.PREFERRED_SIZE,61, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,8, Short.MAX_VALUE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL ING, false)
.addComponent(btnNext,javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(btnLast javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(lblname,javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE,62,
javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(172, 172, 172))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup(
.addContainerGap(156, Short.MAX_VALUE)
.addComponent(jLabel1,javax.swing.GroupLayout.PREFERRED_SIZE,335, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(196, 196, 196))
.addGroup(layout.createSequentialGroup() .addGap(45, 45, 45)
.addComponent(jButton1) .addGap(18, 18, 18)
.addComponent(jButton8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton2)
.addGap(18, 18, 18) .addComponent(jButton3) .addGap(18, 18, 18) .addComponent(jButton4) .addGap(18, 18, 18) .addComponent(jButton5) .addGap(18, 18, 18) .addComponent(jButton6)
.addContainerGap(61, Short.MAX_VALUE)) );
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()
.addContainerGap() .addComponent(jLabel1,javax.swing.GroupLayout.PREFERRED_SIZE,32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(12, 12, 12)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblemp)
.addComponent(btnsearch)
.addComponent(txtSearch,javax.swing.GroupLayout.PREFERRED_SIZE,25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18,18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2)
.addComponent(txtID,javax.swing.GroupLayout.PREFERRED_SIZE,25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3)
.addComponent(txtName,javax.swing.GroupLayout.PREFERRED_SIZE,25, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(lblname))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton7)
.addComponent(txtDOb,javax.swing.GroupLayout.PREFERRED_SIZE,25, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()
.addGap(6, 6, 6)
addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtQual,javax.swing.GroupLayout.PREFERRED_SIZE,25,
javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel8))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtDepjavax.swing.GroupLayout.PREFERRED_SIZE,25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5)) .addGap(17, 17, 17)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6)
.addComponent(txtPass,javax.swing.GroupLayout.PREFERRED_SIZE,25, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup() .addGap(16, 16, 16)
.addComponent(btnNext) .addGap(15, 15, 15) .
addComponent(btnFirst).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNR ELATED)
.addComponent(btnPrevious)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnLast)
.addComponent(jLabel11) .
addComponent(txtcpass,javax.swing.GroupLayout.PREFERRED_SIZE,25,javax.swing.GroupL ayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtSal,\javax.swing.GroupLayout.PREFERRED_SIZE,25,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7) .addComponent(lbl)) .addGap(11,11,11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtPhone,javax.swing.GroupLayout.PREFERRED_SIZE,25,
javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel9)
.addComponent(lblphone,javax.swing.GroupLayout.PREFERRED_SIZE,0, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblPhone,javax.swing.GroupLayout.PREFERRED_SIZE,20, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtEmail,javax.swing.GroupLayout.PREFERRED_SIZE,25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10)) .addComponent(lbldisplay))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton6)
.addComponent(jButton5)
.addComponent(jButton4)
.addComponent(jButton3) .addComponent(jButton2) .addComponent(jButton8) .addComponent(jButton1))
.addContainerGap(42, Short.MAX_VALUE)) );
pack();
}// </editor-fold>
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
Login ln=new Login();
this.hide();
ln.show();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if(txtPass.getText().equals(txtcpass.getText())) {
try {
DB.Connect.openConnection();
String str="Insert into emp values('" + txtID.getText() + "','" + txtName.getText() + "','" + txtDOb.getText()+ "','" + txtQual.getSelectedItem().toString() + "','" + txtDep.getSelectedItem().toString() + "','" + txtPass.getText() + "','" + txtSal.getText()+"','"
+txtPhone.getText()+ "','" +txtEmail.getText()+ "','" +DB.Connect.getDate()+"','"
+DB.Connect.getTime()+ "')";
DB.Connect.stat.executeUpdate(str);
JOptionPane.showMessageDialog(null,"Register Successfully");
DB.Connect.closeConnection();
} catch (Exception e1) { e1.printStackTrace();
} } else
JOptionPane.showMessageDialog(null,"Password Not Matched");
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
txtDOb.setText(null);
txtEmail.setText(null);
txtName.setText(null);
txtPass.setText(null);
txtSal.setText(null);
txtPhone.setText(null);
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
txtSearch.setVisible(true);
btnsearch.setVisible(true);
lblemp.setVisible(true);
}
private void btnsearchActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
try {
// TODO add your handling code here:
boolean b = true;
// TODO add your handling code here:
DB.Connect.openConnection();
String sql = "select * from emp where emp_ID='" +txtSearch.getText()+ "'";
rs = DB.Connect.stat.executeQuery(sql);
if (rs.next()) { setText();
txtSearch.setVisible(false);
btnsearch.setVisible(false);
lblemp.setVisible(false);
}
rs.close();
DB.Connect.closeConnection();
if (b) {
JOptionPane.showMessageDialog(null, "Record Not Found");
}
} catch (SQLException ex) { ex.printStackTrace();
}
} public void updateAccount() {
try{
DB.Connect.openConnection();
DB.Connect.stat.executeUpdate("UPDATE emp SET emp_Pass='" + txtPass.getText() +
"',emp_Sal='" +txtSal.getText() + "',emp_Phone='" + txtPhone.getText() + "',emp_Email='" + txtEmail.getText() + "' WHERE emp_ID='" + txtID.getText() + "'");
DB.Connect.closeConnection();
JOptionPane.showMessageDialog(null,"Updated Successfully");
}
catch(Exception ex) {
ex.printStackTrace();
} }
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
updateAccount();
DB.Connect.record(txtID.getText(),txtName.getText(),txtDOb.getText(),
txtQual.getSelectedItem().toString(),txtDep.getSelectedItem().toString(),txtPass.getText(),txtSal.
getText(),txtPhone.getText(),txtEmail.getText());
} void deleteInfo()
{ try{
DB.Connect.openConnection();
DB.Connect.stat.executeUpdate("delete * from emp where emp_ID='" +txtID.getText()+ "'");
DB.Connect.closeConnection();
JOptionPane.showMessageDialog(null,"Record Deleted Successfully");
}
catch(Exception ex) {
ex.printStackTrace();
} }
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
deleteInfo();
}
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
Admin a=new Admin();
a.show();
} public void getcol() { try {
DefaultTableModel model;
JTable tb;
JScrollPane sb;
JFrame f3 = new JFrame();
tb = new JTable();
tb.setBounds(10, 40, 10, 10);
f3.setSize(900, 450);
f3.setTitle("Report Generation");
sb = new JScrollPane(tb);
sb.setBounds(30, 60, 150, 100);
f3.add(sb);
f3.setVisible(true);
DB.Connect.openConnection();
DB.Connect.rs = DB.Connect.stat.executeQuery("select * from emp");
ResultSetMetaData rsmd = DB.Connect.rs.getMetaData();
// JPanel panel = new JPanel();
// model.addColumn("Purchase");
model = new DefaultTableModel();
model.addColumn("Employee ID");
model.addColumn("Employee Name");
model.addColumn("DOB");
model.addColumn("Qualification");
model.addColumn("Department");
model.addColumn("Password");
model.addColumn("Salary");
model.addColumn("Phone No");
model.addColumn("Email ID");
model.addColumn("Date");
model.addColumn("Time");
// model.addColumn("Purchase");
tb.setModel(model);
String data1[] = new String[11];
while (DB.Connect.rs.next()) {
data1[0] =DB.Connect.rs.getString(1);
data1[1] = DB.Connect.rs.getString(2);
data1[2] = DB.Connect.rs.getString(3);
data1[3] = DB.Connect.rs.getString(4);
data1[4] =DB.Connect. rs.getString(5);
data1[5] =DB.Connect.rs.getString(6);
data1[6] = DB.Connect.rs.getString(7);
data1[7] =DB.Connect.rs.getString(8);
data1[8] =DB.Connect.rs.getString(9);
data1[9] =DB.Connect.rs.getString(10);
data1[10] =DB.Connect.rs.getString(11);
model.addRow(data1);
}
DB.Connect.closeConnection();
} catch (Exception e) { e.printStackTrace();
}
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
getcol();
}
private void btnFirstActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
try {
//DB.Connect.closeConnection();
if(rs.first());
setText();
// connection.close();
} catch (Exception ex) {
// Logger.getLogger(account_register.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void btnLastActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
try {
// DB.Connect.closeConnection();
if(rs.last());
setText();
// connection.close();
} catch (Exception ex) {
// Logger.getLogger(account_register.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void btnPreviousActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
try {
//DB.Connect.closeConnection();
if(rs.previous());
setText();
// connection.close();
// Logger.getLogger(account_register.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void btnNextActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
try {
//connection.open();
//DB.Connect.closeConnection();
if(rs.next());
setText();
// connection.close();
} catch (Exception ex) {
// Logger.getLogger(account_register.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void txtSalKeyPressed(java.awt.event.KeyEvent evt) { // TODO add your handling code here:
String input = txtSal.getText();
Pattern p = Pattern.compile("[A-Z,a-z,&%$@!()*^]");
Matcher m = p.matcher(input);
if (m.find()) { lbl.setVisible(true);
lbl.setText("Invalid !!");
lbl.setVisible(true);
lbl.setForeground(Color.red);
txtSal.setText("");
} else {
lbl.setVisible(false);
} }
private void txtSalActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
}
private void txtPhoneKeyPressed(java.awt.event.KeyEvent evt) { // TODO add your handling code here:
String input = txtPhone.getText();
int a=input.length();
Pattern p = Pattern.compile("[A-Z,a-z,&%$@!()*^]");
Matcher m = p.matcher(input);
if (m.find()) {
lblPhone.setVisible(true);
lblPhone.setText("Invalid!!");
lblPhone.setVisible(true);
lblPhone.setForeground(Color.red);
txtPhone.setText("");
} else {
lblPhone.setVisible(false);
} }
private void txtEmailKeyPressed(java.awt.event.KeyEvent evt) { // TODO add your handling code here:
}
private void txtNameKeyPressed(java.awt.event.KeyEvent evt) { // TODO add your handling code here:
Pattern p = Pattern.compile("[0-9]");
Matcher m = p.matcher(input);
if (m.find()) {
lblname.setText("Invalid!!");
lblname.setVisible(true);
lblname.setForeground(Color.red);
txtName.setText(null);
} else {
lblname.setVisible(false);
}
}
void setText() throws SQLException { txtName.setText(rs.getString(2));
txtDOb.setText(rs.getString(3));
txtQual.setSelectedItem(rs.getString(4));
txtDep.setSelectedItem(rs.getString(5));
txtPass.setText(rs.getString(6));
txtSal.setText(rs.getString(7));
txtPhone.setText(rs.getString(8));
txtEmail.setText(rs.getString(9));
} /**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() { public void run() {
new Admin().setVisible(true);
} });
}
// Variables declaration - do not modify private javax.swing.JButton btnFirst;
private javax.swing.JButton btnLast;
private javax.swing.JButton btnNext;
private javax.swing.JButton btnPrevious;
private javax.swing.JButton btnsearch;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
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.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JLabel lbl;
private javax.swing.JLabel lblPhone;
private javax.swing.JLabel lbldisplay;
private javax.swing.JLabel lblemp;
private javax.swing.JLabel lblname;
private javax.swing.JLabel lblphone;
private javax.swing.JTextField txtDOb;
private javax.swing.JComboBox txtDep;
private javax.swing.JTextField txtEmail;
private javax.swing.JTextField txtID;
private javax.swing.JTextField txtName;
private javax.swing.JPasswordField txtPass;
private javax.swing.JTextField txtPhone;
private javax.swing.JComboBox txtQual;
private javax.swing.JTextField txtSal;
private javax.swing.JTextField txtSearch;
private javax.swing.JPasswordField txtcpass;
// End of variables declaration }