diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..06b6aa0 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,35 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 diff --git a/AddEmployee.form b/AddEmployee.form new file mode 100644 index 0000000..2b07ba2 --- /dev/null +++ b/AddEmployee.form @@ -0,0 +1,693 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AddEmployee.java b/AddEmployee.java new file mode 100644 index 0000000..6c571f8 --- /dev/null +++ b/AddEmployee.java @@ -0,0 +1,934 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +package EMS; + +import java.awt.Image; +import java.awt.event.KeyEvent; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.sql.*; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.ImageIcon; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; + +/** + * + * @author MyPC + */ +public class AddEmployee extends javax.swing.JFrame { + + int count; + private String id; + private String name; + private String surname; + private String gender; + private String email; + private String contact; + private String designation; + private String department; + private String status; + private String datehired; + private String dob; + private String salary; + private String jobtitle; + private String address1; + private String address2; + private String houseno; + private String postcode; + private String imageIcon; + FileInputStream fin; + + private String getCurrentDateTime() { + Calendar cal = new GregorianCalendar(); + int month = cal.get(Calendar.MONTH); + int year = cal.get(Calendar.YEAR); + int day = cal.get(Calendar.DAY_OF_MONTH); + int second = cal.get(Calendar.SECOND); + int minute = cal.get(Calendar.MINUTE); + int hour = cal.get(Calendar.HOUR); + + String dateTime = (month + 1) + "/" + day + "/" + year + " , " + hour + ":" + minute + ":" + second; + return dateTime; + } + + public AddEmployee() { + try { + this.count = idCount() + 1; + } catch (ClassNotFoundException ex) { + Logger.getLogger(AddEmployee.class.getName()).log(Level.SEVERE, null, ex); + } catch (SQLException ex) { + Logger.getLogger(AddEmployee.class.getName()).log(Level.SEVERE, null, ex); + } + + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + buttonGroup1 = new javax.swing.ButtonGroup(); + jPanel1 = new javax.swing.JPanel(); + 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(); + jLabel9 = new javax.swing.JLabel(); + jLabel10 = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + jLabel12 = new javax.swing.JLabel(); + jLabel13 = new javax.swing.JLabel(); + jLabel14 = new javax.swing.JLabel(); + jLabel8 = new javax.swing.JLabel(); + jLabel15 = new javax.swing.JLabel(); + jLabel16 = new javax.swing.JLabel(); + jLabel17 = new javax.swing.JLabel(); + jLabel18 = new javax.swing.JLabel(); + jLabel19 = new javax.swing.JLabel(); + jLabel20 = new javax.swing.JLabel(); + jftid = new javax.swing.JFormattedTextField(); + jtfname = new javax.swing.JTextField(); + jtfsurname = new javax.swing.JTextField(); + jcbdepartment = new javax.swing.JComboBox<>(); + jcbdesignation = new javax.swing.JComboBox<>(); + jcbstatus = new javax.swing.JComboBox<>(); + jtfsalary = new javax.swing.JTextField(); + jtftitle = new javax.swing.JTextField(); + jtfhouseno = new javax.swing.JTextField(); + jtfadd2 = new javax.swing.JTextField(); + jtfadd1 = new javax.swing.JTextField(); + jtfemail = new javax.swing.JTextField(); + jftcontact = new javax.swing.JFormattedTextField(); + jftpostcode = new javax.swing.JFormattedTextField(); + jPanel2 = new javax.swing.JPanel(); + jbtadd = new javax.swing.JButton(); + jbtcancel = new javax.swing.JButton(); + jPanel3 = new javax.swing.JPanel(); + jrbgenfemale = new javax.swing.JRadioButton(); + jrbgenmale = new javax.swing.JRadioButton(); + jDateChooser1 = new com.toedter.calendar.JDateChooser(); + jDateChooser2 = new com.toedter.calendar.JDateChooser(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jMenuBar1 = new javax.swing.JMenuBar(); + jMenu1 = new javax.swing.JMenu(); + jMenu2 = new javax.swing.JMenu(); + + buttonGroup1.add(jrbgenmale); + buttonGroup1.add(jrbgenfemale); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jPanel1.setBackground(new java.awt.Color(255, 255, 0)); + jPanel1.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jPanel1KeyPressed(evt); + } + }); + + jLabel3.setFont(new java.awt.Font("Segoe UI Historic", 0, 12)); // NOI18N + jLabel3.setLabelFor(jftid); + jLabel3.setText("Employee id:-"); + jLabel3.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jLabel3FocusGained(evt); + } + }); + + jLabel4.setFont(new java.awt.Font("Segoe UI Historic", 0, 12)); // NOI18N + jLabel4.setLabelFor(jtfname); + jLabel4.setText("Name:-"); + + jLabel5.setFont(new java.awt.Font("Segoe UI Historic", 0, 12)); // NOI18N + jLabel5.setLabelFor(jtfsurname); + jLabel5.setText("Surname:-"); + + jLabel6.setFont(new java.awt.Font("Segoe UI Historic", 0, 12)); // NOI18N + jLabel6.setText("Date of Birth:-"); + + jLabel7.setLabelFor(jrbgenmale); + jLabel7.setText("Gender:-"); + + jLabel9.setLabelFor(jtfemail); + jLabel9.setText("Email:-"); + + jLabel10.setLabelFor(jftcontact); + jLabel10.setText("Contact:-"); + + jLabel11.setLabelFor(jtfadd1); + jLabel11.setText("Address line 1:-"); + + jLabel12.setLabelFor(jtfadd2); + jLabel12.setText("Address line 2:-"); + + jLabel13.setLabelFor(jtfhouseno); + jLabel13.setText("House no:-"); + + jLabel14.setLabelFor(jftpostcode); + jLabel14.setText("Post code:-"); + + jLabel8.setLabelFor(jcbdepartment); + jLabel8.setText("Department:-"); + + jLabel15.setLabelFor(jcbdesignation); + jLabel15.setText("Designation:-"); + + jLabel16.setLabelFor(jcbstatus); + jLabel16.setText("Status:-"); + + jLabel17.setText("Date hired:-"); + + jLabel18.setLabelFor(jtfsalary); + jLabel18.setText("Basic salary:-"); + + jLabel19.setLabelFor(jtftitle); + jLabel19.setText("Job title:-"); + + jLabel20.setBackground(new java.awt.Color(0, 153, 153)); + jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel20.setText("click
to add
image"); + jLabel20.setOpaque(true); + jLabel20.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel20MouseClicked(evt); + } + }); + + jftid.setText(Integer.toString(count)); + jftid.setEnabled(false); + jftid.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jftidActionPerformed(evt); + } + }); + jftid.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jftidKeyPressed(evt); + } + }); + + jtfname.setToolTipText("hi"); + jtfname.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtfnameKeyPressed(evt); + } + }); + + jtfsurname.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtfsurnameKeyPressed(evt); + } + }); + + jcbdepartment.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "IT", "ME", "CS", "TT", "TC", "EC" })); + jcbdepartment.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcbdepartmentActionPerformed(evt); + } + }); + jcbdepartment.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jcbdepartmentKeyPressed(evt); + } + }); + + jcbdesignation.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "CEO", "CTO", "CMO", "SENIOR MANAGER", "MANAGER", "DEVELOPER", "DESIGNER", "HELPER" })); + jcbdesignation.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jcbdesignationKeyPressed(evt); + } + }); + + jcbstatus.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "MARRIED", "UNMARRIED", "DEVORSED" })); + jcbstatus.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jcbstatusKeyPressed(evt); + } + }); + + jtfsalary.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jtfsalaryActionPerformed(evt); + } + }); + jtfsalary.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtfsalaryKeyPressed(evt); + } + }); + + jtftitle.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtftitleKeyPressed(evt); + } + }); + + jtfhouseno.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtfhousenoKeyPressed(evt); + } + }); + + jtfadd2.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtfadd2KeyPressed(evt); + } + }); + + jtfadd1.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtfadd1KeyPressed(evt); + } + }); + + jtfemail.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtfemailKeyPressed(evt); + } + }); + + jftcontact.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("##########")))); + jftcontact.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jftcontactActionPerformed(evt); + } + }); + jftcontact.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jftcontactKeyPressed(evt); + } + }); + + jftpostcode.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jftpostcodeKeyPressed(evt); + } + }); + + jPanel2.setBackground(new java.awt.Color(255, 255, 0)); + + jbtadd.setText("Add record"); + jbtadd.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtaddActionPerformed(evt); + } + }); + + jbtcancel.setText("Cancel"); + jbtcancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtcancelActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jbtadd, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(45, 45, 45) + .addComponent(jbtcancel, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jbtcancel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jbtadd, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + jPanel3.setBackground(new java.awt.Color(255, 255, 0)); + + jrbgenfemale.setText("Female"); + jrbgenfemale.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jrbgenfemaleKeyPressed(evt); + } + }); + + jrbgenmale.setSelected(true); + jrbgenmale.setText("Male"); + jrbgenmale.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jrbgenmaleKeyPressed(evt); + } + }); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jrbgenmale) + .addGap(26, 26, 26) + .addComponent(jrbgenfemale) + .addContainerGap()) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jrbgenmale) + .addComponent(jrbgenfemale)) + .addContainerGap()) + ); + + jDateChooser1.setDateFormatString("dd/MM/yyyy"); + + jDateChooser2.setDateFormatString("dd/MM/yyyy"); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3) + .addComponent(jLabel4) + .addComponent(jLabel5) + .addComponent(jLabel6) + .addComponent(jLabel9) + .addComponent(jLabel14) + .addComponent(jLabel13) + .addComponent(jLabel12) + .addComponent(jLabel11) + .addComponent(jLabel10) + .addComponent(jLabel7)) + .addGap(25, 25, 25) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jtfhouseno, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtfadd2, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jftcontact, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtfemail, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jftid, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtfname, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtfsurname, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtfadd1, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jDateChooser2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jftpostcode)) + .addGap(85, 85, 85) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel8) + .addGap(18, 18, 18) + .addComponent(jcbdepartment, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel16) + .addComponent(jLabel17)) + .addGap(24, 24, 24) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jcbstatus, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jDateChooser1, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel15) + .addGap(18, 18, 18) + .addComponent(jcbdesignation, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 157, Short.MAX_VALUE) + .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel18) + .addComponent(jLabel19)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jtfsalary, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE) + .addComponent(jtftitle)))) + .addGap(0, 0, Short.MAX_VALUE))) + .addGap(18, 18, 18)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(9, 9, 9) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(jftid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel8) + .addComponent(jcbdepartment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(jtfname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel15) + .addComponent(jcbdesignation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5) + .addComponent(jtfsurname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel16) + .addComponent(jcbstatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jDateChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6) + .addComponent(jLabel17)) + .addComponent(jDateChooser2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel7) + .addComponent(jLabel18) + .addComponent(jtfsalary, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel19) + .addComponent(jtftitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel9) + .addComponent(jtfemail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel10) + .addComponent(jftcontact, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel11) + .addComponent(jtfadd1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(18, 18, 18) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel12) + .addComponent(jtfadd2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel13) + .addComponent(jtfhouseno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel14) + .addComponent(jftpostcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + jLabel1.setText(getCurrentDateTime()); + + jLabel2.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N + jLabel2.setText("Employee details"); + + jMenu1.setText("File"); + jMenuBar1.add(jMenu1); + + jMenu2.setText("Edit"); + jMenuBar1.add(jMenu2); + + setJMenuBar(jMenuBar1); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(22, 22, 22) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(3, 3, 3) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(30, Short.MAX_VALUE)) + ); + + pack(); + }//
//GEN-END:initComponents + + private void jLabel3FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jLabel3FocusGained + // TODO add your handling code here: + }//GEN-LAST:event_jLabel3FocusGained + + private void jtfsalaryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfsalaryActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jtfsalaryActionPerformed + + private void jftidActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jftidActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jftidActionPerformed + + private void jftidKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jftidKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jftid.transferFocus(); + } + }//GEN-LAST:event_jftidKeyPressed + + private void jtfnameKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfnameKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jtfname.transferFocus(); + } + }//GEN-LAST:event_jtfnameKeyPressed + + private void jtfsurnameKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfsurnameKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jtfsurname.transferFocus(); + } + }//GEN-LAST:event_jtfsurnameKeyPressed + + private void jrbgenmaleKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jrbgenmaleKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jrbgenmale.transferFocus(); + } + }//GEN-LAST:event_jrbgenmaleKeyPressed + + private void jtfemailKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfemailKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jtfemail.transferFocus(); + } + }//GEN-LAST:event_jtfemailKeyPressed + + private void jftcontactKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jftcontactKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jftcontact.transferFocus(); + } + }//GEN-LAST:event_jftcontactKeyPressed + + private void jtfadd1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfadd1KeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jtfadd1.transferFocus(); + } + }//GEN-LAST:event_jtfadd1KeyPressed + + private void jtfadd2KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfadd2KeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jtfadd2.transferFocus(); + } + }//GEN-LAST:event_jtfadd2KeyPressed + + private void jtfhousenoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfhousenoKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jtfhouseno.transferFocus(); + } + }//GEN-LAST:event_jtfhousenoKeyPressed + + private void jftpostcodeKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jftpostcodeKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jftpostcode.transferFocus(); + jbtadd.doClick(); + } + }//GEN-LAST:event_jftpostcodeKeyPressed + + private void jcbdepartmentKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcbdepartmentKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jcbdepartment.transferFocus(); + } + }//GEN-LAST:event_jcbdepartmentKeyPressed + + private void jcbdesignationKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcbdesignationKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jcbdesignation.transferFocus(); + } + }//GEN-LAST:event_jcbdesignationKeyPressed + + private void jcbstatusKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcbstatusKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jcbstatus.transferFocus(); + } + }//GEN-LAST:event_jcbstatusKeyPressed + + private void jtfsalaryKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfsalaryKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jtfsalary.transferFocus(); + } + }//GEN-LAST:event_jtfsalaryKeyPressed + + private void jtftitleKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtftitleKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jtftitle.transferFocus(); + } + }//GEN-LAST:event_jtftitleKeyPressed + + private void jrbgenfemaleKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jrbgenfemaleKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jrbgenfemale.transferFocus(); + } + }//GEN-LAST:event_jrbgenfemaleKeyPressed + int idCount() throws ClassNotFoundException, SQLException { + Class.forName("com.mysql.cj.jdbc.Driver"); + + try (Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/shubham", "root", "")) { + + PreparedStatement countQuery = connection.prepareStatement("SELECT COUNT(*) FROM employee"); + ResultSet resultSet = countQuery.executeQuery(); + + int number = 0; + if (resultSet.next()) { + number = resultSet.getInt(1); + } + + return number; + } + } + private void jbtaddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtaddActionPerformed + + id = jftid.getText(); + name = jtfname.getText(); + surname = jtfsurname.getText(); + + if (jrbgenmale.isSelected() == true) { + gender = "male"; + + } + if (jrbgenfemale.isSelected() == true) { + gender = "female"; + } + System.out.println(gender); + email = jtfemail.getText(); + contact = jftcontact.getText(); + designation = jcbdesignation.getSelectedItem().toString(); + department = jcbdepartment.getSelectedItem().toString(); + status = jcbstatus.getSelectedItem().toString(); + SimpleDateFormat fmt = new SimpleDateFormat("dd/MM/yyyy"); + String date = fmt.format(jDateChooser1.getDate()); //jdatechooser + datehired = fmt.format(jDateChooser1.getDate()); + dob = fmt.format(jDateChooser2.getDate()); + System.out.println(datehired); + System.out.println(dob); + salary = jtfsalary.getText(); + jobtitle = jtftitle.getText(); + address1 = jtfadd1.getText(); + address2 = jtfadd2.getText(); + houseno = jtfhouseno.getText(); + postcode = jftpostcode.getText(); + if (id.isEmpty() || name.isEmpty() || surname.isEmpty() || email.isEmpty() + || contact.isEmpty() || designation.isEmpty() || department.isEmpty() || status.isEmpty() + || datehired.isEmpty() || dob.isEmpty() || salary.isEmpty() || jobtitle.isEmpty() + || address1.isEmpty() || houseno.isEmpty() || postcode.isEmpty()) { + + // Show an option or message to the user + JOptionPane.showMessageDialog(this, "Please fill in all fields.", "Incomplete Form", JOptionPane.WARNING_MESSAGE); + } else { + + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + System.out.println("Driver loaded"); + + // Connect to a database + Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/shubham", "root", ""); + System.out.println("Database connected"); + + PreparedStatement stmt = connection.prepareStatement("insert into employee values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); + stmt.setString(1, id); + stmt.setString(2, name); + stmt.setString(3, surname); + stmt.setString(4, dob); + stmt.setString(5, gender); + stmt.setString(6, department); + stmt.setString(7, designation); + stmt.setString(8, status); + stmt.setString(9, datehired); + stmt.setString(10, salary); + stmt.setString(11, jobtitle); + stmt.setString(12, email); + stmt.setString(13, contact); + stmt.setString(14, address1); + stmt.setString(15, address2); + stmt.setString(16, houseno); + stmt.setString(17, postcode); + stmt.setBinaryStream(18, fin, fin.available()); + int norows = stmt.executeUpdate(); + System.out.println("No of rows affected=" + norows); + if (norows != 0) { + String s[] = null; + form.main(s); + dispose(); + } + + connection.close(); + } catch (ClassNotFoundException e) { + System.err.println("Error loading the database driver: " + e.getMessage()); + } catch (SQLException e) { + System.err.println("SQL Error: " + e.getMessage()); + e.printStackTrace(); + } catch (IOException ex) { + Logger.getLogger(AddEmployee.class.getName()).log(Level.SEVERE, null, ex); + } + } + }//GEN-LAST:event_jbtaddActionPerformed + + private void jPanel1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPanel1KeyPressed + // TODO add your handling code here: + }//GEN-LAST:event_jPanel1KeyPressed + + private void jftcontactActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jftcontactActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jftcontactActionPerformed + + private void jcbdepartmentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbdepartmentActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jcbdepartmentActionPerformed + + private void jLabel20MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel20MouseClicked + jLabel20.setText(""); // Clear any existing text in the label + + JFileChooser jfc = new JFileChooser(); + int result = jfc.showOpenDialog(null); + + if (result == JFileChooser.APPROVE_OPTION) { + File selectedFile = jfc.getSelectedFile(); + + // Check if the selected file is an image (you may need to add more file type checks) + if (selectedFile.isFile() && (selectedFile.getName().toLowerCase().endsWith(".jpg") + || selectedFile.getName().toLowerCase().endsWith(".jpeg") + || selectedFile.getName().toLowerCase().endsWith(".png") + || selectedFile.getName().toLowerCase().endsWith(".gif"))) { + + String filename = selectedFile.getAbsolutePath(); + System.out.println(filename); + ImageIcon imageIcon = new ImageIcon(new ImageIcon(filename).getImage().getScaledInstance(jLabel20.getWidth(), jLabel20.getHeight(), Image.SCALE_DEFAULT)); + jLabel20.setIcon(imageIcon); + try { + fin = new FileInputStream(selectedFile.getAbsoluteFile()); + } catch (FileNotFoundException ex) { + Logger.getLogger(AddEmployee.class.getName()).log(Level.SEVERE, null, ex); + } + } else { + // Handle the case where the selected file is not an image + jLabel20.setText("Selected file is not an image."); + } + } + + }//GEN-LAST:event_jLabel20MouseClicked + + private void jbtcancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtcancelActionPerformed + String s[] = null; + form.main(s); + dispose(); + }//GEN-LAST:event_jbtcancelActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* 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(AddEmployee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(AddEmployee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(AddEmployee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(AddEmployee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new AddEmployee().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.ButtonGroup buttonGroup1; + private com.toedter.calendar.JDateChooser jDateChooser1; + private com.toedter.calendar.JDateChooser jDateChooser2; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + 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 jLabel16; + private javax.swing.JLabel jLabel17; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel19; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel20; + 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.JMenu jMenu1; + private javax.swing.JMenu jMenu2; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JButton jbtadd; + private javax.swing.JButton jbtcancel; + private javax.swing.JComboBox jcbdepartment; + private javax.swing.JComboBox jcbdesignation; + private javax.swing.JComboBox jcbstatus; + private javax.swing.JFormattedTextField jftcontact; + private javax.swing.JFormattedTextField jftid; + private javax.swing.JFormattedTextField jftpostcode; + private javax.swing.JRadioButton jrbgenfemale; + private javax.swing.JRadioButton jrbgenmale; + private javax.swing.JTextField jtfadd1; + private javax.swing.JTextField jtfadd2; + private javax.swing.JTextField jtfemail; + private javax.swing.JTextField jtfhouseno; + private javax.swing.JTextField jtfname; + private javax.swing.JTextField jtfsalary; + private javax.swing.JTextField jtfsurname; + private javax.swing.JTextField jtftitle; + // End of variables declaration//GEN-END:variables + +} diff --git a/Audit_details.form b/Audit_details.form new file mode 100644 index 0000000..fb4eeac --- /dev/null +++ b/Audit_details.form @@ -0,0 +1,172 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ diff --git a/Audit_details.java b/Audit_details.java new file mode 100644 index 0000000..e75ec77 --- /dev/null +++ b/Audit_details.java @@ -0,0 +1,266 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package EMS; +import javax.swing.JOptionPane; +import java.awt.*; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import net.proteanit.sql.DbUtils; + +/** + * + * @author Hyrex + */ +public class Audit_details extends javax.swing.JFrame { +Connection conn=null; +ResultSet rs=null; +PreparedStatement ps=null; + /** + * Creates new form Audit_details + */ + public Audit_details() { + initComponents(); + conn=db.java_db(); + Toolkit toolkit = getToolkit(); + Dimension size = toolkit.getScreenSize(); + setLocation(size.width/2 - getWidth()/2, + size.height/2 - getHeight()/2); + + Update_table3(); + + } + + + private void Update_table3() { + try{ + + + String sql ="SELECT i.emp_no ,i.ename, a.username,i.type, a.date, a.action FROM audit_table AS a JOIN info AS i ON a.username = i.username;"; + + ps=conn.prepareStatement(sql); + rs=ps.executeQuery(); + tbl_3.setModel(DbUtils.resultSetToTableModel(rs)); + + } + catch(Exception e){ + JOptionPane.showMessageDialog(null, e); + } + finally { + + try{ + rs.close(); + ps.close(); + + } + catch(Exception e){ + + } + } + } + + + + /** + * 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel3 = new javax.swing.JPanel(); + jScrollPane3 = new javax.swing.JScrollPane(); + tbl_3 = new javax.swing.JTable(); + jButton1 = new javax.swing.JButton(); + jPanel4 = new javax.swing.JPanel(); + jLabel2 = new javax.swing.JLabel(); + txt_search = new javax.swing.JTextField(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setResizable(false); + + jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Login_Record", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Adobe Arabic", 1, 14))); // NOI18N + + tbl_3.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" + } + )); + jScrollPane3.setViewportView(tbl_3); + + jButton1.setText("Reset"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 557, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jButton1))) + .addContainerGap()) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 327, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jButton1) + .addGap(6, 6, 6)) + ); + + jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Adobe Arabic", 1, 14))); // NOI18N + + jLabel2.setText("Employee ID:"); + + txt_search.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + txt_searchKeyReleased(evt); + } + }); + + javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel2) + .addGap(18, 18, 18) + .addComponent(txt_search, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txt_search, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(20, 20, 20) + .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(26, 26, 26) + .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void txt_searchKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_searchKeyReleased + + try { + String searchText = txt_search.getText(); + String sql = "SELECT * FROM audit_table WHERE s_no LIKE ?"; + ps = conn.prepareStatement(sql); + ps.setString(1, "%" + searchText + "%"); // Use % as a wildcard to match any characters before and after the search text + rs = ps.executeQuery(); + tbl_3.setModel(DbUtils.resultSetToTableModel(rs)); + } catch (Exception e) { + JOptionPane.showMessageDialog(null, e); + } finally { + try { + rs.close(); + ps.close(); + } catch (Exception e) { + // Handle any exceptions here + } + } + + + }//GEN-LAST:event_txt_searchKeyReleased + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + // TODO add your handling code here: + + Update_table3(); + txt_search.setText(""); + + }//GEN-LAST:event_jButton1ActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* 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(Audit_details.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(Audit_details.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(Audit_details.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(Audit_details.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + // + // + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new Audit_details().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JScrollPane jScrollPane3; + private javax.swing.JTable tbl_3; + private javax.swing.JTextField txt_search; + // End of variables declaration//GEN-END:variables +} diff --git a/Auditdata.java b/Auditdata.java new file mode 100644 index 0000000..2b987e7 --- /dev/null +++ b/Auditdata.java @@ -0,0 +1,26 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package EMS; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +/** + * + * @author MyPC + */ +class Auditdata { + + public static void auditdata(String username, String action)throws ClassNotFoundException, SQLException{ + try (Connection conn = db.java_db(); + PreparedStatement ps = conn.prepareStatement("INSERT INTO audit_table ( username, action) VALUES (?,?)")) { + ps.setString(1, username); + ps.setString(2, action); + System.out.println(username+" , "+action); + ps.executeUpdate(); + } + } +} diff --git a/DelEmployee.form b/DelEmployee.form new file mode 100644 index 0000000..6162605 --- /dev/null +++ b/DelEmployee.form @@ -0,0 +1,342 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DelEmployee.java b/DelEmployee.java new file mode 100644 index 0000000..2083b51 --- /dev/null +++ b/DelEmployee.java @@ -0,0 +1,411 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +package EMS; + +import java.awt.event.KeyEvent; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.sql.*; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.ButtonModel; +import javax.swing.ImageIcon; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; + +/** + * + * @author MyPC + */ +public class DelEmployee extends javax.swing.JFrame { + + + private String id; + private String name; + private String surname; + private String designation; + private String department; + private String salary; + Connection con = db.java_db(); + + private String getCurrentDateTime() { + Calendar cal = new GregorianCalendar(); + int month = cal.get(Calendar.MONTH); + int year = cal.get(Calendar.YEAR); + int day = cal.get(Calendar.DAY_OF_MONTH); + int second = cal.get(Calendar.SECOND); + int minute = cal.get(Calendar.MINUTE); + int hour = cal.get(Calendar.HOUR); + + String dateTime = (month + 1) + "/" + day + "/" + year + " , " + hour + ":" + minute + ":" + second; + return dateTime; +} + + public DelEmployee() { + + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jLabel8 = new javax.swing.JLabel(); + jLabel15 = new javax.swing.JLabel(); + jLabel18 = new javax.swing.JLabel(); + jtfname = new javax.swing.JTextField(); + jtfsurname = new javax.swing.JTextField(); + jtfsalary = new javax.swing.JTextField(); + jPanel2 = new javax.swing.JPanel(); + jbtcancel = new javax.swing.JButton(); + jPanel3 = new javax.swing.JPanel(); + jtfdepartment = new javax.swing.JTextField(); + jtfdesignation = new javax.swing.JTextField(); + jbtdel = new javax.swing.JButton(); + jtfempid = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + jMenuBar1 = new javax.swing.JMenuBar(); + jMenu1 = new javax.swing.JMenu(); + jMenu2 = new javax.swing.JMenu(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jPanel1.setBackground(new java.awt.Color(255, 255, 0)); + jPanel1.setEnabled(false); + + jLabel4.setFont(new java.awt.Font("Segoe UI Historic", 0, 12)); // NOI18N + jLabel4.setLabelFor(jtfname); + jLabel4.setText("Name:-"); + + jLabel5.setFont(new java.awt.Font("Segoe UI Historic", 0, 12)); // NOI18N + jLabel5.setLabelFor(jtfsurname); + jLabel5.setText("Surname:-"); + + jLabel8.setText("Department:-"); + + jLabel15.setText("Designation:-"); + + jLabel18.setLabelFor(jtfsalary); + jLabel18.setText("Basic salary:-"); + + jtfname.setToolTipText("hi"); + jtfname.setEnabled(false); + + jtfsurname.setEnabled(false); + + jtfsalary.setEnabled(false); + + jPanel2.setBackground(new java.awt.Color(255, 255, 0)); + + jbtcancel.setText("Cancel"); + jbtcancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtcancelActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(116, 116, 116) + .addComponent(jbtcancel, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(168, Short.MAX_VALUE)) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jbtcancel, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 12, Short.MAX_VALUE)) + ); + + jPanel3.setBackground(new java.awt.Color(255, 255, 0)); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 128, Short.MAX_VALUE) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 33, Short.MAX_VALUE) + ); + + jtfdepartment.setEnabled(false); + + jtfdesignation.setEnabled(false); + + jbtdel.setText("Delete Employee"); + jbtdel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtdelActionPerformed(evt); + } + }); + + jtfempid.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtfempidKeyPressed(evt); + } + }); + + jLabel3.setText("emp id :-"); + + jLabel2.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N + jLabel2.setText("Personal details"); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel4) + .addComponent(jLabel15)) + .addGap(37, 37, 37) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtfdesignation, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE) + .addComponent(jtfname) + .addComponent(jbtdel)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(150, 150, 150) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(166, 166, 166) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel8) + .addComponent(jLabel5)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jtfsurname, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE) + .addComponent(jtfdepartment))))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel18) + .addGap(39, 39, 39) + .addComponent(jtfsalary, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(285, 285, 285))) + .addComponent(jLabel2) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(249, 249, 249) + .addComponent(jLabel3) + .addGap(67, 67, 67) + .addComponent(jtfempid, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addGap(14, 14, 14) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(22, 22, 22) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jtfempid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3)) + .addGap(46, 46, 46) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(jtfname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtfsurname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(31, 31, 31) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel15) + .addComponent(jtfdesignation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jtfdepartment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel8)))) + .addGap(18, 18, 18) + .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(7, 7, 7) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jtfsalary, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel18)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 85, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtdel, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(34, 34, 34)) + ); + + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + jLabel1.setText(getCurrentDateTime()); + + jMenu1.setText("File"); + jMenuBar1.add(jMenu1); + + jMenu2.setText("Edit"); + jMenuBar1.add(jMenu2); + + setJMenuBar(jMenuBar1); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(109, 109, 109)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void jtfempidKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfempidKeyPressed + if(evt.getKeyCode() == KeyEvent.VK_ENTER){ + + try { + id = jtfempid.getText(); + PreparedStatement ps = con.prepareStatement("select * from employee where id=?"); + ps.setString(1, id); + System.out.println(id); + + ResultSet rs = ps.executeQuery(); + if (rs.next()) { + // Employee ID is available, retrieve information + name = rs.getString("name"); + surname = rs.getString("surname"); + designation = rs.getString("designation"); + department = rs.getString("department"); + salary = rs.getString("salary"); + jtfname.setText(name); + jtfsurname.setText(surname); + + jtfdesignation.setText(designation); + jtfdepartment.setText(department); + jtfsalary.setText(salary); + + } + else{ + JOptionPane.showMessageDialog(null,"record not found"); + } } catch (SQLException ex) { + Logger.getLogger(DelEmployee.class.getName()).log(Level.SEVERE, null, ex); + }} + + + + + }//GEN-LAST:event_jtfempidKeyPressed + + private void jbtdelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtdelActionPerformed + try { + String reply = DeleteDataBase.deleteData(id); + if(reply.equals("done")){ + + } + else{ + JOptionPane.showMessageDialog(null,"Error"); + } + } catch (ClassNotFoundException ex) { + Logger.getLogger(DelEmployee.class.getName()).log(Level.SEVERE, null, ex); + + } catch (SQLException ex) { + Logger.getLogger(DelEmployee.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_jbtdelActionPerformed + + private void jbtcancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtcancelActionPerformed + String s[] = null; + form.main(s); + dispose(); + }//GEN-LAST:event_jbtcancelActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* 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(AddEmployee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(AddEmployee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(AddEmployee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(AddEmployee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new DelEmployee().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel15; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel8; + private javax.swing.JMenu jMenu1; + private javax.swing.JMenu jMenu2; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JButton jbtcancel; + private javax.swing.JButton jbtdel; + private javax.swing.JTextField jtfdepartment; + private javax.swing.JTextField jtfdesignation; + private javax.swing.JTextField jtfempid; + private javax.swing.JTextField jtfname; + private javax.swing.JTextField jtfsalary; + private javax.swing.JTextField jtfsurname; + // End of variables declaration//GEN-END:variables + +} diff --git a/DeleteDataBase.java b/DeleteDataBase.java new file mode 100644 index 0000000..17b1d1f --- /dev/null +++ b/DeleteDataBase.java @@ -0,0 +1,32 @@ + +package EMS; +import java.sql.*; +/** + * + * @author MyPC + */ +public class DeleteDataBase { + + public static String deleteData(String id)throws ClassNotFoundException,SQLException { + Connection conn = db.java_db(); + + + + + PreparedStatement ps = conn.prepareStatement("delete from employee where id=?"); + ps.setString(1, id); + System.out.println(id); + int norows = ps.executeUpdate(); + System.out.println("No of rows affected="+norows); + ps.close(); + + + conn.close(); + if(norows != 0){ + return "done"; + } + else{ + return "error"; + } + } +} diff --git a/EMS-removebg-preview-removebg-preview.png b/EMS-removebg-preview-removebg-preview.png new file mode 100644 index 0000000..fb7f767 Binary files /dev/null and b/EMS-removebg-preview-removebg-preview.png differ diff --git a/EMS-removebg-preview.png b/EMS-removebg-preview.png new file mode 100644 index 0000000..6bc966e Binary files /dev/null and b/EMS-removebg-preview.png differ diff --git a/EMS.png b/EMS.png new file mode 100644 index 0000000..c5d3653 Binary files /dev/null and b/EMS.png differ diff --git a/LandingPage.form b/LandingPage.form new file mode 100644 index 0000000..fdd712b --- /dev/null +++ b/LandingPage.form @@ -0,0 +1,149 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/LandingPage.java b/LandingPage.java new file mode 100644 index 0000000..f2bd58e --- /dev/null +++ b/LandingPage.java @@ -0,0 +1,193 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +package EMS; + +/** + * + * @author MyPC + */ +public class LandingPage extends javax.swing.JFrame { + + /** + * Creates new form LandingPage + */ + public LandingPage() { + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jMenuBar1 = new javax.swing.JMenuBar(); + jMenu2 = new javax.swing.JMenu(); + jMenuItem1 = new javax.swing.JMenuItem(); + jMenuItem2 = new javax.swing.JMenuItem(); + jMenuItem8 = new javax.swing.JMenuItem(); + jSeparator3 = new javax.swing.JPopupMenu.Separator(); + jMenuItem3 = new javax.swing.JMenuItem(); + jMenuItem4 = new javax.swing.JMenuItem(); + jMenu3 = new javax.swing.JMenu(); + jMenu4 = new javax.swing.JMenu(); + jMenuItem6 = new javax.swing.JMenuItem(); + jMenuItem5 = new javax.swing.JMenuItem(); + jMenuItem7 = new javax.swing.JMenuItem(); + jMenu5 = new javax.swing.JMenu(); + jMenu6 = new javax.swing.JMenu(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jMenu2.setText("File"); + + jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_DOWN_MASK)); + jMenuItem1.setText("Open"); + jMenuItem1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jMenu2.add(jMenuItem1); + + jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.CTRL_DOWN_MASK)); + jMenuItem2.setText("Close"); + jMenuItem2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem2ActionPerformed(evt); + } + }); + jMenu2.add(jMenuItem2); + + jMenuItem8.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_DOWN_MASK)); + jMenuItem8.setText("Save"); + jMenu2.add(jMenuItem8); + jMenu2.add(jSeparator3); + + jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_DOWN_MASK)); + jMenuItem3.setText("Cut"); + jMenuItem3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem3ActionPerformed(evt); + } + }); + jMenu2.add(jMenuItem3); + + jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_DOWN_MASK)); + jMenuItem4.setText("Copy"); + jMenuItem4.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem4ActionPerformed(evt); + } + }); + jMenu2.add(jMenuItem4); + + jMenuBar1.add(jMenu2); + + jMenu3.setText("Edit"); + jMenuBar1.add(jMenu3); + + jMenu4.setText("Payroll"); + + jMenuItem6.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_4, java.awt.event.InputEvent.SHIFT_DOWN_MASK)); + jMenuItem6.setText("Salary"); + jMenu4.add(jMenuItem6); + + jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.CTRL_DOWN_MASK)); + jMenuItem5.setText("Paid"); + jMenu4.add(jMenuItem5); + + jMenuItem7.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_DOWN_MASK)); + jMenuItem7.setText("Recipt"); + jMenu4.add(jMenuItem7); + + jMenuBar1.add(jMenu4); + + jMenu5.setText("About"); + jMenuBar1.add(jMenu5); + + jMenu6.setText("Help"); + jMenuBar1.add(jMenu6); + + setJMenuBar(jMenuBar1); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 657, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 500, Short.MAX_VALUE) + ); + + pack(); + }// //GEN-END:initComponents + + private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jMenuItem3ActionPerformed + + private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jMenuItem4ActionPerformed + + private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jMenuItem2ActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* 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(LandingPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(LandingPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(LandingPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(LandingPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new LandingPage().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JMenu jMenu2; + private javax.swing.JMenu jMenu3; + private javax.swing.JMenu jMenu4; + private javax.swing.JMenu jMenu5; + private javax.swing.JMenu jMenu6; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JMenuItem jMenuItem1; + private javax.swing.JMenuItem jMenuItem2; + private javax.swing.JMenuItem jMenuItem3; + private javax.swing.JMenuItem jMenuItem4; + private javax.swing.JMenuItem jMenuItem5; + private javax.swing.JMenuItem jMenuItem6; + private javax.swing.JMenuItem jMenuItem7; + private javax.swing.JMenuItem jMenuItem8; + private javax.swing.JPopupMenu.Separator jSeparator3; + // End of variables declaration//GEN-END:variables +} diff --git a/LoginPage.form b/LoginPage.form new file mode 100644 index 0000000..e7882bc --- /dev/null +++ b/LoginPage.form @@ -0,0 +1,295 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LoginPage.java b/LoginPage.java new file mode 100644 index 0000000..985d9f3 --- /dev/null +++ b/LoginPage.java @@ -0,0 +1,423 @@ +package EMS; + + +import java.awt.event.KeyEvent; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JOptionPane; + +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +/** + * + * @author MyPC + */ +public class LoginPage extends javax.swing.JFrame { + + static String username; + String password; + String usertype; + + /** + * Creates new form LoginPage + */ + public LoginPage() { + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLabel4 = new javax.swing.JLabel(); + jlbwelcome = new javax.swing.JLabel(); + jlbinfo = new javax.swing.JLabel(); + jPanel2 = new javax.swing.JPanel(); + jtfusername = new javax.swing.JTextField(); + jbtnlogin = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + jlbpswrd = new javax.swing.JLabel(); + jComboBox1 = new javax.swing.JComboBox<>(); + jLabel3 = new javax.swing.JLabel(); + jtfpassfld = new javax.swing.JPasswordField(); + jLabel2 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setBackground(new java.awt.Color(255, 255, 0)); + setLocation(new java.awt.Point(100, 0)); + setResizable(false); + + jPanel1.setBackground(new java.awt.Color(0, 0, 153)); + + jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/EMS/EMS.png"))); // NOI18N + + jlbwelcome.setFont(new java.awt.Font("Segoe UI Historic", 1, 58)); // NOI18N + jlbwelcome.setForeground(new java.awt.Color(255, 255, 255)); + jlbwelcome.setText("Welcome"); + + jlbinfo.setFont(new java.awt.Font("Segoe UI Historic", 0, 18)); // NOI18N + jlbinfo.setForeground(new java.awt.Color(255, 255, 255)); + jlbinfo.setText("@Ashu sharma"); + jlbinfo.setToolTipText("Devloper name"); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(52, 52, 52) + .addComponent(jLabel4)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(91, 91, 91) + .addComponent(jlbwelcome)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(162, 162, 162) + .addComponent(jlbinfo))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(113, 113, 113) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jlbwelcome) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jlbinfo)) + ); + + jPanel2.setBackground(new java.awt.Color(255, 255, 0)); + + jtfusername.setFont(new java.awt.Font("Segoe UI Historic", 0, 24)); // NOI18N + jtfusername.setToolTipText("Enter the username"); + jtfusername.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jtfusernameActionPerformed(evt); + } + }); + jtfusername.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtfusernameKeyPressed(evt); + } + }); + + jbtnlogin.setFont(new java.awt.Font("Segoe UI Historic", 0, 24)); // NOI18N + jbtnlogin.setMnemonic('L'); + jbtnlogin.setText("Login"); + jbtnlogin.setToolTipText("Login"); + jbtnlogin.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 204, 0))); + jbtnlogin.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnloginActionPerformed(evt); + } + }); + jbtnlogin.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jbtnloginKeyPressed(evt); + } + }); + + jLabel1.setFont(new java.awt.Font("Segoe UI Historic", 0, 36)); // NOI18N + jLabel1.setText("Username"); + + jlbpswrd.setFont(new java.awt.Font("Segoe UI Historic", 0, 36)); // NOI18N + jlbpswrd.setText("Password"); + + jComboBox1.setFont(new java.awt.Font("Segoe UI Historic", 0, 24)); // NOI18N + jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Admin", "User" })); + jComboBox1.setToolTipText("Select user type"); + jComboBox1.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jComboBox1KeyPressed(evt); + } + }); + + jLabel3.setFont(new java.awt.Font("Segoe UI Historic", 0, 18)); // NOI18N + jLabel3.setText("Create new account"); + jLabel3.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel3MouseClicked(evt); + } + }); + jLabel3.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jLabel3KeyPressed(evt); + } + }); + + jtfpassfld.setFont(new java.awt.Font("Segoe UI Historic", 0, 24)); // NOI18N + jtfpassfld.setToolTipText("Enter password"); + jtfpassfld.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtfpassfldKeyPressed(evt); + } + }); + + jLabel2.setFont(new java.awt.Font("Segoe UI Historic", 0, 36)); // NOI18N + jLabel2.setText("Type"); + jLabel2.setToolTipText(""); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(152, 152, 152) + .addComponent(jLabel2)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(142, 142, 142) + .addComponent(jbtnlogin, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(102, 102, 102) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jtfpassfld, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtfusername, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel3) + .addGap(9, 9, 9)))) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(111, 111, 111) + .addComponent(jlbpswrd))) + .addContainerGap(162, Short.MAX_VALUE)) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(64, 64, 64) + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jtfusername, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(45, 45, 45) + .addComponent(jlbpswrd) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jtfpassfld, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(28, 28, 28) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(39, 39, 39) + .addComponent(jbtnlogin, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jLabel3) + .addContainerGap(76, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + + pack(); + setLocationRelativeTo(null); + }// //GEN-END:initComponents + private static String getCurrentDate() { + Calendar cal = new GregorianCalendar(); + int month = cal.get(Calendar.MONTH) + 1; // Month is 0-based, so add 1 + int day = cal.get(Calendar.DAY_OF_MONTH); + int year = cal.get(Calendar.YEAR); + + return day + "-" + month + "-" + year; + } + private static String getCurrentTime() { + Calendar cal = new GregorianCalendar(); + int hour = cal.get(Calendar.HOUR_OF_DAY); + int minute = cal.get(Calendar.MINUTE); + int second = cal.get(Calendar.SECOND); + + return hour + ":" + minute + ":" + second; + } + + private void audit(String username, String date, String time) throws ClassNotFoundException, SQLException { + + Class.forName("com.mysql.cj.jdbc.Driver"); + System.out.println("Driver loaded"); + + try ( // Connect to your MySQL database (replace the URL, username, and password) + Connection con = DriverManager.getConnection("jdbc:mysql://localhost/shubham", "root", "")) { + System.out.println("Database connected"); + PreparedStatement ps = con.prepareStatement("INSERT INTO audit_table ( username, date, time) VALUES (?,?,?)"); + ps.setString(1, username); + ps.setString(2, date); + ps.setString(3, time); + + } + + } + private boolean checkCredentials(String username, String password, String usertype) { + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + System.out.println("Driver loaded"); + + // Connect to your MySQL database (replace the URL, username, and password) + Connection con = DriverManager.getConnection("jdbc:mysql://localhost/shubham", "root", ""); + System.out.println("Database connected"); + + PreparedStatement ps = con.prepareStatement("select * from info where username=? and password=? and type=?"); + ps.setString(1, username); + ps.setString(2, password); + ps.setString(3, usertype); + ResultSet rs = ps.executeQuery(); + boolean status = rs.next(); + + con.close(); + return status; + } catch (ClassNotFoundException | SQLException e) { + e.printStackTrace(); + return false; + } + } + private void jtfusernameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfusernameActionPerformed + + + }//GEN-LAST:event_jtfusernameActionPerformed + + private void jtfusernameKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfusernameKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jtfusername.transferFocus(); + } + }//GEN-LAST:event_jtfusernameKeyPressed + + private void jbtnloginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnloginActionPerformed + username = jtfusername.getText(); + password = jtfpassfld.getText(); + usertype = jComboBox1.getSelectedItem().toString(); + // Call a method to check the credentials + boolean loginSuccessful = checkCredentials(username, password, usertype); + if (loginSuccessful) { + try { + + Auditdata.auditdata(username, jbtnlogin.getText()); + + String[] s = null; +// Successful login logic + form.main(s); +// System.out.println("loged in"); +// new form(); + +dispose(); + } catch (ClassNotFoundException ex) { + Logger.getLogger(LoginPage.class.getName()).log(Level.SEVERE, null, ex); + } catch (SQLException ex) { + Logger.getLogger(LoginPage.class.getName()).log(Level.SEVERE, null, ex); + } + } + else{ + JOptionPane.showMessageDialog(null, "Invalid credentials. Please try again.", "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_jbtnloginActionPerformed + public static String getusername(){ + + return username; + } + private void jtfpassfldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfpassfldKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jtfpassfld.transferFocus(); + } + }//GEN-LAST:event_jtfpassfldKeyPressed + + private void jbtnloginKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbtnloginKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jbtnlogin.doClick(); + } + }//GEN-LAST:event_jbtnloginKeyPressed + + private void jComboBox1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jComboBox1KeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jComboBox1.transferFocus(); + } + + }//GEN-LAST:event_jComboBox1KeyPressed + + private void jLabel3KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jLabel3KeyPressed + + }//GEN-LAST:event_jLabel3KeyPressed + + private void jLabel3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel3MouseClicked + String s[] = null; + RegistrationPage.main(s); + dispose(); + }//GEN-LAST:event_jLabel3MouseClicked + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* 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(LoginPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(LoginPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(LoginPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(LoginPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new LoginPage().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox jComboBox1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JButton jbtnlogin; + private javax.swing.JLabel jlbinfo; + private javax.swing.JLabel jlbpswrd; + private javax.swing.JLabel jlbwelcome; + private javax.swing.JPasswordField jtfpassfld; + private javax.swing.JTextField jtfusername; + // End of variables declaration//GEN-END:variables +} diff --git a/Printing.java b/Printing.java new file mode 100644 index 0000000..ff7230f --- /dev/null +++ b/Printing.java @@ -0,0 +1,50 @@ + +package EMS; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStream; +import com.itextpdf.text.Document; +import com.itextpdf.text.Paragraph; +import com.itextpdf.text.pdf.PdfWriter; +import javax.swing.JOptionPane; + +/** + * This class is used to create a pdf file using iText jar. + * + * @author javawithease + */ +public class Printing { + + public static void print(String username ,int year ,int month ,String totalsalary) { + try { + //Create Document instance. + Document document = new Document(); + + //Create OutputStream instance. + OutputStream outputStream + = new FileOutputStream(new File("C:\\intel\\TestFile.pdf")); + + //Create PDFWriter instance. + PdfWriter.getInstance(document, outputStream); + + //Open the document. + document.open(); + + //Add content to the document. + document.add(new Paragraph("username:- "+ username +"\n")); + document.add(new Paragraph("Month:- "+ month +"\n")); + document.add(new Paragraph("Year:- "+ year +"\n")); + document.add(new Paragraph("Total salary:- "+ totalsalary )); + JOptionPane.showMessageDialog(null, "PDF Created", "Info", 0); + //Close document and outputStream. + document.close(); + + outputStream.close(); + + System.out.println("Pdf created successfully."); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/RegistrationPage.form b/RegistrationPage.form new file mode 100644 index 0000000..9c3f680 --- /dev/null +++ b/RegistrationPage.form @@ -0,0 +1,370 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RegistrationPage.java b/RegistrationPage.java new file mode 100644 index 0000000..2a15036 --- /dev/null +++ b/RegistrationPage.java @@ -0,0 +1,441 @@ +package EMS; + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + + +import java.sql.*; +import java.awt.event.KeyEvent; + +/** + * + * @author mlvtec-01 + */ +public class RegistrationPage extends javax.swing.JFrame { + + String name; + String email; + String username; + String password; + String usertype; + public RegistrationPage() { + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jpnwlcom = new javax.swing.JPanel(); + jlbwelcome = new javax.swing.JLabel(); + jpnlogin = new javax.swing.JPanel(); + jtbusername = new javax.swing.JTextField(); + jbtregister = new javax.swing.JButton(); + jlbusername = new javax.swing.JLabel(); + jlbpassword = new javax.swing.JLabel(); + jlbusertap = new javax.swing.JLabel(); + jtbpassword = new javax.swing.JPasswordField(); + jtfname = new javax.swing.JTextField(); + jtbemail = new javax.swing.JTextField(); + jlbemail = new javax.swing.JLabel(); + jcbusertype = new javax.swing.JComboBox<>(); + jlbusertype = new javax.swing.JLabel(); + jlbname = new javax.swing.JLabel(); + jlbwelicon = new javax.swing.JLabel(); + jlbdevname = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setLocation(new java.awt.Point(100, 0)); + setResizable(false); + + jpnwlcom.setBackground(new java.awt.Color(0, 0, 153)); + + jlbwelcome.setFont(new java.awt.Font("Lucida Grande", 1, 68)); // NOI18N + jlbwelcome.setForeground(new java.awt.Color(255, 255, 255)); + jlbwelcome.setText("Welcome"); + + jpnlogin.setBackground(new java.awt.Color(255, 255, 0)); + jpnlogin.setBorder(new javax.swing.border.MatteBorder(null)); + + jtbusername.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N + jtbusername.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtbusernameKeyPressed(evt); + } + }); + + jbtregister.setBackground(new java.awt.Color(204, 204, 0)); + jbtregister.setFont(new java.awt.Font("Lucida Grande", 0, 36)); // NOI18N + jbtregister.setText("Register"); + jbtregister.setBorder(javax.swing.BorderFactory.createTitledBorder("")); + jbtregister.setOpaque(true); + jbtregister.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtregisterActionPerformed(evt); + } + }); + jbtregister.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jbtregisterKeyPressed(evt); + } + }); + + jlbusername.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N + jlbusername.setText("Username"); + + jlbpassword.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N + jlbpassword.setText("Password"); + + jlbusertap.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N + jlbusertap.setText("Login"); + jlbusertap.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jlbusertapMouseClicked(evt); + } + }); + + jtbpassword.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N + jtbpassword.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtbpasswordKeyPressed(evt); + } + }); + + jtfname.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N + jtfname.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jtfnameActionPerformed(evt); + } + }); + jtfname.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtfnameKeyPressed(evt); + } + }); + + jtbemail.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N + jtbemail.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jtbemailActionPerformed(evt); + } + }); + jtbemail.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jtbemailKeyPressed(evt); + } + }); + + jlbemail.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N + jlbemail.setText("Email"); + + jcbusertype.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N + jcbusertype.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Admin", "user" })); + jcbusertype.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcbusertypeActionPerformed(evt); + } + }); + jcbusertype.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jcbusertypeKeyPressed(evt); + } + }); + + jlbusertype.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N + jlbusertype.setText("User type"); + + jlbname.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N + jlbname.setText("Name"); + + javax.swing.GroupLayout jpnloginLayout = new javax.swing.GroupLayout(jpnlogin); + jpnlogin.setLayout(jpnloginLayout); + jpnloginLayout.setHorizontalGroup( + jpnloginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jpnloginLayout.createSequentialGroup() + .addGroup(jpnloginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jpnloginLayout.createSequentialGroup() + .addGap(292, 292, 292) + .addComponent(jlbemail)) + .addGroup(jpnloginLayout.createSequentialGroup() + .addGap(180, 180, 180) + .addGroup(jpnloginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jtfname) + .addComponent(jtbemail) + .addComponent(jtbusername) + .addComponent(jtbpassword) + .addComponent(jcbusertype, 0, 292, Short.MAX_VALUE))) + .addGroup(jpnloginLayout.createSequentialGroup() + .addGap(273, 273, 273) + .addComponent(jlbusername)) + .addGroup(jpnloginLayout.createSequentialGroup() + .addGap(286, 286, 286) + .addComponent(jlbusertype)) + .addGroup(jpnloginLayout.createSequentialGroup() + .addGap(282, 282, 282) + .addComponent(jlbpassword)) + .addGroup(jpnloginLayout.createSequentialGroup() + .addGap(283, 283, 283) + .addComponent(jlbname))) + .addGap(146, 158, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpnloginLayout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addGroup(jpnloginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpnloginLayout.createSequentialGroup() + .addComponent(jlbusertap, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(264, 264, 264)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpnloginLayout.createSequentialGroup() + .addComponent(jbtregister, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(212, 212, 212)))) + ); + jpnloginLayout.setVerticalGroup( + jpnloginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jpnloginLayout.createSequentialGroup() + .addGap(12, 12, 12) + .addComponent(jlbname) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jtfname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(37, 37, 37) + .addComponent(jlbemail) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jtbemail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(37, 37, 37) + .addComponent(jlbusername) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jtbusername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(33, 33, 33) + .addComponent(jlbpassword) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jtbpassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jlbusertype) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcbusertype, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(42, 42, 42) + .addComponent(jbtregister, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jlbusertap, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(85, 85, 85)) + ); + + jlbdevname.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N + jlbdevname.setForeground(new java.awt.Color(255, 255, 255)); + jlbdevname.setText("@Ashu sharma"); + + jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/EMS/EMS.png"))); // NOI18N + + javax.swing.GroupLayout jpnwlcomLayout = new javax.swing.GroupLayout(jpnwlcom); + jpnwlcom.setLayout(jpnwlcomLayout); + jpnwlcomLayout.setHorizontalGroup( + jpnwlcomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jpnwlcomLayout.createSequentialGroup() + .addGroup(jpnwlcomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jpnwlcomLayout.createSequentialGroup() + .addGap(106, 106, 106) + .addComponent(jlbwelicon, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jpnwlcomLayout.createSequentialGroup() + .addGap(25, 25, 25) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 340, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpnwlcomLayout.createSequentialGroup() + .addContainerGap() + .addGroup(jpnwlcomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpnwlcomLayout.createSequentialGroup() + .addComponent(jlbdevname) + .addGap(133, 133, 133)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpnwlcomLayout.createSequentialGroup() + .addComponent(jlbwelcome) + .addGap(49, 49, 49))))) + .addComponent(jpnlogin, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jpnwlcomLayout.setVerticalGroup( + jpnwlcomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jpnwlcomLayout.createSequentialGroup() + .addContainerGap() + .addComponent(jlbwelicon, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 102, Short.MAX_VALUE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jlbwelcome) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 125, Short.MAX_VALUE) + .addComponent(jlbdevname) + .addContainerGap()) + .addComponent(jpnlogin, javax.swing.GroupLayout.PREFERRED_SIZE, 677, Short.MAX_VALUE) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jpnwlcom, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jpnwlcom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void jtbusernameKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtbusernameKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jtbusername.transferFocus(); + } + }//GEN-LAST:event_jtbusernameKeyPressed + + private void jtbemailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtbemailActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jtbemailActionPerformed + + private void jtfnameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfnameActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jtfnameActionPerformed + + private void jcbusertypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbusertypeActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jcbusertypeActionPerformed + + private void jtfnameKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfnameKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jtfname.transferFocus(); + } + }//GEN-LAST:event_jtfnameKeyPressed + + private void jtbemailKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtbemailKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jtbemail.transferFocus(); + } + }//GEN-LAST:event_jtbemailKeyPressed + + private void jtbpasswordKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtbpasswordKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jtbpassword.transferFocus(); + } + }//GEN-LAST:event_jtbpasswordKeyPressed + + private void jcbusertypeKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcbusertypeKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jcbusertype.transferFocus(); + } + }//GEN-LAST:event_jcbusertypeKeyPressed + + private void jbtregisterKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbtregisterKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + jbtregister.doClick(); + } + }//GEN-LAST:event_jbtregisterKeyPressed + + private void jlbusertapMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jlbusertapMouseClicked + String s[] = null; + LoginPage.main(s); + dispose(); + }//GEN-LAST:event_jlbusertapMouseClicked + + private void jbtregisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtregisterActionPerformed + name = jtfname.getText(); + email = jtbemail.getText(); + username = jtbusername.getText(); + password = jtbpassword.getText(); + usertype = jcbusertype.getSelectedItem().toString(); +// System.out.println(name +"\n"+email+"\n"+username+"\n"+password+"\n"+usertype); + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + System.out.println("Driver loaded"); + + // Connect to a database + Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/shubham", "root", ""); + System.out.println("Database connected"); + + PreparedStatement stmt = connection.prepareStatement("insert into info(ename,email,username,password,type) values(?,?,?,?,?)"); + stmt.setString(1, name); // 1 specifies the first parameter in the query + stmt.setString(2, email); + stmt.setString(3, username); + stmt.setString(4, password); + stmt.setString(5, usertype); + int norows = stmt.executeUpdate(); + System.out.println("No of rows affected=" + norows); + if(norows != 0){ + Auditdata.auditdata(username, jbtregister.getText()); + String s[] = null; + LoginPage.main(s); + dispose(); + } + + connection.close(); +} catch (ClassNotFoundException e) { + System.err.println("Error loading the database driver: " + e.getMessage()); +} catch (SQLException e) { + System.err.println("SQL Error: " + e.getMessage()); + e.printStackTrace(); +} + + }//GEN-LAST:event_jbtregisterActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* 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(RegistrationPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(RegistrationPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(RegistrationPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(RegistrationPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new RegistrationPage().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel2; + private javax.swing.JButton jbtregister; + private javax.swing.JComboBox jcbusertype; + private javax.swing.JLabel jlbdevname; + private javax.swing.JLabel jlbemail; + private javax.swing.JLabel jlbname; + private javax.swing.JLabel jlbpassword; + private javax.swing.JLabel jlbusername; + private javax.swing.JLabel jlbusertap; + private javax.swing.JLabel jlbusertype; + private javax.swing.JLabel jlbwelcome; + private javax.swing.JLabel jlbwelicon; + private javax.swing.JPanel jpnlogin; + private javax.swing.JPanel jpnwlcom; + private javax.swing.JTextField jtbemail; + private javax.swing.JPasswordField jtbpassword; + private javax.swing.JTextField jtbusername; + private javax.swing.JTextField jtfname; + // End of variables declaration//GEN-END:variables +} diff --git a/Shubh.java b/Shubh.java new file mode 100644 index 0000000..369bb8f --- /dev/null +++ b/Shubh.java @@ -0,0 +1,2 @@ +package EMS; + diff --git a/bcprov-jdk15on-1.49.jar b/bcprov-jdk15on-1.49.jar new file mode 100644 index 0000000..e1d4bb3 Binary files /dev/null and b/bcprov-jdk15on-1.49.jar differ diff --git a/clear.png b/clear.png new file mode 100644 index 0000000..b607d90 Binary files /dev/null and b/clear.png differ diff --git a/db.java b/db.java new file mode 100644 index 0000000..e831e48 --- /dev/null +++ b/db.java @@ -0,0 +1,26 @@ +package EMS; + +import java.sql.*; +import javax.swing.*; +public class db { + + + + Connection conn=null; + public static Connection java_db(){ + + try{ + Class.forName("com.mysql.cj.jdbc.Driver"); + Connection conn =DriverManager.getConnection("jdbc:mysql://localhost:3306/shubham", "root", ""); + //JOptionPane.showMessageDialog(null, "Connection to database is successful"); + + return conn; + + + }catch (ClassNotFoundException | SQLException e){ + JOptionPane.showMessageDialog(null, e); + return null; + } + + } +} diff --git a/employeehome.form b/employeehome.form new file mode 100644 index 0000000..769eecd --- /dev/null +++ b/employeehome.form @@ -0,0 +1,35 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/employeehome.java b/employeehome.java new file mode 100644 index 0000000..522c3fe --- /dev/null +++ b/employeehome.java @@ -0,0 +1,82 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +package EMS; + +/** + * + * @author MyPC + */ +public class employeehome extends javax.swing.JFrame { + + /** + * Creates new form employeehome + */ + public employeehome() { + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 400, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 300, Short.MAX_VALUE) + ); + + pack(); + }// //GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* 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(employeehome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(employeehome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(employeehome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(employeehome.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new employeehome().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables +} diff --git a/form.form b/form.form new file mode 100644 index 0000000..dd834e8 --- /dev/null +++ b/form.form @@ -0,0 +1,384 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/form.java b/form.java new file mode 100644 index 0000000..1131f01 --- /dev/null +++ b/form.java @@ -0,0 +1,366 @@ +package EMS; + +import java.sql.SQLException; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JOptionPane; + +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +/** + * + * @author MyPC + */ +public class form extends javax.swing.JFrame { + + /** + * Creates new form form + */ + public form() { + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + jbtnlout = new javax.swing.JButton(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jPanel3 = new javax.swing.JPanel(); + jTextField1 = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + jPanel4 = new javax.swing.JPanel(); + jButton1 = new javax.swing.JButton(); + jButton2 = new javax.swing.JButton(); + jButton3 = new javax.swing.JButton(); + jButton4 = new javax.swing.JButton(); + jMenuBar1 = new javax.swing.JMenuBar(); + jMenu1 = new javax.swing.JMenu(); + jMenu2 = new javax.swing.JMenu(); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 100, Short.MAX_VALUE) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 100, Short.MAX_VALUE) + ); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setBackground(new java.awt.Color(255, 255, 0)); + setResizable(false); + + jPanel2.setBackground(new java.awt.Color(51, 51, 255)); + + jbtnlout.setBackground(new java.awt.Color(0, 0, 153)); + jbtnlout.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N + jbtnlout.setForeground(new java.awt.Color(255, 255, 255)); + jbtnlout.setText("Log Out"); + jbtnlout.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnloutActionPerformed(evt); + } + }); + + jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/EMS/EMS-removebg-preview-removebg-preview.png"))); // NOI18N + + jLabel3.setFont(new java.awt.Font("Segoe UI Historic", 1, 48)); // NOI18N + jLabel3.setForeground(new java.awt.Color(255, 255, 255)); + jLabel3.setText("Hello"); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(15, 15, 15) + .addComponent(jLabel2)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(25, 25, 25) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(17, 17, 17) + .addComponent(jbtnlout, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addGap(14, 14, 14) + .addComponent(jLabel2) + .addGap(89, 89, 89) + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 129, Short.MAX_VALUE) + .addComponent(jbtnlout, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(43, 43, 43)) + ); + + jPanel3.setBackground(new java.awt.Color(255, 255, 0)); + + jTextField1.setEditable(false); + jTextField1.setBackground(new java.awt.Color(255, 255, 0)); + jTextField1.setFont(new java.awt.Font("Segoe UI Black", 1, 36)); // NOI18N + jTextField1.setForeground(new java.awt.Color(51, 51, 51)); + jTextField1.setText("Welcome to EMP System"); + jTextField1.setBorder(null); + jTextField1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextField1ActionPerformed(evt); + } + }); + + jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/EMS/info (1).png"))); // NOI18N + jLabel1.setText("Employ Section"); + jLabel1.setToolTipText("All the details about the employee"); + jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); + jLabel1.setIconTextGap(8); + + jPanel4.setBackground(new java.awt.Color(255, 255, 0)); + + jButton1.setBackground(new java.awt.Color(255, 255, 0)); + jButton1.setFont(new java.awt.Font("Segoe UI Historic", 1, 12)); // NOI18N + jButton1.setText("Add
employee"); + jButton1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 0), 3, true)); + jButton1.setOpaque(true); + jButton1.setPreferredSize(new java.awt.Dimension(96, 96)); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + jButton2.setBackground(new java.awt.Color(255, 255, 0)); + jButton2.setFont(new java.awt.Font("Segoe UI Historic", 1, 12)); // NOI18N + jButton2.setText("Update
employee"); + jButton2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 0), 3, true)); + jButton2.setOpaque(true); + jButton2.setPreferredSize(new java.awt.Dimension(96, 96)); + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); + + jButton3.setBackground(new java.awt.Color(255, 255, 0)); + jButton3.setFont(new java.awt.Font("Segoe UI Historic", 1, 12)); // NOI18N + jButton3.setText("Delete
employee"); + jButton3.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 0), 3, true)); + jButton3.setOpaque(true); + jButton3.setPreferredSize(new java.awt.Dimension(96, 96)); + jButton3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton3ActionPerformed(evt); + } + }); + + jButton4.setBackground(new java.awt.Color(255, 255, 0)); + jButton4.setFont(new java.awt.Font("Segoe UI Historic", 1, 12)); // NOI18N + jButton4.setText("Employee
detail"); + jButton4.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 0), 3, true)); + jButton4.setOpaque(true); + jButton4.setPreferredSize(new java.awt.Dimension(96, 96)); + jButton4.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton4ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(40, 40, 40) + .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(40, 40, 40) + .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE) + .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(17, 17, 17)) + ); + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 6, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jTextField1) + .addGroup(jPanel3Layout.createSequentialGroup() + .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 1, Short.MAX_VALUE))) + .addContainerGap()) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addContainerGap(416, Short.MAX_VALUE))) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGap(88, 88, 88) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(61, 61, 61) + .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGap(158, 158, 158) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(360, Short.MAX_VALUE))) + ); + + jMenu1.setText("File"); + jMenuBar1.add(jMenu1); + + jMenu2.setText("Edit"); + jMenuBar1.add(jMenu2); + + setJMenuBar(jMenuBar1); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + + pack(); + }//
//GEN-END:initComponents + + private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jTextField1ActionPerformed + + private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed + String s[] = null; + DelEmployee.main(s); + dispose(); + }//GEN-LAST:event_jButton3ActionPerformed + + private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed + String s[] = null; + updateEmployee.main(s); + }//GEN-LAST:event_jButton2ActionPerformed + + private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed + String []s =null; + salarypage.main(s); + }//GEN-LAST:event_jButton4ActionPerformed + + private void jbtnloutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnloutActionPerformed + int choice = JOptionPane.showConfirmDialog( + null, + "Are you sure you want to Logout?", + "Confirmation", + JOptionPane.YES_NO_OPTION + ); + + if (choice == JOptionPane.YES_OPTION) { + String s[] = null; + this.dispose(); + LoginPage.main(s); + + } else { + // User clicked "No" button or closed the dialog + + } + }//GEN-LAST:event_jbtnloutActionPerformed + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + String s[] = null; + AddEmployee.main(s); + dispose(); + }//GEN-LAST:event_jButton1ActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* 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(form.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(form.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(form.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(form.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new form().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JButton jButton3; + private javax.swing.JButton jButton4; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JMenu jMenu1; + private javax.swing.JMenu jMenu2; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JTextField jTextField1; + private javax.swing.JButton jbtnlout; + // End of variables declaration//GEN-END:variables +} diff --git a/icons8-log-in-48.lnk b/icons8-log-in-48.lnk new file mode 100644 index 0000000..43c34eb Binary files /dev/null and b/icons8-log-in-48.lnk differ diff --git a/info (1).png b/info (1).png new file mode 100644 index 0000000..ae73ec9 Binary files /dev/null and b/info (1).png differ diff --git a/itextpdf-5.5.4.jar b/itextpdf-5.5.4.jar new file mode 100644 index 0000000..ee746d1 Binary files /dev/null and b/itextpdf-5.5.4.jar differ diff --git a/jcalendar-1.4.jar b/jcalendar-1.4.jar new file mode 100644 index 0000000..617a335 Binary files /dev/null and b/jcalendar-1.4.jar differ diff --git a/mysql-connector-j-8.1.0.jar b/mysql-connector-j-8.1.0.jar new file mode 100644 index 0000000..9e38a71 Binary files /dev/null and b/mysql-connector-j-8.1.0.jar differ diff --git a/per.java b/per.java new file mode 100644 index 0000000..6f79b87 --- /dev/null +++ b/per.java @@ -0,0 +1,30 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package EMS; + +/** + * + * @author MyPC + */ +public class per { + String name; + int age; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..3feaa87 --- /dev/null +++ b/readme.md @@ -0,0 +1,43 @@ +# Employee Management System with MySQL Database Integration + +## Introduction + +This Employee Management System is developed using Java Swing for the user interface, JDBC for database connectivity, and MySQL for the database management system. It provides functionalities for managing employee data, including reading, writing, updating, and deleting records. The system features a login/registration page for user authentication and a main page for performing CRUD operations on employee data. + +## Installation and Usage + +### Installation +1. Download the project files from the repository. +2. Set up MySQL database: + - Create a new database named `employee_management`. + - Import the provided SQL script (`database.sql`) to create the necessary tables and populate initial data. +3. Import the project into your preferred Java IDE. +4. Configure JDBC connection settings in the project to connect to your MySQL database. + +### Usage +1. Launch the application. +2. Log in using your username, password, and user type. +3. Upon successful login, access the main page to perform CRUD operations on employee data. +4. Any changes made to employee records will be saved in the MySQL database. + +## Specialties + +- **Efficient CRUD Operations**: The application offers a user-friendly interface for efficient Create, Read, Update, and Delete operations. +- **Data Validation**: Implemented validation mechanisms ensure the integrity and accuracy of the data entered by users. +- **Security Measures**: Appropriate security measures are in place to protect sensitive data stored in the MySQL database. + + +## Snapshots +![Update](https://github.com/Shubham25104/OHT2/assets/117568702/94b6e782-0c1b-4659-86a4-adc4cb7592a8) +![Search](https://github.com/Shubham25104/OHT2/assets/117568702/cb24e06e-201f-4591-9d46-a1587976715a) +![Sal](https://github.com/Shubham25104/OHT2/assets/117568702/146f5a42-a3aa-441c-8107-4939618a0642) +![emp_Sal](https://github.com/Shubham25104/OHT2/assets/117568702/b1215b73-61d7-41ce-82d5-c18ebbf711a9) +![0](https://github.com/Shubham25104/OHT2/assets/117568702/7a32221b-aeee-49cc-b25d-89031c824b4d) + + + + + + + + diff --git a/rs2xml.jar b/rs2xml.jar new file mode 100644 index 0000000..75d9c62 Binary files /dev/null and b/rs2xml.jar differ diff --git a/salarypage.form b/salarypage.form new file mode 100644 index 0000000..cc84980 --- /dev/null +++ b/salarypage.form @@ -0,0 +1,869 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/salarypage.java b/salarypage.java new file mode 100644 index 0000000..f02a870 --- /dev/null +++ b/salarypage.java @@ -0,0 +1,1081 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +package EMS; + +import java.awt.event.KeyEvent; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.LocalDate; +import java.time.YearMonth; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JOptionPane; + +/** + * + * @author MyPC + */ +public class salarypage extends javax.swing.JFrame { + + /** + * Creates new form salarypage + */ + String empid; + String name; + String surname; + String designation; + String department; + String salary; + double allowance1; + double allowance2; + double allowance3; + double allowance4; + double allowance5; + double allowance6; + double total; + Connection conn = db.java_db(); + YearMonth currentYearMonth = getCurrentYearMonth(); + int currentYear = currentYearMonth.getYear(); + int currentMonth = currentYearMonth.getMonthValue(); + + public salarypage() { + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jInternalFrame2 = new javax.swing.JInternalFrame(); + jlbempid = new javax.swing.JLabel(); + jtfempid = new javax.swing.JTextField(); + jmc = new com.toedter.calendar.JMonthChooser(); + jyc = new com.toedter.calendar.JYearChooser(); + jlbmonth = new javax.swing.JLabel(); + jlbyear = new javax.swing.JLabel(); + jbtshow = new javax.swing.JButton(); + jbtprint = new javax.swing.JButton(); + jInternalFrame1 = new javax.swing.JInternalFrame(); + jPanel1 = new javax.swing.JPanel(); + 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(); + jTextField1 = new javax.swing.JTextField(); + jTextField2 = new javax.swing.JTextField(); + jTextField3 = new javax.swing.JTextField(); + jTextField4 = new javax.swing.JTextField(); + jTextField6 = new javax.swing.JTextField(); + jTextField7 = new javax.swing.JTextField(); + jFormattedTextField1 = new javax.swing.JFormattedTextField(); + jLabel19 = new javax.swing.JLabel(); + jtftotalsalary = new javax.swing.JTextField(); + jPanel2 = new javax.swing.JPanel(); + jLabel9 = new javax.swing.JLabel(); + jLabel10 = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + jLabel12 = new javax.swing.JLabel(); + jLabel13 = new javax.swing.JLabel(); + jTextField8 = new javax.swing.JTextField(); + jTextField9 = new javax.swing.JTextField(); + jTextField10 = new javax.swing.JTextField(); + jTextField11 = new javax.swing.JTextField(); + jTextField12 = new javax.swing.JTextField(); + jTextField13 = new javax.swing.JTextField(); + jPanel3 = new javax.swing.JPanel(); + jLabel14 = new javax.swing.JLabel(); + jLabel15 = new javax.swing.JLabel(); + jLabel16 = new javax.swing.JLabel(); + jLabel17 = new javax.swing.JLabel(); + jLabel18 = new javax.swing.JLabel(); + jTextField14 = new javax.swing.JTextField(); + jTextField15 = new javax.swing.JTextField(); + jTextField16 = new javax.swing.JTextField(); + jTextField17 = new javax.swing.JTextField(); + jTextField18 = new javax.swing.JTextField(); + jTextField19 = new javax.swing.JTextField(); + jButton1 = new javax.swing.JButton(); + jButton2 = new javax.swing.JButton(); + jButton3 = new javax.swing.JButton(); + jMenuBar1 = new javax.swing.JMenuBar(); + jMenu1 = new javax.swing.JMenu(); + jMenu2 = new javax.swing.JMenu(); + jMenu3 = new javax.swing.JMenu(); + jMenuItem1 = new javax.swing.JMenuItem(); + jMenuItem2 = new javax.swing.JMenuItem(); + jMenu4 = new javax.swing.JMenu(); + jMenu5 = new javax.swing.JMenu(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jInternalFrame2.setVisible(false); + + jlbempid.setText("Emp id:-"); + + jtfempid.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jtfempidActionPerformed(evt); + } + }); + + jlbmonth.setText("Month"); + + jlbyear.setText("Year"); + jlbyear.setOpaque(true); + + jbtshow.setText("Show"); + + jbtprint.setText("Print"); + + javax.swing.GroupLayout jInternalFrame2Layout = new javax.swing.GroupLayout(jInternalFrame2.getContentPane()); + jInternalFrame2.getContentPane().setLayout(jInternalFrame2Layout); + jInternalFrame2Layout.setHorizontalGroup( + jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jInternalFrame2Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jInternalFrame2Layout.createSequentialGroup() + .addComponent(jlbempid) + .addGap(18, 18, 18) + .addComponent(jtfempid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jInternalFrame2Layout.createSequentialGroup() + .addComponent(jlbyear) + .addGap(18, 18, 18) + .addComponent(jyc, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(70, 70, 70) + .addComponent(jlbmonth))) + .addGap(34, 34, 34) + .addComponent(jmc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(150, 150, 150)) + .addGroup(jInternalFrame2Layout.createSequentialGroup() + .addGap(212, 212, 212) + .addComponent(jbtshow, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(70, 70, 70) + .addComponent(jbtprint, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jInternalFrame2Layout.setVerticalGroup( + jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jInternalFrame2Layout.createSequentialGroup() + .addGap(47, 47, 47) + .addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jlbempid) + .addComponent(jtfempid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(77, 77, 77) + .addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jmc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jlbyear) + .addComponent(jlbmonth)) + .addComponent(jyc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(73, 73, 73) + .addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jbtshow, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtprint, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + jInternalFrame1.setAutoscrolls(true); + jInternalFrame1.setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/EMS/clear.png"))); // NOI18N + jInternalFrame1.setMinimumSize(new java.awt.Dimension(519, 280)); + jInternalFrame1.setName("salary"); // NOI18N + jInternalFrame1.setOpaque(true); + jInternalFrame1.setVisible(true); + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(102, 102, 102), new java.awt.Color(0, 0, 0), new java.awt.Color(204, 204, 255), new java.awt.Color(204, 204, 204)), "Employee Details", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Segoe UI Historic", 1, 18))); // NOI18N + + jLabel2.setText("employee id:-"); + + jLabel3.setText("First name:-"); + + jLabel4.setText("Last name:-"); + + jLabel5.setText("Designation:-"); + + jLabel6.setText("Salary type:-"); + + jLabel7.setText("Department:-"); + + jLabel8.setText("Basic salary:-"); + + jTextField1.setText("__________"); + jTextField1.setEnabled(false); + + jTextField2.setText("__________"); + jTextField2.setEnabled(false); + + jTextField3.setText("__________"); + jTextField3.setEnabled(false); + + jTextField4.setText("__________"); + jTextField4.setEnabled(false); + + jTextField6.setText("__________"); + jTextField6.setEnabled(false); + + jTextField7.setText("__________"); + jTextField7.setEnabled(false); + + jFormattedTextField1.setText("Enter id"); + jFormattedTextField1.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jFormattedTextField1FocusGained(evt); + } + }); + jFormattedTextField1.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jFormattedTextField1KeyPressed(evt); + } + }); + + jLabel19.setText("Total salary:-"); + + jtftotalsalary.setText("__________"); + jtftotalsalary.setEnabled(false); + jtftotalsalary.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jtftotalsalaryActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addGap(41, 41, 41) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel2) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel3) + .addComponent(jLabel4))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(1, 1, 1) + .addComponent(jLabel8))) + .addGap(98, 98, 98) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jTextField4) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jTextField6) + .addComponent(jTextField7) + .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 287, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel7) + .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING))) + .addComponent(jLabel19)) + .addGap(89, 89, 89) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jTextField2) + .addComponent(jTextField3) + .addComponent(jTextField1) + .addComponent(jtftotalsalary)) + .addGap(82, 82, 82)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(30, 30, 30) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(26, 26, 26) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel8) + .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(25, 25, 25)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(34, 34, 34) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel7) + .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6) + .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jtftotalsalary, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel19)) + .addGap(31, 31, 31)))) + ); + + jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(153, 153, 153), new java.awt.Color(0, 0, 0), new java.awt.Color(204, 204, 255), new java.awt.Color(204, 204, 204)), "Salary allowance", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Segoe UI Historic", 1, 18))); // NOI18N + + jLabel9.setText("Travel allowance:-"); + + jLabel10.setText("Food allowance"); + + jLabel11.setText("Performance bonus:-"); + + jLabel12.setText("Percentage(%)"); + + jLabel13.setText("Amount"); + + jTextField8.setText("5"); + jTextField8.setDoubleBuffered(true); + jTextField8.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jTextField8KeyPressed(evt); + } + }); + + jTextField9.setText("___________"); + jTextField9.setEnabled(false); + + jTextField10.setText("5"); + jTextField10.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextField10ActionPerformed(evt); + } + }); + jTextField10.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jTextField10KeyPressed(evt); + } + }); + + jTextField11.setText("5"); + jTextField11.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextField11ActionPerformed(evt); + } + }); + jTextField11.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jTextField11KeyPressed(evt); + } + }); + + jTextField12.setText("___________"); + jTextField12.setEnabled(false); + + jTextField13.setText("___________"); + jTextField13.setEnabled(false); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(36, 36, 36) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel9) + .addComponent(jLabel10) + .addComponent(jLabel11)) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(21, 21, 21) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jTextField11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextField10, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addComponent(jLabel12)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 44, Short.MAX_VALUE) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextField12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextField13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel13) + .addGap(6, 6, 6))) + .addGap(19, 19, 19)) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel12) + .addComponent(jLabel13)) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(5, 5, 5) + .addComponent(jLabel9)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGap(18, 18, 18) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jTextField12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel10) + .addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel11) + .addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextField13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(13, Short.MAX_VALUE)) + ); + + jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(153, 153, 153), new java.awt.Color(0, 0, 0), new java.awt.Color(204, 204, 255), new java.awt.Color(204, 204, 204)), "Salary Deduction", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Segoe UI Historic", 1, 18))); // NOI18N + + jLabel14.setText("EPF:-"); + + jLabel15.setText("Tax:-"); + + jLabel16.setText("Paye:-"); + + jLabel17.setText("Percentage(%)"); + + jLabel18.setText("Amount"); + + jTextField14.setText("12"); + jTextField14.setSelectionEnd(1); + jTextField14.setSelectionStart(1); + jTextField14.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jTextField14KeyPressed(evt); + } + }); + + jTextField15.setText("5"); + jTextField15.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextField15ActionPerformed(evt); + } + }); + jTextField15.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jTextField15KeyPressed(evt); + } + }); + + jTextField16.setText("5"); + jTextField16.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextField16ActionPerformed(evt); + } + }); + jTextField16.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jTextField16KeyPressed(evt); + } + }); + + jTextField17.setText("___________"); + jTextField17.setEnabled(false); + + jTextField18.setText("___________"); + jTextField18.setEnabled(false); + + jTextField19.setText("___________"); + jTextField19.setEnabled(false); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGap(32, 32, 32) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel14) + .addComponent(jLabel15) + .addComponent(jLabel16)) + .addGap(34, 34, 34) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jTextField14, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextField15, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel17) + .addComponent(jTextField16, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 101, Short.MAX_VALUE) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() + .addComponent(jLabel18) + .addGap(34, 34, 34)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() + .addComponent(jTextField17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(12, 12, 12))) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jTextField18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextField19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(12, 12, 12))) + .addGap(20, 20, 20)) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel17) + .addComponent(jLabel18)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jTextField17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel14)) + .addComponent(jTextField14, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(21, 21, 21) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel15) + .addComponent(jTextField15, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextField18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jTextField19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jTextField16, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel16))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + jButton1.setText("Update Detais"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + jButton2.setText("Add details"); + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); + + jButton3.setText("Exit"); + jButton3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton3ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane()); + jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout); + jInternalFrame1Layout.setHorizontalGroup( + jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jInternalFrame1Layout.createSequentialGroup() + .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jInternalFrame1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jInternalFrame1Layout.createSequentialGroup() + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(69, 69, 69) + .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGroup(jInternalFrame1Layout.createSequentialGroup() + .addGap(150, 150, 150) + .addComponent(jButton1) + .addGap(97, 97, 97) + .addComponent(jButton2) + .addGap(95, 95, 95) + .addComponent(jButton3))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jInternalFrame1Layout.setVerticalGroup( + jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jInternalFrame1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(26, 26, 26) + .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton1) + .addComponent(jButton2) + .addComponent(jButton3)) + .addContainerGap(32, Short.MAX_VALUE)) + ); + + jMenu1.setText("File"); + jMenuBar1.add(jMenu1); + + jMenu2.setText("Edit"); + jMenuBar1.add(jMenu2); + + jMenu3.setText("Salary"); + + jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_DOWN_MASK | java.awt.event.InputEvent.CTRL_DOWN_MASK)); + jMenuItem1.setText("Show salary"); + jMenuItem1.setToolTipText("Show salary"); + jMenuItem1.setHideActionText(true); + jMenuItem1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem1ActionPerformed(evt); + } + }); + jMenu3.add(jMenuItem1); + + jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_DOWN_MASK)); + jMenuItem2.setText("Print salary"); + jMenuItem2.setToolTipText("Print salary"); + jMenuItem2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem2ActionPerformed(evt); + } + }); + jMenu3.add(jMenuItem2); + + jMenuBar1.add(jMenu3); + + jMenu4.setText("About"); + jMenuBar1.add(jMenu4); + + jMenu5.setText("Help"); + jMenuBar1.add(jMenu5); + + setJMenuBar(jMenuBar1); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jInternalFrame1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jInternalFrame2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(893, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jInternalFrame1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jInternalFrame2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 550, Short.MAX_VALUE))) + ); + + try { + jInternalFrame1.setMaximum(true); + } catch (java.beans.PropertyVetoException e1) { + e1.printStackTrace(); + } + + pack(); + }// //GEN-END:initComponents + + public static YearMonth getCurrentYearMonth() { + LocalDate currentDate = LocalDate.now(); // Get the current date + YearMonth currentYearMonth = YearMonth.from(currentDate); // Extract the year and month + return currentYearMonth; + } + private void jTextField11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField11ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jTextField11ActionPerformed + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jButton1ActionPerformed + + private void jTextField16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField16ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jTextField16ActionPerformed + + private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed + dispose(); + }//GEN-LAST:event_jButton3ActionPerformed + + private void jTextField8KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField8KeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + try { + double basicSalary = Double.parseDouble(salary); + double percentage = Double.parseDouble(jTextField8.getText()); + allowance1 = (basicSalary * percentage) / 100; + jTextField9.setText(String.format("%.2f", allowance1)); + double totalAllowances = allowance1 + allowance2 + allowance3 + allowance4 + allowance5 + allowance6; + double totalDeductions = 0; // Replace with any deductions if needed + double totalSalary = basicSalary + totalAllowances - totalDeductions; + jtftotalsalary.setText(String.format("%.2f", totalSalary)); + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(this, "Invalid input. Please enter valid numeric values."); + } + } + }//GEN-LAST:event_jTextField8KeyPressed + + private void jTextField10KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField10KeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + try { + double basicSalary = Double.parseDouble(salary); + double percentage = Double.parseDouble(jTextField10.getText()); + allowance2 = (basicSalary * percentage) / 100; + jTextField12.setText(String.format("%.2f", allowance2)); + double totalAllowances = allowance1 + allowance2 + allowance3 + allowance4 + allowance5 + allowance6; + double totalDeductions = 0; // Replace with any deductions if needed + double totalSalary = basicSalary + totalAllowances - totalDeductions; + jtftotalsalary.setText(String.format("%.2f", totalSalary)); + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(this, "Invalid input. Please enter valid numeric values."); + } + } + }//GEN-LAST:event_jTextField10KeyPressed + + private void jTextField11KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField11KeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + try { + double basicSalary = Double.parseDouble(salary); + double percentage = Double.parseDouble(jTextField11.getText()); + allowance3 = (basicSalary * percentage) / 100; + jTextField13.setText(String.format("%.2f", allowance3)); + double totalAllowances = allowance1 + allowance2 + allowance3 + allowance4 + allowance5 + allowance6; + double totalDeductions = 0; // Replace with any deductions if needed + double totalSalary = basicSalary + totalAllowances - totalDeductions; + jtftotalsalary.setText(String.format("%.2f", totalSalary)); + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(this, "Invalid input. Please enter valid numeric values."); + } + } + }//GEN-LAST:event_jTextField11KeyPressed + + private void jTextField14KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField14KeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + try { + double basicSalary = Double.parseDouble(salary); + double percentage = Double.parseDouble(jTextField14.getText()); + allowance4 = (basicSalary * percentage) / 100; + jTextField17.setText(String.format("%.2f", allowance4)); + double totalAllowances = allowance1 + allowance2 + allowance3 + allowance4 + allowance5 + allowance6; + double totalDeductions = 0; // Replace with any deductions if needed + double totalSalary = basicSalary + totalAllowances - totalDeductions; + jtftotalsalary.setText(String.format("%.2f", totalSalary)); + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(this, "Invalid input. Please enter valid numeric values."); +// }jtftotalsalary.setText(String.format("%.2f", total)); + } + } + }//GEN-LAST:event_jTextField14KeyPressed + + private void jTextField15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField15ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jTextField15ActionPerformed + + private void jTextField15KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField15KeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + try { + double basicSalary = Double.parseDouble(salary); + double percentage = Double.parseDouble(jTextField15.getText()); + allowance5 = (basicSalary * percentage) / 100; + jTextField18.setText(String.format("%.2f", allowance5)); + double totalAllowances = allowance1 + allowance2 + allowance3 + allowance4 + allowance5 + allowance6; + double totalDeductions = 0; // Replace with any deductions if needed + double totalSalary = basicSalary + totalAllowances - totalDeductions; + jtftotalsalary.setText(String.format("%.2f", totalSalary)); + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(this, "Invalid input. Please enter valid numeric values."); + } + } + }//GEN-LAST:event_jTextField15KeyPressed + + private void jTextField16KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField16KeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + try { + double basicSalary = Double.parseDouble(salary); + double percentage = Double.parseDouble(jTextField16.getText()); + allowance6 = (basicSalary * percentage) / 100; + jTextField19.setText(String.format("%.2f", allowance6)); + + double totalAllowances = allowance1 + allowance2 + allowance3 + allowance4 + allowance5 + allowance6; + double totalDeductions = 0; // Replace with any deductions if needed + double totalSalary = basicSalary + totalAllowances - totalDeductions; + jtftotalsalary.setText(String.format("%.2f", totalSalary)); + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(this, "Invalid input. Please enter valid numeric values."); + } + } + }//GEN-LAST:event_jTextField16KeyPressed + + private void jTextField10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField10ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jTextField10ActionPerformed + + private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed + jInternalFrame2.setVisible(true); + }//GEN-LAST:event_jMenuItem1ActionPerformed + + private void jtftotalsalaryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtftotalsalaryActionPerformed + double basicSalary = 25000; // Replace with the actual basic salary + double totalAllowances = allowance1 + allowance2 + allowance3; + double totalDeductions = +allowance4 + allowance5 + allowance6; // Replace with any deductions if needed + double totalSalary = basicSalary + totalAllowances - totalDeductions; + jtftotalsalary.setText(String.format("%.2f", totalSalary)); + + }//GEN-LAST:event_jtftotalsalaryActionPerformed + + private void jFormattedTextField1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jFormattedTextField1KeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + + empid = jFormattedTextField1.getText(); + + try { + + PreparedStatement ps = conn.prepareStatement("select * from employee where id=?"); + ps.setString(1, empid); + + ResultSet rs = ps.executeQuery(); + if (rs.next()) { + // Employee ID is available, retrieve information + name = rs.getString("name"); + surname = rs.getString("surname"); + designation = rs.getString("designation"); + department = rs.getString("department"); + salary = rs.getString("salary"); + jTextField6.setText(name); + jTextField3.setText("Monthly"); + jTextField7.setText(surname); + jTextField1.setText(designation); + jTextField2.setText(department); + jTextField4.setText(salary); + + } else { + JOptionPane.showMessageDialog(null, "record not found"); + } + } catch (SQLException ex) { + Logger.getLogger(salarypage.class.getName()).log(Level.SEVERE, null, ex); + } + + } + if (salary != null) { + try { +// double basicSalary = Double.parseDouble(salary); + double basicSalary = Double.parseDouble(salary); + double percentage = Double.parseDouble(jTextField8.getText()); + allowance1 = (basicSalary * percentage) / 100; + jTextField9.setText(String.format("%.2f", allowance1)); + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(this, "Invalid input. Please enter valid numeric values."); + } + + try { + double basicSalary = Double.parseDouble(salary); + double percentage = Double.parseDouble(jTextField10.getText()); + allowance2 = (basicSalary * percentage) / 100; + jTextField12.setText(String.format("%.2f", allowance2)); + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(this, "Invalid input. Please enter valid numeric values."); + } + try { + double basicSalary = Double.parseDouble(salary); + double percentage = Double.parseDouble(jTextField11.getText()); + allowance3 = (basicSalary * percentage) / 100; + jTextField13.setText(String.format("%.2f", allowance3)); + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(this, "Invalid input. Please enter valid numeric values."); + } + try { + double basicSalary = Double.parseDouble(salary); + double percentage = Double.parseDouble(jTextField15.getText()); + allowance4 = (basicSalary * percentage) / 100; + jTextField18.setText(String.format("%.2f", allowance4)); + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(this, "Invalid input. Please enter valid numeric values."); + } + try { + double basicSalary = Double.parseDouble(salary); + double percentage = Double.parseDouble(jTextField16.getText()); + allowance5 = (basicSalary * percentage) / 100; + jTextField19.setText(String.format("%.2f", allowance5)); + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(this, "Invalid input. Please enter valid numeric values."); + } + try { + double basicSalary = Double.parseDouble(salary); + double percentage = Double.parseDouble(jTextField14.getText()); + allowance6 = (basicSalary * percentage) / 100; + jTextField17.setText(String.format("%s", allowance6)); + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(this, "Invalid input. Please enter valid numeric values."); + } + double basicSalary = Double.parseDouble(salary); + double percentage = Double.parseDouble(jTextField14.getText()); + double totalAllowances = allowance1 + allowance2 + allowance3 + allowance4 + allowance5 + allowance6; + double totalDeductions = 0; // Replace with any deductions if needed + double totalSalary = basicSalary + totalAllowances - totalDeductions; + jtftotalsalary.setText(String.format("%.2f", totalSalary)); + + } + }//GEN-LAST:event_jFormattedTextField1KeyPressed + + private void jFormattedTextField1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jFormattedTextField1FocusGained + jFormattedTextField1.setText(""); + }//GEN-LAST:event_jFormattedTextField1FocusGained + + private void jtfempidActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfempidActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jtfempidActionPerformed + + private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed + String total = jtftotalsalary.getText(); + Printing.print(empid, currentYear, currentMonth, total); + }//GEN-LAST:event_jMenuItem2ActionPerformed + + private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed + String id = jFormattedTextField1.getText(); + String ta = jTextField9.getText(); + String fa = jTextField12.getText(); + String pb = jTextField13.getText(); + String epf = jTextField17.getText(); + String tax = jTextField18.getText(); + String paye = jTextField19.getText(); + String totalsalary = jtftotalsalary.getText(); + try { + PreparedStatement stmt = conn.prepareStatement("insert into salary values(?,?,?,?,?,?,?,?,?)"); + + + stmt.setString(1, id); + stmt.setString(2, salary); + stmt.setString(3, totalsalary); + stmt.setString(4, ta); + stmt.setString(5, fa); + stmt.setString(6, pb); + stmt.setString(7, epf); + stmt.setString(8, tax); + stmt.setString(9, paye); + + int norows = stmt.executeUpdate(); + System.out.println("No of rows affected=" + norows); + + + conn.close(); + + } catch (SQLException ex) { + Logger.getLogger(salarypage.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_jButton2ActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* 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(salarypage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(salarypage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(salarypage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(salarypage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new salarypage().setVisible(true); + } + }); + } + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JButton jButton3; + private javax.swing.JFormattedTextField jFormattedTextField1; + private javax.swing.JInternalFrame jInternalFrame1; + private javax.swing.JInternalFrame jInternalFrame2; + private javax.swing.JLabel jLabel10; + 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 jLabel16; + private javax.swing.JLabel jLabel17; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel19; + 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.JMenu jMenu1; + private javax.swing.JMenu jMenu2; + private javax.swing.JMenu jMenu3; + private javax.swing.JMenu jMenu4; + private javax.swing.JMenu jMenu5; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JMenuItem jMenuItem1; + private javax.swing.JMenuItem jMenuItem2; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JTextField jTextField1; + private javax.swing.JTextField jTextField10; + private javax.swing.JTextField jTextField11; + private javax.swing.JTextField jTextField12; + private javax.swing.JTextField jTextField13; + private javax.swing.JTextField jTextField14; + private javax.swing.JTextField jTextField15; + private javax.swing.JTextField jTextField16; + private javax.swing.JTextField jTextField17; + private javax.swing.JTextField jTextField18; + private javax.swing.JTextField jTextField19; + private javax.swing.JTextField jTextField2; + private javax.swing.JTextField jTextField3; + private javax.swing.JTextField jTextField4; + private javax.swing.JTextField jTextField6; + private javax.swing.JTextField jTextField7; + private javax.swing.JTextField jTextField8; + private javax.swing.JTextField jTextField9; + private javax.swing.JButton jbtprint; + private javax.swing.JButton jbtshow; + private javax.swing.JLabel jlbempid; + private javax.swing.JLabel jlbmonth; + private javax.swing.JLabel jlbyear; + private com.toedter.calendar.JMonthChooser jmc; + private javax.swing.JTextField jtfempid; + private javax.swing.JTextField jtftotalsalary; + private com.toedter.calendar.JYearChooser jyc; + // End of variables declaration//GEN-END:variables +} diff --git a/updateEmployee.form b/updateEmployee.form new file mode 100644 index 0000000..1eec387 --- /dev/null +++ b/updateEmployee.form @@ -0,0 +1,439 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/updateEmployee.java b/updateEmployee.java new file mode 100644 index 0000000..4004b2c --- /dev/null +++ b/updateEmployee.java @@ -0,0 +1,515 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +package EMS; + +import java.awt.event.KeyEvent; +import java.sql.*; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JOptionPane; + +/** + * + * @author MyPC + */ +public class updateEmployee extends javax.swing.JFrame { + + private String id; + private String name; + private String surname; + private String email; + private String contact; + private String salary; + private String address1; + private String address2; + private String houseno; + private String postcode; + Connection conn = db.java_db(); + + private String getCurrentDateTime() { + Calendar cal = new GregorianCalendar(); + int month = cal.get(Calendar.MONTH); + int year = cal.get(Calendar.YEAR); + int day = cal.get(Calendar.DAY_OF_MONTH); + int second = cal.get(Calendar.SECOND); + int minute = cal.get(Calendar.MINUTE); + int hour = cal.get(Calendar.HOUR); + + String dateTime = (month + 1) + "/" + day + "/" + year + " , " + hour + ":" + minute + ":" + second; + return dateTime; + } + + public updateEmployee() { + 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jLabel9 = new javax.swing.JLabel(); + jLabel10 = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + jLabel12 = new javax.swing.JLabel(); + jLabel13 = new javax.swing.JLabel(); + jLabel14 = new javax.swing.JLabel(); + jLabel18 = new javax.swing.JLabel(); + jftid = new javax.swing.JFormattedTextField(); + jtfname = new javax.swing.JTextField(); + jtfsurname = new javax.swing.JTextField(); + jtfsalary = new javax.swing.JTextField(); + jtfhouseno = new javax.swing.JTextField(); + jtfadd2 = new javax.swing.JTextField(); + jtfadd1 = new javax.swing.JTextField(); + jtfemail = new javax.swing.JTextField(); + jtfcontact = new javax.swing.JFormattedTextField(); + jftpostcode = new javax.swing.JFormattedTextField(); + jPanel2 = new javax.swing.JPanel(); + jbtupdate = new javax.swing.JButton(); + jbtcancel = new javax.swing.JButton(); + jPanel3 = new javax.swing.JPanel(); + jLabel2 = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + jMenuBar1 = new javax.swing.JMenuBar(); + jMenu1 = new javax.swing.JMenu(); + jMenu2 = new javax.swing.JMenu(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jPanel1.setBackground(new java.awt.Color(255, 255, 0)); + jPanel1.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jPanel1KeyPressed(evt); + } + }); + + jLabel3.setFont(new java.awt.Font("Segoe UI Historic", 0, 12)); // NOI18N + jLabel3.setLabelFor(jftid); + jLabel3.setText("Employee id:-"); + + jLabel4.setFont(new java.awt.Font("Segoe UI Historic", 0, 12)); // NOI18N + jLabel4.setLabelFor(jtfname); + jLabel4.setText("Name:-"); + + jLabel5.setFont(new java.awt.Font("Segoe UI Historic", 0, 12)); // NOI18N + jLabel5.setLabelFor(jtfsurname); + jLabel5.setText("Surname:-"); + + jLabel9.setLabelFor(jtfemail); + jLabel9.setText("Email:-"); + + jLabel10.setLabelFor(jtfcontact); + jLabel10.setText("Contact:-"); + + jLabel11.setLabelFor(jtfadd1); + jLabel11.setText("Address line 1:-"); + + jLabel12.setLabelFor(jtfadd2); + jLabel12.setText("Address line 2:-"); + + jLabel13.setLabelFor(jtfhouseno); + jLabel13.setText("House no:-"); + + jLabel14.setLabelFor(jftpostcode); + jLabel14.setText("Post code:-"); + + jLabel18.setLabelFor(jtfsalary); + jLabel18.setText("Basic salary:-"); + + jftid.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jftidKeyPressed(evt); + } + }); + + jtfname.setToolTipText("hi"); + + jtfsalary.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jtfsalaryActionPerformed(evt); + } + }); + + jtfcontact.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("##########")))); + jtfcontact.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jtfcontactActionPerformed(evt); + } + }); + + jPanel2.setBackground(new java.awt.Color(255, 255, 0)); + + jbtupdate.setText("Update record"); + jbtupdate.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtupdateActionPerformed(evt); + } + }); + + jbtcancel.setText("Cancel"); + jbtcancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtcancelActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jbtupdate, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(45, 45, 45) + .addComponent(jbtcancel, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jbtcancel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jbtupdate, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + jPanel3.setBackground(new java.awt.Color(255, 255, 0)); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 148, Short.MAX_VALUE) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 33, Short.MAX_VALUE) + ); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3) + .addComponent(jLabel4) + .addComponent(jLabel5) + .addComponent(jLabel14) + .addComponent(jLabel13) + .addComponent(jLabel12) + .addComponent(jLabel11) + .addComponent(jLabel10)) + .addGap(25, 25, 25) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jtfhouseno, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtfadd2, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtfcontact, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jftid, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtfname, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtfsurname, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtfadd1, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jftpostcode)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel18) + .addGap(18, 18, 18) + .addComponent(jtfsalary, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(59, 59, 59)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel9) + .addGap(27, 27, 27) + .addComponent(jtfemail) + .addGap(87, 87, 87)))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52, Short.MAX_VALUE) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(39, 39, 39)))) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(12, 12, 12) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(jftid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(jtfname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel18) + .addComponent(jtfsalary, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5) + .addComponent(jtfsurname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel9) + .addComponent(jtfemail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(28, 28, 28)) + .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel10) + .addComponent(jtfcontact, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel11) + .addComponent(jtfadd1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(38, 38, 38) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel12) + .addComponent(jtfadd2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(24, 24, 24) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel13) + .addComponent(jtfhouseno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel14) + .addComponent(jftpostcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(94, 94, 94)) + ); + + jLabel2.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N + jLabel2.setText("Employee details"); + + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + jLabel1.setText(getCurrentDateTime()); + + jMenu1.setText("File"); + jMenuBar1.add(jMenu1); + + jMenu2.setText("Edit"); + jMenuBar1.add(jMenu2); + + setJMenuBar(jMenuBar1); + + 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() + .addGap(22, 22, 22) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(22, Short.MAX_VALUE) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(7, 7, 7) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void jPanel1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPanel1KeyPressed + // TODO add your handling code here: + }//GEN-LAST:event_jPanel1KeyPressed + + private void jbtcancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtcancelActionPerformed + String s[] = null; + form.main(s); + dispose(); + }//GEN-LAST:event_jbtcancelActionPerformed + + private void jbtupdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtupdateActionPerformed + try { + id = jftid.getText(); + name = jtfname.getText(); + surname = jtfsurname.getText(); + email = jtfemail.getText(); + contact = jtfcontact.getText(); + salary = jtfsalary.getText(); + address1 = jtfadd1.getText(); + address2 = jtfadd2.getText(); + houseno = jtfhouseno.getText(); + postcode = jftpostcode.getText(); + + PreparedStatement stmt = conn.prepareStatement("UPDATE employee SET name = ?, surname = ?, email = ?, contact = ?, salary = ?, address1 = ?, address2 = ?, house_no = ?, post_code = ? WHERE id = ?"); + stmt.setString(1, name); + stmt.setString(2, surname); + stmt.setString(3, email); + stmt.setString(4, contact); + stmt.setString(5, salary); + stmt.setString(6, address1); + stmt.setString(7, address2); + stmt.setString(8, houseno); + + stmt.setString(9, postcode); + stmt.setString(10, id); + int norows = stmt.executeUpdate(); + if (norows != 0) { + String s[] = null; + form.main(s); + dispose(); + } + } catch (SQLException ex) { + Logger.getLogger(updateEmployee.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_jbtupdateActionPerformed + + private void jtfcontactActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfcontactActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jtfcontactActionPerformed + + private void jtfsalaryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfsalaryActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jtfsalaryActionPerformed + + private void jftidKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jftidKeyPressed + if(evt.getKeyCode() == KeyEvent.VK_ENTER){ + id = jftid.getText(); + try { + PreparedStatement ps = conn.prepareStatement("select * from employee where id=?"); + ps.setString(1, id); + System.out.print(id); + ResultSet rs = ps.executeQuery(); + if (rs.next()) { + // Employee ID is available, retrieve information + name = rs.getString("name"); + surname = rs.getString("surname"); + email = rs.getString("email"); + contact = rs.getString("contact"); + salary = rs.getString("salary"); + address1 = rs.getString("address1"); + address2 = rs.getString("address2"); + postcode = rs.getString("post_code"); + houseno = rs.getString("house_no"); + jtfname.setText(name); + jtfsurname.setText(surname); + jtfemail.setText(email); + jtfcontact.setText(contact); + jtfsalary.setText(salary); + jtfadd1.setText(address1); + jtfadd2.setText(address2); + jftpostcode.setText(postcode); + jtfhouseno.setText(houseno); + + } + else{ + JOptionPane.showMessageDialog(null,"record not found"); + } + } catch (SQLException ex) { + Logger.getLogger(salarypage.class.getName()).log(Level.SEVERE, null, ex); + } + + } + }//GEN-LAST:event_jftidKeyPressed + + + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* 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(AddEmployee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(AddEmployee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(AddEmployee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(AddEmployee.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new updateEmployee().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel9; + private javax.swing.JMenu jMenu1; + private javax.swing.JMenu jMenu2; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JButton jbtcancel; + private javax.swing.JButton jbtupdate; + private javax.swing.JFormattedTextField jftid; + private javax.swing.JFormattedTextField jftpostcode; + private javax.swing.JTextField jtfadd1; + private javax.swing.JTextField jtfadd2; + private javax.swing.JFormattedTextField jtfcontact; + private javax.swing.JTextField jtfemail; + private javax.swing.JTextField jtfhouseno; + private javax.swing.JTextField jtfname; + private javax.swing.JTextField jtfsalary; + private javax.swing.JTextField jtfsurname; + // End of variables declaration//GEN-END:variables + +}