Home Discussion Discuss: Add Edit And Delete Employee Information

  • very helpfulmicka July 1, 2011 at 11:10 PM

    thanks alot roseindia

  • there is a error in this code jansi January 14, 2012 at 3:27 PM

    i had error in this source code while running the program like this->Error in submitting data.how to solve this error?

  • comment shobhita February 28, 2012 at 11:39 AM

    its so In this section, you will learn how to add, edit and delete the Employee's information from the database using java swing. For this purpose, we have used three tabs using JTabbedPane class. Under these tabs, we have created three forms using JLabel and JTextField class which are enclosed into a panel which is then added to the JTabbedPane. In the first tab, we have prompted the user to enter the form fields to save the new employee's information into the database. The second tab will edit the Employee's information. For this, again, we have created the same form with two buttons. When the user enters the id and click the edit button, the information of the particular employee will be displayed on the respective textfields and the user can easily make changes in it. Then on clicking the save button, the information will get updated. In the third tab, we have allowed the user to delete the particular employee from the database. On entering the Employee id and click the button, the information of that employee will get removed from the database.

  • errordunnnx April 15, 2012 at 2:15 PM

    i just got error when im trying to insert a new data. my db db name : test table : employee attribute : emp_id,emp_name,emp_address,salary and i already change the source code to this : String url = "jdbc:mysql://localhost/test"; String db = "test"; String driver = "com.mysql.jdbc.Driver"; String user = "root"; String pass = "";

  • Thanks a lot....Glory June 21, 2012 at 1:14 PM

    Good Project for learning swing with MYSql connectivity

  • inserting data into database through jtextxfieldMozum July 12, 2012 at 4:47 PM

    I found your code highly which I used to create project shown below invaluable. But I can still not insert data into my database as it displayed error in submitting data when I attempt to run it. The code: package staffsalary; import java.awt.*; import java.awt.Color; import javax.swing.*; import java .awt.event.*; import java.sql.*; import java.text.DecimalFormat; class Staffsalary extends JFrame { DecimalFormat naira = new DecimalFormat("###,##0.00"); JTextField sureNameTxt= new JTextField(10); JLabel surel = new JLabel("Sure name"); JTextField nameTxt = new JTextField(10); JLabel naml = new JLabel("First name"); JTextField deptTxt = new JTextField(10); JLabel deptl = new JLabel("Department"); JComboBox state = new JComboBox(); JLabel statel = new JLabel("State"); JTextField fileTxt = new JTextField(5); JLabel filel = new JLabel("File number"); JTextField glTxt = new JTextField(3); JLabel gll = new JLabel("Grade level"); JTextField acctTxt = new JTextField(10); JLabel acctl = new JLabel("Account\n number"); JTextField bankTxt = new JTextField(10); JLabel bankl = new JLabel("Bank"); JTextField emlTxt = new JTextField(10); JLabel emll = new JLabel("Total emolument"); JComboBox sex = new JComboBox(); JLabel sexl = new JLabel("Marital status"); JLabel dedl = new JLabel("Deductions"); JTextField taxTxt = new JTextField(7); JLabel taxl = new JLabel("PAYE"); JTextField duesTxt = new JTextField(7); JLabel duesl = new JLabel("Union dues"); JTextField swaTxt = new JTextField(7); JLabel swal = new JLabel("SWA"); JTextField nhsTxt = new JTextField(7); JLabel nhsl = new JLabel("NHS"); JTextField penTxt = new JTextField(7); JLabel penl = new JLabel("Pension"); JTextField totTxt = new JTextField(10); JLabel totl = new JLabel("Total deduction"); JTextField netTxt = new JTextField(10); JLabel netl = new JLabel("Net salary"); JLabel bit = new JLabel("Bio Data"); JButton salbtn = new JButton("Compute salary"); JButton resetbtn = new JButton("Reset"); public static void main(String[]args) { System.out.printf("%7s%12s%15s%22s%20s%18s%18s\n","File number","Sure name", "Name","Bank", "Gross pay","Total deduction","Net pay"); Staffsalary jf = new Staffsalary(); } public Staffsalary() { setLayout(new FlowLayout()); setSize(370,500); setTitle("NPC STAFF SALARY PAY ROLL"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().setBackground(Color.PINK); JPanel bio = new JPanel(); bio.add(bit); add("North", bio); JPanel top = new JPanel(); top.setLayout(new FlowLayout()); top.add(surel); top.add(sureNameTxt); top.add(naml); top.add(nameTxt); sureNameTxt.setEditable(true); nameTxt.setEditable(true); add("West", top); JPanel side = new JPanel(); side.setLayout(new FlowLayout()); side.add(deptl); side.add(deptTxt); side.add(statel); state.addItem("Abia"); state.addItem("Adamawa"); state.addItem("Akwa Ibom"); state.addItem("Anambra"); state.addItem("Bauchi"); state.addItem("Bayelsa"); state.addItem("Benue"); state.addItem("Borno"); state.addItem("CrossRiver"); state.addItem("Delta"); state.addItem("Ebonyi"); state.addItem("Edo"); state.addItem("Ekiti"); state.addItem("Enugu"); state.addItem("Gombe"); state.addItem("Imo"); state.addItem("Jigawa"); state.addItem("Kaduna"); state.addItem("Kano"); state.addItem("Katsina"); state.addItem("Kebbi"); state.addItem("Kogi"); state.addItem("Kwara"); state.addItem("Lagos"); state.addItem("Nassarawa"); state.addItem("Niger"); state.addItem("Ogun"); state.addItem("Ondo"); state.addItem("Osun"); state.addItem("Oyo"); state.addItem("Rivers"); state.addItem("Sokoto"); state.addItem("Taraba"); state.addItem("Yobe"); state.addItem("Zamfara"); state.addItem("FCT"); side.add(state); deptTxt.setEditable(true); add("West", side); JPanel low = new JPanel(); low.setLayout(new FlowLayout()); low.add(filel); low.add(fileTxt); low.add(gll); low.add(glTxt); fileTxt.setEditable(true); glTxt.setEditable(true); add("West", low); JPanel rigth = new JPanel(); rigth.setLayout(new FlowLayout()); rigth.add(acctl); rigth.add(acctTxt); rigth.add(bankl); rigth.add(bankTxt); add("West", rigth); JPanel left = new JPanel(); left.setLayout(new FlowLayout()); left.add(emll); left.add(emlTxt); add("West", left); JPanel back = new JPanel(); back.setLayout(new FlowLayout()); sex.addItem("Married"); sex.addItem("Single"); sex.addItem("Seperated"); sex.addItem("Divorce"); sex.addItem("Widow"); back.add(sex); add("West", back); JPanel front = new JPanel(); front.setLayout(new FlowLayout()); front.add(dedl); add("Center", front); JPanel centre = new JPanel(); centre.setLayout(new FlowLayout()); centre.add(taxl); centre.add(taxTxt); centre.add(duesl); centre.add(duesTxt); add("West", centre); JPanel act = new JPanel(); act.setLayout(new FlowLayout()); act.add(swal); act.add(swaTxt); act.add(nhsl); act.add(nhsTxt); add("West", act); JPanel sat = new JPanel(); sat.setLayout(new FlowLayout()); sat.add(penl); sat.add(penTxt); add("West", sat); JPanel middle = new JPanel(); middle.setLayout(new FlowLayout()); middle.add(totl); middle.add(totTxt); totTxt.setEditable(false); add("West", middle); JPanel wide = new JPanel(); wide.setLayout(new FlowLayout()); wide.add(netl); wide.add(netTxt); netTxt.setEditable(false); add("West", wide); final JPanel min = new JPanel(); min.setLayout(new FlowLayout()); min.add(salbtn); min.add(resetbtn); add("West", min); resetbtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ sureNameTxt.setText(" "); nameTxt.setText(" "); deptTxt.setText(" "); fileTxt.setText(" "); bankTxt.setText(" "); acctTxt.setText(" "); emlTxt.setText(" "); taxTxt.setText(" "); duesTxt.setText(" "); swaTxt.setText(" "); nhsTxt.setText(" "); penTxt.setText(" "); totTxt.setText(" "); netTxt.setText(" "); glTxt.setText(" "); } }); salbtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent er) { double tamount = calculateSalary(); double ttamt = tamount; taxTxt.setText("" + naira.format(ttamt * 0.026398)); duesTxt.setText("" + naira.format(ttamt * 0.00771730)); double swat = 0; nhsTxt.setText("" + naira.format(ttamt * 0.0115767)); penTxt.setText("" + naira.format(ttamt * 0.05636)); emlTxt.setText("" +naira.format(ttamt)); double totalDeduction = (ttamt * 0.026398 )+ (ttamt * 0.00771730) + (ttamt * 0.0115767) + (ttamt * 0.05636 ) + swat; double netPay = (ttamt - totalDeduction); totTxt.setText(" " + naira.format(totalDeduction)); netTxt.setText(" " + naira.format(netPay)); String due = duesTxt.getText(); String nhs = nhsTxt.getText(); String pen = penTxt.getText(); String eml = emlTxt.getText(); String tot = totTxt.getText(); String net = netTxt.getText(); String tx = taxTxt.getText(); String sureName = sureNameTxt.getText(); String name = nameTxt.getText(); String acc = acctTxt.getText(); String bnk = bankTxt.getText(); String file = fileTxt.getText(); String dep = deptTxt.getText(); String url = "jdbc:mysql://localhost:3306/salary"; String user = "admin"; String pass = ""; System.out.printf( "\n%s" ,file + " " +sureName + " "+ name + " " + dep +" " + bnk + " " + naira.format(ttamt ) + " "+ naira.format(totalDeduction) + " " + " " +naira.format( netPay)+" "+acc) ; try{ Connection con = DriverManager.getConnection(url, user, pass); PreparedStatement st=con.prepareStatement("insert into staffs(`file_name`," + "`sure_name`,`first_name`,`department`,`payee`,`union_dues`,`nhs`,`pension`," + "`total_emolument`,`total_deduction`,`net_salary`,`bank_name`,`accountNumber`" + ") values(?,?,?,?,?,?,?,?,?,?,?,?,?)"); st.setString(1, file); st.setString(2,sureName); st.setString(3, name); st.setString(4, dep); st.setString(5, tx); st.setString(6, due); st.setString(7, nhs); st.setString(8, pen); st.setString(9, eml); st.setString(10, tot); st.setString(11, net); st.setString(12, bnk); st.setString(13, acc); st.executeUpdate(); JOptionPane.showMessageDialog(null, "Data is successfully inserted into database"); con.close(); } catch(Exception e){ JOptionPane.showMessageDialog(null, "error in submitting data"); } } }); setResizable(true); setVisible(true); } public double calculateSalary() { String gdrStr = JOptionPane.showInputDialog("Enter grade level"); String stepStr = JOptionPane.showInputDialog("Enter step"); int gdr = Integer.parseInt(gdrStr); int step = Integer.parseInt(stepStr); double amount; switch (gdr) { case 1: amount = 17073.17 + ((step - 1) * 4469); return amount; case 2: amount = 17350.50 + ((step - 1) * 486.92); return amount; case 3: amount = 17587.33 + ((step - 1) * 598.50); return amount; case 4: amount = 18422.67 + ((step- 1) * 719.08); return amount; case 5: amount = 20874.33 + ((step - 1) * 835.33); return amount; case 6: amount = 25452.42 + ((step - 1) * 950.92); return amount; case 7: amount = 42263.75 + ((step - 1) * 1562.33); return amount; case 8: amount = 54615.33 + ((step - 1) * 1860); return amount; case 9: amount = 64154.83 + ((step - 1) * 2214.50); return amount; case 10: amount = 75309.25 + ((step - 1) * 2435.75); return amount; case 12: amount = 86867.33 + ((step - 1) * 3777.42); return amount; case 13: amount = 96952.75 + ((step - 1) * 3993.50); return amount; case 14: amount = 107084.83 + ((step - 1) * 4299.25); return amount; case 15: amount = 147318 + ((step - 1) ) * 6088.83; return amount; case 16: amount = 182239.75 + ((step - 1) * 7292.67); return amount; case 17: amount = 347733.33 + ((step - 1) * 1313.92); return amount; default : amount = 0; return amount; } } }

  • javasunny July 15, 2012 at 11:59 AM

    it was very helpfull

  • About Sampol Inventry SystemMohamed Hafees July 16, 2012 at 8:34 PM

    HI All I am Hafees from Srilanka. I am a software engineering student. Now i want to create a INVENTORY SYSTEM for my end of my course but i try to create system but result error, error. So please if you can do any help for me please inform through my mail id . Mohamed Hafees

  • Thankskrishan mishra October 23, 2012 at 4:29 PM

    Hi, Iam krishan mishra.iwould like to you that, this code is very usefull for those person who is bignner in java . kindly provide some more java code and programm with concept. Thanks & Regards Krishan Mishra

  • Instruction about the above programHIREN MODI November 7, 2012 at 4:21 PM

    It shows the error * Error in Data Write/Edit/Delete but you set String pass =""; // then it works perfectly

  • ERRORRumiana October 6, 2013 at 6:49 PM

    Hi! I have a error when I insert data intro table. I create a database employee with following fields - emp_id, emp_name, emp_address, salary in test, but still failing. What is wrong?

  • apprremathias January 10, 2014 at 6:49 PM

    really this is fantastic example !!!!!!!!!!!!

  • databasetarun December 3, 2011 at 5:47 AM

    how can i replace mysql with sqlite database...plz guid me..i want to make it standalone application.

Post your Comment



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
General

Add Edit And Delete Employee Information
Add Edit and Delete Employee Information Using Swing  ..., edit and delete the Employee's information from the database using java swing... information into the database. The second tab will edit the Employee's information 

JSP Servlet Questions

delete
type="button" name="edit" value="Delete" style="background-color:red;font-weight... = conn.createStatement(); st.executeUpdate("DELETE FROM employee WHERE empid...delete  how delete only one row in the database using jsp.database 

Struts Questions

delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name 

Struts Questions

delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name 

Struts Questions

delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name 

Struts Questions

delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name 

Struts Questions

delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name 

Struts Questions

delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name 

Struts Questions

delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name 

Struts Questions

delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name 

Struts Questions

delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name 

Struts Questions

delete and edit options in struts
delete and edit options in struts  Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...="500"></td><td><input type="button" value="Delete" name 

Struts Questions

delete and edit options in struts
delete and edit options in struts   Hi, I am doing an web application... errors but the edit and delete operations were not working, so please modify my...;/action> <!-- end of Edit items --> <!-- Delete Items 

JSP Servlet Questions

data grid with edit and delete options at each row.
data grid with edit and delete options at each row.  i want to display the table data in the format of data grid with edit and delete options at each row. i need it very urgently. advance thanks 

JSP Servlet Questions

get details of employee after enter the emp_id
option add new,modify and delet employee   Please visit the following.../JSP-Servlet/18899-data-grid-with-edit-and-delete-options-at-each-row-.html...get details of employee after enter the emp_id  how to get employee 

JSP Servlet Questions

get details of employee after enter the emp_id
option add new,modify and delet employee   Please visit the following.../JSP-Servlet/18899-data-grid-with-edit-and-delete-options-at-each-row-.html...get details of employee after enter the emp_id  how to get employee 

Swing AWT

Employee form
Employee form  In employee form emp Id id after any data iserted is incremented for oher data insertion. insert, delete, update buttons when we cleak the select buttoun then the created table data iserted automaticaly 

JSP Servlet Questions

insert , edit , and delete button in one jsp page
insert , edit , and delete button in one jsp page  hello I want to ask about the way of creating a jsp page contains insert , edit , and delete buttons and manipulate data in database directly. any help please or hints 

JavaScript Questions

employee records
employee records  Pl give one script like i will creat one table name... will enter New record and another form like emp_code query and update or delete and one report like details of employee thanks 

JavaScript Questions

employee records
employee records  Pl give one script like i will creat one table name... will enter New record and another form like emp_code query and update or delete and one report like details of employee thanks 

JavaScript Questions

employee records
employee records  Pl give one script like i will creat one table name... will enter New record and another form like emp_code query and update or delete and one report like details of employee thanks 

JSP Servlet Questions

edit data
edit data  sir i want to do edit a particular customers information after he logs in, i am also using sessions. thank you 

JSP Servlet Questions

application for an Employee
: in this page it should modify employee data and persist in DB 3.DISPLAY:it should display all the records and should have the option to delete a record 

JSP Servlet Questions

Delete and edit data in xml file using JSP
Delete and edit data in xml file using JSP   I want to know how to delete and edit data from an XML file by use of JSP. I have XML file having tasks... in the xml file,I want to delete and edit some tasks using task id then how can i do 

PHP Questions

Edit the record.
Edit the record.  sir, I have a table consist of huge data.I have displayed that data.side of them there is an edit button which will edit that particular record.after editing the data i want to edit another row which is next 

JSP Servlet Questions

jsp :how to edit table of data displayed using jsp when clicked on edit button
jsp :how to edit table of data displayed using jsp when clicked on edit button  i have a jsp program which displays data in the form of table ..now i want to delete this information in table when click on delete button and save 

JSP Servlet Questions

create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?  I have a project ie create an application for users to create,edit and delete tasks: taskid, taskname, date, project in JSP and struts 

JSP Servlet Questions

create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?  I have a project ie create an application for users to create,edit and delete tasks: taskid, taskname, date, project in JSP and struts 

JSP Interview Questions

jsp :how to edit table of data displayed using jsp when clicked on edit button
want to edit this information in table when clicked on edit button and save...jsp :how to edit table of data displayed using jsp when clicked on edit... the particular edit button, that data will get shown in another page and allow the user 

JSP Servlet Questions

Update / Edit data
Update / Edit data  Hello, i want to create a page to edit or update... consists of that particular id. When the user clicks the particular edit button...(url+db,userName,password); String query = "select * from employee"; st 

DMCA.com