Professional Documents
Culture Documents
Menu bar
Login
this.setvisible(false);
new emp1.setvisible(true);
Employee registration:
this.setvisible(false);
new Employeeregistration().setvisible(true);
Employee details:
this.setvisible(false);
new Employeedetails().setvisible(true);
new sallog().setvisible(true);
new salarylogin().setvisible(true);
Toolbar
-Search
if(pd.equals("one")){
this.setVisible(false);
new emp1().setVisible(true);
else{
JOptionPane.showMessageDialog(null,"Invalid Password");
Clear:
t1.setText("");
pwd.setText("");
Exit:
System.exit(0);
Coding:
Save:
try{
Class.forName("java.sql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost/employee","root","deep");
stmt=con.createStatement();
rs=stmt.executeQuery(sql);
while(rs.next()){
String eid=txtid.getText();
String ename=txtname.getText();
String edepart=txtdepartment.getText();
String edate=txtdate.getText();
String eaddress=txtadd.getText();
String ecity=txtcity.getText();
String ephone=txtphone.getText();
int rowsEffected=stmt.executeUpdate(query);
catch(Exception ex){
JOptionPane.showMessageDialog(this, ex);}
Back to main:
this.setVisible(false);
new emp1().setVisible(true);
Clear:
txtid.setText("");
txtname.setText("");
txtadd.setText("");
txtcity.setText("");
txtdepartment.setText("");
txtphone.setText("");
txtdate.setText("");
This window displays the details of all the employees which have been
entered into the application through the registration window. The
‘Display Details’ button displays all the details from which the user can
look out for required details.
Coding:
Display Details:
// Before writting the followng line, you should import the line:
if (rows > 0) {
for (int i = 0; i < rows; i++) {
model.removeRow(0);
// SQL Query
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
String ename=rs.getString("emp_name");
String edepart=rs.getString("emp_depart");
String edate=rs.getString("emp_date");
String eadd=rs.getString("emp_add");
String ecity=rs.getString("emp_city");
String ephone=rs.getString("emp_phone");
System.out.println(eid + "|" + ename + "|" +edepart + "|" + edate + "|" + eadd + "|" + ecity
+ "|" + ephone);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
new emp1().setVisible(true);
Run mode:
When a user wants to access the employee salary input form, from safety and
security point of view he/she cannot directly access it .First of all a password
window appears ,if the user enters the correct password if and only if the
salary input form appears.
Coding
if(pd.equals("sal")){
this.setVisible(false);
new salaryinput().setVisible(true);
else{
}
If you entered the correct password, the following form will appear.
Coding:
Calculate salary:
int ehra,eda,esal,ebasic,eit;
ehra=Integer.parseInt(hra.getText());
eda=Integer.parseInt(da.getText());
ebasic=Integer.parseInt(basic.getText());
eit=ebasic/10;
esal=(ebasic+ehra+eda)-eit;
it.setText(""+eit);
sal.setText(""+esal);
Save:
try{
Class.forName("java.sql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost/employee","root","juhi");
stmt=con.createStatement();
rs=stmt.executeQuery(sql);
while(rs.next()){
String emid=txtid.getText();
String ename=txtname.getText();
String edepart=txtdep.getText();
String ehra=hra.getText();
String eda=da.getText();
String ebasic=basic.getText();
String eit=it.getText();
String esal=sal.getText();
int rowsEffected=stmt.executeUpdate(query);
catch(Exception ex){
JOptionPane.showMessageDialog(this, ex);}
Clear:
txtid.setText("");
txtname.setText("");
txtdep.setText("");
da.setText("");
hra.setText("");
basic.setText("");
sal.setText("");
it.setText("");
If any unknown person wants to access the salary input form who do not know the correct
password
He/she will get a message indicating wrong password and will not be able to access the form.
Since
salary
details are secret ,so anyone who wants to access the details has to enter password in a
password window.
If you enter the correct password, following window will appear .
Coding:
Display Details:
// Before writting the following line, you should import the line:
if (rows > 0) {
model.removeRow(0);
// SQL Query
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
String ename=rs.getString("emp_name");
String edepart=rs.getString("emp_dept");
String ebasic=rs.getString("basic");
String ehra=rs.getString("hra");
String eda=rs.getString("da");
String eit=rs.getString("incometax");
String esal=rs.getString("sal");
System.out.println(eid + "|" + ename + "|" +edepart + "|" + ebasic + "|" + ehra + "|" + eda +
"|" + eit+"|"+esal);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
new emp1().setVisible(true);